Skip to content

A simple genetic algorithm to search for good constants in a diffusion function

Notifications You must be signed in to change notification settings

VerKWer/diffusion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Genetic Search of Diffusion Parameters

This program requires Rust's nightly channel! Moreover, we try to avoid heap-allocation as much as possible, which means that all parameters are hard-coded in src/globals.rs. Changing any one of them requires recompiling the program. As a consequence of trying to keep everything on the stack, it is necessary to increase the default stack size. Otherwise, serde will (probably) cause a stack overflow when trying to deserialise a previously stored state.

The easiest is to just execute the run script in the root directory.

Profiling

To make profiling easier, there is a profile feature. When enabled, we only go through a single generation (evaluating it and performing the tournament selection) in the main thread and print the best candidate found. This makes it easier to analyse performance bottlenecks with standard tools such as flamegraph and valgrind. To build it, simply use

RUSTFLAGS="-C target-cpu=native" cargo build --release --features profile

(the release profile already includes debug info). Afterwards, one can use e.g. cachegrind like so:

valgrind --tool=cachegrind --branch-sim=yes --cachegrind-out-file=cachegrind.out target/release/diffusion

Getting a flamegraph is even easier:

cargo flamegraph --bin diffusion --features profile