argmin-rs / argmin

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

Constrained Optimization (especially lower+upper bounds) #137

Open Julian-J-S opened 2 years ago

Julian-J-S commented 2 years ago

Hello, Coming from Python (scipy.optimize.minimize) and MATLAB (fmincon), I can't find a way to specify bounds (and other constraints), which to me are very essential parts of an optimization problem.

Python / Scipy:

res = minimize(opti_fun, x0, bounds=mybounds, constraints=myconstraints)

Matlab:

res = fmincon(opti_fun, x0, A, b, Aeq, beq, lowerbound, upperbound)

Looking through the documentation, I could not find that this is implemented. (With the exception of some manual bounds in the simulatedannealing.rs example). Is this something that is being worked on? Or is it planned? Or is it too complicated / time consuming at the moment? Or did I just miss something here? I would love to have constrained optimization (at least with bounds) in Rust!

stefan-k commented 2 years ago

Unfortunately there is no constrained optimization yet (apart from, as you noted, SA, and possibly PSO). It is definitely planned; however due to other responsibilities I'm afraid I can't give you a timeline as to when this will happen.

Julian-J-S commented 2 years ago

Thanks for the reply. Looking forward to the implementation! =)

sahilosaro commented 2 years ago

Any update on this?

stefan-k commented 2 years ago

Unfortunately not yet. I plan to have a look at it after the release of version 0.6.

relf commented 1 year ago

FWIW, I would like to mention here that external solvers handle constraints. In both case, cost function returns a vector: the first component is the actual cost value, the remaining components are constraints values.

Notice that egobox-ego::EgorSolver adjusts x to make constraints negative while cobyla::CobylaSolver try to make them positive.

Euraxluo commented 3 months ago

I don't know what role this library will play in constraint optimization, solver caller?, don't be silly and do it in Python