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

restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 12366 136
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ausimian
Castle is a package I put together to assist with building Elixir releases capable of being live-upgraded via the ‘official’ release hand...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
drozdzynski
Storex is a frontend store with state management handled on the backend. It allows you to update the store state both from the frontend a...
New
gushonorato
Hey everyone! :waving_hand: I’m excited to share a new library with you all: Magic Auth! It’s an authentication library for Phoenix proj...
New

Other Trending Topics Top

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
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews