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

Question regarding the instance_constraints #147

Closed Peter230655 closed 2 months ago

Peter230655 commented 2 months ago

I think, I found that instance_constraints may be given 'along the way', so to speak. What I mean is this: my drone starts at A(0|0|0), and must be at B(100|100|100) at t = duration. I can request, that it is at C(50|50|50) at, say t = duration /2. Playing around with this, it seems to work.

Assuming I am right here, my question is: solve also returns a dictionary, I call it info. info[g] contains the errors. the final_state_constraints errors are the last len(final_state_constraints) entries in info[g]. This I was told earlier. Would generalize like this: The last len(instance_constraints) entries of info[g] give the errors in the instance_constraints?

Thanks for any help!

moorepants commented 2 months ago

Instance constraints simply added constraints to the NLP problem that are specified at specific instances of time. You can select any time during the duration and you can set as many as you desire. Initial and final time constraints are common but you can specify any intermediate ones also.

opty organizes the constraints in a standard pattern: kinematics differential equations, dynamical differential equations, and then instance constraints. We use this code to extract them when we plot them: https://github.com/csu-hmc/opty/blob/599d87448c2fc44e38d0f3183635746bbfd41b93/opty/direct_collocation.py#L379

Peter230655 commented 2 months ago

Thanks for the prompt an clear reply! opty is REALLY neat!