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.
4 Likes
hoodie
June 12, 2016, 12:36pm
2
You seem to have some merge residue in lib.rs:14ff
Thanks, I've fixed it!
Hitting return too early...
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 created a new, very small random lib for choosing randomly samples by their weights/probabilites.
As far as I know this feature is not part of the random crate. So may be there is interest to merge this lib to rust random.
###Advantages
There is a good diversity for the case that all weights are equally distributed (in contrast to the roulette wheel selection algorithm which tends to select the same sample n times)
Blazingly fast: O(n) (Roulette wheel selection algorithm: O(n * log n))
The…
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
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!