Main

Economic Model Predictive Control (MPC)

Main.EconomicDynamicOptimization History

Hide minor edits - Show changes to output

March 08, 2018, at 03:01 PM by 45.56.3.173 -
Changed line 7 from:
The commercial fishing optimal control problem has an integral objective function. The population of fish ''x'' is influenced by how many fish are removed each year that depends on ''u''. The objective is to maximize the revenue from fishing over a 10 year time period. If there is overfishing (high ''u'') then the returns for subsequent years are reduced and the fish population does not recover. This optimal control problem finds the optimal extraction profile to maximize the commercial fishing profit.
to:
The commercial fishing optimal control problem has an integral profit function that includes the cost of operations and the revenue from fish sales. The population of fish ''x'' is influenced by how many fish are removed each year that depends on ''u''. The objective is to maximize the revenue from fishing over a 10 year time period. If there is overfishing (high ''u'') then the returns for subsequent years are reduced and the fish population does not recover. This optimal control problem finds the optimal extraction profile to maximize the commercial fishing profit.
March 08, 2018, at 02:48 PM by 45.56.3.173 -
Deleted lines 8-43:
Integrals are a natural expression of many systems where the accumulation of a quantity is maximized or minimized. The integral is the profit function over the 10 year time period.

{$\max_{u(t)} \int_0^{10} \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
{$\mathrm{subject \; to}$}
{$\frac{dx}{dt}=r \, x(t) \left(1-\frac{x(t)}{k}\right)-u \, U_{max}$}
{$x(0) = 70$}
{$0 \le u(t) \le 1$}
{$E=1, \, c=17.5, \, r=0.71, \, k=80.5, \, U_{max}=20$}

Integral expressions are reformulated in differential and algebraic form by defining a new variable.

{$J = \int_0^{10} \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}

The new variable ''J'' and integral are differentiated and included as an additional equation. The problem then becomes a maximization of the new variable ''J'' at the final time.

{$\max_{u(t)} J\left(t_f\right)$}
{$\mathrm{subject \; to}$}
{$\frac{dx}{dt}=r \, x(t) \left(1-\frac{x(t)}{k}\right)-u \, U_{max}$}
{$\frac{dJ}{dt} = \left(E-\frac{c}{x}\right) u \, U_{max}$}
{$x(0) = 70$}
{$J(0) = 0$}
{$0 \le u(t) \le 1$}
{$t_f = 10, \, E=1, \, c=17.5, \, r=0.71, \, k=80.5, \, U_{max}=20$}

The initial condition of the integral ''J'' starts at zero and becomes the integral in the time range of 0 to 10. The end value is maximized at the final point in the time horizon of the optimal control problem. A maximization problem is converted to a minimization problem by multiplying the objective by negative one.

{$\max_{u(t)} J\left(t_f\right) = -\min_{u(t)} J\left(t_f\right)$}

Most optimization solvers require an objective function minimization, including GEKKO and APMonitor.

!!!! Solutions

----

Attach:download.png [[Attach:dynamic_optimization_fishery.zip|Economic Optimization of Fishery in MATLAB and Python]]

Changed line 10 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/MA53XPp-a7I" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/y26X-BSf8KU" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Deleted lines 12-15:
----

%width=550px%Attach:fishing_gekko.png

Added lines 84-119:
Integrals are a natural expression of many systems where the accumulation of a quantity is maximized or minimized. The integral is the profit function over the 10 year time period.

{$\max_{u(t)} \int_0^{10} \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
{$\mathrm{subject \; to}$}
{$\frac{dx}{dt}=r \, x(t) \left(1-\frac{x(t)}{k}\right)-u \, U_{max}$}
{$x(0) = 70$}
{$0 \le u(t) \le 1$}
{$E=1, \, c=17.5, \, r=0.71, \, k=80.5, \, U_{max}=20$}

Integral expressions are reformulated in differential and algebraic form by defining a new variable.

{$J = \int_0^{10} \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}

The new variable ''J'' and integral are differentiated and included as an additional equation. The problem then becomes a maximization of the new variable ''J'' at the final time.

{$\max_{u(t)} J\left(t_f\right)$}
{$\mathrm{subject \; to}$}
{$\frac{dx}{dt}=r \, x(t) \left(1-\frac{x(t)}{k}\right)-u \, U_{max}$}
{$\frac{dJ}{dt} = \left(E-\frac{c}{x}\right) u \, U_{max}$}
{$x(0) = 70$}
{$J(0) = 0$}
{$0 \le u(t) \le 1$}
{$t_f = 10, \, E=1, \, c=17.5, \, r=0.71, \, k=80.5, \, U_{max}=20$}

The initial condition of the integral ''J'' starts at zero and becomes the integral in the time range of 0 to 10. The end value is maximized at the final point in the time horizon of the optimal control problem. A maximization problem is converted to a minimization problem by multiplying the objective by negative one.

{$\max_{u(t)} J\left(t_f\right) = -\min_{u(t)} J\left(t_f\right)$}

Most optimization solvers require an objective function minimization, including GEKKO and APMonitor.

%width=550px%Attach:fishing_gekko.png

!!!! Solutions in APM MATLAB and APM Python

Attach:download.png [[Attach:dynamic_optimization_fishery.zip|Economic Optimization of Fishery in MATLAB and Python]]

Added line 121:
<iframe width="560" height="315" src="https://www.youtube.com/embed/MA53XPp-a7I" frameborder="0" allowfullscreen></iframe>
Deleted lines 122-123:

----
March 08, 2018, at 02:25 PM by 45.56.3.173 -
Changed line 1 from:
(:title Economic Optimization of Fishing:)
to:
(:title Economic Model Predictive Control (MPC):)
March 07, 2018, at 07:34 PM by 10.37.83.132 -
Changed lines 37-38 from:
Most optimization solvers require an objective function minimization.
to:
Most optimization solvers require an objective function minimization, including GEKKO and APMonitor.
Added lines 51-52:
%width=550px%Attach:fishing_gekko.png
Added lines 56-120:
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt

# create GEKKO model
m = GEKKO()

# time points
n=501
m.time = np.linspace(0,10,n)

# constants
E = 1
c = 17.5
r = 0.71
k = 80.5
U_max = 20

# fishing rate
u = m.MV(value=1,lb=0,ub=1)
u.STATUS = 1
u.DCOST = 0

# fish population
x = m.Var(value=70)

# fish population balance
m.Equation(x.dt() == r*x*(1-x/k)-u*U_max)

# objective (profit)
J = m.Var(value=0)
# final objective
Jf = m.FV()
Jf.STATUS = 1
m.Connection(Jf,J,pos2='end')
m.Equation(J.dt() == (E-c/x)*u*U_max)
# maximize profit
m.Obj(-Jf)

# options
m.options.IMODE = 6  # optimal control
m.options.NODES = 3  # collocation nodes
m.options.SOLVER = 3 # solver (IPOPT)

# solve optimization problem
m.solve()

# print profit
print('Optimal Profit: ' + str(Jf.value[0]))

# plot results
plt.figure(1)
plt.subplot(2,1,1)
plt.plot(m.time,J.value,'r--',label='profit')
plt.plot(m.time[-1],Jf.value[0],'ro',markersize=10,\
        label='final profit = '+str(Jf.value[0]))
plt.plot(m.time,x.value,'b-',label='fish population')
plt.ylabel('Value')
plt.legend()
plt.subplot(2,1,2)
plt.plot(m.time,u.value,'k.-',label='fishing rate')
plt.ylabel('Rate')
plt.xlabel('Time (yr)')
plt.legend()
plt.show()
March 07, 2018, at 07:06 PM by 10.37.83.132 -
Changed lines 16-17 from:
{$E=1, \, c=17.5 \, r=0.71 \, k=80.5 \, U_{max}=20$}
to:
{$E=1, \, c=17.5, \, r=0.71, \, k=80.5, \, U_{max}=20$}
Changed line 31 from:
{$t_f = 10, \, E=1, \, c=17.5 \, r=0.71 \, k=80.5 \, U_{max}=20$}
to:
{$t_f = 10, \, E=1, \, c=17.5, \, r=0.71, \, k=80.5, \, U_{max}=20$}
March 07, 2018, at 07:00 PM by 10.37.83.132 -
Changed line 11 from:
{$\max_{u(t)} \int_0^10 \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
to:
{$\max_{u(t)} \int_0^{10} \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
Changed line 20 from:
{$J = \int_0^10 \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
to:
{$J = \int_0^{10} \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
March 07, 2018, at 06:59 PM by 10.37.83.132 -
Changed line 1 from:
(:title Economic Optimization of Commercial Fishing:)
to:
(:title Economic Optimization of Fishing:)
Changed lines 7-9 from:
The commercial fishing optimal control problem has an integral objective function. Integrals are a natural expression of many systems where the accumulation of a quantity is maximized or minimized.
to:
The commercial fishing optimal control problem has an integral objective function. The population of fish ''x'' is influenced by how many fish are removed each year that depends on ''u''. The objective is to maximize the revenue from fishing over a 10 year time period. If there is overfishing (high ''u'') then the returns for subsequent years are reduced and the fish population does not recover. This optimal control problem finds the optimal extraction profile to maximize the commercial fishing profit.

Integrals are a natural expression of many systems where the accumulation of a quantity is maximized or minimized. The integral is the profit function over the 10 year time period
.
March 07, 2018, at 06:55 PM by 10.37.83.132 -
Added lines 1-64:
(:title Economic Optimization of Commercial Fishing:)
(:keywords nonlinear control, fishing, optimal control, dynamic optimization, sustainability, MATLAB, Python, GEKKO, optimization suite:)
(:description Economic optimization using model forecasts for harvesting and supply. The problem is solved with MATLAB, Python, and GEKKO.:)

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

The commercial fishing optimal control problem has an integral objective function. Integrals are a natural expression of many systems where the accumulation of a quantity is maximized or minimized.

{$\max_{u(t)} \int_0^10 \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}
{$\mathrm{subject \; to}$}
{$\frac{dx}{dt}=r \, x(t) \left(1-\frac{x(t)}{k}\right)-u \, U_{max}$}
{$x(0) = 70$}
{$0 \le u(t) \le 1$}
{$E=1, \, c=17.5 \, r=0.71 \, k=80.5 \, U_{max}=20$}

Integral expressions are reformulated in differential and algebraic form by defining a new variable.

{$J = \int_0^10 \left(E-\frac{c}{x}\right) u \, U_{max} \, dt$}

The new variable ''J'' and integral are differentiated and included as an additional equation. The problem then becomes a maximization of the new variable ''J'' at the final time.

{$\max_{u(t)} J\left(t_f\right)$}
{$\mathrm{subject \; to}$}
{$\frac{dx}{dt}=r \, x(t) \left(1-\frac{x(t)}{k}\right)-u \, U_{max}$}
{$\frac{dJ}{dt} = \left(E-\frac{c}{x}\right) u \, U_{max}$}
{$x(0) = 70$}
{$J(0) = 0$}
{$0 \le u(t) \le 1$}
{$t_f = 10, \, E=1, \, c=17.5 \, r=0.71 \, k=80.5 \, U_{max}=20$}

The initial condition of the integral ''J'' starts at zero and becomes the integral in the time range of 0 to 10. The end value is maximized at the final point in the time horizon of the optimal control problem. A maximization problem is converted to a minimization problem by multiplying the objective by negative one.

{$\max_{u(t)} J\left(t_f\right) = -\min_{u(t)} J\left(t_f\right)$}

Most optimization solvers require an objective function minimization.

!!!! Solutions

----

Attach:download.png [[Attach:dynamic_optimization_fishery.zip|Economic Optimization of Fishery in MATLAB and Python]]

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

----

(:toggle hide gekko button show="GEKKO (Python) Solution":)
(:div id=gekko:)
(:source lang=python:)
(:sourceend:)
(:divend:)

(:html:)
(:htmlend:)

----

!!!! References

# Beal, L., GEKKO for Dynamic Optimization, 2018, URL: http://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. [[http://dx.doi.org/10.1016/j.compchemeng.2014.04.013|Article]]