darwin-rs
Library Listed Dormant
Evolutionary algorithms library written in Rust.
- Downloads
- 11
- Dependents
- 0
- Stars
- 129
- Forks
- 16
- Contributors
- 4
- Commits
- 150
- Latest release
- 0.4.0 ·
About
This library allows you to write evolutionary algorithms (EA) using the Rust programming language.
Written by Willi Kappler, License: MIT - Version 0.4 (2017.06.26)
Documentation: darwin-rs


The example folder contains these examples:
- TSP (traveling salesman problem): the classic type of problem for EA (see two pictures above).
- Sudoku: a sudoku solver using EA.
- Queens: solving the queens problem with EA. Although not as fast as this one or this one ;-)
- OCR: a simple optical character recognition example. Two strings are drawn (rendered) using a truetype font on a image buffer and then a perfect match representing the drawn text is found.
darwin-rs uses semantic versioning
Usage:
Add the following to the Cargo.toml in your project:
[dependencies]
darwin-rs = "0.4"
And this in the rust source code of your application:
extern crate darwin_rs;
use darwin_rs::{Individual, SimulationBuilder, Population, PopulationBuilder, SimError};
Basically you have to implement the trait Individual for your data structure:
Read the full README
#[derive(Debug, Clone)]
struct MyStruct {
text: String
}
impl Individual for MyStruct {
fn mutate(&mut self) {
// Mutate the struct here.
...
}
fn calculate_fitness(&mut self) -> f64 {
// Calculate how good the data values are compared to the perfect solution
...
}
fn reset(&mut self) {
// Resets all the data for this individual instance.
// This is done to avoid getting stuck in a local minimum.
...
}
}
These three methods are needed:
mutate(&mut self): Mutates the content of the struct.
calculate_fitness(&mut self) -> f64: This calculates the fitness value, that is how close is this individual struct instance to the perfect solution ? Lower values means better fit (== less error == smaller distance from the optimum).
reset(&mut self): Resets all the data after a specific number of iteration (see reset_limit), to avoid local minima.
There is one more method (new_fittest_found) but it is optional and the default implementation does nothing.
If you want to share a large data structure between all the individuals you need Arc, see TSP and OCR examples.
Now you have to create one or more populations that can have different properties:
// A helper function that creates a vector of individuals of your data structure:
let my_pop = make_population(100);
let population1 = PopulationBuilder::<MyStruct>::new()
.set_id(1)
.initial_population(&my_pop)
.increasing_exp_mutation_rate(1.03)
.reset_limit_increment(100)
.reset_limit_start(100)
.reset_limit_end(1000)
.finalize().unwrap();
let population2 = PopulationBuilder::<MyStruct>::new()
.set_id(2)
.initial_population(&my_pop)
.increasing_exp_mutation_rate(1.04)
.reset_limit_increment(200)
.reset_limit_start(100)
.reset_limit_end(2000)
.finalize().unwrap();
set_id(): Sets the population ID. This can be any positive u32 integer. Currently this is only used for internal statistics, for example: which population does have the most fittest individuals ? This may help you to set the correct parameters for your simulations.
initial_population(): This method takes a vector of individuals. The best practice is to use a helper function, see examples.
increasing_exp_mutation_rate(): Sets the mutation rate for each individual: Use exponential mutation rate.
reset_limit_increment(): Increase the reset limit by this amount every time the iteration counter reaches the limit
reset_limit_start(): The start value of the reset limit.
reset_limit_end(): The end value of the reset limit. If this end value is reached the reset limit is reset to the start value above.
Alternatively you can also put all the populations inside a vector.
After that you have to create a new instance of the simulation and provide the settings:
let my_builder = SimulationBuilder::<MyStruct>::new()
.factor(0.34)
.threads(2)
.add_population(population1)
.add_population(population2)
.finalize();
match my_builder {
Err(SimError::EndIterationTooLow) => println!("more than 10 iteratons needed"),
Ok(mut my_simulation) => {
my_simulation.run();
println!("total run time: {} ms", my_simulation.total_time_in_ms);
println!("improvement factor: {}", my_simulation.simulation_result.improvement_factor);
println!("number of iterations: {}", my_simulation.simulation_result.iteration_counter);
my_simulation.print_fitness();
}
}
factor(): Sets the termination condition: if the improvement factor is better or equal to this value, the simulation stops.
threads(): Number of threads to use for the simulation.
add_population(): This adds the previously created population to the simulation.
finalize(): Finish setup and do sanity check. Returns Ok(Simulation) if there are no errors in the configuration.
add_muliple_populations(): Allows you to add all the populations inside a vector in one method call.
Then just do a match on the result of finalize() and call simulation.run() to start the simulation. After the finishing it, you can access some statistics (total_time_in_ms, improvement_factor, iteration_counter) and the populations of course:
for population in my_simulation.habitat {
for wrapper in population.population {...}
}
Each individual is wrapped inside a Wrapper struct that contains additional information needed for the simulation: fitness and the number of mutations.
See also the example folder for full working programs.
Discussion:
Used crates:
- jobsteal: parallelization
- error-chain: easy error handling
- log: use logging mechanism instead of
println!()
Similar crates:
- genetic-files
- RsGenetic
- evo-rs
- calco-rs
- GenGen
- parasailors
- random-wheel-rs
- roulette-wheel-rs
- differential-evolution-rs
- evolve-sbrain
- Nodevo
- Oxigen
Any feedback is welcome!
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- No Python binding crate found
- License
- MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
Evolutionary algorithms library written in Rust. |
11 downloads over 30 days | 0 | 129 | 0.4.0 | GPU support unknown | No native code found | MIT |
|
radiate Listed
A Rust library for genetic algorithms and artificial evolution. Python bindings |
971 downloads over 30 days | 0 | 257 | 1.3.2 | GPU support unknown | No native code found | MIT |
|
Rust bindings for the liblinear C++ library |
922 downloads over 30 days | 1 | 10 | 1.0.0 | GPU support unknown | Binds native code: liblinear.a. Build uses a native toolchain: cc | MIT |
|
treeboost Listed
Gradient-boosted decision trees for tabular data: trains a baseline model in one call, with full control over boosting modes and configs, and Scalar, AVX-512, SVE2, WGPU and CUDA backends. Python bindings |
18 downloads over 30 days | 0 | 9 | 0.1.2 | CUDA, WebGPU | No native code found | Apache-2.0 |
|
Rust library for Self Organising Maps (SOM). |
9 downloads over 30 days | 0 | 36 | 1.1.1 | GPU support unknown | No native code found | MIT |
|
Fwumious Wabbit, fast on-line machine learning toolkit written in Rust |
0 binary downloads per release | Not applicable | 141 | Not measured | Not measured | Not measured | |
|
Fast, large scale library for computing rankings and features based on various pairwise and graph algorithms |
Not measured | Not applicable | 10 | Not measured | Not measured | Not measured | Apache-2.0 |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 0 active dependents and 0 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 129 stars, 16 forks and 4 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
- The project is dormant and not finished. Dormancy rule
What else the check found
- The last activity is on 11 Jul 2022, 1582 days ago. That reaches the 365 days the rules expect, so the project is dormant. Dormancy rule
Not measured: Latest release fails cargo check.
Check notes
- the repo manifest Cargo.toml declares the crate, and no release commit proves the link
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.4.0 base 140, raised to the 365-day floor: E = 365 daysdormancy: last activity 2022-07-11, 1582 days ago, E = 365: dormantfeatured: not featured: active_users 0 < 11 and new_adopters 0 < 9 and repository route stars 129 (needs 4539), forks 16 (needs 434), contributors 4 (needs 79); dormant and not stablelisted: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- repo manifest, fetched
- GitHub contributors, fetched
Adoption0 active dependents, 0 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 0 | crates.io database dump | Yes | |
| New dependents (365 days) | 0 | crates.io database dump | Yes | |
| Peak active dependents | 0 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 4 years ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2022-07-11 | GitHub repository | Yes | |
| Latest release | 2017-06-26 | crates.io database dump | Yes | |
| First release | 2016-06-11 | crates.io database dump | Yes | |
| Latest version | 0.4.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 0 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | repo manifest | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution5 releases, 11 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 5 | crates.io database dump | Yes | |
| Downloads over 30 days | 11 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository129 stars, 16 forks, 4 contributors, 150 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 129 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 16 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 4 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 150 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 0 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.