seanmor5

seanmor5

Author of Genetic Algorithms in Elixir

Hey all,

I wanted to get some experience writing libraries in Elixir, so I started a project today called Genex.

https://github.com/seanmor5/genex

Genex is a simple library that makes it easy to write Genetic Algorithms in Elixir. All you have to do is specify some parameters, define a few functions, and then run the algorithm.

This library is VERY new (I literally just started it today). So it doesn’t have sufficient tests, documentation, or really much of anything yet. It is NOWHERE near finished.

I was looking for suggestions, tips, ideas, etc. for the rest of the way forward. I know Elixir isn’t really the best language for this stuff, but it’s a fun little project. I’ve had fun messing around solving very basic optimization problems with it.

Let me know what you guys think! If you want to contribute, send me a message!

Showing Posts 1 to 10

seanmor5

seanmor5 OP

Author of Genetic Algorithms in Elixir

To anybody following this project:

v0.1.0 was just released and published to Hex.

Documentation
Package

This version includes a few basic selection, crossover, and mutation methods, a text visualization module, and a Genealogy tree implementation. It has many limitations and many more features are in the works; however, this is a usable working version.

Enjoy!

seanmor5

seanmor5 OP

Author of Genetic Algorithms in Elixir

v0.1.1

Documentation
Package

What’s New

  • Bug Fixes
  • Finalized Implementation of Selection, Mutation, and Crossover Functions
  • Improved Documentation

What’s Next

  • Adding Statistics to Population Struct
  • Support for multiple Populations and Migration between Populations
  • More comprehensive documentation
seanmor5

seanmor5 OP

Author of Genetic Algorithms in Elixir

v0.1.2

Documentation
Package

What’s New

  • Bug Fixes
  • Improved Documentation (Including full customization guide)
  • Statistics collection using built in or 3rd party modules
  • Implementation of Crossover Rate, Mutation Rate, and Radiation as overridable functions to change with population parameters

What’s Next

  • PERFORMANCE

From the start of this project, I understood Elixir and the BEAM are not ideal for this kind of application; however, I am really falling in love with the simplicity Elixir and this Library can offer to these kinds of problems. That being said, I know this library’s performance will likely never rival DEAP or similar implementations in languages like C or Rust; however, I know the performance itself can be improved.

If you check out some of the benchmarks in the Git Repository, you’ll see how hopelessly slow a lot of the evolutionary operators are. I’m considering 3 options for solving this problem:

  1. Parallelization using Task API or Flow as well as scrutinizing my implementations of the various algorithms. This is probably the route I’m going to explore first and settle with for the next release.
  2. NIFs. My research tells me this is an absolutely ideal use case for NIFs. Essentially, we just need the evolutionary operators (crossover, mutation, selection) implemented as NIFs. The operators just need to perform computation on large lists really fast and return the result. This seems like an ideal use case for NIFs. If anybody has experience writing them in Rust or C, please shoot me a message so we can discuss!
  3. Ports. This option doesn’t make much sense in my opinion although if anybody can make an argument for it, I’d be willing to listen.

If you’re writing anything cool with Genex or just playing around - please let me know! I don’t expect this library to be very popular but it’s been a lot of fun to work on :slight_smile:

OvermindDL1

OvermindDL1

Ideal use-case for Rust (and the Rustler library). :slight_smile:

Don’t forget to look at the Matrax or whatever it was called library, it exposes some BLAS NIF functionality!

Rainer

Rainer

Interesting project, years ago I played with genetic algorithms and it was quite fun.
I’d also go for the combination with Rust.

If only I had time…

seanmor5

seanmor5 OP

Author of Genetic Algorithms in Elixir

v0.1.4

Documentation
Package

What’s New

  • Bug fixes
  • 3.51x Performance Improvement in single_point crossover
  • 2.35x Performance Improvement in two_point crossover
  • Addition of benchmark/0 function to benchmark your algorithm
  • Addition of track_history? flag to turn off and on the Genealogy tree feature (see problems for why).

What’s Next

  • Exploring the idea of using the Matrex library per @OvermindDL1 suggestion. Representing the Populations and Chromosomes as matrices gives access to their REALLY fast matrix functions.
  • Also began messing around with implementing the operators as NIFs last night. 2 problems I ran into: Rustler’s current release doesn’t support Erlang 22. Not a huge problem because their master branch does, more a minor inconvenience. 2nd problem is it was my first experience with Rust and I couldn’t write anything efficient to save my life :slight_smile:.

Problems

  • I had to add the track_history? flag because I couldn’t get Benchee to play nicely with the current Genealogy tree implementation. The Genealogy tree is just an Erlang digraph. The problem is Benchee runs in it’s own process and Erlang digraph’s are protected by default. I thought it would be an easy fix - considering you can make ETS table’s public - however, digraph’s protection options are only :protected and :private. If anybody has a workaround for this, I’d love to hear it!

Thanks!

seanmor5

seanmor5 OP

Author of Genetic Algorithms in Elixir

v0.2.0

Documentation
Package

What’s New

  • Bug Fixes
  • Changed to libgraph for Genealogy Tree
  • Added ability to export Genealogy to DOT file
  • Removed track_history? flag
  • Added a WHOLE bunch of tests so it should be pretty stable
  • Improved Documentation
  • Additional helper methods for evolutionary operators

What’s Next

  • Configuration on run call instead of at Module definition (allows for comparison of the same problem without having to define another module).
  • Still looking into performance, bear with me while I learn Rust :slight_smile:
  • Logbook which basically stores EVERY population that ever existed throughout the algorithm run time. Probably will just use ETS to start with configuration options for Redis or whatever else people want to use.

I’ve been making releases basically consistently once a day; however, I’ll be heading back to school tomorrow so the rate of development will slow down a bit. I have some plans for future features, but I won’t be able to commit as much time as I have to it in the coming weeks.

OvermindDL1

OvermindDL1

Yeah I relate there, except I work for a college instead of being a student (so done with that well over a decade ago!), we’ve been crazy getting everything ready for the new semester, like everything needed updates… ^.^

Love watching this develop! When I get time I’m planning to experiment, I love genetic algorithms and it’s been years since I’ve messed with it. ^.^

seanmor5

seanmor5 OP

Author of Genetic Algorithms in Elixir

Love watching this develop! When I get time I’m planning to experiment, I love genetic algorithms and it’s been years since I’ve messed with it. ^.^

I appreciate the support! The library has been a lot of fun to mess around with. I’ve had a good time just coming up with examples and playing with the different options. Whenever you do get the chance to experiment, I’d love to hear what you come up with!!

preciz

preciz

You might be interested in these:

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews