Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constraints for optimization problems #484

Closed
JingyuQian opened this issue Mar 17, 2023 · 2 comments
Closed

Add constraints for optimization problems #484

JingyuQian opened this issue Mar 17, 2023 · 2 comments

Comments

@JingyuQian
Copy link
Contributor

🚀 Feature

Don'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.

Motivation

Some optimization problems take on the form:

$$min\text{ } F(x,y,z),\text{ } s.t. \text{ }x\leq\alpha,...$$

while $F(x,y,z)$ is easy to implement as:

$$F(x,y,z)=\sum_i[w_ig_i(x,y,z)]^2$$

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 $w_i$, but I found it in practice this doesn't work very well.

Pitch

Something like the following

objective = th.Objective()
# Add losses
objective.add_loss(loss_function)
...
# Add constraints
objective.add_constraint(constraint_function)

Additional context

The project casadi has something as

from casadi import Opti
optim = Opti()
optim.subject_to(optim.bounded(lower_bound, x, upper_bound))
@luisenp
Copy link
Contributor

luisenp commented Mar 20, 2023

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.

@JingyuQian
Copy link
Contributor Author

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.

@facebookresearch facebookresearch locked and limited conversation to collaborators Mar 22, 2023
@mhmukadam mhmukadam converted this issue into discussion #487 Mar 22, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants