Main

## Main.MinimizeFinalTime History

February 15, 2019, at 05:14 PM by 10.37.111.106 -
Changed lines 69-71 from:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is

{$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}
to:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=f(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f  dt}. The new time scaled differential equation is

{$0=f\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}
March 01, 2018, at 04:51 PM by 45.56.3.173 -
Deleted lines 10-57:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is

{$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\dot x=f(x,u)}, this equation is time scaled

{$\frac{\frac{dx}{dt}}{t_f}=f(x,u)$}

and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.

The Jennings optimal control problem minimizes the final time subject to differential constraints. Minimizing final time is found in many areas such as manufacturing, transportation, and energy systems. In each case, it is the desired end-state that must be met while the optimizer seeks to arrive at those conditions in the shortest time.

{$\min_{u(t)} \; t_f$}
{$\mathrm{subject \; to}$}
{$\frac{dx_1}{dt}=u$}
{$\frac{dx_2}{dt}=\cos\left(x_1(t)\right)$}
{$\frac{dx_3}{dt}=\sin\left(x_1(t)\right)$}
{$x(0) = \left[\pi/2,4,0\right]$}
{$x_2\left(t_f\right)=0$}
{$x_3\left(t_f\right)=0$}
{$-2 \le u(t) \le 2$}

The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter that scales the final time. The conditions {x_2(t_f)=0} and {x_3(t_f)=0} are binding at the end and limit the system from having a lower final time.

{$\min_{u(t), t_f} \; t_f$}
{$\mathrm{subject \; to}$}
{$\frac{dx_1}{dt}=t_f \, u$}
{$\frac{dx_2}{dt}=t_f \, \cos\left(x_1(t)\right)$}
{$\frac{dx_3}{dt}=t_f \, \sin\left(x_1(t)\right)$}
{$x(0) = \left[\pi/2,4,0\right]$}
{$x_2\left(t_f\right)=0$}
{$x_3\left(t_f\right)=0$}
{$-2 \le u(t) \le 2$}

The parameter {t_f} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Feedforward Variable/Fixed Value]] so that it has only one value over the time horizon. The adjustable value {u} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Manipulated Variable]] that is adjustable at all time points in the time horizon.

!!!! Solutions

----

Attach:download.png [[Attach:dynamic_optimization_jennings.zip|Jennings Problem in MATLAB and Python]]

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/yuj217itTa8" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

----

Changed lines 69-111 from:
----
to:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is

{$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\dot x=f(x,u)}, this equation is time scaled

{$\frac{\frac{dx}{dt}}{t_f}=f(x,u)$}

and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.

The Jennings optimal control problem minimizes the final time subject to differential constraints. Minimizing final time is found in many areas such as manufacturing, transportation, and energy systems. In each case, it is the desired end-state that must be met while the optimizer seeks to arrive at those conditions in the shortest time.

{$\min_{u(t)} \; t_f$}
{$\mathrm{subject \; to}$}
{$\frac{dx_1}{dt}=u$}
{$\frac{dx_2}{dt}=\cos\left(x_1(t)\right)$}
{$\frac{dx_3}{dt}=\sin\left(x_1(t)\right)$}
{$x(0) = \left[\pi/2,4,0\right]$}
{$x_2\left(t_f\right)=0$}
{$x_3\left(t_f\right)=0$}
{$-2 \le u(t) \le 2$}

The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter that scales the final time. The conditions {x_2(t_f)=0} and {x_3(t_f)=0} are binding at the end and limit the system from having a lower final time.

{$\min_{u(t), t_f} \; t_f$}
{$\mathrm{subject \; to}$}
{$\frac{dx_1}{dt}=t_f \, u$}
{$\frac{dx_2}{dt}=t_f \, \cos\left(x_1(t)\right)$}
{$\frac{dx_3}{dt}=t_f \, \sin\left(x_1(t)\right)$}
{$x(0) = \left[\pi/2,4,0\right]$}
{$x_2\left(t_f\right)=0$}
{$x_3\left(t_f\right)=0$}
{$-2 \le u(t) \le 2$}

