csu-hmc / opty

A library for using direct collocation in the optimization of dynamic systems.
http://opty.readthedocs.io
Other
86 stars 20 forks source link

Request for support for inequality constraint equations #156

Open Peter230655 opened 1 month ago

Peter230655 commented 1 month ago

As I was told, opty can handle algebraic constraint equations. Can it also handle alegebraic inequalities? What I mean is this: Say, $a, b \in R, a < b$. Let $f (q_i)$ be a scalar function of the generalized coordinates. Would $a < f(q_i) < b \longleftrightarrow$ $f(q_i) - b < 0$ $a - f(q_i) < 0$ be possible?

Thanks for any help!

moorepants commented 1 month ago

No, that is currently not supported, but opty could support anything that fits an NLP problem that IPOPT can solve. See the definition here: https://coin-or.github.io/Ipopt/

Someone would have to implement inequality algebraic constraints in opty. It only constructs equality constraints at the moment.

Peter230655 commented 1 month ago

Clear thanks! Should I close the issue, my question was answered!, or leave it open for possible future activity by someone?

moorepants commented 1 month ago

I changed the title and we can leave it as an open issue.

moorepants commented 1 week ago

I think this should be relatively easy to implement. We just need a flag to Problem that lets you change:

$$ 0 < g(x) < 0 $$

to

$$ lower < g(x) < upper $$

Maybe something like:

Problem(..., inequalities=((3, -1.2, 5.0), (8, 0.0, np.inf)))

Where the first number in each tuple corresponds to the index in the equations of motion that holds $g(x)$ and the next two numbers are lower and upper bounds for that equation.

Peter230655 commented 1 week ago

I guess, you meant $0 \leq g(x) \leq 0$ The situation I wanted to model would certainly be covered by this! Unfortunately, I would have no idea how to implement it. :-(

moorepants commented 1 week ago

Unfortunately, I would have no idea how to implement it. :-(

I don't believe that. :)

Peter230655 commented 1 week ago

Easier than GitHub / PRs ? :-)