argmin-rs / argmin

Numerical optimization in pure Rust
http://argmin-rs.org
Apache License 2.0
934 stars 73 forks source link

Add Differential Evolution Algorithm #499

Open steinhauserc opened 2 months ago

steinhauserc commented 2 months ago

Differential evolution would be an addition to the evolutionary algorithms implemented in argmin-rs. The only other I've seen so far is Particle Swarm Optimization. It's good that this algorithm implementation already exists because some things like PopulationState already exists.

A "full" implementation would have a relatively large list of different evolution strategies (see scipy.optimize.differential_evolution for examples). I think it would be reasonable for the initial implementation in argmin-rs to have a couple of different strategies available and to be implemented such that it's relatively simple to add additional strategies in the future.

steinhauserc commented 2 months ago

I'm new to rust but am happy to work on adding this algorithm to argmin-rs. It's a bit of a small task to help me learn. I may have a question or two along the way. From reading the Particle Swarm Optimization, I think it will be relatively simple to use that as an example outline for how to implement the algorithm in the argmin-rs. framework.

steinhauserc commented 2 months ago

I think I'm most of the way to having an initial implementation working but I'm getting hung up on the following. Part of the evolution step involves constructing a state vector where some of the elements come from vector x and others come from a "mutated" vector.

To borrow from the wikipedia page, here's a text description of what's happening.

If r_i < CR or i=R, then set y_i = ..., otherwise set y_i=x_i

This just requires being able to modify indexed values of each state vector which feels like it should be trivial, but I'm having trouble making it happen within the framework where type P has a list of traits (like here).

I might be able to make it work for me individually, but part of my objective for this initial rust project is to make it compliant with the overall library.

Any help pointing me in the right direction would be greatly appreciated.