opensim-org / opensim-moco

Solve optimal control problems for musculoskeletal models using OpenSim and direct collocation.
https://opensim.stanford.edu/moco
Apache License 2.0
57 stars 16 forks source link

Ipopt aborting after calling restoration phase near feasible point #142

Open nickbianco opened 6 years ago

nickbianco commented 6 years ago

While writing test cases for #137, I started encountering Ipopt errors similar to the following:

image

The image below is an output from an optimization where I solved for the actuator controls to a make a double pendulum "unfold" to become fully upright, while obeying a point-on-line constraint applied to the model's end-effector (100 mesh points, 1e-3 tol, limited-memory).

In some cases, including the one below, it is particularly confusing because it appears that Ipopt is attempting to enter restoration mode even though the constraint violation is quite low (often less than 1e-6).

The Ipopt setting "accept_after_max_steps" allows a user to specify an integer representing the maximum number of line search steps Ipopt performs at each iteration, even if the line search algorithm doesn't converge. I've found this setting useful in some cases to prevent Ipopt from aborting (seemingly) early. Although, in some cases, capping line search steps too much seems prohibitive to convergence.

It would be good to know more about why this failure occurs, for which types of direct collocation problems (e.g. model constraints) are prone to it have it occur, and if there are preventative measures we could to avoid it so users are less likely to encounter it themselves.

image

antoinefalisse commented 6 years ago

@nickbianco, I think this paragraph from this paper might be relevant regarding this issue:

For most problems, the algorithm terminated with ’restoration phase failed’. The restoration phase tries to find a decrease in the constraint violation when the normal algorithm is not able to improve. In practice, the restoration phase can be called even when the constraint violation is small (Wachter and Biegler 2006). This likely happens due to the nonlinearity of the metabolic rate objective. However, the algorithm was fast enough to be able to attempt multiple random initial guesses. In most studies, an initial guess is used closer to the optimal solution, so it should be easier to successfully find an optimal solution.

Not sure how you can prevent this issue except by starting from a different initial guess though. Is your initial guess feasible?

chrisdembia commented 6 years ago

Thanks @antoinefalisse; this is insightful. I didn't see that paper yet.

nickbianco commented 6 years ago

Yes, thanks for the link @antoinefalisse. Turns out for the problem above, there was an error in how I was specifying the defect constraints.