facebookresearch / nevergrad

A Python toolbox for performing gradient-free optimization
https://facebookresearch.github.io/nevergrad/
MIT License
3.89k stars 349 forks source link

Multiple constraints #1594

Open Oguked opened 4 months ago

Oguked commented 4 months ago

I couldn't find an option to add multiple constraints. I want to optimize in 3d space. Several separate 3d regions should be part of the search space.

My use case is sensor placement optimization. I want to define disconnected regions where sensors can be placed, e.g. certain areas at different walls of a robot cell. The optimizer should provide solutions within these regions. How can I define a parameter space like that?

teytaud commented 4 months ago

Hello! There is no problem for multiple constraints. You can add constraints with the contraint_violation mechanism.

For example with ask and tell: optimizer.tell(candidate, value, [constraint_violation1, constraint_violation2, constraint_violation3])

Other examples at: https://facebookresearch.github.io/nevergrad/optimization.html

(register_cheap_constraint is another possibility, but for most users constraint_violations is better)