There are the Inverted Pendulum Optimal Control and the Double Inverted Pendulum Optimal Control example problems for reference. The terminal cost can be set by adding an additional weight (w1
-w4
) to each term to prioritize which one is met. In the example cases, all final conditions are met so the terminal cost is zero when (w1=1
, w2=1
, w3=1
, w4=1
). The solution may change when using different terminal weights.
m.Minimize(final*w1*(x-xf)**2)
m.Minimize(final*w2*(xdot-xdotf)**2)
m.Minimize(final*w3*(q1-q1f)**2)
m.Minimize(final*w4*(q1dot-q1dotf)**2)
The terminal set is the set of final conditions that can be adjusted such as xf
, xdotf
, q1f
, and q1dotf
. Hard constraints can be used instead of the soft (objective-based) constraints above.
m.Equation(final*(x-xf)==0)
m.Equation(final*(xdot-xdotf)==0)
m.Equation(final*(q1-q1f)==0)
m.Equation(final*(q1dot-q1dotf)==0)
However, this may lead to an infeasible solution if all constraints can't be met.