The parameter {t_f} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Feedforward Variable/Fixed Value]] so that it has only one value over the time horizon. The adjustable value {u} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Manipulated Variable]] that is adjustable at all time points in the time horizon.

!!!! Solutions

Attach:download.png [[Attach:dynamic_optimization_jennings.zip|Jennings Problem in MATLAB and Python]]

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/yuj217itTa8" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
March 01, 2018, at 05:55 AM by 45.56.3.173 -

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/cfDoe3mRWmQ" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
(:htmlend:)
Changed line 23 from:
{$\frac{dx_3}{dt}=\sin\left(x_2(t)\right)$}
to:
{$\frac{dx_3}{dt}=\sin\left(x_1(t)\right)$}
Changed line 35 from:
{$\frac{dx_3}{dt}=t_f \, \sin\left(x_2(t)\right)$}
to:
{$\frac{dx_3}{dt}=t_f \, \sin\left(x_1(t)\right)$}
Changed line 87 from:
m.Equation(x3.dt()==m.sin(x2)*tf)
to:
m.Equation(x3.dt()==m.sin(x1)*tf)
Changed lines 65-66 from:
m.time = np.linspace(0,1,nt)
to:
tm = np.linspace(0,1,nt)
m.time = tm
Changed lines 87-88 from:
m.Equation(x3.dt()==m.sin(x1)*tf)
to:
m.Equation(x3.dt()==m.sin(x2)*tf)
Deleted line 94:
Deleted line 96:
tm = tm * tf.value
Changed lines 102-105 from:
plt.plot(m.time,x1.value,'k-',LineWidth=2,label=r'$x_1$')
plt.plot(m.time,x2.value,'b-',LineWidth=2,label=r'$x_2$')
plt.plot(m.time,x3.value,'g--',LineWidth=2,label=r'$x_3$')
plt.plot(m.time,u.value,'r--',LineWidth=2,label=r'$u$')
to:
plt.plot(tm,x1.value,'k-',LineWidth=2,label=r'$x_1$')
plt.plot(tm,x2.value,'b-',LineWidth=2,label=r'$x_2$')
plt.plot(tm,x3.value,'g--',LineWidth=2,label=r'$x_3$')
plt.plot(tm,u.value,'r--',LineWidth=2,label=r'$u$')
Changed lines 7-9 from:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then {0=(\frac{\frac{dx}{dt}}{t_f},x,u)}. In semi-explicit form {\dot x=f(x,u)}, this equation is time scale {\frac{\frac{dx}{dt}}{t_f}=f(x,u)} and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.

The Jennings optimal control problem is to minimize the final time subject to differential constraints. Minimizing final time is found in many areas such as manufacturing, transportation, and energy systems. In each case, it is the desired end-state that must be met while the optimizer seeks to arrive at those conditions in the shortest time.
to:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is

{$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\dot x=f(x,u)}, this equation is time scaled

{$\frac{\frac{dx}{dt}}{t_f}=f(x,u)$}

and
rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.

The Jennings optimal control problem minimizes the final time subject to differential constraints. Minimizing final time is found in many areas such as manufacturing, transportation, and energy systems. In each case, it is the desired end-state that must be met while the optimizer seeks to arrive at those conditions in the shortest time.
Changed lines 7-8 from:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=\left(\frac{dx}{dt},x,u\right)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then {0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)}. In semi-explicit form {\dot x=f(x,u)}, this equation is time scale {\frac{\frac{dx}{dt}}{t_f}=f(x,u)} and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.
to:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=(\frac{dx}{dt},x,u)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then {0=(\frac{\frac{dx}{dt}}{t_f},x,u)}. In semi-explicit form {\dot x=f(x,u)}, this equation is time scale {\frac{\frac{dx}{dt}}{t_f}=f(x,u)} and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.
Changed line 21 from:
The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter that scales the final time. The conditions {x_2\left(t_f\right)=0} and {x_3\left(t_f\right)=0} are binding at the end and limit the system from having a lower final time.
to:
The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter that scales the final time. The conditions {x_2(t_f)=0} and {x_3(t_f)=0} are binding at the end and limit the system from having a lower final time.
Changed line 7 from:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {$0=\left(\frac{dx}{dt},x,u\right)$} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then {$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}. In semi-explicit form {\dot x=f(x,u)}, this equation is time scale {\frac{\frac{dx}{dt}}{t_f}=f(x,u)} and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.
to:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {0=\left(\frac{dx}{dt},x,u\right)} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then {0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)}. In semi-explicit form {\dot x=f(x,u)}, this equation is time scale {\frac{\frac{dx}{dt}}{t_f}=f(x,u)} and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.
Changed lines 21-22 from:
The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter as follows:
to:
The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter that scales the final time. The conditions {x_2\left(t_f\right)=0} and {x_3\left(t_f\right)=0} are binding at the end and limit the system from having a lower final time.
Changed line 33 from:
The parameter {t_f} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Feedforward Variable or Fixed Value]] while the adjustable value {u} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Manipulated Variable]].
to:
The parameter {t_f} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Feedforward Variable/Fixed Value]] so that it has only one value over the time horizon. The adjustable value {u} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Manipulated Variable]] that is adjustable at all time points in the time horizon.
Changed lines 7-15 from:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is:

