csu-hmc / opty

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

Question: get the 'violation' of the terms in the objective function #142

Closed Peter230655 closed 6 months ago

Peter230655 commented 6 months ago

As I learned, it is easy to get the violation of the state variables and of the final constraints: they are returned in info['g']. But how do I get the violations of the objective function / still better of each term in it?

As I recall, when I started with opty, there was a discussion on their plot routine, and @tjstienstra suggested a better version (?). Anyway, if I know where these values are, I can probably plot them

Thanks for any help!

moorepants commented 6 months ago

There is no "violation" of the objective, there is just the value of the objective given the state and controls. The Problem class stores the objective for each iteration. You can return the objective for any result with Problem.objective() and you can access all of the objective values from each iteration with Problem.obj_value. You can plot the objective value as a function of iteration value with Problem.plot_objective_value().

Peter230655 commented 6 months ago

Thanks! I will try this.