seanmor5

seanmor5

Author of Genetic Algorithms in Elixir

Genex - Genetic Algorithms in Elixir

Hey all,

I wanted to get some experience writing libraries in Elixir, so I started a project today called 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!

Most Liked

seanmor5

seanmor5

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:

seanmor5

seanmor5

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

Author of Genetic Algorithms in Elixir

Hey guys, sorry I haven’t been able to put much time into this library due to school; however, I have a quick announcement and update.

First, I added a new function interactive/2 up on the master branch for creating Interactive Genetic Algorithms. Basically, you call interactive/2 in your fitness_function/1 definition.

The function accepts chromosome and view which is a function for displaying the Chromosome struct. It defaults to IO.inspect.

This came from a paper I read on Web Design Optimization using GAs. Basically, each Chromosome is displayed to a user and THEY determine the fitness based on some arbitrary criteria. In the case of web pages, it was on how appealing the page looked.

This concept was pretty cool to me so I added the functionality to Genex. You can see the example in the examples directory.

v1.0 Update

I am pushing towards v1.0 slowly but surely. This will include major restructuring of the library and introduce a bunch of new and exciting concepts including Multi-Objective Optimization, Multiple Populations, Customizable Evolutions, different reinsertion strategies, etc. I’m also working on a Web Visualizer of GAs using Phoenix Live View.

I expect v1.0 to be pretty full featured and well-tested when it’s released, and because my time is limited with school, I don’t anticipate it will be out for another month or two.

I plan to use this library for some Academic Research (not just trivial examples like I have been), so expect some pretty cool things in the near future!

If anybody wants to help out, let me know!

seanmor5

seanmor5

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!

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…

Where Next?

Popular in Libraries Top

sabiwara
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code. You can try it out using this basic Elixir playground made ...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. Features Unstyled Phoenix components. Storybook that can be added to...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
mbuhot
EctoJob A transactional job queue built with Ecto, PostgreSQL and GenStage Available on Hex.pm: ecto_job | Hex Docs: API Reference — ec...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. [demo] The distributed characteristics of Elixir and the low memory foo...
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
wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Th...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

Sub Categories:

We're in Beta

About us Mission Statement