Lotka Volterra Fishing Optimization

Main.LotkaVolterra History

Hide minor edits - Show changes to output

March 30, 2023, at 01:46 PM by 136.36.4.38 -
Changed line 19 from:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the squared error to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the manipulated variable {`w(t)`}. The time window is from 0 to 12.
to:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the squared error to drive both the predator and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the manipulated variable {`w(t)`}. The time window is from 0 to 12.
March 24, 2023, at 06:20 PM by 10.35.117.248 -
Changed lines 5-6 from:
%width=550px%Attach:lotka_volterra.png
to:
(:html:)
<iframe width="560" height="315" src="https://www
.youtube.com/embed/iwdKOgt9Pnc" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
(:htmlend:)

Added lines 153-154:

%width=550px%Attach:lotka_volterra.png
March 24, 2023, at 05:31 PM by 10.35.117.248 -
Changed line 2 from:
(:keywords preditor, prey, equilibrium, optimization, optimal control, benchmark, nonlinear control, dynamic optimization, engineering optimization, Python, GEKKO, differential, algebraic, modeling language:)
to:
(:keywords predator, prey, equilibrium, optimization, optimal control, benchmark, nonlinear control, dynamic optimization, engineering optimization, Python, GEKKO, differential, algebraic, modeling language:)
March 24, 2023, at 05:00 PM by 10.35.117.248 -
Changed line 162 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 [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization|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. 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. [[https://apmonitor.com/wiki/index.php/Main/APMonitorReferences|Cite Gekko Paper]]
March 24, 2023, at 04:59 PM by 10.35.117.248 -
Changed lines 87-88 from:
'''Avoid Actuator Chatter with Objective Dead-Band'''
to:
!!!! Avoid Actuator Chatter
Changed line 154 from:
'''Reference'''
to:
!!!! Reference
March 24, 2023, at 04:58 PM by 10.35.117.248 -
Changed line 17 from:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the squared error to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the manipulated variable {`w(t)`}. The time window is from 0 to 12 and the parameters have values {`c_1=0.4`} and {`c_2=0.2`}.
to:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the squared error to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the manipulated variable {`w(t)`}. The time window is from 0 to 12.
March 24, 2023, at 04:35 PM by 10.35.117.248 -
Added lines 151-156:

----

'''Reference'''

* Sager, S., Bock, H.G., Diehl, M., Reinelt, G., Schloder, J.P. (2006). Numerical Methods for Optimal Control with Binary Control Functions Applied to a Lotka-Volterra Type Fishing Problem. In: Seeger, A. (eds) Recent Advances in Optimization. Lecture Notes in Economics and Mathematical Systems, vol 563. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-28258-0_17
March 24, 2023, at 04:29 PM by 10.35.117.248 -
Changed line 25 from:
(:toggle hide solution button show="Lotka Volterra Source":)
to:
(:toggle hide solution button show="🐍 Lotka Volterra Python Source":)
Changed line 93 from:
(:toggle hide solution2 button show="Dead-band MPC Source":)
to:
(:toggle hide solution2 button show="🐍 Dead-band MPC Python Source":)
March 24, 2023, at 11:50 AM by 10.35.117.248 -
March 24, 2023, at 11:48 AM by 10.35.117.248 -
Changed lines 19-20 from:
The Lotka Volterra fishing problem seeks an optimal fishing strategy over a fixed time horizon to bring both predator and prey fish to a desired steady state. The manipulted variable is the fishing by man. The manipulated variable is either continuous or a discrete value with no fishing (0) or full fishing (1).
to:
The Lotka Volterra fishing problem seeks an optimal fishing strategy over a fixed time horizon to bring both predator and prey fish to a desired steady state. The manipulated variable is the fishing by man. The manipulated variable is either continuous or a discrete value with no fishing (0) or full fishing (1).
Added lines 84-150:

----

'''Avoid Actuator Chatter with Objective Dead-Band'''

The solution with a squared objective has chatter in the fishing decision variable ''w'' as the fishing fleet is deployed and returns repeatedly to achieve a perfect balance between predator and prey. This repeated action can wear out an actuator such as a valve that is quickly switched open or closed or a motor that switched on or off. The fishing fleet deployment schedule would also have additional costs for the fishermen and logistics to implement the schedule. A potential improvement is to set up a dead-band around the objective or to include actuator move-suppression. A dead-band of +/-0.05 is set around the objective of 1.0 so that 0.95 to 1.05 are acceptable for the predator and prey levels.

%width=550px%Attach:lotka_volterra_mpc.png

(:toggle hide solution2 button show="Dead-band MPC Source":)
(:div id=solution2:)
(:source lang=python:)
import numpy as np
import matplotlib.pyplot as plt
from gekko import GEKKO

m = GEKKO(remote=True)

# Add 0.01 as first step
# 0,0.01,0.1,0.2,0.3,...11.9,12.0)
m.time = np.insert(np.linspace(0,12,121),1,0.01)

# change solver options
m.solver_options = ['minlp_gap_tol 0.001',\
                    'minlp_maximum_iterations 10000',\
                    'minlp_max_iter_with_int_sol 30',\
                    'minlp_branch_method 3',\
                    'minlp_integer_tol 0.001',\
                    'minlp_integer_leaves 0',\
                    'minlp_maximum_iterations 200']

c0 = 0.4; c1 = 0.2

last = m.Param(np.zeros(122))
last.value[-1] = 1

x0 = m.CV(value=0.5,lb=0)
x0.STATUS = 1; x0.SPHI=1.05; x0.SPLO=0.95
x1 = m.CV(value=0.7,lb=0)
x1.STATUS = 1; x1.SPHI=1.05; x1.SPLO=0.95

w = m.MV(value=0,lb=0,ub=1,integer=True)
w.STATUS = 1

m.Equations([x0.dt() == x0 - x0*x1 - c0*x0*w,\
            x1.dt() == - x1 + x0*x1 - c1*x1*w])

m.options.IMODE = 6
m.options.NODES = 2
m.options.SOLVER = 1
m.options.MV_TYPE = 0
m.solve()

plt.figure(figsize=(6,4))
plt.subplot(2,1,1)
plt.step(m.time,w.value,'r-',label='w')
plt.legend(loc=1); plt.grid(); plt.ylabel('Fleet Deployed')
plt.subplot(2,1,2)
plt.plot([0,12],[1.05,1.05],'g:',label=r'$SP_{HI}$')
plt.plot([0,12],[0.95,0.95],'g:',label=r'$SP_{LO}$')
plt.plot(m.time,x0.value,'b-',label=r'Prey $(x_0)$')
plt.plot(m.time,x1.value,'k-',label=r'Predator $(x_1)$')
plt.xlabel('Time'); plt.ylabel('Fish')
plt.legend(loc=1); plt.grid(); plt.tight_layout()
plt.savefig('lotka2.png',dpi=300); plt.show()
(:sourceend:)
(:divend:)
March 24, 2023, at 11:20 AM by 10.35.117.248 -
Changed line 13 from:
{$\quad \quad  \frac{dx_2}{dt} = \left(x_0-1\right)^2 + \left(x_1-1\right)^2$}
to:
{$\quad \quad  x_2 = \int_0^{t_f} \left(x_0-1\right)^2 + \left(x_1-1\right)^2 dt$}
Changed line 17 from:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the objective to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the decision variable {`w(t)`}. The time window is from 0 to 12 and the parameters have values {`c_1=0.4`} and {`c_2=0.2`}.
to:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the squared error to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the manipulated variable {`w(t)`}. The time window is from 0 to 12 and the parameters have values {`c_1=0.4`} and {`c_2=0.2`}.
March 24, 2023, at 11:17 AM by 10.35.117.248 -
Changed line 7 from:
A Mixed Integer Optimal Control Problem (MIOCP) is the Lotka Volterra fishing problem. It finds an fishing strategy over 12 years to equilibrate the predator-prey fish to a sustainable steady-state value. The Lotka Volterra equations for a predator-prey system have an additional term to introduce fishing by man with constants {`c_0=0.4`} and {`c_1=0.2`}.
to:
The Lotka Volterra fishing problem is a Mixed Integer Optimal Control Problem (MIOCP). It finds a fishing strategy over 12 years to equilibrate the predator-prey fish to a sustainable steady-state value. The Lotka Volterra equations for a predator-prey system have an additional term to introduce fishing by man with constants {`c_0=0.4`} and {`c_1=0.2`}.
March 23, 2023, at 03:19 AM by 198.134.98.50 -
March 23, 2023, at 03:19 AM by 198.134.98.50 -
Changed line 89 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. 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 23, 2023, at 03:17 AM by 198.134.98.50 -
Added lines 17-18:
The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the objective to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the decision variable {`w(t)`}. The time window is from 0 to 12 and the parameters have values {`c_1=0.4`} and {`c_2=0.2`}.
Changed lines 21-25 from:
The mathematical equations are Ordinary Differential Equations (ODEs). The optimal binary manipulated variable chatters on and off, making the Lotka Volterra fishing problem an interesting benchmark of mixed-integer optimal control solvers. The mixed-integer optimal control problem is given by

{$ \begin{array}{llclr} \min_{x,w} & x_2(t_f) \\ \mbox{s.t.} & \dot{x}_0 & = &  x_0 - x_0 x_1 - \; c_0 x_0 \; w \\ & \dot{x}_1 & = & - x_1 + x_0 x_1 - \; c_1 x_1 \; w  \\ & \dot{x}_2 & = & (x_0 - 1)^2 + (x_1 - 1)^2  \\ & x(0) &=& (0.5, 0.7, 0)^T \\ & w(t) &\in&  \{0, 1\} \end{array} $}

The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the objective to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the decision variable {`w(t)`}. The time window is from 0 to 12 and the parameters have values {`c_1=0.4`} and {`c_2=0.2`}
.
to:
The mathematical equations are Ordinary Differential Equations (ODEs). The optimal binary manipulated variable chatters on and off, making the Lotka Volterra fishing problem an interesting benchmark of mixed-integer optimal control solvers.
March 23, 2023, at 03:15 AM by 198.134.98.50 -
Changed line 21 from:
{$ \begin{array}{llclr} \min_{x, w} & x_2(t_f) \\ \mbox{s.t.} & \dot{x}_0 & = &  x_0 - x_0 x_1 - \; c_0 x_0 \; w \\ & \dot{x}_1 & = & - x_1 + x_0 x_1 - \; c_1 x_1 \; w  \\ & \dot{x}_2 & = & (x_0 - 1)^2 + (x_1 - 1)^2  \\ & x(0) &=& (0.5, 0.7, 0)^T \\ & w(t) &\in&  \{0, 1\} \end{array} $}
to:
{$ \begin{array}{llclr} \min_{x,w} & x_2(t_f) \\ \mbox{s.t.} & \dot{x}_0 & = &  x_0 - x_0 x_1 - \; c_0 x_0 \; w \\ & \dot{x}_1 & = & - x_1 + x_0 x_1 - \; c_1 x_1 \; w  \\ & \dot{x}_2 & = & (x_0 - 1)^2 + (x_1 - 1)^2  \\ & x(0) &=& (0.5, 0.7, 0)^T \\ & w(t) &\in&  \{0, 1\} \end{array} $}
March 23, 2023, at 03:15 AM by 198.134.98.50 -
Changed line 5 from:
%width=550px%lotka_volterra.png
to:
%width=550px%Attach:lotka_volterra.png
March 23, 2023, at 03:14 AM by 198.134.98.50 -
Added lines 1-91:
(:title Lotka Volterra Fishing Optimization:)
(:keywords preditor, prey, equilibrium, optimization, optimal control, benchmark, nonlinear control, dynamic optimization, engineering optimization, Python, GEKKO, differential, algebraic, modeling language:)
(:description The Lotka Volterra fishing problem solved with Python Gekko.:)

%width=550px%lotka_volterra.png

A Mixed Integer Optimal Control Problem (MIOCP) is the Lotka Volterra fishing problem. It finds an fishing strategy over 12 years to equilibrate the predator-prey fish to a sustainable steady-state value. The Lotka Volterra equations for a predator-prey system have an additional term to introduce fishing by man with constants {`c_0=0.4`} and {`c_1=0.2`}.

{$\min_{x,w} x_2 \left( t_f \right)$}

{$\mathrm{s.t.} \quad \frac{dx_0}{dt} = x_0 - x_0 x_1 - c_0 x_0 w$}
{$\quad \quad  \frac{dx_1}{dt} = -x_1 + x_0 x_1 - c_1 x_1 w$}
{$\quad \quad  \frac{dx_2}{dt} = \left(x_0-1\right)^2 + \left(x_1-1\right)^2$}
{$\quad \quad x(0) = (0.5,0.7,0)^T$}
{$\quad \quad w(t) \in {{0,1}}$}

The Lotka Volterra fishing problem seeks an optimal fishing strategy over a fixed time horizon to bring both predator and prey fish to a desired steady state. The manipulted variable is the fishing by man. The manipulated variable is either continuous or a discrete value with no fishing (0) or full fishing (1).

The mathematical equations are Ordinary Differential Equations (ODEs). The optimal binary manipulated variable chatters on and off, making the Lotka Volterra fishing problem an interesting benchmark of mixed-integer optimal control solvers. The mixed-integer optimal control problem is given by

{$ \begin{array}{llclr} \min_{x, w} & x_2(t_f) \\ \mbox{s.t.} & \dot{x}_0 & = &  x_0 - x_0 x_1 - \; c_0 x_0 \; w \\ & \dot{x}_1 & = & - x_1 + x_0 x_1 - \; c_1 x_1 \; w  \\ & \dot{x}_2 & = & (x_0 - 1)^2 + (x_1 - 1)^2  \\ & x(0) &=& (0.5, 0.7, 0)^T \\ & w(t) &\in&  \{0, 1\} \end{array} $}

The differential states {`x_0`} and {`x_1`} are the biomass of prey and predator, respectively. The third differential state is the integral of the objective to drive both the predictor and prey biomass values to 1.0. The decision to send out the fishing fleet at time {`t`} is the decision variable {`w(t)`}. The time window is from 0 to 12 and the parameters have values {`c_1=0.4`} and {`c_2=0.2`}.

%width=550px%Attach:lotka_volterra_fishing.png

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

m = GEKKO(remote=False)

# Add 0.01 as first step
# 0,0.01,0.1,0.2,0.3,...11.9,12.0)
m.time = np.insert(np.linspace(0,12,121),1,0.01)

# change solver options
m.solver_options = ['minlp_gap_tol 0.001',\
                    'minlp_maximum_iterations 10000',\
                    'minlp_max_iter_with_int_sol 100',\
                    'minlp_branch_method 1',\
                    'minlp_integer_tol 0.001',\
                    'minlp_integer_leaves 0',\
                    'minlp_maximum_iterations 200']

c0 = 0.4; c1 = 0.2

last = m.Param(np.zeros(122))
last.value[-1] = 1

x0 = m.Var(value=0.5,lb=0)
x1 = m.Var(value=0.7,lb=0)
x2 = m.Var(value=0.0,lb=0)
w = m.MV(value=0,lb=0,ub=1,integer=True)
w.STATUS = 1

m.Minimize(last*x2)

m.Equations([x0.dt() == x0 - x0*x1 - c0*x0*w,\
            x1.dt() == - x1 + x0*x1 - c1*x1*w,\
            x2 == m.integral((x0-1)**2 + (x1-1)**2)])

m.options.IMODE = 6
m.options.NODES = 3
m.options.SOLVER = 1
m.options.MV_TYPE = 0
m.solve()

plt.figure(figsize=(6,4))
plt.step(m.time,w.value,'r-',label='w (0/1)')
plt.plot(m.time,x0.value,'b-',label=r'$x_0$')
plt.plot(m.time,x1.value,'k-',label=r'$x_1$')
plt.plot(m.time,x2.value,'g-',label=r'$x_2$')
plt.xlabel('Time'); plt.ylabel('Variables')
plt.legend(loc='best'); plt.grid(); plt.tight_layout()
plt.savefig('lotka.png',dpi=300); plt.show()
(:sourceend:)
(:divend:)

Attach:download.png [[Attach:lotka_volterra_fishing.zip|Download MATLAB Solution Files]]

An MINLP solution is calculated with [[https://apopt.com|APOPT]] with an objective function value of {`x_2(t_f) = 1.3495`}.

----

%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.