Aircraft Optimization

Apps.AircraftControl History

Hide minor edits - Show changes to output

March 27, 2023, at 02:31 PM by 10.35.117.248 -
Changed lines 5-6 from:
%width=550px%Attach:aircraft.png
to:
(:html:)
<iframe width="560" height="315" src="https://www
.youtube.com/embed/VAaPJP65p-o" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
(:htmlend:)

Added lines 78-79:

%width=550px%Attach:aircraft.png
March 27, 2023, at 02:14 PM by 10.35.117.248 -
Changed line 39 from:
# Control signal - aeleron angle
to:
# Control signal - aileron angle
March 27, 2023, at 02:06 PM by 10.35.117.248 -
Changed line 65 from:
plt.plot(tm,w,'r:',lw=2,label='Aeleron Angle')
to:
plt.plot(tm,w,'r:',lw=2,label='Aileron Angle')
March 26, 2023, at 01:31 PM by 136.36.4.38 -
Changed lines 81-85 from:
The [[https://gekko.readthedocs.io/en/latest/|Gekko Optimization Suite]] is a machine learning and optimization package in Python for mixed-integer and differential algebraic equations. The GEKKO package is available in Python with '''pip install gekko'''. There are [[link|additional example problems]] for equation solving, optimization, regression, dynamic simulation, model predictive control, and machine learning.
to:
The [[https://gekko.readthedocs.io/en/latest/|Gekko Optimization Suite]] is a machine learning and optimization package in Python for mixed-integer and differential algebraic equations.

📄 [[https://apmonitor.com/wiki/index.php/Main/APMonitorReferences|Gekko Publication and References]]

The GEKKO package is available in Python with
'''pip install gekko'''. There are [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization|additional example problems]] for equation solving, optimization, regression, dynamic simulation, model predictive control, and machine learning.
March 26, 2023, at 01:31 PM by 136.36.4.38 -
Changed lines 7-8 from:
The aircraft optimization problem is based on a simple aircraft model. The mathematical equations are ordinary differential equations (ODEs) that are integrated to final time ''T''. The objective is to minimize the time required to achieve zero angle of attack, pitch angle, and pitch rate. The manipulated variable (control) is the aeleron angle.
to:
The aircraft optimization problem is based on a simple aircraft model. The mathematical equations are ordinary differential equations (ODEs) that are integrated to final time ''T''. The objective is to minimize the time required to achieve zero angle of attack, pitch angle, and pitch rate. The manipulated variable (control) is the aileron angle.
Added lines 17-19:

The problem is transformed to aileron angle 0 to 1 with an equivalent substitution.

March 26, 2023, at 01:29 PM by 136.36.4.38 -
Changed line 9 from:
{$ \begin{array}{llcl} \min_{x, w, T} & T \\ \mbox{s.t.} & \dot{x}_0 &=& -0.877 \; x_0 + x_2 - 0.088 \; x_0 \; x_2 + 0.47 \; x_0^2 - 0.019 \; x_1^2 - x_0^2 \; x_2 + 3.846 \; x_0^3 \\ &&& - 0.215 \; w + 0.28 \; x_0^2 \; w + 0.47 \; x_0 \; w^2 + 0.63 \; w^3 \\ & \dot{x}_1 &=& x_2 \\ & \dot{x}_2 &=& -4.208 \; x_0 - 0.396 \; x_2 - 0.47 \; x_0^2 - 3.564 \; x_0^3 \\ &&& -20.967 \; w + 6.265 \; x_0^2 \; w + 46 \; x_0 \; w^2 + 61.4 \; w^3 \\ & x(0) &=& (0.4655,0,0)^T \\ & x(T) &=& (0,0,0)^T \\ & w(t) &\in& \{-0.05236,0.05236\} \end{array} $}
to:
{$ \begin{array}{llcl} \min_{x, w, T} & T \\ \mbox{s.t.} & \dot{x}_0 &=& -0.877 \; x_0 + x_2 - 0.088 \; x_0 \; x_2 + 0.47 \; x_0^2 \\ &&& - 0.019 \; x_1^2 - x_0^2 \; x_2 + 3.846 \; x_0^3 \\ &&& - 0.215 \; w + 0.28 \; x_0^2 \; w + 0.47 \; x_0 \; w^2 + 0.63 \; w^3 \\ & \dot{x}_1 &=& x_2 \\ & \dot{x}_2 &=& -4.208 \; x_0 - 0.396 \; x_2 - 0.47 \; x_0^2 - 3.564 \; x_0^3 \\ &&& -20.967 \; w + 6.265 \; x_0^2 \; w + 46 \; x_0 \; w^2 + 61.4 \; w^3 \\ & x(0) &=& (0.4655,0,0)^T \\ & x(T) &=& (0,0,0)^T \\ & w(t) &\in& \{-0.05236,0.05236\} \end{array} $}
March 26, 2023, at 01:28 PM by 136.36.4.38 -
Added lines 1-78:
(:title Aircraft Optimization:)
(:keywords optimization, aircraft, angle, binary, optimal control, benchmark, nonlinear control, dynamic optimization, engineering optimization, Python, GEKKO, differential, algebraic, modeling language:)
(:description Aircraft optimization solved with Python Gekko.:)

%width=550px%Attach:aircraft.png

The aircraft optimization problem is based on a simple aircraft model. The mathematical equations are ordinary differential equations (ODEs) that are integrated to final time ''T''. The objective is to minimize the time required to achieve zero angle of attack, pitch angle, and pitch rate. The manipulated variable (control) is the aeleron angle.

{$ \begin{array}{llcl} \min_{x, w, T} & T \\ \mbox{s.t.} & \dot{x}_0 &=& -0.877 \; x_0 + x_2 - 0.088 \; x_0 \; x_2 + 0.47 \; x_0^2 - 0.019 \; x_1^2 - x_0^2 \; x_2 + 3.846 \; x_0^3 \\ &&& - 0.215 \; w + 0.28 \; x_0^2 \; w + 0.47 \; x_0 \; w^2 + 0.63 \; w^3 \\ & \dot{x}_1 &=& x_2 \\ & \dot{x}_2 &=& -4.208 \; x_0 - 0.396 \; x_2 - 0.47 \; x_0^2 - 3.564 \; x_0^3 \\ &&& -20.967 \; w + 6.265 \; x_0^2 \; w + 46 \; x_0 \; w^2 + 61.4 \; w^3 \\ & x(0) &=& (0.4655,0,0)^T \\ & x(T) &=& (0,0,0)^T \\ & w(t) &\in& \{-0.05236,0.05236\} \end{array} $}

where {`x_0`} is the angle of attack in radians, {`x_1`} is the pitch angle, {`x_2`} is the pitch rate in rad/s, and the control function {`w`} is the tail deflection angle in radians. Both initial and terminal values of the differential states are fixed.

%width=550px%Attach:aircraft_solution.png

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

m = GEKKO(remote=False)
n = 101; m.time = np.linspace(0,1,n)

ksi = 0.05236
tf = m.FV(value=5, lb=1, ub=10)
tf.STATUS = 1
m.Minimize(tf/n)

# x0 = angle of attack
# x1 = pitch angle
# x2 = pitch rate
x0,x1,x2 = m.Array(m.Var,3,value=0,lb=-1,ub=1)
x0.value = 0.4655

# Control signal - aeleron angle
w = m.MV(value=0, lb=0, ub=1); w.STATUS=1

m.Equation(x0.dt()/tf == -0.877*x0 + x2 - 0.088*x0*x2
          + 0.47*x0**2 - 0.019*x1**2 -x0**2*x2 + 3.846*x0**3
          -(0.215*ksi-0.28*x0**2*ksi -0.47*x0*ksi**2 - 0.63*ksi**3)*w
          -(-0.215*ksi + 0.28*x0**2 -0.47*x0*ksi**2 + 0.63*ksi**3)*(1-w))
m.Equation(x1.dt()/tf==x2)
m.Equation(x2.dt()/tf == -4.208*x0 - 0.396*x2 - 0.47*x0**2 - 3.564*x0**3
          +20.967*ksi - 6.265*x0**2*ksi + 46*x0*ksi**2 -61.4*ksi**3
          -(20.967*ksi - 6.265*x0**2*ksi - 61.4*ksi**3)*2*w)

m.fix_final(x0,0)
m.fix_final(x1,0)
m.fix_final(x2,0)

m.options.IMODE=6
m.options.SOLVER=1
m.options.MAX_ITER=1000

m.options.COLDSTART=0
m.solve()

tm = tf.value[0]*m.time
plt.figure(figsize=(6,4))
plt.subplot(2,1,1)
plt.plot(tm,w,'r:',lw=2,label='Aeleron Angle')
plt.grid(); plt.legend()
plt.subplot(2,1,2)
plt.plot(tm,x0,'r-',lw=2,label='AOA')
plt.plot(tm,x1,'b:',lw=2,label='Pitch')
plt.plot(tm,x2,'k--',lw=2,label='Pitch Rate')
plt.grid(); plt.legend()
plt.savefig('aircraft.png',dpi=300);
plt.tight_layout(); plt.show()
(:sourceend:)
(:divend:)

----

%width=200px%Attach:gekko.png

The [[https://gekko.readthedocs.io/en/latest/|Gekko Optimization Suite]] is a machine learning and optimization package in Python for mixed-integer and differential algebraic equations. The GEKKO package is available in Python with '''pip install gekko'''. There are [[link|additional example problems]] for equation solving, optimization, regression, dynamic simulation, model predictive control, and machine learning.