{$0=\left(\frac{dx}{dt},x,u\right)$}

for
simulation time 0 to 1. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then:

{$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\frac{\frac{dx}{dt}}{t_f}=f(x,u)}, this equation can be rearranged to {\frac{dx}{dt}=t_f f(x,u)}.
to:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is {$0=\left(\frac{dx}{dt},x,u\right)$} for simulation time 0.0 to 1.0. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then {$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}. In semi-explicit form {\dot x=f(x,u)}, this equation is time scale {\frac{\frac{dx}{dt}}{t_f}=f(x,u)} and rearranged to the final form as applied to the Jennings optimal control problem {\frac{dx}{dt}=t_f f(x,u)}.
Changed lines 5-6 from:
'''Objective:''' Set up and solve the Jennings optimal control benchmark problem. Create a program to optimize and display the results. ''Estimated Time: 30 minutes''
to:
'''Objective:''' Solve an optimal control problem with a minimal final time. Set up and solve the Jennings optimal control benchmark problem. Create a program to optimize and display the results. ''Estimated Time: 30 minutes''

A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is:

{$0=\left(\frac{dx}{dt},x,u\right)$}

for simulation time 0 to 1. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then:

{$0=\left(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\frac{\frac{dx}{dt}}{t_f}=f(x,u)}, this equation can be rearranged to {\frac{dx}{dt}=t_f f(x,u)}.

Changed lines 29-37 from:
A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is:

{$0=\right(\frac{dx}{dt},x,u\right)$}

for simulation time 0 to 1. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then:

{$0=\right(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\frac{\frac{dx}{dt}}{t_f}=f(x,u)}, this equation can be rearranged to {\frac{dx}{dt}=t_f \, f(x,u)}. The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f
} parameter as follows:
to:
The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter as follows:
(:title Minimize Final Time (Jennings):)
(:keywords nonlinear control, Jennings, optimal control, dynamic optimization, engineering optimization, MATLAB, Python, GEKKO, optimization suite:)
(:description Jennings optimal control problem solved with MATLAB, Python, and GEKKO. The objective is to minimize the final time subject to differential constraints, initial conditions, and select final conditions.:)

'''Objective:''' Set up and solve the Jennings optimal control benchmark problem. Create a program to optimize and display the results. ''Estimated Time: 30 minutes''

The Jennings optimal control problem is to minimize the final time subject to differential constraints. Minimizing final time is found in many areas such as manufacturing, transportation, and energy systems. In each case, it is the desired end-state that must be met while the optimizer seeks to arrive at those conditions in the shortest time.

{$\min_{u(t)} \; t_f$}
{$\mathrm{subject \; to}$}
{$\frac{dx_1}{dt}=u$}
{$\frac{dx_2}{dt}=\cos\left(x_1(t)\right)$}
{$\frac{dx_3}{dt}=\sin\left(x_2(t)\right)$}
{$x(0) = \left[\pi/2,4,0\right]$}
{$x_2\left(t_f\right)=0$}
{$x_3\left(t_f\right)=0$}
{$-2 \le u(t) \le 2$}

A differential equation is time-scaled by adding a final time parameter {t_f} that scales a simulation from time 0 to 1 to a range of 0 to {t_f}. The differential equation simulation time is adjusted by dividing each derivative term by {t_f}. A general expression for a differential equation is:

{$0=\right(\frac{dx}{dt},x,u\right)$}

for simulation time 0 to 1. The {dt} term is adjusted from the current time derivative to a modified time derivative by adding the final time {t_f} as {t_f \, dt}. The new time scaled differential equation is then:

{$0=\right(\frac{\frac{dx}{dt}}{t_f},x,u\right)$}

In semi-explicit form {\frac{\frac{dx}{dt}}{t_f}=f(x,u)}, this equation can be rearranged to {\frac{dx}{dt}=t_f \, f(x,u)}. The Jennings problem is solved by specifying a time horizon from 0.0 to 1.0 with the additional {t_f} parameter as follows:

{$\min_{u(t), t_f} \; t_f$}
{$\mathrm{subject \; to}$}
{$\frac{dx_1}{dt}=t_f \, u$}
{$\frac{dx_2}{dt}=t_f \, \cos\left(x_1(t)\right)$}
{$\frac{dx_3}{dt}=t_f \, \sin\left(x_2(t)\right)$}
{$x(0) = \left[\pi/2,4,0\right]$}
{$x_2\left(t_f\right)=0$}
{$x_3\left(t_f\right)=0$}
{$-2 \le u(t) \le 2$}

The parameter {t_f} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Feedforward Variable or Fixed Value]] while the adjustable value {u} is declared as a [[https://apmonitor.com/wiki/index.php/Main/INFO|Manipulated Variable]].

!!!! Solutions

----

Attach:download.png [[Attach:dynamic_optimization_jennings.zip|Jennings Problem in MATLAB and Python]]

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/yuj217itTa8" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

----

(:toggle hide gekko button show="GEKKO (Python) Solution":)
(:div id=gekko:)
(:source lang=python:)
import numpy as np
from gekko import GEKKO
import matplotlib.pyplot as plt

m = GEKKO()

nt = 501
m.time = np.linspace(0,1,nt)

# Variables
x1 = m.Var(value=np.pi/2.0)
x2 = m.Var(value=4.0)
x3 = m.Var(value=0.0)

p = np.zeros(nt)
p[-1] = 1.0
final = m.Param(value=p)

# FV
tf = m.FV(value=1.0,lb=0.1,ub=100.0)
tf.STATUS = 1

# MV
u = m.MV(value=0,lb=-2,ub=2)
u.STATUS = 1

m.Equation(x1.dt()==u*tf)
m.Equation(x2.dt()==m.cos(x1)*tf)
m.Equation(x3.dt()==m.sin(x1)*tf)

m.Equation(x2*final<=0)
m.Equation(x3*final<=0)

m.Obj(tf)

m.options.IMODE = 6

m.solve()

print('Final Time: ' + str(tf.value))

plt.figure(1)
plt.plot(m.time,x1.value,'k-',LineWidth=2,label=r'$x_1$')
plt.plot(m.time,x2.value,'b-',LineWidth=2,label=r'$x_2$')
plt.plot(m.time,x3.value,'g--',LineWidth=2,label=r'$x_3$')
plt.plot(m.time,u.value,'r--',LineWidth=2,label=r'$u$')
plt.legend(loc='best')
plt.xlabel('Time')
plt.ylabel('Value')
plt.show()
(:sourceend:)
(:divend:)

----

!!!! References

# Beal, L., GEKKO for Dynamic Optimization, 2018, URL: https://gekko.readthedocs.io/en/latest/

# Hedengren, J. D. and Asgharzadeh Shishavan, R., Powell, K.M., and Edgar, T.F., Nonlinear Modeling, Estimation and Predictive Control in APMonitor, Computers and Chemical Engineering, Volume 70, pg. 133–148, 2014. [[https://dx.doi.org/10.1016/j.compchemeng.2014.04.013|Article]]