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

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
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
CodeSync
:microphone: ElixirConf 2026 - Call for Talks is open! We’re heading to Chicago :united_states: :round_pushpin: In person + virtual :d...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews