Darwin-rs: evolutionary algorithms with Rust


Hi everyone,

I’ve written my first crate: darwin-rs.
It helps you to write evolutionary algorithms (EA) in Rust.

There are currently three examples:

  • TSP (traveling salesman problem): the classic type of problem for EA
  • Sudoku: a sudoku solver using EA
  • Queens: solving the queens problem with EA

More examples will follow.

It was quite a pleasure to write this in Rust and I’m not 100% sure about the (API) design yet, so this may change in the future.

Let me know what you think.


You seem to have some merge residue in lib.rs:14ff


Thanks, I’ve fixed it!
Hitting return too early… :wink:


Interesting. If you want to improve your performance, you could resample the population in O(n) instead of O(n * log n) if you use my Random Choice Lib:

I am refering to this line of code of yours:


Thanks for the info!

I was going to look into how to use your crate after you announced it :wink:

Version 0.2 of darwin.rs will be released soon (I hope the code clean up that I’m currently working on will not take too much time…)


Thanks! I’m going to implement an in place version of this algorithm, but you have to wait until wednesday or thursday.

Please contact me, if there are any problems or you want to improve the code or API.


Cool, that would be great!

No need to rush, I’ll have to clean up the examples first and I’m currently busy with other stuff…


New version v0.3 released:

  • Write output into a log file instead of using print!().
  • Remove new() from trait Individual, provide reset() instead.
  • All mutexes removed.
  • User must now provide whole population but can now use shared configuration / data instead of using lazy_static.
  • Calculate_fitness now needs (&mut self).
  • Add option share_fittest to share the fittest individual between all population after each iteration.
  • Add ocr2 example.
  • Add optional method new_fittest_found() to write out some statistics. Default implementation does nothing.
  • Add fitness counter statistic to population.
  • Fix bug in parallelization using jobsteal.
  • Fix bug in TSP2 example.

I’m working on two applications that will use darwin-rs directly.

Feedback, questions, etc. are welcome!