Add constraints for optimization problems #487
-
🚀 FeatureDon't know if this has been raised before or should be the purpose of this lib, but it would be nice to allow adding constraints for an optimization problem. MotivationSome optimization problems take on the form: while the constraints don't have an explicit way to implement. One alternative is to write it as a normal loss and give a relatively large PitchSomething like the following objective = th.Objective()
# Add losses
objective.add_loss(loss_function)
...
# Add constraints
objective.add_constraint(constraint_function) Additional contextThe project from casadi import Opti
optim = Opti()
optim.subject_to(optim.bounded(lower_bound, x, upper_bound)) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Hi @JingyuQian. Thanks for your interest in Theseus and the feature request! We are in fact starting to work on this feature, and there is an experimental PR up #457 (only for equality constraints). It's still pretty early in development, but we are hoping to have something running within the next two months. |
Beta Was this translation helpful? Give feedback.
-
Thanks @luisenp ! For my use case, inequality constraints are required, but this is good news to hear. I'll close this and keep watching the PR. |
Beta Was this translation helpful? Give feedback.
-
@JingyuQian Thanks for your interest! I am curious what application you have in mind to leverage inequality constraints? We have indeed received feature request for inequality constraints from many users (one of the most commonly requested ones), but given our team's bandwidth it will take us longer to prioritize and work on it. In the meantime, we of course welcome any community support :) |
Beta Was this translation helpful? Give feedback.
-
Another thing I'm curious about is, will the added constraints (both equality/inequality) affect the differentiability of a Theseus layer? |
Beta Was this translation helpful? Give feedback.
Hi @JingyuQian. Thanks for your interest in Theseus and the feature request!
We are in fact starting to work on this feature, and there is an experimental PR up #457 (only for equality constraints). It's still pretty early in development, but we are hoping to have something running within the next two months.