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

Improve constraint violation visualization #125

Closed tjstienstra closed 3 months ago

tjstienstra commented 4 months ago

Fixes #123 and #53

Changes

Correct the slicing of the constraints_violation vector. The constraint vector is formatted as (refer to the creation of the constraint function and the wrapper:

[con_1_2, ..., con_1_N,
con_2_2, ..., con_2_N,
...,
con_n_2, ..., con_n_N,
*instance_constraints]

where con_1_2, ..., con_1_N the constraint violation is at every node for the first discrete equation of motion.

Only create a single axis for showing the EoM violation, as they are not officially coupled to specific states. Yes, it is correct to say that most will specify the first n//2 as kinematic differential equations, but that is not required.

Only plot the constraint violations of the instance constraints if there are any instance constraints.

tjstienstra commented 4 months ago

Here is the new version of the pendulum from the examples page constr_viols_pend And here are the plot constraints of the first optimization problem in the BRiM paper constr_viols

moorepants commented 4 months ago

Is setting the x tick labels at 90 degree rotation better, in general? If so, maybe adjust that while you are at it.

tjstienstra commented 4 months ago

Is setting the x tick labels at 90 degree rotation better, in general? If so, maybe adjust that while you are at it.

I don't like those ticks in general, they always make a mess especially if a constraint is a longer equation. In this case, if you would choose -90, you actually run into the problem that a part of your equation falls outside (below) the figure.

tjstienstra commented 4 months ago

It is that you like to see which one it approximately is, but otherwise I would just throw them all together in a single boxplot

moorepants commented 4 months ago

We can go with this as is and address formatting later.

moorepants commented 3 months ago

Forgot about this. Merging.

moorepants commented 3 months ago

The docs show this for the pendulum swing up: pendulum_swing_up_01_new which is quite smooth compared to the old: pendulum_swing_up_01

moorepants commented 3 months ago

Also isn't as small.