Total number of variables does not add up

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Pagnon David
Posts: 82
Joined: Mon Jan 06, 2014 3:13 am

Total number of variables does not add up

Post by Pagnon David » Mon Sep 25, 2023 2:19 pm

Hello,

When running IPOPT within Moco, it seems like the number of variables does not add up. Could you help me understand it?

Code: Select all

Total number of variables............................:    22913
                     variables with only lower bounds:        0
                variables with lower and upper bounds:    22172
                     variables with only upper bounds:        0
Total number of equality constraints.................:    20152
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0
Thank you!

User avatar
Nicholas Bianco
Posts: 963
Joined: Thu Oct 04, 2012 8:09 pm

Re: Total number of variables does not add up

Post by Nicholas Bianco » Mon Oct 02, 2023 9:38 am

Hi David,

This means that there are some variables in the problem that do not have any bounds set for them. These could be variables in the Moco problem, or slack variables added by Ipopt.

Best,
Nick

User avatar
Pagnon David
Posts: 82
Joined: Mon Jan 06, 2014 3:13 am

Re: Total number of variables does not add up

Post by Pagnon David » Mon Oct 02, 2023 3:38 pm

Thanks, it makes sense!

User avatar
Pagnon David
Posts: 82
Joined: Mon Jan 06, 2014 3:13 am

Re: Total number of variables does not add up

Post by Pagnon David » Thu Oct 19, 2023 7:47 am

Hi,

I'm still definitely a beginner at Moco and NLP in general, so please excuse my potentially naive questions.

I'm looking at the Moco objective function and the constraints it is subject to, as well as the output posted above.

I am wondering, what are some variables that would typically not have any lower nor upper bounds?

And what is the rationale behind the fact that the number of variables is slightly larger than the number of equality constraints? I guess that the constraints involve most variables but not all of them. Which ones would not be constrained?

Thanks in advance! If this is not clear, I can probably think a bit more and reformulate it.

User avatar
Nicholas Bianco
Posts: 963
Joined: Thu Oct 04, 2012 8:09 pm

Re: Total number of variables does not add up

Post by Nicholas Bianco » Thu Oct 19, 2023 9:49 am

Hi David,

All questions are welcome!

Any variables that you do not provide bounds for will not have bounds in the IPOPT optimization problem. Moco automatically sets bounds for most variables based on ranges set in the model, but this sometimes doesn't catch all variables. Also, I misspoke before, IPOPT does introduce additional "slack" variables in optimization problems, but I do not think that are counted in the problem output you see.

The number of variables is not necessarily the same (and typically is not) the same as the number of equality constraints in the problem. Note that IPOPT treats simple variable bounds differently than other constraints in the problem. Furthermore, since bounds are usually less than/greater than constraints, they wouldn't show up in the equality constraint count anyway.

Hopefully this is helpful.

Best,
Nick

POST REPLY