<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mintoc.de/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JohnHedengren</id>
	<title>mintOC - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://mintoc.de/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JohnHedengren"/>
	<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Special:Contributions/JohnHedengren"/>
	<updated>2026-06-09T09:04:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2343</id>
		<title>Time optimal car problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2343"/>
		<updated>2022-08-28T13:23:10Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Update with latest Gekko v1.0.5&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Time optimal car problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The end point constraints are imposed as hard constraints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
# set up the gekko model&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
&lt;br /&gt;
# set up the time (minimize the time with time scaling)&lt;br /&gt;
m.time = np.linspace(0, 1, 100)&lt;br /&gt;
&lt;br /&gt;
# set up the variables&lt;br /&gt;
Z1 = m.Var(value=0, ub=330, lb=0)&lt;br /&gt;
Z2 = m.Var(value=0, ub=33, lb=0)&lt;br /&gt;
m.fix_final(Z2, 0)&lt;br /&gt;
m.fix_final(Z1, 300)&lt;br /&gt;
&lt;br /&gt;
# set up the value we modify over the horizon&lt;br /&gt;
tf = m.FV(value=500, lb=0.1)&lt;br /&gt;
tf.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# set up the MV&lt;br /&gt;
u = m.MV(integer=True, lb=-2, ub=1)&lt;br /&gt;
u.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# set up the equations&lt;br /&gt;
m.Equation(Z1.dt() / tf == Z2)&lt;br /&gt;
m.Equation(Z2.dt() / tf == u)&lt;br /&gt;
&lt;br /&gt;
# set the objective&lt;br /&gt;
m.Obj(tf)&lt;br /&gt;
&lt;br /&gt;
# set up the options&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
m.solve(disp=False)&lt;br /&gt;
&lt;br /&gt;
# print the time&lt;br /&gt;
print(&amp;quot;Total time taken: &amp;quot; + str(tf.NEWVAL))&lt;br /&gt;
&lt;br /&gt;
# plot the results&lt;br /&gt;
plt.figure()&lt;br /&gt;
plt.subplot(211)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z1, label=r&#039;$Z_1$&#039;)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z2, label=r&#039;$Z_2$&#039;)&lt;br /&gt;
plt.ylabel(&#039;Z&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.subplot(212)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, u, label=r&#039;$u$&#039;)&lt;br /&gt;
plt.ylabel(&#039;u&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with APOPT with an objective function value of &amp;lt;math&amp;gt;30.3077&amp;lt;/math&amp;gt;. Thanks to [https://www.linkedin.com/in/tjasperson/ Tanner Jasperson] for providing a solution.&lt;br /&gt;
&lt;br /&gt;
[[File:Time_optimal_car_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Batch_reactor_GEKKO.png&amp;diff=2289</id>
		<title>File:Batch reactor GEKKO.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Batch_reactor_GEKKO.png&amp;diff=2289"/>
		<updated>2019-04-11T13:49:25Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Batch_reactor_(GEKKO)&amp;diff=2288</id>
		<title>Batch reactor (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Batch_reactor_(GEKKO)&amp;diff=2288"/>
		<updated>2019-04-11T13:49:07Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Add gekko solution for batch reactor.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Batch reactor]] problem in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The model in Python code for a fixed control discretization grid uses orthogonal collocation and a simultaneous optimization method. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
&lt;br /&gt;
nt = 501&lt;br /&gt;
m.time = np.linspace(0,1,nt)&lt;br /&gt;
&lt;br /&gt;
# Variables&lt;br /&gt;
x1 = m.Var(value=1)&lt;br /&gt;
x2 = m.Var(value=0)&lt;br /&gt;
T = m.MV(value=398,lb=298,ub=398)&lt;br /&gt;
T.STATUS = 1&lt;br /&gt;
T.DCOST = 1e-6&lt;br /&gt;
k1 = m.Intermediate(4000*m.exp(-2500/T))&lt;br /&gt;
k2 = m.Intermediate(6.2e5*m.exp(-5000/T))&lt;br /&gt;
&lt;br /&gt;
p = np.zeros(nt)&lt;br /&gt;
p[-1] = 1.0&lt;br /&gt;
final = m.Param(value=p)&lt;br /&gt;
&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1.dt()==-k1*x1**2)&lt;br /&gt;
m.Equation(x2.dt()==k1*x1**2 - k2*x2)&lt;br /&gt;
&lt;br /&gt;
# Objective Function&lt;br /&gt;
# maximize final x2&lt;br /&gt;
m.Obj(-x2*final)&lt;br /&gt;
&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
print(&#039;Optimal x2(tf): &#039; + str(x2.value[-1]))&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.subplot(2,1,1)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;k:&#039;,\&lt;br /&gt;
         LineWidth=2,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;b-&#039;,\&lt;br /&gt;
         LineWidth=2,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.plot(m.time[-1],x2.value[-1],&#039;o&#039;,\&lt;br /&gt;
         color=&#039;orange&#039;,MarkerSize=5,\&lt;br /&gt;
         label=r&#039;$x_2\left(t_f\right)$&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.ylabel(&#039;Mole Fraction&#039;)&lt;br /&gt;
plt.subplot(2,1,2)&lt;br /&gt;
plt.plot(m.time,T.value,&#039;r--&#039;,\&lt;br /&gt;
         LineWidth=2,label=&#039;Temperature&#039;)&lt;br /&gt;
plt.ylabel(r&#039;$T/;(^oC)$&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Value&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A solution is calculated with an objective function value of x2(tf) = 0.6108.&lt;br /&gt;
&lt;br /&gt;
[[File:Batch_reactor_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Batch_reactor&amp;diff=2287</id>
		<title>Batch reactor</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Batch_reactor&amp;diff=2287"/>
		<updated>2019-04-11T13:42:22Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &amp;lt;math&amp;gt; &amp;lt;/math&amp;gt; rendering appears to be broken&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nc        = 2&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This batch reactor problem describes the consecutive reaction of some substance A via substance B into a desired product C.&lt;br /&gt;
&lt;br /&gt;
The system is interacted with via the control function &amp;lt;math&amp;gt; T(t) &amp;lt;/math&amp;gt; which stands for the temperature.&lt;br /&gt;
The goal is to produce as much of substance B (which can then be converted into product C) as possible within the time limit.&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
The optimal control problem is given by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llcl}&lt;br /&gt;
 \displaystyle \max_{x, u} &amp;amp; x_2(t_f)   \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp; \dot{x}_1 &amp;amp; = &amp;amp; -k_1 x_1^2.\\&lt;br /&gt;
 &amp;amp; \dot{x}_2 &amp;amp; = &amp;amp; k_1 x_1^2 - k_2 x_2,\\&lt;br /&gt;
 &amp;amp; k_1 &amp;amp; = &amp;amp; 4000 \; e^{(-2500/T(t))}, \\&lt;br /&gt;
 &amp;amp; k_2 &amp;amp; = &amp;amp; 620000 \; e^{(-5000/T(t))}, \\[1.5ex]&lt;br /&gt;
 &amp;amp; x(0) &amp;amp;=&amp;amp; (1, 0)^T, \\&lt;br /&gt;
 &amp;amp; T(t) &amp;amp;\in&amp;amp;  [298, 398].&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; x_1(t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; x_2(t) &amp;lt;/math&amp;gt; represent the concentrations of A and B at timepoint &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; respectively. The control function &amp;lt;math&amp;gt; T(t) &amp;lt;/math&amp;gt; represents the temperature.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
The starting time and end time are given by &amp;lt;math&amp;gt; [t_0, t_f] = [0, 1] &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Reference Solutions ==&lt;br /&gt;
&lt;br /&gt;
This solution was computed using JuMP with a collocation method and 300 discretization points. The differential equations were solved using the explicit Euler Method. The source code can be found at [[Batch reactor (JuMP)]].&lt;br /&gt;
&lt;br /&gt;
The optimal objective value of the problem is x2(tf) = 0.611715.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Reference solution plots&amp;quot; widths=&amp;quot;180px&amp;quot; heights=&amp;quot;140px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
 File:batch_reactor_states_plot.png| Optimal states &amp;lt;math&amp;gt; x_1(t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x_2(t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
 File:batch_reactor_control_plot.png| Optimal control &amp;lt;math&amp;gt;u(t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Batch reactor (GEKKO)]]&lt;br /&gt;
* [[:Category: Julia/JuMP | JuMP code]] at [[Batch reactor (JuMP)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
The problem can be found in [http://www.tomopt.com/docs/TOMLAB_PROPT.pdf the Tomlab PROPT guide] or in [http://www.kirp.chtf.stuba.sk/moodle/mod/resource/view.php?id=5464 the Dynopt guide].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category:Chemical engineering]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Batch_reactor&amp;diff=2286</id>
		<title>Batch reactor</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Batch_reactor&amp;diff=2286"/>
		<updated>2019-04-11T13:41:03Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Add link to GEKKO solution&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nc        = 2&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This batch reactor problem describes the consecutive reaction of some substance A via substance B into a desired product C.&lt;br /&gt;
&lt;br /&gt;
The system is interacted with via the control function &amp;lt;math&amp;gt; T(t) &amp;lt;/math&amp;gt; which stands for the temperature.&lt;br /&gt;
The goal is to produce as much of substance B (which can then be converted into product C) as possible within the time limit.&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
The optimal control problem is given by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llcl}&lt;br /&gt;
 \displaystyle \max_{x, u} &amp;amp; x_2(t_f)   \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp; \dot{x}_1 &amp;amp; = &amp;amp; -k_1 x_1^2.\\&lt;br /&gt;
 &amp;amp; \dot{x}_2 &amp;amp; = &amp;amp; k_1 x_1^2 - k_2 x_2,\\&lt;br /&gt;
 &amp;amp; k_1 &amp;amp; = &amp;amp; 4000 \; e^{(-2500/T(t))}, \\&lt;br /&gt;
 &amp;amp; k_2 &amp;amp; = &amp;amp; 620000 \; e^{(-5000/T(t))}, \\[1.5ex]&lt;br /&gt;
 &amp;amp; x(0) &amp;amp;=&amp;amp; (1, 0)^T, \\&lt;br /&gt;
 &amp;amp; T(t) &amp;amp;\in&amp;amp;  [298, 398].&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; x_1(t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; x_2(t) &amp;lt;/math&amp;gt; represent the concentrations of A and B at timepoint &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; respectively. The control function &amp;lt;math&amp;gt; T(t) &amp;lt;/math&amp;gt; represents the temperature.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
The starting time and end time are given by &amp;lt;math&amp;gt; [t_0, t_f] = [0, 1] &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Reference Solutions ==&lt;br /&gt;
&lt;br /&gt;
This solution was computed using JuMP with a collocation method and 300 discretization points. The differential equations were solved using the explicit Euler Method. The source code can be found at [[Batch reactor (JuMP)]].&lt;br /&gt;
&lt;br /&gt;
The optimal objective value of the problem is &amp;lt;math&amp;gt; x_2(t_f) = 0.611715 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Reference solution plots&amp;quot; widths=&amp;quot;180px&amp;quot; heights=&amp;quot;140px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
 File:batch_reactor_states_plot.png| Optimal states &amp;lt;math&amp;gt; x_1(t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x_2(t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
 File:batch_reactor_control_plot.png| Optimal control &amp;lt;math&amp;gt;u(t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Batch reactor (GEKKO)]]&lt;br /&gt;
* [[:Category: Julia/JuMP | JuMP code]] at [[Batch reactor (JuMP)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
The problem can be found in [http://www.tomopt.com/docs/TOMLAB_PROPT.pdf the Tomlab PROPT guide] or in [http://www.kirp.chtf.stuba.sk/moodle/mod/resource/view.php?id=5464 the Dynopt guide].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category:Chemical engineering]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_shale_pyrolysis_(GEKKO)&amp;diff=2285</id>
		<title>Oil shale pyrolysis (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_shale_pyrolysis_(GEKKO)&amp;diff=2285"/>
		<updated>2019-03-15T02:06:33Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Oil Shale Pyrolysis]] problem in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The model in Python code for a fixed control discretization grid uses orthogonal collocation and a simultaneous optimization method. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt  &lt;br /&gt;
&lt;br /&gt;
m=GEKKO()&lt;br /&gt;
&lt;br /&gt;
nt = 101&lt;br /&gt;
m.time = np.linspace(0,1,nt)&lt;br /&gt;
&lt;br /&gt;
# Constants&lt;br /&gt;
R = m.Const(value=1.9858775e-3) # Gas constant [kcal/mol*K] &lt;br /&gt;
&lt;br /&gt;
# Final Time = FV&lt;br /&gt;
tf = m.FV(value=1,lb=0.1,ub=20)&lt;br /&gt;
tf.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# MV&lt;br /&gt;
T = m.MV(value=425, ub=475, lb=425) # degC&lt;br /&gt;
T.STATUS = 1&lt;br /&gt;
T.DCOST = 0&lt;br /&gt;
&lt;br /&gt;
# Variables&lt;br /&gt;
x1 = m.Var(value = 1) # kerogen&lt;br /&gt;
x2 = m.Var(value = 0) # pyrolytic bitumen&lt;br /&gt;
x3 = m.Var(value = 0) # oil and gas&lt;br /&gt;
x4 = m.Var(value = 0) # carbon residue&lt;br /&gt;
&lt;br /&gt;
p = np.zeros(nt)&lt;br /&gt;
p[-1] = 1.0&lt;br /&gt;
final = m.Param(value=p)&lt;br /&gt;
&lt;br /&gt;
# Parameters&lt;br /&gt;
# Frequency factor&lt;br /&gt;
a1 = m.Param(value=np.exp(8.86))&lt;br /&gt;
a2 = m.Param(value=np.exp(24.25))&lt;br /&gt;
a3 = m.Param(value=np.exp(23.67))&lt;br /&gt;
a4 = m.Param(value=np.exp(18.75))&lt;br /&gt;
a5 = m.Param(value=np.exp(20.7))&lt;br /&gt;
# Activation envergy [Kcal/g-mole]&lt;br /&gt;
b1 = m.Param(value=20.3)&lt;br /&gt;
b2 = m.Param(value=37.4)&lt;br /&gt;
b3 = m.Param(value=33.8)&lt;br /&gt;
b4 = m.Param(value=28.2)&lt;br /&gt;
b5 = m.Param(value=31.0)&lt;br /&gt;
&lt;br /&gt;
# Intermediates&lt;br /&gt;
k1 = m.Intermediate(a1 * m.exp(-b1/(R*(T+273.15))))&lt;br /&gt;
k2 = m.Intermediate(a2 * m.exp(-b2/(R*(T+273.15))))&lt;br /&gt;
k3 = m.Intermediate(a3 * m.exp(-b3/(R*(T+273.15))))&lt;br /&gt;
k4 = m.Intermediate(a4 * m.exp(-b4/(R*(T+273.15))))&lt;br /&gt;
k5 = m.Intermediate(a5 * m.exp(-b5/(R*(T+273.15))))&lt;br /&gt;
&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1.dt()/tf == -k1*x1 - (k3 + k4 + k5) * x1*x2)&lt;br /&gt;
m.Equation(x2.dt()/tf == k1*x1 - k2*x2 + k3*x1*x2)&lt;br /&gt;
m.Equation(x3.dt()/tf == k2*x2 + k4*x1*x2)&lt;br /&gt;
m.Equation(x4.dt()/tf == k5*x1*x2)&lt;br /&gt;
&lt;br /&gt;
# Objective function&lt;br /&gt;
m.Obj(-final*x2)&lt;br /&gt;
&lt;br /&gt;
m.options.SOLVER = 3&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
&lt;br /&gt;
tm = m.time * tf.value[0]&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,1)&lt;br /&gt;
plt.plot(tm,x1.value,&#039;k:&#039;,LineWidth=2,label=r&#039;$x_1$=Kerogen&#039;)&lt;br /&gt;
plt.plot(tm,x2.value,&#039;b-&#039;,LineWidth=2,label=r&#039;$x_2$=Pyrolytic Bitumen&#039;)&lt;br /&gt;
plt.ylabel(&#039;Fraction&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,2)&lt;br /&gt;
plt.plot(tm,x3.value,&#039;g--&#039;,LineWidth=2,label=r&#039;$x_3$=Oil &amp;amp; Gas&#039;)&lt;br /&gt;
plt.plot(tm,x4.value,&#039;r-.&#039;,LineWidth=2,label=r&#039;$x_4$=Carbon Residue&#039;)&lt;br /&gt;
plt.ylabel(&#039;Fraction&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,3)&lt;br /&gt;
plt.plot(tm,T.value,&#039;r-&#039;,LineWidth=2,label=&#039;Temperature&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(r&#039;Temp ($^o$C)&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A solution is calculated with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 0.35062&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Oil_Shale_Pyrolysis_GEKKO.png]]&lt;br /&gt;
&lt;br /&gt;
Thanks to [https://www.linkedin.com/in/junho-park-90b86967/ Junho Park] for providing the solution.&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_shale_pyrolysis_(GEKKO)&amp;diff=2284</id>
		<title>Oil shale pyrolysis (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_shale_pyrolysis_(GEKKO)&amp;diff=2284"/>
		<updated>2019-03-15T02:04:03Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Oil Shale Pyrolysis]] problem in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The model in Python code for a fixed control discretization grid uses orthogonal collocation and a simultaneous optimization method. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt  &lt;br /&gt;
&lt;br /&gt;
m=GEKKO()&lt;br /&gt;
&lt;br /&gt;
nt = 101&lt;br /&gt;
m.time = np.linspace(0,1,nt)&lt;br /&gt;
&lt;br /&gt;
# Constants&lt;br /&gt;
R = m.Const(value=1.9858775e-3) # Gas constant [kcal/mol*K] &lt;br /&gt;
&lt;br /&gt;
# Final Time = FV&lt;br /&gt;
tf = m.FV(value=1,lb=0.1,ub=20)&lt;br /&gt;
tf.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# MV&lt;br /&gt;
T = m.MV(value=425, ub=475, lb=425) # degC&lt;br /&gt;
T.STATUS = 1&lt;br /&gt;
T.DCOST = 0&lt;br /&gt;
&lt;br /&gt;
# Variables&lt;br /&gt;
x1 = m.Var(value = 1) # kerogen&lt;br /&gt;
x2 = m.Var(value = 0) # pyrolytic bitumen&lt;br /&gt;
x3 = m.Var(value = 0) # oil and gas&lt;br /&gt;
x4 = m.Var(value = 0) # carbon residue&lt;br /&gt;
&lt;br /&gt;
p = np.zeros(nt)&lt;br /&gt;
p[-1] = 1.0&lt;br /&gt;
final = m.Param(value=p)&lt;br /&gt;
&lt;br /&gt;
# Parameters&lt;br /&gt;
# Frequency factor&lt;br /&gt;
a1 = m.Param(value=np.exp(8.86))&lt;br /&gt;
a2 = m.Param(value=np.exp(24.25))&lt;br /&gt;
a3 = m.Param(value=np.exp(23.67))&lt;br /&gt;
a4 = m.Param(value=np.exp(18.75))&lt;br /&gt;
a5 = m.Param(value=np.exp(20.7))&lt;br /&gt;
# Activation envergy [Kcal/g-mole]&lt;br /&gt;
b1 = m.Param(value=20.3)&lt;br /&gt;
b2 = m.Param(value=37.4)&lt;br /&gt;
b3 = m.Param(value=33.8)&lt;br /&gt;
b4 = m.Param(value=28.2)&lt;br /&gt;
b5 = m.Param(value=31.0)&lt;br /&gt;
&lt;br /&gt;
# Intermediates&lt;br /&gt;
k1 = m.Intermediate(a1 * m.exp(-b1/(R*(T+273.15))))&lt;br /&gt;
k2 = m.Intermediate(a2 * m.exp(-b2/(R*(T+273.15))))&lt;br /&gt;
k3 = m.Intermediate(a3 * m.exp(-b3/(R*(T+273.15))))&lt;br /&gt;
k4 = m.Intermediate(a4 * m.exp(-b4/(R*(T+273.15))))&lt;br /&gt;
k5 = m.Intermediate(a5 * m.exp(-b5/(R*(T+273.15))))&lt;br /&gt;
&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1.dt()/tf == -k1*x1 - (k3 + k4 + k5) * x1*x2)&lt;br /&gt;
m.Equation(x2.dt()/tf == k1*x1 - k2*x2 + k3*x1*x2)&lt;br /&gt;
m.Equation(x3.dt()/tf == k2*x2 + k4*x1*x2)&lt;br /&gt;
m.Equation(x4.dt()/tf == k5*x1*x2)&lt;br /&gt;
&lt;br /&gt;
# Objective function&lt;br /&gt;
m.Obj(-final*x2)&lt;br /&gt;
&lt;br /&gt;
m.options.SOLVER = 3&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
&lt;br /&gt;
tm = m.time * tf.value[0]&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,1)&lt;br /&gt;
plt.plot(tm,x1.value,&#039;k:&#039;,LineWidth=2,label=r&#039;$x_1$=Kerogen&#039;)&lt;br /&gt;
plt.plot(tm,x2.value,&#039;b-&#039;,LineWidth=2,label=r&#039;$x_2$=Pyrolytic Bitumen&#039;)&lt;br /&gt;
plt.ylabel(&#039;Fraction&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,2)&lt;br /&gt;
plt.plot(tm,x3.value,&#039;g--&#039;,LineWidth=2,label=r&#039;$x_3$=Oil &amp;amp; Gas&#039;)&lt;br /&gt;
plt.plot(tm,x4.value,&#039;r-.&#039;,LineWidth=2,label=r&#039;$x_4$=Carbon Residue&#039;)&lt;br /&gt;
plt.ylabel(&#039;Fraction&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,3)&lt;br /&gt;
plt.plot(tm,T.value,&#039;r-&#039;,LineWidth=2,label=&#039;Temperature&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(r&#039;Temp ($^o$C)&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A solution is calculated with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 0.35062&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Oil_Shale_Pyrolysis_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Oil_Shale_Pyrolysis_GEKKO.png&amp;diff=2283</id>
		<title>File:Oil Shale Pyrolysis GEKKO.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Oil_Shale_Pyrolysis_GEKKO.png&amp;diff=2283"/>
		<updated>2019-03-15T02:03:10Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_shale_pyrolysis_(GEKKO)&amp;diff=2282</id>
		<title>Oil shale pyrolysis (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_shale_pyrolysis_(GEKKO)&amp;diff=2282"/>
		<updated>2019-03-15T02:02:52Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Oil shale pyrolysis solution in GEKKO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Oil Shale Pyrolysis]] problem in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The model in Python code for a fixed control discretization grid uses orthogonal collocation and a simultaneous optimization method. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt  &lt;br /&gt;
&lt;br /&gt;
m=GEKKO()&lt;br /&gt;
&lt;br /&gt;
nt = 101&lt;br /&gt;
m.time = np.linspace(0,1,nt)&lt;br /&gt;
&lt;br /&gt;
# Constants&lt;br /&gt;
R = m.Const(value=1.9858775e-3) # Gas constant [kcal/mol*K] &lt;br /&gt;
&lt;br /&gt;
# Final Time = FV&lt;br /&gt;
tf = m.FV(value=1,lb=0.1,ub=20)&lt;br /&gt;
tf.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# MV&lt;br /&gt;
T = m.MV(value=425, ub=475, lb=425) # degC&lt;br /&gt;
T.STATUS = 1&lt;br /&gt;
T.DCOST = 0&lt;br /&gt;
&lt;br /&gt;
# Variables&lt;br /&gt;
x1 = m.Var(value = 1) # kerogen&lt;br /&gt;
x2 = m.Var(value = 0) # pyrolytic bitumen&lt;br /&gt;
x3 = m.Var(value = 0) # oil and gas&lt;br /&gt;
x4 = m.Var(value = 0) # carbon residue&lt;br /&gt;
&lt;br /&gt;
p = np.zeros(nt)&lt;br /&gt;
p[-1] = 1.0&lt;br /&gt;
final = m.Param(value=p)&lt;br /&gt;
&lt;br /&gt;
# Parameters&lt;br /&gt;
# Frequency factor&lt;br /&gt;
a1 = m.Param(value=np.exp(8.86))&lt;br /&gt;
a2 = m.Param(value=np.exp(24.25))&lt;br /&gt;
a3 = m.Param(value=np.exp(23.67))&lt;br /&gt;
a4 = m.Param(value=np.exp(18.75))&lt;br /&gt;
a5 = m.Param(value=np.exp(20.7))&lt;br /&gt;
# Activation envergy [Kcal/g-mole]&lt;br /&gt;
b1 = m.Param(value=20.3)&lt;br /&gt;
b2 = m.Param(value=37.4)&lt;br /&gt;
b3 = m.Param(value=33.8)&lt;br /&gt;
b4 = m.Param(value=28.2)&lt;br /&gt;
b5 = m.Param(value=31.0)&lt;br /&gt;
&lt;br /&gt;
# Intermediates&lt;br /&gt;
k1 = m.Intermediate(a1 * m.exp(-b1/(R*(T+273.15))))&lt;br /&gt;
k2 = m.Intermediate(a2 * m.exp(-b2/(R*(T+273.15))))&lt;br /&gt;
k3 = m.Intermediate(a3 * m.exp(-b3/(R*(T+273.15))))&lt;br /&gt;
k4 = m.Intermediate(a4 * m.exp(-b4/(R*(T+273.15))))&lt;br /&gt;
k5 = m.Intermediate(a5 * m.exp(-b5/(R*(T+273.15))))&lt;br /&gt;
&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1.dt()/tf == -k1*x1 - (k3 + k4 + k5) * x1*x2)&lt;br /&gt;
m.Equation(x2.dt()/tf == k1*x1 - k2*x2 + k3*x1*x2)&lt;br /&gt;
m.Equation(x3.dt()/tf == k2*x2 + k4*x1*x2)&lt;br /&gt;
m.Equation(x4.dt()/tf == k5*x1*x2)&lt;br /&gt;
&lt;br /&gt;
# Objective function&lt;br /&gt;
m.Obj(-final*x2)&lt;br /&gt;
&lt;br /&gt;
m.options.SOLVER = 3&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
&lt;br /&gt;
tm = m.time * tf.value[0]&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,1)&lt;br /&gt;
plt.plot(tm,x1.value,&#039;k:&#039;,LineWidth=2,label=r&#039;$x_1$=Kerogen&#039;)&lt;br /&gt;
plt.plot(tm,x2.value,&#039;b-&#039;,LineWidth=2,label=r&#039;$x_2$=Pyrolytic Bitumen&#039;)&lt;br /&gt;
plt.ylabel(&#039;Fraction&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,2)&lt;br /&gt;
plt.plot(tm,x3.value,&#039;g--&#039;,LineWidth=2,label=r&#039;$x_3$=Oil &amp;amp; Gas&#039;)&lt;br /&gt;
plt.plot(tm,x4.value,&#039;r-.&#039;,LineWidth=2,label=r&#039;$x_4$=Carbon Residue&#039;)&lt;br /&gt;
plt.ylabel(&#039;Fraction&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.subplot(3,1,3)&lt;br /&gt;
plt.plot(tm,T.value,&#039;r-&#039;,LineWidth=2,label=&#039;Temperature&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(r&#039;Temp ($^o$C)&#039;)&lt;br /&gt;
&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A solution is calculated with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.349497&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Oil_Shale_Pyrolysis_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2281</id>
		<title>Oil Shale Pyrolysis</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2281"/>
		<updated>2019-03-15T02:02:13Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 4&lt;br /&gt;
|nx        = 4&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nw        = 0&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following problem is an example from the global optimal control literature and was introduced in &amp;lt;bib id=&amp;quot;Wen1977&amp;quot; /&amp;gt;. The process starts with kerogen and is decomposed into pyrolytic bitumen, oil and gas, and residual carbon. The objective is to maximize the fraction of pyrolytic bitumen. There are 5 reactions including:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 \xrightarrow{k_1} A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_2 \xrightarrow{k_2} A_3&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_3} A_2 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_4} A_3 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_5} A_4 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each reaction is governed by a rate described by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k_i = k_{i0} \exp{\left(-E_i/RT\right)}, (i=1,2,3,4,5)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{lll}&lt;br /&gt;
 \displaystyle \max_{T} &amp;amp;  \displaystyle &amp;amp;x_2(t_N)  \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \displaystyle \dot{x}_1 &amp;amp;= -k_1x_1-(k_3+k_4+k_5)x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_2 &amp;amp;= k_1x_1-k_2x_2 + k_3x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_3 &amp;amp;= k_2x_2 + k_4x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_4 &amp;amp;= k_5x_1x_2\\ &lt;br /&gt;
 &amp;amp;  \displaystyle k_i &amp;amp;= a_i e^{-\frac{b_i}{RT}},\quad \forall i\in \{1,\dots,5\} \\ [1.5ex]&lt;br /&gt;
 &amp;amp;  \displaystyle t &amp;amp;\in \left[t_0,t_N\right] \\&lt;br /&gt;
 &amp;amp;  \displaystyle T(t) &amp;amp;\in \left[698.15K,748.15K\right]\\&lt;br /&gt;
 &amp;amp;  \displaystyle x(t_0) &amp;amp;= (1,0,0,0)^T\\&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+State variables&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Initial value (&amp;lt;math&amp;gt;t_0&amp;lt;/math&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_1(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_2(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_3(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_4(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;20.3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;37.4&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;33.8&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;28.2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;31.0&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(8.86)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(24.25)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(23.67)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(18.75)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(20.7)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Control variable&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Interval&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|[698.15,748.15]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Solutions ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Oil shale pyrolysis (GEKKO)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2280</id>
		<title>Oil Shale Pyrolysis</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2280"/>
		<updated>2019-03-15T01:54:31Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 4&lt;br /&gt;
|nx        = 4&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nw        = 0&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following problem is an example from the global optimal control literature and was introduced in &amp;lt;bib id=&amp;quot;Wen1977&amp;quot; /&amp;gt;. The process starts with kerogen and is decomposed into pyrolytic bitumen, oil and gas, and residual carbon. The objective is to maximize the fraction of pyrolytic bitumen. There are 5 reactions including:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 \xrightarrow{k_1} A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_2 \xrightarrow{k_2} A_3&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_3} A_2 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_4} A_3 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_5} A_4 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each reaction is governed by a rate described by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k_i = k_{i0} \exp{\left(-E_i/RT\right)}, (i=1,2,3,4,5)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{lll}&lt;br /&gt;
 \displaystyle \max_{T} &amp;amp;  \displaystyle &amp;amp;x_2(t_N)  \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \displaystyle \dot{x}_1 &amp;amp;= -k_1x_1-(k_3+k_4+k_5)x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_2 &amp;amp;= k_1x_1-k_2x_2 + k_3x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_3 &amp;amp;= k_2x_2 + k_4x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_4 &amp;amp;= k_5x_1x_2\\ &lt;br /&gt;
 &amp;amp;  \displaystyle k_i &amp;amp;= a_i e^{-\frac{b_i}{RT}},\quad \forall i\in \{1,\dots,5\} \\ [1.5ex]&lt;br /&gt;
 &amp;amp;  \displaystyle t &amp;amp;\in \left[t_0,t_N\right] \\&lt;br /&gt;
 &amp;amp;  \displaystyle T(t) &amp;amp;\in \left[698.15K,748.15K\right]\\&lt;br /&gt;
 &amp;amp;  \displaystyle x(t_0) &amp;amp;= (1,0,0,0)^T\\&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+State variables&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Initial value (&amp;lt;math&amp;gt;t_0&amp;lt;/math&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_1(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_2(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_3(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_4(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;20.3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;37.4&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;33.8&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;28.2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;31.0&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(8.86)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(24.25)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(23.67)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(18.75)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(20.7)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Control variable&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Interval&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|[698.15,748.15]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference solution ==&lt;br /&gt;
&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are not yet available.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2279</id>
		<title>Oil Shale Pyrolysis</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2279"/>
		<updated>2019-03-15T01:52:52Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Mathematical formulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nw        = 0&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following problem is an example from the global optimal control literature and was introduced in &amp;lt;bib id=&amp;quot;Wen1977&amp;quot; /&amp;gt;. The process starts with kerogen and is decomposed into pyrolytic bitumen, oil and gas, and residual carbon. The objective is to maximize the fraction of pyrolytic bitumen. There are 5 reactions including:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 \xrightarrow{k_1} A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_2 \xrightarrow{k_2} A_3&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_3} A_2 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_4} A_3 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_5} A_4 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each reaction is governed by a rate described by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k_i = k_{i0} \exp{\left(-E_i/RT\right)}, (i=1,2,3,4,5)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{lll}&lt;br /&gt;
 \displaystyle \max_{T} &amp;amp;  \displaystyle &amp;amp;x_2(t_N)  \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \displaystyle \dot{x}_1 &amp;amp;= -k_1x_1-(k_3+k_4+k_5)x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_2 &amp;amp;= k_1x_1-k_2x_2 + k_3x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_3 &amp;amp;= k_2x_2 + k_4x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_4 &amp;amp;= k_5x_1x_2\\ &lt;br /&gt;
 &amp;amp;  \displaystyle k_i &amp;amp;= a_i e^{-\frac{b_i}{RT}},\quad \forall i\in \{1,\dots,5\} \\ [1.5ex]&lt;br /&gt;
 &amp;amp;  \displaystyle t &amp;amp;\in \left[t_0,t_N\right] \\&lt;br /&gt;
 &amp;amp;  \displaystyle T(t) &amp;amp;\in \left[698.15K,748.15K\right]\\&lt;br /&gt;
 &amp;amp;  \displaystyle x(t_0) &amp;amp;= (1,0,0,0)^T\\&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+State variables&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Initial value (&amp;lt;math&amp;gt;t_0&amp;lt;/math&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_1(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_2(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_3(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_4(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;20.3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;37.4&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;33.8&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;28.2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;31.0&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(8.86)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(24.25)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(23.67)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(18.75)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(20.7)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Control variable&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Interval&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|[698.15,748.15]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference solution ==&lt;br /&gt;
&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are not yet available.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2278</id>
		<title>Oil Shale Pyrolysis</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2278"/>
		<updated>2019-03-15T01:51:49Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Mathematical formulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nw        = 0&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following problem is an example from the global optimal control literature and was introduced in &amp;lt;bib id=&amp;quot;Wen1977&amp;quot; /&amp;gt;. The process starts with kerogen and is decomposed into pyrolytic bitumen, oil and gas, and residual carbon. The objective is to maximize the fraction of pyrolytic bitumen. There are 5 reactions including:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 \xrightarrow{k_1} A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_2 \xrightarrow{k_2} A_3&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_3} A_2 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_4} A_3 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_5} A_4 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each reaction is governed by a rate described by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k_i = k_{i0} \exp{\left(-E_i/RT\right)}, (i=1,2,3,4,5)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{lll}&lt;br /&gt;
 \displaystyle \min_{T} &amp;amp;  \displaystyle &amp;amp;-x_2(t_N)  \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \displaystyle \dot{x}_1 &amp;amp;= -k_1x_1-(k_3+k_4+k_5)x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_2 &amp;amp;= k_1x_1-k_2x_2 + k_3x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_3 &amp;amp;= k_2x_2 + k_4x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_4 &amp;amp;= k_5x_1x_2\\ &lt;br /&gt;
 &amp;amp;  \displaystyle k_i &amp;amp;= a_i e^{-\frac{b_i}{RT}},\quad \forall i\in \{1,\dots,5\} \\ [1.5ex]&lt;br /&gt;
 &amp;amp;  \displaystyle t &amp;amp;\in \left[t_0,t_N\right] \\&lt;br /&gt;
 &amp;amp;  \displaystyle T(t) &amp;amp;\in \left[698.15K,748.15K\right]\\&lt;br /&gt;
 &amp;amp;  \displaystyle x(t_0) &amp;amp;= (1,0,0,0)^T\\&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+State variables&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Initial value (&amp;lt;math&amp;gt;t_0&amp;lt;/math&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_1(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_2(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_3(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_4(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;20.3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;37.4&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;33.8&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;28.2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;31.0&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(8.86)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(24.25)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(23.67)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(18.75)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(20.7)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Control variable&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Interval&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|[698.15,748.15]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference solution ==&lt;br /&gt;
&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are not yet available.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2277</id>
		<title>Oil Shale Pyrolysis</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2277"/>
		<updated>2019-03-15T01:51:20Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nw        = 0&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following problem is an example from the global optimal control literature and was introduced in &amp;lt;bib id=&amp;quot;Wen1977&amp;quot; /&amp;gt;. The process starts with kerogen and is decomposed into pyrolytic bitumen, oil and gas, and residual carbon. The objective is to maximize the fraction of pyrolytic bitumen. There are 5 reactions including:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 \xrightarrow{k_1} A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_2 \xrightarrow{k_2} A_3&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_3} A_2 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_4} A_3 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_5} A_4 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each reaction is governed by a rate described by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k_i = k_{i0} \exp{\left(-E_i/RT\right)}, (i=1,2,3,4,5)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{lll}&lt;br /&gt;
 \displaystyle \min_{T} &amp;amp;  \displaystyle &amp;amp;-x_1(t_N)  \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \displaystyle \dot{x}_1 &amp;amp;= -k_1x_1-(k_3+k_4+k_5)x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_2 &amp;amp;= k_1x_1-k_2x_2 + k_3x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_3 &amp;amp;= k_2x_2 + k_4x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_4 &amp;amp;= k_5x_1x_2\\ &lt;br /&gt;
 &amp;amp;  \displaystyle k_i &amp;amp;= a_i e^{-\frac{b_i}{RT}},\quad \forall i\in \{1,\dots,5\} \\ [1.5ex]&lt;br /&gt;
 &amp;amp;  \displaystyle t &amp;amp;\in \left[t_0,t_N\right] \\&lt;br /&gt;
 &amp;amp;  \displaystyle T(t) &amp;amp;\in \left[698.15K,748.15K\right]\\&lt;br /&gt;
 &amp;amp;  \displaystyle x(t_0) &amp;amp;= (1,0,0,0)^T\\&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+State variables&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Initial value (&amp;lt;math&amp;gt;t_0&amp;lt;/math&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_1(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_2(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_3(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_4(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;20.3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;37.4&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;33.8&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;28.2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;31.0&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(8.86)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(24.25)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(23.67)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(18.75)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{(20.7)}&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Control variable&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Interval&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|[698.15,748.15]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference solution ==&lt;br /&gt;
&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are not yet available.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2276</id>
		<title>Oil Shale Pyrolysis</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Oil_Shale_Pyrolysis&amp;diff=2276"/>
		<updated>2019-03-15T01:49:16Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nw        = 0&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following problem is an example from the global optimal control literature and was introduced in &amp;lt;bib id=&amp;quot;Wen1977&amp;quot; /&amp;gt;. The process starts with kerogen and is decomposed into pyrolytic bitumen, oil and gas, and residual carbon. The objective is to maximize the fraction of pyrolytic bitumen. There are 5 reactions including:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 \xrightarrow{k_1} A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_2 \xrightarrow{k_2} A_3&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_3} A_2 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_4} A_3 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A_1 + A_2 \xrightarrow{k_5} A_4 + A_2&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each reaction is governed by a rate described by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k_i = k_{i0} \exp{-E_i/RT}, (i=1,2,3,4,5)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{lll}&lt;br /&gt;
 \displaystyle \min_{T} &amp;amp;  \displaystyle &amp;amp;-x_1(t_N)  \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \displaystyle \dot{x}_1 &amp;amp;= -k_1x_1-(k_3+k_4+k_5)x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_2 &amp;amp;= k_1x_1-k_2x_2 + k_3x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_3 &amp;amp;= k_2x_2 + k_4x_1x_2\\&lt;br /&gt;
 &amp;amp;  \displaystyle \dot{x}_4 &amp;amp;= k_5x_1x_2\\ &lt;br /&gt;
 &amp;amp;  \displaystyle k_i &amp;amp;= a_i e^{-\frac{b_i}{RT}},\quad \forall i\in \{1,\dots,5\} \\ [1.5ex]&lt;br /&gt;
 &amp;amp;  \displaystyle t &amp;amp;\in \left[t_0,t_N\right] \\&lt;br /&gt;
 &amp;amp;  \displaystyle T(t) &amp;amp;\in \left[698.15K,748.15K\right]\\&lt;br /&gt;
 &amp;amp;  \displaystyle x(t_0) &amp;amp;= (1,0,0,0)^T\\&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+State variables&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Initial value (&amp;lt;math&amp;gt;t_0&amp;lt;/math&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_1(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_2(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_3(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;x_4(t_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;20.3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;37.4&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;33.8&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;28.2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;a_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;31.0&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{8.86}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{24.25}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_3&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{23.67}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_4&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{18.75}&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;b_5&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;\exp{20.7}&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Control variable&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Interval&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|[698.15,748.15]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference solution ==&lt;br /&gt;
&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are not yet available.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Hanging_chain_problem_(GEKKO)&amp;diff=2275</id>
		<title>Hanging chain problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Hanging_chain_problem_(GEKKO)&amp;diff=2275"/>
		<updated>2019-03-14T17:25:21Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Solver Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the energy minimization of the [[Hanging chain problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The end point constraints are imposed as soft constraints (objective terms).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
n = 51&lt;br /&gt;
Lp = 4&lt;br /&gt;
b = 3&lt;br /&gt;
a = 1&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
m.time = np.linspace(0, 1, n)&lt;br /&gt;
&lt;br /&gt;
x1 = m.Var(value=a, lb=0, ub=10)&lt;br /&gt;
x2 = m.Var(value=0, lb=0, ub=10)&lt;br /&gt;
x3 = m.Var(value=0, lb=0, ub=10)&lt;br /&gt;
&lt;br /&gt;
u = m.MV(value=0, lb=-10, ub=20) # integer=True,&lt;br /&gt;
&lt;br /&gt;
tmp = np.zeros(n)&lt;br /&gt;
tmp[-1] = 1&lt;br /&gt;
&lt;br /&gt;
final = m.Param(value=tmp)&lt;br /&gt;
&lt;br /&gt;
m.Equation(x1.dt() == u)&lt;br /&gt;
m.Equation(x2.dt() == x1 * (1+u**2)**0.5)&lt;br /&gt;
m.Equation(x3.dt() == (1+u**2)**0.5)&lt;br /&gt;
# m.Equation((x1-b)*final == 0)&lt;br /&gt;
# m.Equation((x3-Lp)*final == 0)&lt;br /&gt;
&lt;br /&gt;
m.Obj(1000*(x1-b)**2*final)&lt;br /&gt;
m.Obj(1000*(x3-Lp)**2*final)&lt;br /&gt;
&lt;br /&gt;
#m.fix(x1, n-1, b)&lt;br /&gt;
#m.fix(x3, n-1, Lp)&lt;br /&gt;
&lt;br /&gt;
m.options.SOLVER = 3&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.Obj(x2*final)&lt;br /&gt;
&lt;br /&gt;
# initialize&lt;br /&gt;
m.options.TIME_SHIFT = 0&lt;br /&gt;
u.STATUS = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
u.STATUS = 1&lt;br /&gt;
u.DCOST = 1e-3&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.subplot(2,1,1)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;r--&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.plot(m.time,x3.value,&#039;k:&#039;,label=r&#039;$x_3$&#039;)&lt;br /&gt;
plt.ylabel(&#039;x&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.xlim([0,1])&lt;br /&gt;
plt.subplot(2,1,2)&lt;br /&gt;
plt.plot(2,1,2)&lt;br /&gt;
plt.plot(m.time,u.value,&#039;k-&#039;,label=r&#039;$u$&#039;)&lt;br /&gt;
plt.ylabel(&#039;u&#039;)&lt;br /&gt;
plt.xlim([0,1])&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Solver Results ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with IPOPT with an objective function value of 5.13266.&lt;br /&gt;
&lt;br /&gt;
[[File:Hanging_chain_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Hanging_chain_problem_(GEKKO)&amp;diff=2274</id>
		<title>Hanging chain problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Hanging_chain_problem_(GEKKO)&amp;diff=2274"/>
		<updated>2019-03-14T17:25:05Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Results with APOPT (MINLP) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the energy minimization of the [[Hanging chain problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The end point constraints are imposed as soft constraints (objective terms).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
n = 51&lt;br /&gt;
Lp = 4&lt;br /&gt;
b = 3&lt;br /&gt;
a = 1&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
m.time = np.linspace(0, 1, n)&lt;br /&gt;
&lt;br /&gt;
x1 = m.Var(value=a, lb=0, ub=10)&lt;br /&gt;
x2 = m.Var(value=0, lb=0, ub=10)&lt;br /&gt;
x3 = m.Var(value=0, lb=0, ub=10)&lt;br /&gt;
&lt;br /&gt;
u = m.MV(value=0, lb=-10, ub=20) # integer=True,&lt;br /&gt;
&lt;br /&gt;
tmp = np.zeros(n)&lt;br /&gt;
tmp[-1] = 1&lt;br /&gt;
&lt;br /&gt;
final = m.Param(value=tmp)&lt;br /&gt;
&lt;br /&gt;
m.Equation(x1.dt() == u)&lt;br /&gt;
m.Equation(x2.dt() == x1 * (1+u**2)**0.5)&lt;br /&gt;
m.Equation(x3.dt() == (1+u**2)**0.5)&lt;br /&gt;
# m.Equation((x1-b)*final == 0)&lt;br /&gt;
# m.Equation((x3-Lp)*final == 0)&lt;br /&gt;
&lt;br /&gt;
m.Obj(1000*(x1-b)**2*final)&lt;br /&gt;
m.Obj(1000*(x3-Lp)**2*final)&lt;br /&gt;
&lt;br /&gt;
#m.fix(x1, n-1, b)&lt;br /&gt;
#m.fix(x3, n-1, Lp)&lt;br /&gt;
&lt;br /&gt;
m.options.SOLVER = 3&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.Obj(x2*final)&lt;br /&gt;
&lt;br /&gt;
# initialize&lt;br /&gt;
m.options.TIME_SHIFT = 0&lt;br /&gt;
u.STATUS = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
u.STATUS = 1&lt;br /&gt;
u.DCOST = 1e-3&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.subplot(2,1,1)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;r--&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.plot(m.time,x3.value,&#039;k:&#039;,label=r&#039;$x_3$&#039;)&lt;br /&gt;
plt.ylabel(&#039;x&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.xlim([0,1])&lt;br /&gt;
plt.subplot(2,1,2)&lt;br /&gt;
plt.plot(2,1,2)&lt;br /&gt;
plt.plot(m.time,u.value,&#039;k-&#039;,label=r&#039;$u$&#039;)&lt;br /&gt;
plt.ylabel(&#039;u&#039;)&lt;br /&gt;
plt.xlim([0,1])&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Solver Results ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with IPOPT with an objective function value of &amp;lt;math&amp;gt;5.13266&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Hanging_chain_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Template:Current_News&amp;diff=2273</id>
		<title>Template:Current News</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Template:Current_News&amp;diff=2273"/>
		<updated>2019-03-14T17:19:22Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Created results page with Python GEKKO, news item&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;background:#EEEEFF;&amp;quot;&lt;br /&gt;
&amp;lt;!-- Add news below this comment --&amp;gt;&lt;br /&gt;
{{News|2019/3/14| Added multiple control problems with [[:Category: Gekko | Python GEKKO]] implementation}}&lt;br /&gt;
{{News|2016/7/26 | Added [[Industrial robot]] problem}}&lt;br /&gt;
{{News|2016/7/24 | Added [[Continuously Stirred Tank Reactor problem | CSTR problem]]}}&lt;br /&gt;
{{News|2016/6/30 | Added [[Electric Car]] problem}}&lt;br /&gt;
{{News|2016/5/5| Added multiple control problems with [[:Category: AMPL/TACO | AMPL with TACO]] implementation}}&lt;br /&gt;
{{News|2016/2/23|Added [[Control of Heat Equation with Actuator Placement | Actuator Placement]] control problem and [[:Category:Elliptic | Elliptic]], [[:Category:Parabolic | Parabolic]] and [[:Category:Hyperbolic | Hyperbolic]] categories}}&lt;br /&gt;
&amp;lt;!-- Add news above this comment --&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;!-- Text within the following tag is not shown when this page is included in a different page (e.g. the main page, &amp;quot;News&amp;quot; section --&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt; &lt;br /&gt;
== Older news ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;background:#eaecd0;&amp;quot;&lt;br /&gt;
&amp;lt;!-- Copy old news below this comment --&amp;gt;&lt;br /&gt;
{{News|2016/1/10|Added [[Van der Pol Oscillator]], [[Batch reactor]], [[Cushioned Oscillation]] and [[Goddart&#039;s rocket problem]] control problems}}&lt;br /&gt;
{{News|2015/11/10|Moved mintoc.de to a new server}}&lt;br /&gt;
{{News|2012/09/01|Added the [[Lotka Experimental Design]] and a [[:Category:Optimum Experimental Design | category for experimental design problems]]}}&lt;br /&gt;
{{News|2011/09/29|Added the [[:Category:AMPL/TACO | first set of AMPL optimal control problems]] using the TACO toolkit}}&lt;br /&gt;
{{News|2010/11/21|Added New York [[Subway ride]] control problem}}&lt;br /&gt;
{{News|2010/11/18|Extended description of [[:Category:Problem characterization | problem characterization]]}}&lt;br /&gt;
{{News|2010/11/18|Description of benchmark library as [http://mathopt.de/PUBLICATIONS/Sager2011b.pdf pdf file] preprint}}&lt;br /&gt;
{{News|2010/08/16|Added [[Bang-bang approximation of a traveling wave]] 1D PDE example}}&lt;br /&gt;
{{News|2010/02/11|Launch of EU project [http://embocon.org embocon.org]}}&lt;br /&gt;
{{News|2009/11/20|Added [[External Links]] page}}&lt;br /&gt;
{{News|2009/10/26|Revision and Correction of several [[:Category:Optimica | optimica]] models}}&lt;br /&gt;
{{News|2009/08/26|Knitro solution for [[F-8 aircraft (AMPL)]]}}&lt;br /&gt;
{{News|2009/08/11|[[F-8 aircraft]] new local minimum found with [[:Category:Optimica | optimica]]/ipopt}}&lt;br /&gt;
{{News|2009/07/31|New category [[:Category:Optimica | optimica]] introduced}}&lt;br /&gt;
{{News|2009/07/07|[[:Category:AMPL]] revised page with discretized MINLPs in AMPL format}}&lt;br /&gt;
&amp;lt;!-- Add news above this comment --&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Adding items ==&lt;br /&gt;
If you want to add events you have to edit this page. At the top of the page you will see something like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
{| style=&amp;quot;background:#EEEEFF;&amp;quot;&lt;br /&gt;
&amp;lt;!-- Add items below this comment --&amp;gt;&lt;br /&gt;
{{News|2008/08/14, 15:15|Presentation of the restructured group wiki in the group meeting, room 432.}}&lt;br /&gt;
&amp;lt;!-- Add items above this comment --&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add a new item you have to enter a line of the form:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
{{News|date|content}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt; is the date and &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; is the subject and further information. The field &amp;lt;code&amp;gt;News&amp;lt;/code&amp;gt; is mandatory. Please write the &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt; in the format &#039;&#039;&#039;YYYY/MM/DD, HH:MM&#039;&#039;&#039; to keep it nice and clean. The field &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; can contain any information you like (but please keep it short) and even wiki syntax is possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please keep the items in a chronological order and remove older ones to keep the list short.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Category:News]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Double_Tank_(GEKKO)&amp;diff=2272</id>
		<title>Double Tank (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Double_Tank_(GEKKO)&amp;diff=2272"/>
		<updated>2019-03-14T17:12:46Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Double Tank]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The integral is converted to a differential equation through differentiation and definition of a new variable x3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
&lt;br /&gt;
m = GEKKO() # create GEKKO model&lt;br /&gt;
&lt;br /&gt;
# Add 0.01 as first step&lt;br /&gt;
# 0,0.01,0.1,0.2,0.3,...9.9,10.0)&lt;br /&gt;
m.time = np.insert(np.linspace(0,10,201),1,0.01)&lt;br /&gt;
&lt;br /&gt;
# change solver options&lt;br /&gt;
m.solver_options = [&#039;minlp_gap_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 10000&#039;,\&lt;br /&gt;
                    &#039;minlp_max_iter_with_int_sol 100&#039;,\&lt;br /&gt;
                    &#039;minlp_branch_method 1&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_leaves 0&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 200&#039;]&lt;br /&gt;
&lt;br /&gt;
k1 = 2&lt;br /&gt;
k2 = 3&lt;br /&gt;
&lt;br /&gt;
last = m.Param(np.zeros(202))&lt;br /&gt;
last.value[-1] = 1&lt;br /&gt;
&lt;br /&gt;
sigma=m.MV(value=1,lb=1,ub=2,integer=True)&lt;br /&gt;
x1 = m.Var(value=2)&lt;br /&gt;
x2 = m.Var(value=2)&lt;br /&gt;
x3 = m.Var(value=0)&lt;br /&gt;
sigma.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
m.Obj(last*x3)&lt;br /&gt;
&lt;br /&gt;
m.Equations([x1.dt() == sigma - m.sqrt(x1),\&lt;br /&gt;
             x2.dt() == m.sqrt(x1) - m.sqrt(x2),\&lt;br /&gt;
             x3.dt() == k1*(x2-k2)**2])&lt;br /&gt;
&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
m.options.MV_TYPE = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(m.time,sigma.value,&#039;r-&#039;,label=r&#039;$\sigma$ (1/2)&#039;)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with APOPT with an objective function value of 4.767757. &lt;br /&gt;
&lt;br /&gt;
[[File:Double_Tank_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Double_Tank_GEKKO.png&amp;diff=2271</id>
		<title>File:Double Tank GEKKO.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Double_Tank_GEKKO.png&amp;diff=2271"/>
		<updated>2019-03-14T17:12:04Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Double_Tank_(GEKKO)&amp;diff=2270</id>
		<title>Double Tank (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Double_Tank_(GEKKO)&amp;diff=2270"/>
		<updated>2019-03-14T17:11:36Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Create results page with Python GEKKO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Double Tank]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The integral is converted to a differential equation through differentiation and definition of a new variable x3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
&lt;br /&gt;
m = GEKKO() # create GEKKO model&lt;br /&gt;
&lt;br /&gt;
# Add 0.01 as first step&lt;br /&gt;
# 0,0.01,0.1,0.2,0.3,...9.9,10.0)&lt;br /&gt;
m.time = np.insert(np.linspace(0,10,201),1,0.01)&lt;br /&gt;
&lt;br /&gt;
# change solver options&lt;br /&gt;
m.solver_options = [&#039;minlp_gap_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 10000&#039;,\&lt;br /&gt;
                    &#039;minlp_max_iter_with_int_sol 100&#039;,\&lt;br /&gt;
                    &#039;minlp_branch_method 1&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_leaves 0&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 200&#039;]&lt;br /&gt;
&lt;br /&gt;
k1 = 2&lt;br /&gt;
k2 = 3&lt;br /&gt;
&lt;br /&gt;
last = m.Param(np.zeros(202))&lt;br /&gt;
last.value[-1] = 1&lt;br /&gt;
&lt;br /&gt;
sigma=m.MV(value=1,lb=1,ub=2,integer=True)&lt;br /&gt;
x1 = m.Var(value=2)&lt;br /&gt;
x2 = m.Var(value=2)&lt;br /&gt;
x3 = m.Var(value=0)&lt;br /&gt;
sigma.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
m.Obj(last*x3)&lt;br /&gt;
&lt;br /&gt;
m.Equations([x1.dt() == sigma - m.sqrt(x1),\&lt;br /&gt;
             x2.dt() == m.sqrt(x1) - m.sqrt(x2),\&lt;br /&gt;
             x3.dt() == k1*(x2-k2)**2])&lt;br /&gt;
&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
m.options.MV_TYPE = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(m.time,sigma.value,&#039;r-&#039;,label=r&#039;$\sigma$ (1/2)&#039;)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with APOPT with an objective function value of &amp;lt;math&amp;gt;4.767757&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
[[File:Double_Tank_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Double_Tank&amp;diff=2269</id>
		<title>Double Tank</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Double_Tank&amp;diff=2269"/>
		<updated>2019-03-14T17:07:54Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Reference Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nw        = 1&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The double tank problem is a basic example for a switching system. It contains the dynamics of an upper and a lower tank, connected to each other with a pipe. The goal is to minimize the deviation of a certain fluid level &amp;lt;math&amp;gt;k_2&amp;lt;/math&amp;gt; in the lower tank. The problem was introduced and discussed in a variety of publications for the optimal control of constrained switched systems, e.g. &amp;lt;bib id=&amp;quot;Henrion2014&amp;quot; /&amp;gt; (Link: [http://homepages.laas.fr/henrion/papers/switch.pdf Henrion et al.]) and &amp;lt;bib id=&amp;quot;Vasudevan2013&amp;quot; /&amp;gt; (Link: [http://epubs.siam.org/doi/pdf/10.1137/120901507 Vasudevan et al.]).&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llll}&lt;br /&gt;
 \displaystyle \min_{\sigma} &amp;amp;  \displaystyle \int_{0}^{T} &amp;amp; k_1(x_2-k_2)^2  \; \text{d}t\\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \dot{x}_1 &amp;amp; = c_{\sigma(t)}-\sqrt{x_1}, \\[1.5ex]&lt;br /&gt;
 &amp;amp;  \dot{x}_2 &amp;amp; = \sqrt{x_1}-\sqrt{x_2}, \\[1.5ex]&lt;br /&gt;
 &amp;amp;  x(0) &amp;amp; = (2,2)^T, \\[1.5ex]&lt;br /&gt;
 &amp;amp;  \sigma(t) &amp;amp; \in \{1,2\} \qquad &amp;amp;\text{for } t\in[0,T].\\[1.5ex]&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The two states of the system correspond to the fluid levels of an upper and a lower tank.&lt;br /&gt;
The output of the upper tank flows into the lower tank, the output of the lower&lt;br /&gt;
tank exits the system, and the flow into the upper tank is restricted to either &amp;lt;math&amp;gt;c_1&amp;lt;/math&amp;gt; [lt/s]&lt;br /&gt;
or &amp;lt;math&amp;gt;c_2&amp;lt;/math&amp;gt; [lt/s].  The dynamics in each mode are then derived using [https://en.wikipedia.org/wiki/Torricelli&#039;s_law Torricelli’s law], as&lt;br /&gt;
shown in constraints 1 and 2. The objective of the optimization is to have the fluid level in the&lt;br /&gt;
lower tank equal to &amp;lt;math&amp;gt;k_2&amp;lt;/math&amp;gt; [m], as reflected in the cost function.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
In an exemplary test, the parameters were chosen to be:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;k_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;k_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;c_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;c_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;10&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference Solution ==&lt;br /&gt;
The problem is solved in Python with [[:Category: Gekko | GEKKO]] or Matlab (version 2014b) with [[:Category: switch | Switch]]. The switch codes rely on [http://homepages.laas.fr/henrion/software/gloptipoly3/ GloptiPoly 3] and the solver [http://sedumi.ie.lehigh.edu/ SeDuMi 1.3] (optimization over symmetric cones). &lt;br /&gt;
By introducing the lifts &amp;lt;math&amp;gt;l_i=\sqrt{x_i}&amp;lt;/math&amp;gt;, algebraically constrained as &amp;lt;math&amp;gt;l_i^2=x_i, \; l_i\geq 0,&amp;lt;/math&amp;gt; the problem is recast with polynomial data. In this way way switch in connection with GloptiPoly3 can be applied. GloptiPoly 3 is a Matlab package developed by Didier Henrion for generalized problems of moments and needs polynomial input data. The exact code used to solve the problem can be found under [[Double Tank (switch)]]. The calculated objective is 4.7296 with the following trajectories of states and controls:&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Reference solution plots&amp;quot; widths=&amp;quot;180px&amp;quot; heights=&amp;quot;140px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
 Image:State_sequence_Tank.jpg| State trajectory over time.&lt;br /&gt;
 Image:Control_sequence_Tank.jpg| Control sequence over time.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Variants ==&lt;br /&gt;
&lt;br /&gt;
There are several alternative formulations and variants of the above problem, in particular&lt;br /&gt;
&lt;br /&gt;
* different control functions for the two tanks, see [[Double Tank multimode problem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Double Tank (GEKKO)]]&lt;br /&gt;
* [[:Category: switch | switch code]] at [[Double Tank (switch)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 CLAEYS, Mathieu; DAAFOUZ Jamal; HENRION Didier Modal occupation measures and LMI relaxations for nonlinear switched systems control. arXiv preprint arXiv:1404.4699 (2014)&lt;br /&gt;
&lt;br /&gt;
 VASUDEVAN, Ramanarayan, et al. Consistent Approximations for the Optimal Control of Constrained Switched Systems---Part 2: An Implementable Algorithm. SIAM Journal on Control and Optimization, 2013, 51. Jg., Nr. 6, S. 4484-4503.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category: Tracking objective]]&lt;br /&gt;
[[Category: State dependent switches]]&lt;br /&gt;
[[Category:Bang bang]]&lt;br /&gt;
[[Category:Path-constrained arcs]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Double_Tank&amp;diff=2268</id>
		<title>Double Tank</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Double_Tank&amp;diff=2268"/>
		<updated>2019-03-14T17:04:26Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 2&lt;br /&gt;
|nw        = 1&lt;br /&gt;
|nre       = 2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The double tank problem is a basic example for a switching system. It contains the dynamics of an upper and a lower tank, connected to each other with a pipe. The goal is to minimize the deviation of a certain fluid level &amp;lt;math&amp;gt;k_2&amp;lt;/math&amp;gt; in the lower tank. The problem was introduced and discussed in a variety of publications for the optimal control of constrained switched systems, e.g. &amp;lt;bib id=&amp;quot;Henrion2014&amp;quot; /&amp;gt; (Link: [http://homepages.laas.fr/henrion/papers/switch.pdf Henrion et al.]) and &amp;lt;bib id=&amp;quot;Vasudevan2013&amp;quot; /&amp;gt; (Link: [http://epubs.siam.org/doi/pdf/10.1137/120901507 Vasudevan et al.]).&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llll}&lt;br /&gt;
 \displaystyle \min_{\sigma} &amp;amp;  \displaystyle \int_{0}^{T} &amp;amp; k_1(x_2-k_2)^2  \; \text{d}t\\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp;  \dot{x}_1 &amp;amp; = c_{\sigma(t)}-\sqrt{x_1}, \\[1.5ex]&lt;br /&gt;
 &amp;amp;  \dot{x}_2 &amp;amp; = \sqrt{x_1}-\sqrt{x_2}, \\[1.5ex]&lt;br /&gt;
 &amp;amp;  x(0) &amp;amp; = (2,2)^T, \\[1.5ex]&lt;br /&gt;
 &amp;amp;  \sigma(t) &amp;amp; \in \{1,2\} \qquad &amp;amp;\text{for } t\in[0,T].\\[1.5ex]&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The two states of the system correspond to the fluid levels of an upper and a lower tank.&lt;br /&gt;
The output of the upper tank flows into the lower tank, the output of the lower&lt;br /&gt;
tank exits the system, and the flow into the upper tank is restricted to either &amp;lt;math&amp;gt;c_1&amp;lt;/math&amp;gt; [lt/s]&lt;br /&gt;
or &amp;lt;math&amp;gt;c_2&amp;lt;/math&amp;gt; [lt/s].  The dynamics in each mode are then derived using [https://en.wikipedia.org/wiki/Torricelli&#039;s_law Torricelli’s law], as&lt;br /&gt;
shown in constraints 1 and 2. The objective of the optimization is to have the fluid level in the&lt;br /&gt;
lower tank equal to &amp;lt;math&amp;gt;k_2&amp;lt;/math&amp;gt; [m], as reflected in the cost function.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
In an exemplary test, the parameters were chosen to be:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Parameters&lt;br /&gt;
|-&lt;br /&gt;
|Symbol&lt;br /&gt;
|Value&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;k_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;k_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;c_1&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;c_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;&lt;br /&gt;
|&amp;lt;math&amp;gt;10&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Reference Solution ==&lt;br /&gt;
The problem was solved in Matlab (version 2014b) with [[:Category: switch | Switch]]. The switch codes rely on [http://homepages.laas.fr/henrion/software/gloptipoly3/ GloptiPoly 3] and the solver [http://sedumi.ie.lehigh.edu/ SeDuMi 1.3] (optimization over symmetric cones). &lt;br /&gt;
By introducing the lifts &amp;lt;math&amp;gt;l_i=\sqrt{x_i}&amp;lt;/math&amp;gt;, algebraically constrained as &amp;lt;math&amp;gt;l_i^2=x_i, \; l_i\geq 0,&amp;lt;/math&amp;gt; the problem is recast with polynomial data. In this way way switch in connection with GloptiPoly3 can be applied. GloptiPoly 3 is a Matlab package developed by Didier Henrion for generalized problems of moments and needs polynomial input data. The exact code used to solve the problem can be found under [[Double Tank (switch)]]. The calculated objective is 4.7296 with the following trajectories of states and controls:&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Reference solution plots&amp;quot; widths=&amp;quot;180px&amp;quot; heights=&amp;quot;140px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
 Image:State_sequence_Tank.jpg| State trajectory over time.&lt;br /&gt;
 Image:Control_sequence_Tank.jpg| Control sequence over time.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Variants ==&lt;br /&gt;
&lt;br /&gt;
There are several alternative formulations and variants of the above problem, in particular&lt;br /&gt;
&lt;br /&gt;
* different control functions for the two tanks, see [[Double Tank multimode problem]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Double Tank (GEKKO)]]&lt;br /&gt;
* [[:Category: switch | switch code]] at [[Double Tank (switch)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 CLAEYS, Mathieu; DAAFOUZ Jamal; HENRION Didier Modal occupation measures and LMI relaxations for nonlinear switched systems control. arXiv preprint arXiv:1404.4699 (2014)&lt;br /&gt;
&lt;br /&gt;
 VASUDEVAN, Ramanarayan, et al. Consistent Approximations for the Optimal Control of Constrained Switched Systems---Part 2: An Implementable Algorithm. SIAM Journal on Control and Optimization, 2013, 51. Jg., Nr. 6, S. 4484-4503.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category: Tracking objective]]&lt;br /&gt;
[[Category: State dependent switches]]&lt;br /&gt;
[[Category:Bang bang]]&lt;br /&gt;
[[Category:Path-constrained arcs]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2267</id>
		<title>Time optimal car problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2267"/>
		<updated>2019-03-13T19:42:41Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Time optimal car problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The end point constraints are imposed as hard constraints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
# set up the gekko model&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
&lt;br /&gt;
# set up the time (minimize the time with time scaling)&lt;br /&gt;
m.time = np.linspace(0, 1, 100)&lt;br /&gt;
&lt;br /&gt;
# set up the variables&lt;br /&gt;
Z1 = m.Var(value=0, ub=330, lb=0)&lt;br /&gt;
Z2 = m.Var(value=0, ub=33, lb=0)&lt;br /&gt;
m.fix(Z2, len(m.time)-1, 0)&lt;br /&gt;
m.fix(Z1, len(m.time)-1, 300)&lt;br /&gt;
&lt;br /&gt;
# set up the value we modify over the horizon&lt;br /&gt;
tf = m.FV(value=500, lb=0.1)&lt;br /&gt;
tf.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# set up the MV&lt;br /&gt;
u = m.MV(integer=True, lb=-2, ub=1)&lt;br /&gt;
u.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# set up the equations&lt;br /&gt;
m.Equation(Z1.dt() / tf == Z2)&lt;br /&gt;
m.Equation(Z2.dt() / tf == u)&lt;br /&gt;
&lt;br /&gt;
# set the objective&lt;br /&gt;
m.Obj(tf)&lt;br /&gt;
&lt;br /&gt;
# set up the options&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
m.solve(disp=False)&lt;br /&gt;
&lt;br /&gt;
# print the time&lt;br /&gt;
print(&amp;quot;Total time taken: &amp;quot; + str(tf.NEWVAL))&lt;br /&gt;
&lt;br /&gt;
# plot the results&lt;br /&gt;
plt.figure()&lt;br /&gt;
plt.subplot(211)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z1, label=r&#039;$Z_1$&#039;)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z2, label=r&#039;$Z_2$&#039;)&lt;br /&gt;
plt.ylabel(&#039;Z&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.subplot(212)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, u, label=r&#039;$u$&#039;)&lt;br /&gt;
plt.ylabel(&#039;u&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with APOPT with an objective function value of &amp;lt;math&amp;gt;30.3077&amp;lt;/math&amp;gt;. Thanks to [https://www.linkedin.com/in/tjasperson/ Tanner Jasperson] for providing a solution.&lt;br /&gt;
&lt;br /&gt;
[[File:Time_optimal_car_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Time_optimal_car_GEKKO.png&amp;diff=2266</id>
		<title>File:Time optimal car GEKKO.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Time_optimal_car_GEKKO.png&amp;diff=2266"/>
		<updated>2019-03-13T19:36:42Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2265</id>
		<title>Time optimal car problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2265"/>
		<updated>2019-03-13T19:36:27Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Create results page with Python GEKKO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the [[Time optimal car problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The end point constraints are imposed as hard constraints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
# set up the gekko model&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
&lt;br /&gt;
# set up the time (minimize the time with time scaling)&lt;br /&gt;
m.time = np.linspace(0, 1, 100)&lt;br /&gt;
&lt;br /&gt;
# set up the variables&lt;br /&gt;
Z1 = m.Var(value=0, ub=330, lb=0)&lt;br /&gt;
Z2 = m.Var(value=0, ub=33, lb=0)&lt;br /&gt;
m.fix(Z2, len(m.time)-1, 0)&lt;br /&gt;
m.fix(Z1, len(m.time)-1, 300)&lt;br /&gt;
&lt;br /&gt;
# set up the value we modify over the horizon&lt;br /&gt;
tf = m.FV(value=500, lb=0.1)&lt;br /&gt;
tf.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# set up the MV&lt;br /&gt;
u = m.MV(integer=True, lb=-2, ub=1)&lt;br /&gt;
u.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
# set up the equations&lt;br /&gt;
m.Equation(Z1.dt() / tf == Z2)&lt;br /&gt;
m.Equation(Z2.dt() / tf == u)&lt;br /&gt;
&lt;br /&gt;
# set the objective&lt;br /&gt;
m.Obj(tf)&lt;br /&gt;
&lt;br /&gt;
# set up the options&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
m.solve(disp=False)&lt;br /&gt;
&lt;br /&gt;
# print the time&lt;br /&gt;
print(&amp;quot;Total time taken: &amp;quot; + str(tf.NEWVAL))&lt;br /&gt;
&lt;br /&gt;
# plot the results&lt;br /&gt;
plt.figure()&lt;br /&gt;
plt.subplot(211)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z1, label=r&#039;$Z_1$&#039;)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z2, label=r&#039;$Z_2$&#039;)&lt;br /&gt;
plt.ylabel(&#039;Z&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.subplot(212)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, u, label=r&#039;$u$&#039;)&lt;br /&gt;
plt.ylabel(&#039;u&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with APOPT with an objective function value of &amp;lt;math&amp;gt;30.3077&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Time_optimal_car_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem&amp;diff=2264</id>
		<title>Time optimal car problem</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem&amp;diff=2264"/>
		<updated>2019-03-13T19:30:54Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Create results page with Python GEKKO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
		|nd        = 1&lt;br /&gt;
		|nx        = 2&lt;br /&gt;
		|nu        = 1&lt;br /&gt;
		|nc        = 6&lt;br /&gt;
		|nre       = 4&lt;br /&gt;
	}}&amp;lt;!-- Do not insert line break here or Dimensions Box moves up in the layout...&lt;br /&gt;
	&lt;br /&gt;
--&amp;gt;The Time optimal car problem &amp;quot;consists of starting and stopping a car in minimum for a fixed distance (300 units)&amp;quot; and can be found e.g. in &amp;lt;bib id=&amp;quot;Cuthrell1987&amp;quot; /&amp;gt; and &amp;lt;bib id=&amp;quot;Logsdon1992&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llclr}&lt;br /&gt;
	\displaystyle \min_{z, u, t_f} &amp;amp; t_f   \\[1.5ex]&lt;br /&gt;
	\mbox{s.t.} &lt;br /&gt;
	&amp;amp; \dot{z}_1 &amp;amp; = &amp;amp; z_2, \\&lt;br /&gt;
	&amp;amp; \dot{z}_2 &amp;amp; = &amp;amp; u, \\[1.5ex]&lt;br /&gt;
	&amp;amp; z(0) &amp;amp;=&amp;amp; (0,0)^T, \\&lt;br /&gt;
	&amp;amp; z(t_f) &amp;amp;=&amp;amp; (300,0)^T, \\[1.5ex]&lt;br /&gt;
	&amp;amp; z_1(t) &amp;amp; \in &amp;amp; [0,33],\\&lt;br /&gt;
	&amp;amp; z_2(t) &amp;amp; \in &amp;amp; [0,330],\\&lt;br /&gt;
	&amp;amp; u(t) &amp;amp; \in &amp;amp; [-2,1].\\&lt;br /&gt;
	\end{array} &lt;br /&gt;
	&amp;lt;/math&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt; z = (z_1, z_2)^T &amp;lt;/math&amp;gt;.&lt;br /&gt;
	&lt;br /&gt;
== Source Code ==&lt;br /&gt;
	&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
&lt;br /&gt;
* [[:Category:AMPL/TACO | AMPL/TACO code]] at [[Time optimal car problem (TACO)]]&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Time optimal car problem (GEKKO)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
	&amp;lt;biblist /&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
	[[Category:MIOCP]]&lt;br /&gt;
	[[Category:ODE model]]&lt;br /&gt;
	[[Category:Minimum time]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Hanging_chain_GEKKO.png&amp;diff=2263</id>
		<title>File:Hanging chain GEKKO.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Hanging_chain_GEKKO.png&amp;diff=2263"/>
		<updated>2019-03-13T19:27:52Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Hanging_chain_problem_(GEKKO)&amp;diff=2262</id>
		<title>Hanging chain problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Hanging_chain_problem_(GEKKO)&amp;diff=2262"/>
		<updated>2019-03-13T19:27:36Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Add GEKKO Python solution&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the energy minimization of the [[Hanging chain problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;. The Python code uses orthogonal collocation and a simultaneous optimization method. The end point constraints are imposed as soft constraints (objective terms).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
n = 51&lt;br /&gt;
Lp = 4&lt;br /&gt;
b = 3&lt;br /&gt;
a = 1&lt;br /&gt;
m = GEKKO()&lt;br /&gt;
m.time = np.linspace(0, 1, n)&lt;br /&gt;
&lt;br /&gt;
x1 = m.Var(value=a, lb=0, ub=10)&lt;br /&gt;
x2 = m.Var(value=0, lb=0, ub=10)&lt;br /&gt;
x3 = m.Var(value=0, lb=0, ub=10)&lt;br /&gt;
&lt;br /&gt;
u = m.MV(value=0, lb=-10, ub=20) # integer=True,&lt;br /&gt;
&lt;br /&gt;
tmp = np.zeros(n)&lt;br /&gt;
tmp[-1] = 1&lt;br /&gt;
&lt;br /&gt;
final = m.Param(value=tmp)&lt;br /&gt;
&lt;br /&gt;
m.Equation(x1.dt() == u)&lt;br /&gt;
m.Equation(x2.dt() == x1 * (1+u**2)**0.5)&lt;br /&gt;
m.Equation(x3.dt() == (1+u**2)**0.5)&lt;br /&gt;
# m.Equation((x1-b)*final == 0)&lt;br /&gt;
# m.Equation((x3-Lp)*final == 0)&lt;br /&gt;
&lt;br /&gt;
m.Obj(1000*(x1-b)**2*final)&lt;br /&gt;
m.Obj(1000*(x3-Lp)**2*final)&lt;br /&gt;
&lt;br /&gt;
#m.fix(x1, n-1, b)&lt;br /&gt;
#m.fix(x3, n-1, Lp)&lt;br /&gt;
&lt;br /&gt;
m.options.SOLVER = 3&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.Obj(x2*final)&lt;br /&gt;
&lt;br /&gt;
# initialize&lt;br /&gt;
m.options.TIME_SHIFT = 0&lt;br /&gt;
u.STATUS = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
u.STATUS = 1&lt;br /&gt;
u.DCOST = 1e-3&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.subplot(2,1,1)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;r--&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.plot(m.time,x3.value,&#039;k:&#039;,label=r&#039;$x_3$&#039;)&lt;br /&gt;
plt.ylabel(&#039;x&#039;)&lt;br /&gt;
plt.legend()&lt;br /&gt;
plt.xlim([0,1])&lt;br /&gt;
plt.subplot(2,1,2)&lt;br /&gt;
plt.plot(2,1,2)&lt;br /&gt;
plt.plot(m.time,u.value,&#039;k-&#039;,label=r&#039;$u$&#039;)&lt;br /&gt;
plt.ylabel(&#039;u&#039;)&lt;br /&gt;
plt.xlim([0,1])&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with IPOPT with an objective function value of &amp;lt;math&amp;gt;5.13266&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Hanging_chain_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Hanging_chain_problem&amp;diff=2261</id>
		<title>Hanging chain problem</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Hanging_chain_problem&amp;diff=2261"/>
		<updated>2019-03-13T19:19:14Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Source Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 3&lt;br /&gt;
|nu        = 1&lt;br /&gt;
|nc        = 4&lt;br /&gt;
|nre       = 5&lt;br /&gt;
}}&amp;lt;!-- Do not insert line break here or Dimensions Box moves up in the layout...&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;The Hanging chain problem is concerned with finding a chain (of uniform density) of length &amp;lt;math&amp;gt; L &amp;lt;/math&amp;gt; suspendend between two points &amp;lt;math&amp;gt; a, b &amp;lt;/math&amp;gt; with minimal potential energy. (Problem taken from the [http://www.mcs.anl.gov/~more/cops/ COPS library])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
The problem is given by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llcl}&lt;br /&gt;
 \displaystyle \min_{x, u} &amp;amp; x_2(t_f)   \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &amp;amp; \dot{x}_1 &amp;amp; = &amp;amp;  u, \\&lt;br /&gt;
 &amp;amp; \dot{x}_2 &amp;amp; = &amp;amp; x_1 (1+u^2)^{1/2},  \\&lt;br /&gt;
 &amp;amp; \dot{x}_3 &amp;amp; = &amp;amp; (1+u^2)^{1/2}, \\&lt;br /&gt;
 &amp;amp; x(t_0) &amp;amp;=&amp;amp; (a,0,0)^T, \\&lt;br /&gt;
 &amp;amp; x_1(t_f) &amp;amp;=&amp;amp; b, \\&lt;br /&gt;
 &amp;amp; x_3(t_f) &amp;amp;=&amp;amp; Lp, \\&lt;br /&gt;
 &amp;amp; x(t) &amp;amp;\in&amp;amp; [0,10], \\&lt;br /&gt;
 &amp;amp; u(t) &amp;amp;\in&amp;amp;  [-10,20].&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
In this model the parameters used are&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{rcl}&lt;br /&gt;
[t_0, t_f] &amp;amp;=&amp;amp; [0, 1],\\&lt;br /&gt;
(a,b) &amp;amp;=&amp;amp; (1,3),\\&lt;br /&gt;
Lp &amp;amp;=&amp;amp; 4.&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
&lt;br /&gt;
* [[:Category:AMPL/TACO | AMPL/TACO code]] at [[Hanging chain problem (TACO)]]&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Hanging chain problem (GEKKO)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category:Minimum energy]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(GEKKO)&amp;diff=2260</id>
		<title>Lotka Volterra fishing problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(GEKKO)&amp;diff=2260"/>
		<updated>2019-03-13T19:17:01Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the MIOCP [[Lotka Volterra fishing problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The model in Python code for a fixed control discretization grid using orthogonal collocation and a simultaneous optimization method. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
&lt;br /&gt;
m = GEKKO() # create GEKKO model&lt;br /&gt;
&lt;br /&gt;
# Add 0.01 as first step&lt;br /&gt;
# 0,0.01,0.1,0.2,0.3,...11.9,12.0)&lt;br /&gt;
m.time = np.insert(np.linspace(0,12,121),1,0.01)&lt;br /&gt;
&lt;br /&gt;
# change solver options&lt;br /&gt;
m.solver_options = [&#039;minlp_gap_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 10000&#039;,\&lt;br /&gt;
                    &#039;minlp_max_iter_with_int_sol 100&#039;,\&lt;br /&gt;
                    &#039;minlp_branch_method 1&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_leaves 0&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 200&#039;]&lt;br /&gt;
&lt;br /&gt;
c0 = 0.4 &lt;br /&gt;
c1 = 0.2&lt;br /&gt;
&lt;br /&gt;
last = m.Param(np.zeros(122))&lt;br /&gt;
last.value[-1] = 1&lt;br /&gt;
&lt;br /&gt;
x0 = m.Var(value=0.5,lb=0)&lt;br /&gt;
x1 = m.Var(value=0.7,lb=0)&lt;br /&gt;
x2 = m.Var(value=0.0,lb=0)&lt;br /&gt;
w = m.MV(value=0,lb=0,ub=1,integer=True)&lt;br /&gt;
w.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
m.Obj(last*x2)&lt;br /&gt;
&lt;br /&gt;
m.Equations([x0.dt() == x0 - x0*x1 - c0*x0*w,\&lt;br /&gt;
             x1.dt() == - x1 + x0*x1 - c1*x1*w,\&lt;br /&gt;
             x2.dt() == (x0-1)**2 + (x1-1)**2])&lt;br /&gt;
&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
m.options.MV_TYPE = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(m.time,w.value,&#039;r-&#039;,label=&#039;w (0/1)&#039;)&lt;br /&gt;
plt.plot(m.time,x0.value,&#039;b-&#039;,label=r&#039;$x_0$&#039;)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with [https://apopt.com APOPT] with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.349497&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Volterra_fishing_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Volterra_fishing_GEKKO.png&amp;diff=2259</id>
		<title>File:Volterra fishing GEKKO.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Volterra_fishing_GEKKO.png&amp;diff=2259"/>
		<updated>2019-03-13T19:16:16Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(GEKKO)&amp;diff=2258</id>
		<title>Lotka Volterra fishing problem (GEKKO)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(GEKKO)&amp;diff=2258"/>
		<updated>2019-03-13T19:15:50Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Create results page with Python GEKKO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the MIOCP [[Lotka Volterra fishing problem]] in [https://gekko.readthedocs.io/en/latest/ GEKKO] Python format. The model in Python code for a fixed control discretization grid using orthogonal collocation and a simultaneous optimization method. The GEKKO package is available with &#039;&#039;&#039;pip install gekko&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
&lt;br /&gt;
m = GEKKO() # create GEKKO model&lt;br /&gt;
&lt;br /&gt;
# Add 0.01 as first step&lt;br /&gt;
# 0,0.01,0.1,0.2,0.3,...11.9,12.0)&lt;br /&gt;
m.time = np.insert(np.linspace(0,12,121),1,0.01)&lt;br /&gt;
&lt;br /&gt;
# change solver options&lt;br /&gt;
m.solver_options = [&#039;minlp_gap_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 10000&#039;,\&lt;br /&gt;
                    &#039;minlp_max_iter_with_int_sol 100&#039;,\&lt;br /&gt;
                    &#039;minlp_branch_method 1&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_tol 0.001&#039;,\&lt;br /&gt;
                    &#039;minlp_integer_leaves 0&#039;,\&lt;br /&gt;
                    &#039;minlp_maximum_iterations 200&#039;]&lt;br /&gt;
&lt;br /&gt;
c0 = 0.4 &lt;br /&gt;
c1 = 0.2&lt;br /&gt;
&lt;br /&gt;
last = m.Param(np.zeros(122))&lt;br /&gt;
last.value[-1] = 1&lt;br /&gt;
&lt;br /&gt;
x0 = m.Var(value=0.5,lb=0)&lt;br /&gt;
x1 = m.Var(value=0.7,lb=0)&lt;br /&gt;
x2 = m.Var(value=0.0,lb=0)&lt;br /&gt;
w = m.MV(value=0,lb=0,ub=1,integer=True)&lt;br /&gt;
w.STATUS = 1&lt;br /&gt;
&lt;br /&gt;
m.Obj(last*x2)&lt;br /&gt;
&lt;br /&gt;
m.Equations([x0.dt() == x0 - x0*x1 - c0*x0*w,\&lt;br /&gt;
             x1.dt() == - x1 + x0*x1 - c1*x1*w,\&lt;br /&gt;
             x2.dt() == (x0-1)**2 + (x1-1)**2])&lt;br /&gt;
&lt;br /&gt;
m.options.IMODE = 6&lt;br /&gt;
m.options.NODES = 3&lt;br /&gt;
m.options.SOLVER = 1&lt;br /&gt;
m.options.MV_TYPE = 0&lt;br /&gt;
m.solve()&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(m.time,w.value,&#039;r-&#039;,label=&#039;w (0/1)&#039;)&lt;br /&gt;
plt.plot(m.time,x0.value,&#039;b-&#039;,label=r&#039;$x_0$&#039;)&lt;br /&gt;
plt.plot(m.time,x1.value,&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(m.time,x2.value,&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with [https://apopt.com APOPT] with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.36&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Volterra_fishing_GEKKO.png]]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Gekko]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2257</id>
		<title>Category:Gekko</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2257"/>
		<updated>2019-03-13T19:08:11Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;GEKKO&#039;&#039;&#039; Python package solves large-scale mixed-integer and differential algebraic equations with nonlinear programming solvers (IPOPT, APOPT, BPOPT, SNOPT, MINOS). Modes of operation include machine learning, data reconciliation, real-time optimization, dynamic simulation, and nonlinear model predictive control. In addition, the package solves Linear programming (LP), Quadratic programming (QP), Quadratically constrained quadratic program (QCQP), Nonlinear programming (NLP), Mixed integer programming (MIP), and Mixed integer linear programming (MILP). GEKKO is available in Python and installed with pip from PyPI of the Python Software Foundation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
pip install gekko&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
GEKKO works on all platforms (Windows, MacOS, Linux, ARM processors) and with Python 2.7 and 3+. By default, the problem is sent to a public server where the solution is computed and returned to Python. There is a Windows and Linux option to solve without an Internet connection. GEKKO is an extension of the APMonitor Optimization Suite but has integrated the modeling and solution visualization directly within Python. A mathematical model is expressed in terms of variables and equations such as the Hock &amp;amp; Schittkowski Benchmark Problem #71 used to test the performance of nonlinear programming solvers. This particular optimization problem has an objective function &amp;lt;math&amp;gt;\min_{x\in\mathbb R}\; x_1 x_4 (x_1+x_2+x_3)+x_3&amp;lt;/math&amp;gt; and subject to the inequality constraint &amp;lt;math&amp;gt;x_1 x_2 x_3 x_4 \ge 25&amp;lt;/math&amp;gt; and equality constraint &amp;lt;math&amp;gt;{x_1}^2 + {x_2}^2 + {x_3}^2 + {x_4}^2=40&amp;lt;/math&amp;gt;. The four variables must be between a lower bound of 1 and an upper bound of 5. The initial guess values are &amp;lt;math&amp;gt;x_1 = 1, x_2=5, x_3=5, x_4=1&amp;lt;/math&amp;gt;. This optimization problem is solved with GEKKO as shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
m = GEKKO() # Initialize gekko&lt;br /&gt;
# Initialize variables&lt;br /&gt;
x1 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
x2 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x3 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x4 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1*x2*x3*x4&amp;gt;=25)&lt;br /&gt;
m.Equation(x1**2+x2**2+x3**2+x4**2==40)&lt;br /&gt;
m.Obj(x1*x4*(x1+x2+x3)+x3) # Objective&lt;br /&gt;
m.solve(disp=False) # Solve&lt;br /&gt;
print(&#039;x1: &#039; + str(x1.value))&lt;br /&gt;
print(&#039;x2: &#039; + str(x2.value))&lt;br /&gt;
print(&#039;x3: &#039; + str(x3.value))&lt;br /&gt;
print(&#039;x4: &#039; + str(x4.value))&lt;br /&gt;
print(&#039;Objective: &#039; + str(m.options.objfcnval))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Gekko_(optimization_software) GEKKO on Wikipedia]&lt;br /&gt;
* [https://gekko.readthedocs.io/en/latest/ GEKKO Documentation]&lt;br /&gt;
* [https://github.com/BYU-PRISM/GEKKO GEKKO Source Code]&lt;br /&gt;
* [https://pypi.org/project/gekko GEKKO on PyPI] for Python pip install&lt;br /&gt;
* GEKKO is open-source product of [https://www.nsf.gov/awardsearch/showAward?AWD_ID=1547110 National Science Foundation (NSF) research grant 1547110]&lt;br /&gt;
* [http://apmonitor.com/wiki/index.php/Main/APMonitorReferences References to APMonitor and GEKKO] in the literature&lt;br /&gt;
* [https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization 18 examples of GEKKO]: machine learning, optimal control, data regression&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2256</id>
		<title>Category:Gekko</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2256"/>
		<updated>2019-03-13T19:07:27Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Correct link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;GEKKO&#039;&#039;&#039; Python package solves large-scale mixed-integer and differential algebraic equations with nonlinear programming solvers (IPOPT, APOPT, BPOPT, SNOPT, MINOS). Modes of operation include machine learning, data reconciliation, real-time optimization, dynamic simulation, and nonlinear model predictive control. In addition, the package solves Linear programming (LP), Quadratic programming (QP), Quadratically constrained quadratic program (QCQP), Nonlinear programming (NLP), Mixed integer programming (MIP), and Mixed integer linear programming (MILP). GEKKO is available in Python and installed with pip from PyPI of the Python Software Foundation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
pip install gekko&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
GEKKO works on all platforms (Windows, MacOS, Linux, ARM processors) and with Python 2.7 and 3+. By default, the problem is sent to a public server where the solution is computed and returned to Python. There is a Windows and Linux option to solve without an Internet connection. GEKKO is an extension of the [[Category:APMonitor|APMonitor Optimization Suite]] but has integrated the modeling and solution visualization directly within Python. A mathematical model is expressed in terms of variables and equations such as the Hock &amp;amp; Schittkowski Benchmark Problem #71 used to test the performance of nonlinear programming solvers. This particular optimization problem has an objective function &amp;lt;math&amp;gt;\min_{x\in\mathbb R}\; x_1 x_4 (x_1+x_2+x_3)+x_3&amp;lt;/math&amp;gt; and subject to the inequality constraint &amp;lt;math&amp;gt;x_1 x_2 x_3 x_4 \ge 25&amp;lt;/math&amp;gt; and equality constraint &amp;lt;math&amp;gt;{x_1}^2 + {x_2}^2 + {x_3}^2 + {x_4}^2=40&amp;lt;/math&amp;gt;. The four variables must be between a lower bound of 1 and an upper bound of 5. The initial guess values are &amp;lt;math&amp;gt;x_1 = 1, x_2=5, x_3=5, x_4=1&amp;lt;/math&amp;gt;. This optimization problem is solved with GEKKO as shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
m = GEKKO() # Initialize gekko&lt;br /&gt;
# Initialize variables&lt;br /&gt;
x1 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
x2 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x3 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x4 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1*x2*x3*x4&amp;gt;=25)&lt;br /&gt;
m.Equation(x1**2+x2**2+x3**2+x4**2==40)&lt;br /&gt;
m.Obj(x1*x4*(x1+x2+x3)+x3) # Objective&lt;br /&gt;
m.solve(disp=False) # Solve&lt;br /&gt;
print(&#039;x1: &#039; + str(x1.value))&lt;br /&gt;
print(&#039;x2: &#039; + str(x2.value))&lt;br /&gt;
print(&#039;x3: &#039; + str(x3.value))&lt;br /&gt;
print(&#039;x4: &#039; + str(x4.value))&lt;br /&gt;
print(&#039;Objective: &#039; + str(m.options.objfcnval))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Gekko_(optimization_software) GEKKO on Wikipedia]&lt;br /&gt;
* [https://gekko.readthedocs.io/en/latest/ GEKKO Documentation]&lt;br /&gt;
* [https://github.com/BYU-PRISM/GEKKO GEKKO Source Code]&lt;br /&gt;
* [https://pypi.org/project/gekko GEKKO on PyPI] for Python pip install&lt;br /&gt;
* GEKKO is open-source product of [https://www.nsf.gov/awardsearch/showAward?AWD_ID=1547110 National Science Foundation (NSF) research grant 1547110]&lt;br /&gt;
* [http://apmonitor.com/wiki/index.php/Main/APMonitorReferences References to APMonitor and GEKKO] in the literature&lt;br /&gt;
* [https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization 18 examples of GEKKO]: machine learning, optimal control, data regression&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2255</id>
		<title>Category:Gekko</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2255"/>
		<updated>2019-03-13T19:06:28Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Clean up GEKKO page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;GEKKO&#039;&#039;&#039; Python package solves large-scale mixed-integer and differential algebraic equations with nonlinear programming solvers (IPOPT, APOPT, BPOPT, SNOPT, MINOS). Modes of operation include machine learning, data reconciliation, real-time optimization, dynamic simulation, and nonlinear model predictive control. In addition, the package solves Linear programming (LP), Quadratic programming (QP), Quadratically constrained quadratic program (QCQP), Nonlinear programming (NLP), Mixed integer programming (MIP), and Mixed integer linear programming (MILP). GEKKO is available in Python and installed with pip from PyPI of the Python Software Foundation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
pip install gekko&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
GEKKO works on all platforms (Windows, MacOS, Linux, ARM processors) and with Python 2.7 and 3+. By default, the problem is sent to a public server where the solution is computed and returned to Python. There is a Windows and Linux option to solve without an Internet connection. GEKKO is an extension of the [[APMonitor|APMonitor Optimization Suite]] but has integrated the modeling and solution visualization directly within Python. A mathematical model is expressed in terms of variables and equations such as the Hock &amp;amp; Schittkowski Benchmark Problem #71 used to test the performance of nonlinear programming solvers. This particular optimization problem has an objective function &amp;lt;math&amp;gt;\min_{x\in\mathbb R}\; x_1 x_4 (x_1+x_2+x_3)+x_3&amp;lt;/math&amp;gt; and subject to the inequality constraint &amp;lt;math&amp;gt;x_1 x_2 x_3 x_4 \ge 25&amp;lt;/math&amp;gt; and equality constraint &amp;lt;math&amp;gt;{x_1}^2 + {x_2}^2 + {x_3}^2 + {x_4}^2=40&amp;lt;/math&amp;gt;. The four variables must be between a lower bound of 1 and an upper bound of 5. The initial guess values are &amp;lt;math&amp;gt;x_1 = 1, x_2=5, x_3=5, x_4=1&amp;lt;/math&amp;gt;. This optimization problem is solved with GEKKO as shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
m = GEKKO() # Initialize gekko&lt;br /&gt;
# Initialize variables&lt;br /&gt;
x1 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
x2 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x3 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x4 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1*x2*x3*x4&amp;gt;=25)&lt;br /&gt;
m.Equation(x1**2+x2**2+x3**2+x4**2==40)&lt;br /&gt;
m.Obj(x1*x4*(x1+x2+x3)+x3) # Objective&lt;br /&gt;
m.solve(disp=False) # Solve&lt;br /&gt;
print(&#039;x1: &#039; + str(x1.value))&lt;br /&gt;
print(&#039;x2: &#039; + str(x2.value))&lt;br /&gt;
print(&#039;x3: &#039; + str(x3.value))&lt;br /&gt;
print(&#039;x4: &#039; + str(x4.value))&lt;br /&gt;
print(&#039;Objective: &#039; + str(m.options.objfcnval))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Gekko_(optimization_software) GEKKO on Wikipedia]&lt;br /&gt;
* [https://gekko.readthedocs.io/en/latest/ GEKKO Documentation]&lt;br /&gt;
* [https://github.com/BYU-PRISM/GEKKO GEKKO Source Code]&lt;br /&gt;
* [https://pypi.org/project/gekko GEKKO on PyPI] for Python pip install&lt;br /&gt;
* GEKKO is open-source product of [https://www.nsf.gov/awardsearch/showAward?AWD_ID=1547110 National Science Foundation (NSF) research grant 1547110]&lt;br /&gt;
* [http://apmonitor.com/wiki/index.php/Main/APMonitorReferences References to APMonitor and GEKKO] in the literature&lt;br /&gt;
* [https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization 18 examples of GEKKO]: machine learning, optimal control, data regression&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2254</id>
		<title>Category:Gekko</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Category:Gekko&amp;diff=2254"/>
		<updated>2019-03-13T19:03:15Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Create GEKKO page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;GEKKO&#039;&#039;&#039; Python package&amp;lt;ref&amp;gt;{{cite journal | last=Beal | first=L. | title=GEKKO Optimization Suite | journal=Processes | year=2018 | doi=10.3390/pr6080106  | volume=6 | number=8 | pages=106}}&amp;lt;/ref&amp;gt; solves large-scale mixed-integer and differential algebraic equations with nonlinear programming solvers ([[IPOPT]], [[APOPT]], BPOPT, [[SNOPT]], [[MINOS_(optimization_software)|MINOS]]). Modes of operation include machine learning, data reconciliation, real-time optimization, dynamic simulation, and nonlinear [[Model_predictive_control|model predictive control]]. In addition, the package solves [[Linear programming]] (LP), [[Quadratic programming]] (QP), [[Quadratically constrained quadratic program]] (QCQP), [[Nonlinear programming]] (NLP), [[Mixed integer programming]] (MIP), and [[Mixed integer linear programming]] (MILP). GEKKO is available in Python and installed with pip from PyPI of the Python Software Foundation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
pip install gekko&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
GEKKO works on all platforms (Windows, MacOS, Linux, ARM processors) and with Python 2.7 and 3+. By default, the problem is sent to a public server where the solution is computed and returned to Python. There is a Windows and Linux option to solve without an Internet connection. GEKKO is an extension of the [[APMonitor|APMonitor Optimization Suite]] but has integrated the modeling and solution visualization directly within Python. A mathematical model is expressed in terms of variables and equations such as the Hock &amp;amp; Schittkowski Benchmark Problem #71&amp;lt;ref&amp;gt;W. Hock and K. Schittkowski, Test Examples for Nonlinear Programming Codes, Lecture Notes in Economics and Mathematical Systems, Vol. 187, Springer 1981.&amp;lt;/ref&amp;gt; used to test the performance of [[nonlinear programming]] solvers. This particular optimization problem has an objective function &amp;lt;math&amp;gt;\min_{x\in\mathbb R}\; x_1 x_4 (x_1+x_2+x_3)+x_3&amp;lt;/math&amp;gt; and subject to the inequality constraint &amp;lt;math&amp;gt;x_1 x_2 x_3 x_4 \ge 25&amp;lt;/math&amp;gt; and equality constraint &amp;lt;math&amp;gt;{x_1}^2 + {x_2}^2 + {x_3}^2 + {x_4}^2=40&amp;lt;/math&amp;gt;. The four variables must be between a lower bound of 1 and an upper bound of 5. The initial guess values are &amp;lt;math&amp;gt;x_1 = 1, x_2=5, x_3=5, x_4=1&amp;lt;/math&amp;gt;. This optimization problem is solved with GEKKO as shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from gekko import GEKKO&lt;br /&gt;
m = GEKKO() # Initialize gekko&lt;br /&gt;
# Initialize variables&lt;br /&gt;
x1 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
x2 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x3 = m.Var(value=5,lb=1,ub=5)&lt;br /&gt;
x4 = m.Var(value=1,lb=1,ub=5)&lt;br /&gt;
# Equations&lt;br /&gt;
m.Equation(x1*x2*x3*x4&amp;gt;=25)&lt;br /&gt;
m.Equation(x1**2+x2**2+x3**2+x4**2==40)&lt;br /&gt;
m.Obj(x1*x4*(x1+x2+x3)+x3) # Objective&lt;br /&gt;
m.solve(disp=False) # Solve&lt;br /&gt;
print(&#039;x1: &#039; + str(x1.value))&lt;br /&gt;
print(&#039;x2: &#039; + str(x2.value))&lt;br /&gt;
print(&#039;x3: &#039; + str(x3.value))&lt;br /&gt;
print(&#039;x4: &#039; + str(x4.value))&lt;br /&gt;
print(&#039;Objective: &#039; + str(m.options.objfcnval))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Applications of GEKKO==&lt;br /&gt;
&lt;br /&gt;
Applications include [[Cogeneration|cogeneration (power and heat)]]&amp;lt;ref&amp;gt;{{cite journal | last=Mojica | first=J. | title=Optimal combined long-term facility design and short-term operational strategy for CHP capacity investments | journal=Energy | year=2017 | doi=10.1016/j.energy.2016.12.009 | volume=118 | pages=97–115}}&amp;lt;/ref&amp;gt;, [[Oil well|drilling automation]]&amp;lt;ref&amp;gt;{{cite journal | last=Eaton | first=A. | title=Real time model identification using multi-fidelity models in managed pressure drilling | journal=Computers &amp;amp; Chemical Engineering | year=2017 | doi=10.1016/j.compchemeng.2016.11.008 | volume=97 | pages=76–84}}&amp;lt;/ref&amp;gt;, severe slugging control&amp;lt;ref&amp;gt;{{cite journal | last=Eaton | first=A. | title=Post-installed fiber optic pressure sensors on subsea production risers for severe slugging control | journal=OMAE 2015 Proceedings, St. John&#039;s, Canada | year=2015 | url=http://apm.byu.edu/prism/uploads/Projects/Eaton_OMAE15.pdf}}&amp;lt;/ref&amp;gt;, solar thermal energy production&amp;lt;ref&amp;gt;{{cite journal | last=Powell | first=K. | title=Dynamic Optimization of a Hybrid Solar Thermal and Fossil Fuel System | journal=Solar Energy | year=2014 | doi=10.1016/j.solener.2014.07.004 | volume=108 | pages=210–218}}&amp;lt;/ref&amp;gt;, [[solid oxide fuel cell]]s&amp;lt;ref&amp;gt;{{cite journal | last=Spivey | first=B. | title=Dynamic Modeling of Reliability Constraints in Solid Oxide Fuel Cells and Implications for Advanced Control | journal=AIChE Annual Meeting Proceedings, Salt Lake City, Utah | year=2010 | url=http://apmonitor.com/wiki/uploads/Apps/sofc.pdf}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite journal | last=Spivey | first=B. | title=Dynamic modeling, simulation, and MIMO predictive control of a tubular solid oxide fuel cell | journal=Journal of Process Control | year=2012 | doi=10.1016/j.jprocont.2012.01.015 | volume=22 | issue=8 | pages=1502–1520}}&amp;lt;/ref&amp;gt;, flow assurance &amp;lt;ref&amp;gt;{{cite journal | last=Hedengren | first=J. | title=New flow assurance system with high speed subsea fiber optic monitoring of pressure and temperature | journal=ASME 37th International Conference on Ocean, Offshore and Arctic Engineering, OMAE2018/78079, Madrid, Spain | pages=V005T04A034 | year=2018| doi=10.1115/OMAE2018-78079 | isbn=978-0-7918-5124-1 }}&amp;lt;/ref&amp;gt;, [[Enhanced oil recovery]] &amp;lt;ref&amp;gt;{{cite journal | last=Udy | first=J. | title=Reduced order modeling for reservoir injection optimization and forecasting | journal=FOCAPO / CPC 2017, Tuscon, AZ | year=2017 | url=https://apm.byu.edu/prism/uploads/Members/udy2017_eor.pdf}}&amp;lt;/ref&amp;gt;, [[Essential oil]] extraction&amp;lt;ref&amp;gt;{{cite journal | last=Valderrama | first=F. | title=An optimal control approach to steam distillation of essential oils from aromatic plants | journal=Computers &amp;amp; Chemical Engineering | volume=117 | pages=25–31 | year=2018 | doi=10.1016/j.compchemeng.2018.05.009 }}&amp;lt;/ref&amp;gt;, and [[Unmanned aerial vehicle|Unmanned Aerial Vehicles (UAVs)]]&amp;lt;ref&amp;gt;{{cite journal | last=Sun | first=L. | title=Optimal Trajectory Generation using Model Predictive Control for Aerially Towed Cable Systems | journal=Journal of Guidance, Control, and Dynamics | year=2013 | url=http://apm.byu.edu/prism/uploads/Members/sun_2013.pdf}}&amp;lt;/ref&amp;gt;. There are many other references to [http://apmonitor.com/wiki/index.php/Main/APMonitorReferences APMonitor and GEKKO] as a sample of the types of applications that can be solved. GEKKO is developed from the National Science Foundation (NSF) research grant #1547110 &amp;lt;ref&amp;gt;{{cite journal | last=Beal | first=L. | title=Integrated scheduling and control in discrete-time with dynamic parameters and constraints | journal=Computers &amp;amp; Chemical Engineering | volume=115 | pages=361–376 | year=2018 | doi=10.1016/j.compchemeng.2018.04.010}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite journal | last=Beal | first=L. | title=Combined model predictive control and scheduling with dominant time constant compensation | journal=Computers &amp;amp; Chemical Engineering | volume=104 | pages=271–282 | year=2017 | url=https://scholarsarchive.byu.edu/facpub/1905/ | doi=10.1016/j.compchemeng.2017.04.024}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite journal | last=Beal | first=L. | title=Economic benefit from progressive integration of scheduling and control for continuous chemical processes | journal=Processes | year=2017 | doi=10.3390/pr5040084 | volume=5| issue=4 | pages=84 }}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite journal | last=Petersen | first=D. | title=Combined noncyclic scheduling and advanced control for continuous chemical processes | journal=Processes | year=2017 | doi=10.3390/pr5040083 | volume=5| issue=4 | pages=83 }}&amp;lt;/ref&amp;gt; and is detailed in a Special Issue collection on combined scheduling and control&amp;lt;ref&amp;gt;{{cite journal | last=Hedengren | first=J. | title=Special issue: combined scheduling and control | journal=Processes | volume=6 | issue=3 | pages=24 | year=2018 | url=http://www.mdpi.com/journal/processes/special_issues/Combined_Scheduling | doi=10.3390/pr6030024}}&amp;lt;/ref&amp;gt;. Other notable mentions of GEKKO are the listing in the Decision Tree for Optimization Software&amp;lt;ref&amp;gt;{{cite web |url=http://plato.asu.edu/sub/tools.html |title=Decision Tree for Optimization Software |last=Mittleman |first=Hans |date=1 May 2018 |website=Plato |publisher=Arizona State University |access-date=1 May 2018&lt;br /&gt;
 |quote=Object-oriented python library for mixed-integer and differential-algebraic equations}}&amp;lt;/ref&amp;gt;, added support for [[APOPT]] and BPOPT solvers&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 |url=https://apopt.com |title=Solver Solutions  |publisher=Advanced Process Solutions, LLC |access-date=1 May 2018 |quote=GEKKO Python with APOPT or BPOPT Solvers}}&amp;lt;/ref&amp;gt;, projects reports of the online Dynamic Optimization course from international participants&amp;lt;ref&amp;gt;{{cite web |url=http://apmonitor.com/do/index.php/Main/ProjectLab |title=Dynamic Optimization Projects |last=Everton |first=Colling |website=Petrobras |publisher=Petrobras, Statoil, Facebook |access-date=1 May 2018 |quote=Example Presentation: Everton Colling of Petrobras shares his experience with GEKKO for modeling and nonlinear control of distillation}}&amp;lt;/ref&amp;gt;. GEKKO is a topic in online forums where users are solving optimization and optimal control problems&amp;lt;ref&amp;gt;{{cite web |url=https://groups.google.com/forum/#!searchin/apmonitor/gekko |title=APMonitor Google Group: GEKKO |website=Google |access-date=1 May 2018}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |url=https://scicomp.stackexchange.com/questions/83/is-there-a-high-quality-nonlinear-programming-solver-for-python |title=Computational Science: Is there a high quality nonlinear programming solver for Python? |website=SciComp |access-date=1 May 2018}}&amp;lt;/ref&amp;gt;. GEKKO is used for advanced control in the Temperature Control Lab (TCLab)&amp;lt;ref&amp;gt;{{cite web |url=https://media.readthedocs.org/pdf/tclab/stable/tclab.pdf |title=TCLab Documentation |last=Kantor |first=Jeff |date=2 May 2018 |website=ReadTheDocs |publisher=University of Notre Dame |access-date=2 May 2018&lt;br /&gt;
 |quote=pip install tclab}}&amp;lt;/ref&amp;gt; for process control education at 20 universities&amp;lt;ref&amp;gt;{{cite web |url=https://jckantor.github.io/CBE30338/ |title=Chemical Process Control |last=Kantor |first=Jeff |date=2 May 2018 |website=GitHub |publisher=University of Notre Dame |access-date=2 May 2018&lt;br /&gt;
 |quote=Using the Temperature Control Lab (TCLab)}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |url=http://apmonitor.com/do/index.php/Main/AdvancedTemperatureControl |title=Advanced Temperature Control Lab |last=Hedengren |first=John |date=2 May 2018 |website=Dynamic Optimization Course |publisher=Brigham Young University |access-date=2 May 2018 |quote=Hands-on applications of advanced temperature control}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |url=https://github.com/alchemyst/Dynamics-and-Control |title=Jupyter notebooks for Dynamics and Control |last=Sandrock |first=Carl |date=2 May 2018 |website=GitHub |publisher=University of Pretoria, South Africa |access-date=2 May 2018 |quote=CPN321 (Process Dynamics), and CPB421 (Process Control) at the Chemical Engineering department of the University of Pretoria}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |url=http://cache.org/files/winter-2018-dynamic-simulation.pdf |title=CACHE News (Winter 2018): Incorporating Dynamic Simulation into Chemical Engineering Curricula |date=2 May 2018 |website=CACHE: Computer Aids for Chemical Engineering |publisher=University of Texas at Austin |access-date=2 May 2018 |quote=Short Course at the ASEE 2017 Summer School hosted at SCSU by Hedengren (BYU), Grover (Georgia Tech), and Badgwell (ExxonMobil)}}&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [https://gekko.readthedocs.io/en/latest/ GEKKO Documentation]&lt;br /&gt;
* [https://github.com/BYU-PRISM/GEKKO GEKKO Source Code]&lt;br /&gt;
* [https://pypi.org/project/gekko GEKKO on PyPI] for Python pip install&lt;br /&gt;
* GEKKO is open-source product of [https://www.nsf.gov/awardsearch/showAward?AWD_ID=1547110 National Science Foundation (NSF) research grant 1547110]&lt;br /&gt;
* [http://apmonitor.com/wiki/index.php/Main/APMonitorReferences References to APMonitor and GEKKO] in the literature&lt;br /&gt;
* [https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization 18 examples of GEKKO]: machine learning, optimal control, data regression&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem&amp;diff=2253</id>
		<title>Lotka Volterra fishing problem</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem&amp;diff=2253"/>
		<updated>2019-03-13T18:59:17Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Add GEKKO link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 3&lt;br /&gt;
|nw        = 1&lt;br /&gt;
|nre       = 3&lt;br /&gt;
}}&amp;lt;!-- Do not insert line break here or Dimensions Box moves up in the layout...&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;The &#039;&#039;&#039;Lotka Volterra fishing problem&#039;&#039;&#039; looks for an optimal fishing strategy to be performed on a fixed time horizon to bring the biomasses of both predator as prey fish to a prescribed steady state. The problem was set up as a small-scale benchmark problem. &lt;br /&gt;
The well known [http://en.wikipedia.org/wiki/Lotka_volterra Lotka Volterra equations] for a predator-prey system have been augmented by an additional linear term, relating to fishing by man. The control can be regarded both in a relaxed, as in a discrete manner, corresponding to a part of the fleet, or the full fishing fleet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The mathematical equations form a small-scale [[:Category:ODE model|ODE model]]. The interior point equality conditions fix the initial values of the differential states.&lt;br /&gt;
&lt;br /&gt;
The optimal integer control functions shows [[:Category:Chattering|chattering]] behavior, making the Lotka Volterra fishing problem an ideal candidate for benchmarking of algorithms.&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
The mixed-integer optimal control problem is given by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llclr}&lt;br /&gt;
 \displaystyle \min_{x, w} &amp;amp; x_2(t_f)   \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &lt;br /&gt;
 &amp;amp; \dot{x}_0 &amp;amp; = &amp;amp;  x_0 - x_0 x_1 - \; c_0 x_0 \; w, \\&lt;br /&gt;
 &amp;amp; \dot{x}_1 &amp;amp; = &amp;amp; - x_1 + x_0 x_1 - \; c_1 x_1 \; w,  \\&lt;br /&gt;
 &amp;amp; \dot{x}_2 &amp;amp; = &amp;amp; (x_0 - 1)^2 + (x_1 - 1)^2,  \\[1.5ex]&lt;br /&gt;
 &amp;amp; x(0) &amp;amp;=&amp;amp; (0.5, 0.7, 0)^T, \\&lt;br /&gt;
 &amp;amp; w(t) &amp;amp;\in&amp;amp;  \{0, 1\}.&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the differential states &amp;lt;math&amp;gt;(x_0, x_1)&amp;lt;/math&amp;gt; describe the biomasses of prey and predator, respectively. The third differential state is used here to transform the objective, an integrated deviation, into the Mayer formulation &amp;lt;math&amp;gt;\min \; x_2(t_f)&amp;lt;/math&amp;gt;. The decision, whether the fishing fleet is actually fishing at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is denoted by &amp;lt;math&amp;gt;w(t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
These fixed values are used within the model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{rcl}&lt;br /&gt;
[t_0, t_f] &amp;amp;=&amp;amp; [0, 12],\\&lt;br /&gt;
(c_0, c_1) &amp;amp;=&amp;amp; (0.4, 0.2).&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference Solutions ==&lt;br /&gt;
&lt;br /&gt;
If the problem is relaxed, i.e., we demand that &amp;lt;math&amp;gt;w(t)&amp;lt;/math&amp;gt; be in the continuous interval &amp;lt;math&amp;gt;[0, 1]&amp;lt;/math&amp;gt; instead of the binary choice &amp;lt;math&amp;gt;\{0,1\}&amp;lt;/math&amp;gt;, the optimal solution can be determined by means of [http://en.wikipedia.org/wiki/Pontryagin%27s_minimum_principle Pontryagins maximum principle]. The optimal solution contains a singular arc, as can be seen in the plot of the optimal control. The two differential states and corresponding adjoint variables in the indirect approach are also displayed. A different approach to solving the relaxed problem is by using a direct method such as collocation or Bock&#039;s direct multiple shooting method. Optimal solutions for different control discretizations are also plotted in the leftmost figure.&lt;br /&gt;
&lt;br /&gt;
The optimal objective value of this relaxed problem is &amp;lt;math&amp;gt;x_2(t_f) = 1.34408&amp;lt;/math&amp;gt;. As follows from MIOC theory &amp;lt;bib id=&amp;quot;Sager2011d&amp;quot; /&amp;gt; this is the best lower bound on the optimal value of the original problem with the integer restriction on the control function. In other words, this objective value can be approximated arbitrarily close, if the control only switches often enough between 0 and 1. As no optimal solution exists, two suboptimal ones are shown, one with only two switches and an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.38276&amp;lt;/math&amp;gt;, and one with 56 switches and &amp;lt;math&amp;gt;x_2(t_f) = 1.34416&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Reference solution plots&amp;quot; widths=&amp;quot;180px&amp;quot; heights=&amp;quot;140px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
 Image:lotkaRelaxedControls.png| Optimal relaxed control determined by an indirect approach and by a direct approach on different control discretization grids.&lt;br /&gt;
 Image:lotkaindirektStates.png| Differential states and corresponding adjoint variables in the indirect approach.&lt;br /&gt;
 Image:lotka2Switches.png| Control and differential states with only two switches.&lt;br /&gt;
 Image:lotka56Switches.png| Control and differential states with 56 switches.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
&lt;br /&gt;
* [[:Category:ACADO | ACADO code]] at [[Lotka Volterra fishing problem (ACADO)]]&lt;br /&gt;
* [[:Category:AMPL | AMPL code]] at [[Lotka Volterra fishing problem (AMPL)]]&lt;br /&gt;
* [[:Category:APMonitor | APMonitor code]] at [[Lotka Volterra fishing problem (APMonitor)]]&lt;br /&gt;
* [[:Category:Bocop | Bocop code]] at [[Lotka Volterra fishing problem (Bocop)]]&lt;br /&gt;
* [[:Category:Casadi | Casadi code]] at [[Lotka Volterra fishing problem (Casadi)]]&lt;br /&gt;
* [[:Category:Gekko | GEKKO Python code]] at [[Lotka Volterra fishing problem (GEKKO)]]&lt;br /&gt;
* [[:Category:JModelica | JModelica code]] at [[Lotka Volterra fishing problem (JModelica)]]&lt;br /&gt;
* [[:Category:Julia/JuMP | JuMP code]] at [[Lotka Volterra fishing problem (JuMP)]]&lt;br /&gt;
* [[:Category:Muscod | Muscod code]] at [[Lotka Volterra fishing problem (Muscod)]]&lt;br /&gt;
* [[:Category:switch | switch code]] at [[Lotka Volterra fishing problem (switch)]]&lt;br /&gt;
* [[:Category:TomDyn/PROPT | PROPT code]] at [[Lotka Volterra fishing problem (TomDyn/PROPT)]]&lt;br /&gt;
&lt;br /&gt;
== Variants ==&lt;br /&gt;
&lt;br /&gt;
There are several alternative formulations and variants of the above problem, in particular&lt;br /&gt;
&lt;br /&gt;
* a prescribed time grid for the control function &amp;lt;bib id=&amp;quot;Sager2006&amp;quot; /&amp;gt;, see also [[Lotka Volterra fishing problem (AMPL)]],&lt;br /&gt;
* a time-optimal formulation to get into a steady-state &amp;lt;bib id=&amp;quot;Sager2005&amp;quot; /&amp;gt;,&lt;br /&gt;
* the usage of a different target steady-state, as the one corresponding to &amp;lt;math&amp;gt; w(t) = 1&amp;lt;/math&amp;gt; which is &amp;lt;math&amp;gt;(1 + c_1, 1 - c_0)&amp;lt;/math&amp;gt;, see [[Lotka Volterra multi-arcs problem]]&lt;br /&gt;
* different fishing control functions for the two species, see [[Lotka Volterra Multimode fishing problem]]&lt;br /&gt;
* different parameters and start values.&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and Further Reading ==&lt;br /&gt;
The Lotka Volterra fishing problem was introduced by Sebastian Sager in a proceedings paper &amp;lt;bib id=&amp;quot;Sager2006&amp;quot; /&amp;gt; and revisited in his PhD thesis &amp;lt;bib id=&amp;quot;Sager2005&amp;quot; /&amp;gt;. These are also the references to look for more details.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category:Tracking objective]]&lt;br /&gt;
[[Category:Chattering]]&lt;br /&gt;
[[Category:Sensitivity-seeking arcs]]&lt;br /&gt;
[[Category:Population dynamics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--Testing Graphviz&lt;br /&gt;
&amp;lt;graphviz border=&#039;frame&#039; format=&#039;svg&#039;&amp;gt;&lt;br /&gt;
digraph G {Hello-&amp;gt;World!}&lt;br /&gt;
&amp;lt;/graphviz&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(APMonitor)&amp;diff=2155</id>
		<title>Lotka Volterra fishing problem (APMonitor)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(APMonitor)&amp;diff=2155"/>
		<updated>2017-11-20T22:15:45Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Results with APOPT (MINLP) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the MIOCP [[Lotka Volterra fishing problem]] in [http://www.apmonitor.com APMonitor] Python format. A MATLAB version is also available from the [http://apmonitor.com/do/index.php/Main/DiscreteVariables Dynamic Optimization Course] as [http://apmonitor.com/do/uploads/Main/lotka_volterra_fishing.zip Example 3 (lotka_volterra_fishing.zip)].&lt;br /&gt;
&lt;br /&gt;
=== APMonitor ===&lt;br /&gt;
&lt;br /&gt;
The model in Python code for a fixed control discretization grid using orthogonal collocation and a simultaneous optimization method. The APMonitor package is available with &#039;&#039;&#039;pip install APMonitor&#039;&#039;&#039; or from the [https://github.com/APMonitor/apm_python/blob/master/apm.py APMonitor Python Github repository].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
# retrieve apm.py from&lt;br /&gt;
# https://raw.githubusercontent.com/APMonitor/apm_python/master/apm.py&lt;br /&gt;
# or&lt;br /&gt;
# http://apmonitor.com/wiki/index.php/Main/PythonApp&lt;br /&gt;
# from apm import *&lt;br /&gt;
&lt;br /&gt;
# pip install with &#039;pip install APMonitor&#039;&lt;br /&gt;
from APMonitor.apm import *&lt;br /&gt;
&lt;br /&gt;
# local APMonitor servers are available for Windows or Linux&lt;br /&gt;
# http://apmonitor.com/wiki/index.php/Main/APMonitorServer&lt;br /&gt;
# with clients in Python, MATLAB, and Julia&lt;br /&gt;
&lt;br /&gt;
# write model&lt;br /&gt;
model = &#039;&#039;&#039;&lt;br /&gt;
! apopt MINLP solver options (see apopt.com)&lt;br /&gt;
File apopt.opt&lt;br /&gt;
 minlp_maximum_iterations 1000     ! minlp iterations&lt;br /&gt;
 minlp_max_iter_with_int_sol 50    ! minlp iterations if integer solution is found&lt;br /&gt;
 minlp_as_nlp 0                    ! treat minlp as nlp&lt;br /&gt;
 nlp_maximum_iterations 200        ! nlp sub-problem max iterations&lt;br /&gt;
 minlp_branch_method 1             ! 1 = depth first, 2 = breadth first&lt;br /&gt;
 minlp_gap_tol 0.001               ! covergence tolerance&lt;br /&gt;
 minlp_integer_tol 0.001           ! maximum deviation from whole number to be considered an integer&lt;br /&gt;
 minlp_integer_leaves 0            ! create soft (1) integer leaves or hard (2) integer leaves with branching  &lt;br /&gt;
End File&lt;br /&gt;
&lt;br /&gt;
Constants&lt;br /&gt;
  c0 = 0.4 &lt;br /&gt;
  c1 = 0.2&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
  last&lt;br /&gt;
&lt;br /&gt;
Variables&lt;br /&gt;
  x0 = 0.5 , &amp;gt;= 0&lt;br /&gt;
  x1 = 0.7 , &amp;gt;= 0&lt;br /&gt;
  x2 = 0.0 , &amp;gt;= 0&lt;br /&gt;
  int_w = 0 , &amp;gt;= 0 , &amp;lt;= 1&lt;br /&gt;
&lt;br /&gt;
Intermediates&lt;br /&gt;
  w = int_w&lt;br /&gt;
&lt;br /&gt;
Equations&lt;br /&gt;
  minimize last * x2&lt;br /&gt;
&lt;br /&gt;
  $x0 = x0 - x0*x1 - c0*x0*w &lt;br /&gt;
  $x1 = - x1 + x0*x1 - c1*x1*w&lt;br /&gt;
  $x2 = (x0-1)^2 + (x1-1)^2                                                                                       &lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
fid = open(&#039;lotka_volterra.apm&#039;,&#039;w&#039;)&lt;br /&gt;
fid.write(model)&lt;br /&gt;
fid.close()&lt;br /&gt;
&lt;br /&gt;
# write data file&lt;br /&gt;
time = np.linspace(0,12,121)&lt;br /&gt;
time = np.insert(time, 1, 0.01)&lt;br /&gt;
last = np.zeros(122)&lt;br /&gt;
last[-1] = 1.0&lt;br /&gt;
data = np.vstack((time,last))&lt;br /&gt;
np.savetxt(&#039;data.csv&#039;,data.T,delimiter=&#039;,&#039;,header=&#039;time,last&#039;,comments=&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
# specify server and application name&lt;br /&gt;
s = &#039;http://byu.apmonitor.com&#039;&lt;br /&gt;
#s = &#039;http://127.0.0.1/&#039;  # for local APMonitor server&lt;br /&gt;
a = &#039;lotka&#039;&lt;br /&gt;
&lt;br /&gt;
apm(s,a,&#039;clear all&#039;)&lt;br /&gt;
apm_load(s,a,&#039;lotka_volterra.apm&#039;)&lt;br /&gt;
csv_load(s,a,&#039;data.csv&#039;)&lt;br /&gt;
&lt;br /&gt;
apm_option(s,a,&#039;nlc.imode&#039;,6)              # Nonlinear control / dynamic optimization&lt;br /&gt;
apm_option(s,a,&#039;nlc.nodes&#039;,3)&lt;br /&gt;
&lt;br /&gt;
apm_info(s,a,&#039;MV&#039;,&#039;int_w&#039;)                 # M or MV = Manipulated variable - independent variable over time horizon&lt;br /&gt;
apm_option(s,a,&#039;int_w.status&#039;,1)           # Status: 1=ON, 0=OFF&lt;br /&gt;
apm_option(s,a,&#039;int_w.mv_type&#039;,0)          # MV Type = Zero Order Hold&lt;br /&gt;
&lt;br /&gt;
apm_option(s,a,&#039;nlc.solver&#039;,1)             # 1 = APOPT&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
output = apm(s,a,&#039;solve&#039;)            &lt;br /&gt;
print(output)&lt;br /&gt;
&lt;br /&gt;
# retrieve solution&lt;br /&gt;
y = apm_sol(s,a)&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(y[&#039;time&#039;],y[&#039;int_w&#039;],&#039;r-&#039;,label=&#039;w (0/1)&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x0&#039;],&#039;b-&#039;,label=r&#039;$x_0$&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x1&#039;],&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x2&#039;],&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with [https://apopt.com APOPT] with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.36&amp;lt;/math&amp;gt;. APOPT requires 50 NLP solutions to find an integer solution (111 seconds of processing time). Each NLP solution in the branch and bound method requires an average of 2.2 seconds to complete with a range between 12.99 and 0.57 seconds.&lt;br /&gt;
&lt;br /&gt;
[[File:Volterra_fishing_APMonitor.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ----------------------------------------------------------------&lt;br /&gt;
 APMonitor, Version 0.7.9&lt;br /&gt;
 APMonitor Optimization Suite&lt;br /&gt;
 ----------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 --------- APM Model Size ------------&lt;br /&gt;
 Each time step contains&lt;br /&gt;
   Objects      :            0&lt;br /&gt;
   Constants    :            2&lt;br /&gt;
   Variables    :            5&lt;br /&gt;
   Intermediates:            1&lt;br /&gt;
   Connections  :            0&lt;br /&gt;
   Equations    :            5&lt;br /&gt;
   Residuals    :            4&lt;br /&gt;
 &lt;br /&gt;
 Number of state variables:           2178&lt;br /&gt;
 Number of total equations: -         2057&lt;br /&gt;
 Number of slack variables: -            0&lt;br /&gt;
 ---------------------------------------&lt;br /&gt;
 Degrees of freedom       :            121&lt;br /&gt;
 &lt;br /&gt;
 ----------------------------------------------&lt;br /&gt;
 Dynamic Control with APOPT Solver&lt;br /&gt;
 ----------------------------------------------&lt;br /&gt;
Iter:     1 I:  0 Tm:     12.99 NLPi:   93 Dpth:    0 Lvs:    2 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     2 I:  0 Tm:      2.82 NLPi:   18 Dpth:    1 Lvs:    3 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     3 I:  0 Tm:      3.39 NLPi:   30 Dpth:    2 Lvs:    4 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     4 I:  0 Tm:     10.37 NLPi:  131 Dpth:    3 Lvs:    5 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     5 I:  0 Tm:      1.81 NLPi:   10 Dpth:    4 Lvs:    6 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     6 I:  0 Tm:      7.93 NLPi:  102 Dpth:    5 Lvs:    7 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     7 I:  0 Tm:      3.22 NLPi:   28 Dpth:    6 Lvs:    8 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     8 I:  0 Tm:      1.85 NLPi:   12 Dpth:    7 Lvs:    9 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     9 I:  0 Tm:     10.24 NLPi:  140 Dpth:    8 Lvs:   10 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:    10 I:  0 Tm:      2.04 NLPi:    9 Dpth:    9 Lvs:   11 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    11 I:  0 Tm:      6.50 NLPi:   86 Dpth:   10 Lvs:   12 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    12 I:  0 Tm:      1.94 NLPi:   17 Dpth:   11 Lvs:   13 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    13 I:  0 Tm:      2.17 NLPi:   18 Dpth:   12 Lvs:   14 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    14 I:  0 Tm:      3.56 NLPi:   44 Dpth:   13 Lvs:   15 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    15 I:  0 Tm:      2.34 NLPi:   23 Dpth:   14 Lvs:   16 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    16 I:  0 Tm:      2.46 NLPi:   26 Dpth:   15 Lvs:   17 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    17 I:  0 Tm:      2.72 NLPi:   26 Dpth:   16 Lvs:   18 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    18 I:  0 Tm:      3.99 NLPi:   60 Dpth:   17 Lvs:   19 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    19 I:  0 Tm:      1.91 NLPi:   10 Dpth:   18 Lvs:   20 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    20 I:  0 Tm:      1.23 NLPi:    7 Dpth:   19 Lvs:   21 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    21 I:  0 Tm:      1.37 NLPi:    8 Dpth:   20 Lvs:   22 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    22 I:  0 Tm:      1.37 NLPi:   12 Dpth:   21 Lvs:   23 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    23 I:  0 Tm:      1.34 NLPi:   11 Dpth:   22 Lvs:   24 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    24 I:  0 Tm:      1.30 NLPi:    8 Dpth:   23 Lvs:   25 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    25 I:  0 Tm:      1.33 NLPi:   14 Dpth:   24 Lvs:   26 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    26 I:  0 Tm:      1.13 NLPi:    7 Dpth:   25 Lvs:   27 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    27 I:  0 Tm:      0.97 NLPi:    7 Dpth:   26 Lvs:   28 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    28 I:  0 Tm:      0.99 NLPi:    6 Dpth:   27 Lvs:   29 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    29 I:  0 Tm:      0.93 NLPi:    6 Dpth:   28 Lvs:   30 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    30 I:  0 Tm:      0.66 NLPi:    5 Dpth:   29 Lvs:   31 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    31 I:  0 Tm:      0.73 NLPi:    5 Dpth:   30 Lvs:   32 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    32 I:  0 Tm:      0.66 NLPi:    5 Dpth:   31 Lvs:   33 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    33 I:  0 Tm:      0.70 NLPi:    5 Dpth:   32 Lvs:   34 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    34 I:  0 Tm:      0.67 NLPi:    5 Dpth:   33 Lvs:   35 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    35 I:  0 Tm:      0.82 NLPi:    9 Dpth:   34 Lvs:   36 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    36 I:  0 Tm:      0.77 NLPi:    8 Dpth:   35 Lvs:   37 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    37 I:  0 Tm:      0.75 NLPi:    8 Dpth:   36 Lvs:   38 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    38 I:  0 Tm:      0.69 NLPi:    6 Dpth:   37 Lvs:   39 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    39 I:  0 Tm:      0.71 NLPi:    6 Dpth:   38 Lvs:   40 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    40 I:  0 Tm:      0.81 NLPi:    9 Dpth:   39 Lvs:   41 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    41 I:  0 Tm:      0.70 NLPi:    8 Dpth:   40 Lvs:   42 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    42 I:  0 Tm:      0.69 NLPi:    6 Dpth:   41 Lvs:   43 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    43 I:  0 Tm:      0.67 NLPi:    5 Dpth:   42 Lvs:   44 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    44 I:  0 Tm:      0.60 NLPi:    4 Dpth:   43 Lvs:   45 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    45 I:  0 Tm:      0.71 NLPi:    6 Dpth:   44 Lvs:   46 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    46 I:  0 Tm:      0.59 NLPi:    4 Dpth:   45 Lvs:   47 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    47 I:  0 Tm:      0.69 NLPi:    6 Dpth:   46 Lvs:   48 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    48 I:  0 Tm:      0.65 NLPi:    5 Dpth:   47 Lvs:   49 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
--Integer Solution:   1.36E+00 Lowest Leaf:   1.34E+00 Gap:   1.35E-02&lt;br /&gt;
Iter:    49 I:  0 Tm:      0.57 NLPi:    3 Dpth:   48 Lvs:   48 Obj:  1.36E+00 Gap:  1.35E-02&lt;br /&gt;
Iter:    50 I:  0 Tm:      1.29 NLPi:    8 Dpth:   48 Lvs:   47 Obj:  1.36E+00 Gap:  1.35E-02&lt;br /&gt;
 Warning: best integer solution returned after maximum MINLP iterations&lt;br /&gt;
 Adjust minlp_max_iter_with_int_sol           50  in apopt.opt to change limit&lt;br /&gt;
 Successful solution&lt;br /&gt;
 &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 Solver         :  APOPT (v1.0)&lt;br /&gt;
 Solution time  :    111.364099999999      sec&lt;br /&gt;
 Objective      :    1.36258198934523     &lt;br /&gt;
 Successful solution&lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
[[Category:APMonitor]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=File:Volterra_fishing_APMonitor.png&amp;diff=2154</id>
		<title>File:Volterra fishing APMonitor.png</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=File:Volterra_fishing_APMonitor.png&amp;diff=2154"/>
		<updated>2017-11-20T22:13:04Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(APMonitor)&amp;diff=2153</id>
		<title>Lotka Volterra fishing problem (APMonitor)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(APMonitor)&amp;diff=2153"/>
		<updated>2017-11-20T22:12:26Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Results section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the MIOCP [[Lotka Volterra fishing problem]] in [http://www.apmonitor.com APMonitor] Python format. A MATLAB version is also available from the [http://apmonitor.com/do/index.php/Main/DiscreteVariables Dynamic Optimization Course] as [http://apmonitor.com/do/uploads/Main/lotka_volterra_fishing.zip Example 3 (lotka_volterra_fishing.zip)].&lt;br /&gt;
&lt;br /&gt;
=== APMonitor ===&lt;br /&gt;
&lt;br /&gt;
The model in Python code for a fixed control discretization grid using orthogonal collocation and a simultaneous optimization method. The APMonitor package is available with &#039;&#039;&#039;pip install APMonitor&#039;&#039;&#039; or from the [https://github.com/APMonitor/apm_python/blob/master/apm.py APMonitor Python Github repository].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
# retrieve apm.py from&lt;br /&gt;
# https://raw.githubusercontent.com/APMonitor/apm_python/master/apm.py&lt;br /&gt;
# or&lt;br /&gt;
# http://apmonitor.com/wiki/index.php/Main/PythonApp&lt;br /&gt;
# from apm import *&lt;br /&gt;
&lt;br /&gt;
# pip install with &#039;pip install APMonitor&#039;&lt;br /&gt;
from APMonitor.apm import *&lt;br /&gt;
&lt;br /&gt;
# local APMonitor servers are available for Windows or Linux&lt;br /&gt;
# http://apmonitor.com/wiki/index.php/Main/APMonitorServer&lt;br /&gt;
# with clients in Python, MATLAB, and Julia&lt;br /&gt;
&lt;br /&gt;
# write model&lt;br /&gt;
model = &#039;&#039;&#039;&lt;br /&gt;
! apopt MINLP solver options (see apopt.com)&lt;br /&gt;
File apopt.opt&lt;br /&gt;
 minlp_maximum_iterations 1000     ! minlp iterations&lt;br /&gt;
 minlp_max_iter_with_int_sol 50    ! minlp iterations if integer solution is found&lt;br /&gt;
 minlp_as_nlp 0                    ! treat minlp as nlp&lt;br /&gt;
 nlp_maximum_iterations 200        ! nlp sub-problem max iterations&lt;br /&gt;
 minlp_branch_method 1             ! 1 = depth first, 2 = breadth first&lt;br /&gt;
 minlp_gap_tol 0.001               ! covergence tolerance&lt;br /&gt;
 minlp_integer_tol 0.001           ! maximum deviation from whole number to be considered an integer&lt;br /&gt;
 minlp_integer_leaves 0            ! create soft (1) integer leaves or hard (2) integer leaves with branching  &lt;br /&gt;
End File&lt;br /&gt;
&lt;br /&gt;
Constants&lt;br /&gt;
  c0 = 0.4 &lt;br /&gt;
  c1 = 0.2&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
  last&lt;br /&gt;
&lt;br /&gt;
Variables&lt;br /&gt;
  x0 = 0.5 , &amp;gt;= 0&lt;br /&gt;
  x1 = 0.7 , &amp;gt;= 0&lt;br /&gt;
  x2 = 0.0 , &amp;gt;= 0&lt;br /&gt;
  int_w = 0 , &amp;gt;= 0 , &amp;lt;= 1&lt;br /&gt;
&lt;br /&gt;
Intermediates&lt;br /&gt;
  w = int_w&lt;br /&gt;
&lt;br /&gt;
Equations&lt;br /&gt;
  minimize last * x2&lt;br /&gt;
&lt;br /&gt;
  $x0 = x0 - x0*x1 - c0*x0*w &lt;br /&gt;
  $x1 = - x1 + x0*x1 - c1*x1*w&lt;br /&gt;
  $x2 = (x0-1)^2 + (x1-1)^2                                                                                       &lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
fid = open(&#039;lotka_volterra.apm&#039;,&#039;w&#039;)&lt;br /&gt;
fid.write(model)&lt;br /&gt;
fid.close()&lt;br /&gt;
&lt;br /&gt;
# write data file&lt;br /&gt;
time = np.linspace(0,12,121)&lt;br /&gt;
time = np.insert(time, 1, 0.01)&lt;br /&gt;
last = np.zeros(122)&lt;br /&gt;
last[-1] = 1.0&lt;br /&gt;
data = np.vstack((time,last))&lt;br /&gt;
np.savetxt(&#039;data.csv&#039;,data.T,delimiter=&#039;,&#039;,header=&#039;time,last&#039;,comments=&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
# specify server and application name&lt;br /&gt;
s = &#039;http://byu.apmonitor.com&#039;&lt;br /&gt;
#s = &#039;http://127.0.0.1/&#039;  # for local APMonitor server&lt;br /&gt;
a = &#039;lotka&#039;&lt;br /&gt;
&lt;br /&gt;
apm(s,a,&#039;clear all&#039;)&lt;br /&gt;
apm_load(s,a,&#039;lotka_volterra.apm&#039;)&lt;br /&gt;
csv_load(s,a,&#039;data.csv&#039;)&lt;br /&gt;
&lt;br /&gt;
apm_option(s,a,&#039;nlc.imode&#039;,6)              # Nonlinear control / dynamic optimization&lt;br /&gt;
apm_option(s,a,&#039;nlc.nodes&#039;,3)&lt;br /&gt;
&lt;br /&gt;
apm_info(s,a,&#039;MV&#039;,&#039;int_w&#039;)                 # M or MV = Manipulated variable - independent variable over time horizon&lt;br /&gt;
apm_option(s,a,&#039;int_w.status&#039;,1)           # Status: 1=ON, 0=OFF&lt;br /&gt;
apm_option(s,a,&#039;int_w.mv_type&#039;,0)          # MV Type = Zero Order Hold&lt;br /&gt;
&lt;br /&gt;
apm_option(s,a,&#039;nlc.solver&#039;,1)             # 1 = APOPT&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
output = apm(s,a,&#039;solve&#039;)            &lt;br /&gt;
print(output)&lt;br /&gt;
&lt;br /&gt;
# retrieve solution&lt;br /&gt;
y = apm_sol(s,a)&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(y[&#039;time&#039;],y[&#039;int_w&#039;],&#039;r-&#039;,label=&#039;w (0/1)&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x0&#039;],&#039;b-&#039;,label=r&#039;$x_0$&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x1&#039;],&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x2&#039;],&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results with APOPT (MINLP) ==&lt;br /&gt;
&lt;br /&gt;
An MINLP solution is calculated with [https://apopt.com|APOPT] with an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.36&amp;lt;/math&amp;gt;. APOPT requires 52 NLP solutions to find an integer solution (111.0 seconds of processing time).&lt;br /&gt;
&lt;br /&gt;
[[File:Volterra_fishing_APMonitor.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ----------------------------------------------------------------&lt;br /&gt;
 APMonitor, Version 0.7.9&lt;br /&gt;
 APMonitor Optimization Suite&lt;br /&gt;
 ----------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 --------- APM Model Size ------------&lt;br /&gt;
 Each time step contains&lt;br /&gt;
   Objects      :            0&lt;br /&gt;
   Constants    :            2&lt;br /&gt;
   Variables    :            5&lt;br /&gt;
   Intermediates:            1&lt;br /&gt;
   Connections  :            0&lt;br /&gt;
   Equations    :            5&lt;br /&gt;
   Residuals    :            4&lt;br /&gt;
 &lt;br /&gt;
 Number of state variables:           2178&lt;br /&gt;
 Number of total equations: -         2057&lt;br /&gt;
 Number of slack variables: -            0&lt;br /&gt;
 ---------------------------------------&lt;br /&gt;
 Degrees of freedom       :            121&lt;br /&gt;
 &lt;br /&gt;
 ----------------------------------------------&lt;br /&gt;
 Dynamic Control with APOPT Solver&lt;br /&gt;
 ----------------------------------------------&lt;br /&gt;
Iter:     1 I:  0 Tm:     12.99 NLPi:   93 Dpth:    0 Lvs:    2 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     2 I:  0 Tm:      2.82 NLPi:   18 Dpth:    1 Lvs:    3 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     3 I:  0 Tm:      3.39 NLPi:   30 Dpth:    2 Lvs:    4 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     4 I:  0 Tm:     10.37 NLPi:  131 Dpth:    3 Lvs:    5 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     5 I:  0 Tm:      1.81 NLPi:   10 Dpth:    4 Lvs:    6 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     6 I:  0 Tm:      7.93 NLPi:  102 Dpth:    5 Lvs:    7 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     7 I:  0 Tm:      3.22 NLPi:   28 Dpth:    6 Lvs:    8 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     8 I:  0 Tm:      1.85 NLPi:   12 Dpth:    7 Lvs:    9 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:     9 I:  0 Tm:     10.24 NLPi:  140 Dpth:    8 Lvs:   10 Obj:  1.34E+00 Gap:       NaN&lt;br /&gt;
Iter:    10 I:  0 Tm:      2.04 NLPi:    9 Dpth:    9 Lvs:   11 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    11 I:  0 Tm:      6.50 NLPi:   86 Dpth:   10 Lvs:   12 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    12 I:  0 Tm:      1.94 NLPi:   17 Dpth:   11 Lvs:   13 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    13 I:  0 Tm:      2.17 NLPi:   18 Dpth:   12 Lvs:   14 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    14 I:  0 Tm:      3.56 NLPi:   44 Dpth:   13 Lvs:   15 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    15 I:  0 Tm:      2.34 NLPi:   23 Dpth:   14 Lvs:   16 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    16 I:  0 Tm:      2.46 NLPi:   26 Dpth:   15 Lvs:   17 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    17 I:  0 Tm:      2.72 NLPi:   26 Dpth:   16 Lvs:   18 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    18 I:  0 Tm:      3.99 NLPi:   60 Dpth:   17 Lvs:   19 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    19 I:  0 Tm:      1.91 NLPi:   10 Dpth:   18 Lvs:   20 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    20 I:  0 Tm:      1.23 NLPi:    7 Dpth:   19 Lvs:   21 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    21 I:  0 Tm:      1.37 NLPi:    8 Dpth:   20 Lvs:   22 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    22 I:  0 Tm:      1.37 NLPi:   12 Dpth:   21 Lvs:   23 Obj:  1.35E+00 Gap:       NaN&lt;br /&gt;
Iter:    23 I:  0 Tm:      1.34 NLPi:   11 Dpth:   22 Lvs:   24 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    24 I:  0 Tm:      1.30 NLPi:    8 Dpth:   23 Lvs:   25 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    25 I:  0 Tm:      1.33 NLPi:   14 Dpth:   24 Lvs:   26 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    26 I:  0 Tm:      1.13 NLPi:    7 Dpth:   25 Lvs:   27 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    27 I:  0 Tm:      0.97 NLPi:    7 Dpth:   26 Lvs:   28 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    28 I:  0 Tm:      0.99 NLPi:    6 Dpth:   27 Lvs:   29 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    29 I:  0 Tm:      0.93 NLPi:    6 Dpth:   28 Lvs:   30 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    30 I:  0 Tm:      0.66 NLPi:    5 Dpth:   29 Lvs:   31 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    31 I:  0 Tm:      0.73 NLPi:    5 Dpth:   30 Lvs:   32 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    32 I:  0 Tm:      0.66 NLPi:    5 Dpth:   31 Lvs:   33 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    33 I:  0 Tm:      0.70 NLPi:    5 Dpth:   32 Lvs:   34 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    34 I:  0 Tm:      0.67 NLPi:    5 Dpth:   33 Lvs:   35 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    35 I:  0 Tm:      0.82 NLPi:    9 Dpth:   34 Lvs:   36 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    36 I:  0 Tm:      0.77 NLPi:    8 Dpth:   35 Lvs:   37 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    37 I:  0 Tm:      0.75 NLPi:    8 Dpth:   36 Lvs:   38 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    38 I:  0 Tm:      0.69 NLPi:    6 Dpth:   37 Lvs:   39 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    39 I:  0 Tm:      0.71 NLPi:    6 Dpth:   38 Lvs:   40 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    40 I:  0 Tm:      0.81 NLPi:    9 Dpth:   39 Lvs:   41 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    41 I:  0 Tm:      0.70 NLPi:    8 Dpth:   40 Lvs:   42 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    42 I:  0 Tm:      0.69 NLPi:    6 Dpth:   41 Lvs:   43 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    43 I:  0 Tm:      0.67 NLPi:    5 Dpth:   42 Lvs:   44 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    44 I:  0 Tm:      0.60 NLPi:    4 Dpth:   43 Lvs:   45 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    45 I:  0 Tm:      0.71 NLPi:    6 Dpth:   44 Lvs:   46 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    46 I:  0 Tm:      0.59 NLPi:    4 Dpth:   45 Lvs:   47 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    47 I:  0 Tm:      0.69 NLPi:    6 Dpth:   46 Lvs:   48 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
Iter:    48 I:  0 Tm:      0.65 NLPi:    5 Dpth:   47 Lvs:   49 Obj:  1.36E+00 Gap:       NaN&lt;br /&gt;
--Integer Solution:   1.36E+00 Lowest Leaf:   1.34E+00 Gap:   1.35E-02&lt;br /&gt;
Iter:    49 I:  0 Tm:      0.57 NLPi:    3 Dpth:   48 Lvs:   48 Obj:  1.36E+00 Gap:  1.35E-02&lt;br /&gt;
Iter:    50 I:  0 Tm:      1.29 NLPi:    8 Dpth:   48 Lvs:   47 Obj:  1.36E+00 Gap:  1.35E-02&lt;br /&gt;
 Warning: best integer solution returned after maximum MINLP iterations&lt;br /&gt;
 Adjust minlp_max_iter_with_int_sol           50  in apopt.opt to change limit&lt;br /&gt;
 Successful solution&lt;br /&gt;
 &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 Solver         :  APOPT (v1.0)&lt;br /&gt;
 Solution time  :    111.364099999999      sec&lt;br /&gt;
 Objective      :    1.36258198934523     &lt;br /&gt;
 Successful solution&lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
[[Category:APMonitor]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(APMonitor)&amp;diff=2152</id>
		<title>Lotka Volterra fishing problem (APMonitor)</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem_(APMonitor)&amp;diff=2152"/>
		<updated>2017-11-20T22:03:56Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: APMontor solution of Volterra fishing problem&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a solution of the MIOCP [[Lotka Volterra fishing problem]] in [http://www.apmonitor.com APMonitor] Python format. A MATLAB version is also available from the [http://apmonitor.com/do/index.php/Main/DiscreteVariables Dynamic Optimization Course] as [http://apmonitor.com/do/uploads/Main/lotka_volterra_fishing.zip Example 3 (lotka_volterra_fishing.zip)].&lt;br /&gt;
&lt;br /&gt;
=== APMonitor ===&lt;br /&gt;
&lt;br /&gt;
The model in Python code for a fixed control discretization grid using orthogonal collocation and a simultaneous optimization method. The APMonitor package is available with &#039;&#039;&#039;pip install APMonitor&#039;&#039;&#039; or from the [https://github.com/APMonitor/apm_python/blob/master/apm.py APMonitor Python Github repository].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
# retrieve apm.py from&lt;br /&gt;
# https://raw.githubusercontent.com/APMonitor/apm_python/master/apm.py&lt;br /&gt;
# or&lt;br /&gt;
# http://apmonitor.com/wiki/index.php/Main/PythonApp&lt;br /&gt;
# from apm import *&lt;br /&gt;
&lt;br /&gt;
# pip install with &#039;pip install APMonitor&#039;&lt;br /&gt;
from APMonitor.apm import *&lt;br /&gt;
&lt;br /&gt;
# local APMonitor servers are available for Windows or Linux&lt;br /&gt;
# http://apmonitor.com/wiki/index.php/Main/APMonitorServer&lt;br /&gt;
# with clients in Python, MATLAB, and Julia&lt;br /&gt;
&lt;br /&gt;
# write model&lt;br /&gt;
model = &#039;&#039;&#039;&lt;br /&gt;
! apopt MINLP solver options (see apopt.com)&lt;br /&gt;
File apopt.opt&lt;br /&gt;
 minlp_maximum_iterations 1000     ! minlp iterations&lt;br /&gt;
 minlp_max_iter_with_int_sol 50    ! minlp iterations if integer solution is found&lt;br /&gt;
 minlp_as_nlp 0                    ! treat minlp as nlp&lt;br /&gt;
 nlp_maximum_iterations 200        ! nlp sub-problem max iterations&lt;br /&gt;
 minlp_branch_method 1             ! 1 = depth first, 2 = breadth first&lt;br /&gt;
 minlp_gap_tol 0.001               ! covergence tolerance&lt;br /&gt;
 minlp_integer_tol 0.001           ! maximum deviation from whole number to be considered an integer&lt;br /&gt;
 minlp_integer_leaves 0            ! create soft (1) integer leaves or hard (2) integer leaves with branching  &lt;br /&gt;
End File&lt;br /&gt;
&lt;br /&gt;
Constants&lt;br /&gt;
  c0 = 0.4 &lt;br /&gt;
  c1 = 0.2&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
  last&lt;br /&gt;
&lt;br /&gt;
Variables&lt;br /&gt;
  x0 = 0.5 , &amp;gt;= 0&lt;br /&gt;
  x1 = 0.7 , &amp;gt;= 0&lt;br /&gt;
  x2 = 0.0 , &amp;gt;= 0&lt;br /&gt;
  int_w = 0 , &amp;gt;= 0 , &amp;lt;= 1&lt;br /&gt;
&lt;br /&gt;
Intermediates&lt;br /&gt;
  w = int_w&lt;br /&gt;
&lt;br /&gt;
Equations&lt;br /&gt;
  minimize last * x2&lt;br /&gt;
&lt;br /&gt;
  $x0 = x0 - x0*x1 - c0*x0*w &lt;br /&gt;
  $x1 = - x1 + x0*x1 - c1*x1*w&lt;br /&gt;
  $x2 = (x0-1)^2 + (x1-1)^2                                                                                       &lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
fid = open(&#039;lotka_volterra.apm&#039;,&#039;w&#039;)&lt;br /&gt;
fid.write(model)&lt;br /&gt;
fid.close()&lt;br /&gt;
&lt;br /&gt;
# write data file&lt;br /&gt;
time = np.linspace(0,12,121)&lt;br /&gt;
time = np.insert(time, 1, 0.01)&lt;br /&gt;
last = np.zeros(122)&lt;br /&gt;
last[-1] = 1.0&lt;br /&gt;
data = np.vstack((time,last))&lt;br /&gt;
np.savetxt(&#039;data.csv&#039;,data.T,delimiter=&#039;,&#039;,header=&#039;time,last&#039;,comments=&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
# specify server and application name&lt;br /&gt;
s = &#039;http://byu.apmonitor.com&#039;&lt;br /&gt;
#s = &#039;http://127.0.0.1/&#039;  # for local APMonitor server&lt;br /&gt;
a = &#039;lotka&#039;&lt;br /&gt;
&lt;br /&gt;
apm(s,a,&#039;clear all&#039;)&lt;br /&gt;
apm_load(s,a,&#039;lotka_volterra.apm&#039;)&lt;br /&gt;
csv_load(s,a,&#039;data.csv&#039;)&lt;br /&gt;
&lt;br /&gt;
apm_option(s,a,&#039;nlc.imode&#039;,6)              # Nonlinear control / dynamic optimization&lt;br /&gt;
apm_option(s,a,&#039;nlc.nodes&#039;,3)&lt;br /&gt;
&lt;br /&gt;
apm_info(s,a,&#039;MV&#039;,&#039;int_w&#039;)                 # M or MV = Manipulated variable - independent variable over time horizon&lt;br /&gt;
apm_option(s,a,&#039;int_w.status&#039;,1)           # Status: 1=ON, 0=OFF&lt;br /&gt;
apm_option(s,a,&#039;int_w.mv_type&#039;,0)          # MV Type = Zero Order Hold&lt;br /&gt;
&lt;br /&gt;
apm_option(s,a,&#039;nlc.solver&#039;,1)             # 1 = APOPT&lt;br /&gt;
&lt;br /&gt;
# solve&lt;br /&gt;
output = apm(s,a,&#039;solve&#039;)            &lt;br /&gt;
print(output)&lt;br /&gt;
&lt;br /&gt;
# retrieve solution&lt;br /&gt;
y = apm_sol(s,a)&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.step(y[&#039;time&#039;],y[&#039;int_w&#039;],&#039;r-&#039;,label=&#039;w (0/1)&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x0&#039;],&#039;b-&#039;,label=r&#039;$x_0$&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x1&#039;],&#039;k-&#039;,label=r&#039;$x_1$&#039;)&lt;br /&gt;
plt.plot(y[&#039;time&#039;],y[&#039;x2&#039;],&#039;g-&#039;,label=r&#039;$x_2$&#039;)&lt;br /&gt;
plt.xlabel(&#039;Time&#039;)&lt;br /&gt;
plt.ylabel(&#039;Variables&#039;)&lt;br /&gt;
plt.legend(loc=&#039;best&#039;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
&lt;br /&gt;
=== IPOPT ===&lt;br /&gt;
The relaxed solution calculated by IPOPT (Ipopt 3.12, Linux x86_64, default settings, 4 GHz quadcore, Linux 4.2.0-23-generic) has an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.34428&amp;lt;/math&amp;gt;. IPOPT requires 22 iterations (6.062 seconds of processing time). The following is a Gnuplot compatible tabular version of the solution:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#         t,         x_0,         x_1,           u&lt;br /&gt;
          0,         0.5,         0.7, 5.18436e-09&lt;br /&gt;
       0.12,    0.519594,    0.659989, 5.42459e-09&lt;br /&gt;
       0.24,    0.542429,    0.623852, 5.79496e-09&lt;br /&gt;
       0.36,    0.568601,    0.591429, 6.30563e-09&lt;br /&gt;
       0.48,     0.59823,    0.562571, 6.97415e-09&lt;br /&gt;
        0.6,    0.631456,    0.537143,   7.827e-09&lt;br /&gt;
       0.72,     0.66843,    0.515028, 8.90236e-09&lt;br /&gt;
       0.84,    0.709312,    0.496134, 1.02545e-08&lt;br /&gt;
       0.96,     0.75426,    0.480401, 1.19611e-08&lt;br /&gt;
       1.08,    0.803421,      0.4678, 1.41346e-08&lt;br /&gt;
        1.2,    0.856919,    0.458344, 1.69417e-08&lt;br /&gt;
       1.32,    0.914842,    0.452091, 2.06377e-08&lt;br /&gt;
       1.44,     0.97722,    0.449154, 2.56285e-08&lt;br /&gt;
       1.56,       1.044,    0.449708,  3.2592e-08&lt;br /&gt;
       1.68,     1.11503,    0.454003, 4.27322e-08&lt;br /&gt;
        1.8,     1.18998,    0.462372, 5.83658e-08&lt;br /&gt;
       1.92,     1.26837,    0.475251, 8.44574e-08&lt;br /&gt;
       2.04,     1.34942,    0.493189, 1.33425e-07&lt;br /&gt;
       2.16,     1.43209,    0.516862, 2.44977e-07&lt;br /&gt;
       2.28,     1.51492,    0.547087, 6.24464e-07&lt;br /&gt;
        2.4,     1.59605,    0.584816,    0.715281&lt;br /&gt;
       2.52,     1.61776,     0.61833,    0.999999&lt;br /&gt;
       2.64,     1.61116,      0.6499,    0.999999&lt;br /&gt;
       2.76,     1.59844,     0.68229,           1&lt;br /&gt;
       2.88,     1.57963,    0.714939,           1&lt;br /&gt;
          3,     1.55497,    0.747196,           1&lt;br /&gt;
       3.12,     1.52487,    0.778343,    0.999999&lt;br /&gt;
       3.24,     1.48993,    0.807625,    0.999999&lt;br /&gt;
       3.36,      1.4509,     0.83429,    0.999999&lt;br /&gt;
       3.48,     1.40865,    0.857635,    0.999998&lt;br /&gt;
        3.6,     1.36412,    0.877047,    0.999997&lt;br /&gt;
       3.72,     1.31827,    0.892039,    0.999991&lt;br /&gt;
       3.84,     1.27203,     0.90228,    0.999646&lt;br /&gt;
       3.96,     1.22628,    0.907616,    0.536112&lt;br /&gt;
       4.08,     1.20755,    0.919653,    0.581667&lt;br /&gt;
        4.2,     1.18502,    0.928525,    0.503883&lt;br /&gt;
       4.32,     1.16606,    0.936899,    0.464153&lt;br /&gt;
       4.44,     1.14851,    0.944178,    0.418428&lt;br /&gt;
       4.56,     1.13278,    0.950658,    0.378617&lt;br /&gt;
       4.68,     1.11859,    0.956378,    0.341493&lt;br /&gt;
        4.8,     1.10582,    0.961433,      0.3073&lt;br /&gt;
       4.92,     1.09438,    0.965904,    0.276462&lt;br /&gt;
       5.04,     1.08411,    0.969849,    0.248219&lt;br /&gt;
       5.16,     1.07492,    0.973333,    0.222481&lt;br /&gt;
       5.28,      1.0667,    0.976412,     0.19935&lt;br /&gt;
        5.4,     1.05936,     0.97913,    0.178262&lt;br /&gt;
       5.52,      1.0528,    0.981533,    0.159402&lt;br /&gt;
       5.64,     1.04696,    0.983656,    0.142349&lt;br /&gt;
       5.76,     1.04175,    0.985532,    0.127041&lt;br /&gt;
       5.88,      1.0371,    0.987191,      0.1133&lt;br /&gt;
          6,     1.03297,    0.988657,    0.100985&lt;br /&gt;
       6.12,     1.02929,    0.989954,   0.0899604&lt;br /&gt;
       6.24,     1.02601,    0.991101,   0.0800981&lt;br /&gt;
       6.36,      1.0231,    0.992117,   0.0712934&lt;br /&gt;
       6.48,     1.02051,    0.993015,   0.0634308&lt;br /&gt;
        6.6,     1.01821,    0.993811,   0.0564127&lt;br /&gt;
       6.72,     1.01617,    0.994515,   0.0501573&lt;br /&gt;
       6.84,     1.01435,    0.995139,   0.0445824&lt;br /&gt;
       6.96,     1.01274,    0.995691,   0.0396177&lt;br /&gt;
       7.08,     1.01131,     0.99618,   0.0351979&lt;br /&gt;
        7.2,     1.01003,    0.996613,   0.0312714&lt;br /&gt;
       7.32,      1.0089,    0.996997,    0.027765&lt;br /&gt;
       7.44,      1.0079,    0.997337,   0.0246626&lt;br /&gt;
       7.56,     1.00701,    0.997639,   0.0218975&lt;br /&gt;
       7.68,     1.00622,    0.997905,   0.0194423&lt;br /&gt;
        7.8,     1.00552,    0.998142,   0.0172603&lt;br /&gt;
       7.92,      1.0049,    0.998351,   0.0153224&lt;br /&gt;
       8.04,     1.00435,    0.998537,   0.0136015&lt;br /&gt;
       8.16,     1.00386,    0.998701,   0.0120735&lt;br /&gt;
       8.28,     1.00342,    0.998847,   0.0107171&lt;br /&gt;
        8.4,     1.00303,    0.998976,  0.00951328&lt;br /&gt;
       8.52,     1.00269,     0.99909,  0.00844491&lt;br /&gt;
       8.64,     1.00239,    0.999191,  0.00749702&lt;br /&gt;
       8.76,     1.00212,    0.999281,  0.00665598&lt;br /&gt;
       8.88,     1.00188,     0.99936,  0.00590975&lt;br /&gt;
          9,     1.00167,     0.99943,  0.00524776&lt;br /&gt;
       9.12,     1.00148,    0.999492,  0.00466052&lt;br /&gt;
       9.24,     1.00131,    0.999547,  0.00413914&lt;br /&gt;
       9.36,     1.00117,    0.999596,  0.00367206&lt;br /&gt;
       9.48,     1.00103,    0.999637,  0.00326159&lt;br /&gt;
        9.6,     1.00092,    0.999675,  0.00290302&lt;br /&gt;
       9.72,     1.00082,    0.999707,  0.00258504&lt;br /&gt;
       9.84,     1.00072,    0.999736,  0.00230262&lt;br /&gt;
       9.96,     1.00064,    0.999762,  0.00205186&lt;br /&gt;
      10.08,     1.00057,    0.999785,  0.00182951&lt;br /&gt;
       10.2,     1.00051,    0.999805,  0.00163302&lt;br /&gt;
      10.32,     1.00045,    0.999822,  0.00146039&lt;br /&gt;
      10.44,      1.0004,    0.999838,  0.00131011&lt;br /&gt;
      10.56,     1.00036,    0.999851,  0.00118097&lt;br /&gt;
      10.68,     1.00032,    0.999863,  0.00107188&lt;br /&gt;
       10.8,     1.00028,    0.999872, 0.000981659&lt;br /&gt;
      10.92,     1.00025,     0.99988,  0.00090944&lt;br /&gt;
      11.04,     1.00022,    0.999886, 0.000854893&lt;br /&gt;
      11.16,     1.00019,     0.99989, 0.000818284&lt;br /&gt;
      11.28,     1.00017,    0.999892, 0.000801181&lt;br /&gt;
       11.4,     1.00014,    0.999891, 0.000807844&lt;br /&gt;
      11.52,     1.00012,    0.999886, 0.000848734&lt;br /&gt;
      11.64,     1.00009,    0.999878, 0.000951928&lt;br /&gt;
      11.76,     1.00006,    0.999864,  0.00121852&lt;br /&gt;
      11.88,     1.00002,    0.999838,  0.00267036&lt;br /&gt;
         12,    0.999915,    0.999769,           0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
[[Category:APMonitor]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Category:APMonitor&amp;diff=2151</id>
		<title>Category:APMonitor</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Category:APMonitor&amp;diff=2151"/>
		<updated>2017-11-20T21:43:46Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Availibility */ minor clarification&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Advanced process monitor (APMonitor)&#039;&#039;&#039;, is a modeling language for mixed integer and differential algebraic equations. It is a free web-service or locally installed service for solving this class of problems.  APMonitor is suited for large-scale problems and allows solutions of linear programming, integer programming, nonlinear programming, nonlinear mixed integer programming, dynamic simulation, moving horizon estimation, and nonlinear model predictive control. APMonitor does not solve the problems directly, but calls nonlinear programming solvers such as APOPT, BPOPT, IPOPT, MINOS, and SNOPT.&lt;br /&gt;
&lt;br /&gt;
==Programming Language Integration==&lt;br /&gt;
&lt;br /&gt;
Julia, MATLAB, and Python are mathematical programming languages that have APMonitor integration through web-service APIs. The interfaces are built-in optimization toolboxes or modules to both load and process solutions of optimization problems. APMonitor is an object-oriented modeling language and optimization suite that relies on programming languages to load, run, and retrieve solutions. APMonitor models and data are compiled at run-time and translated into objects that are solved by an optimization engine such as APOPT (MINLP) or IPOPT (NLP). The optimization engine is not specified by APMonitor, allowing several different optimization engines to be switched out. The simulation or optimization mode is also configurable to reconfigure the model for dynamic simulation, nonlinear model predictive control, moving horizon estimation or general problems in mathematical optimization.&lt;br /&gt;
&lt;br /&gt;
==High Index DAEs==&lt;br /&gt;
&lt;br /&gt;
The highest order of a derivative that is necessary to return a DAE to ODE form is called the &#039;&#039;differentiation index&#039;&#039;. A standard way for dealing with high-index DAEs is to differentiate the equations to put them in index-1 DAE or ODE form with Pantelides algorithm. However, this approach can cause a number of undesirable numerical issues such as instability.  While the syntax is similar to other modeling languages, APMonitor solves DAEs of any index without rearrangement or differentiation.&lt;br /&gt;
&lt;br /&gt;
== Availibility ==&lt;br /&gt;
The APMonitor Python package can be installed with &#039;&#039;&#039;pip install APMonitor&#039;&#039;&#039; or from the following Python code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Install APMonitor&lt;br /&gt;
import pip&lt;br /&gt;
pip.main([&#039;install&#039;,&#039;APMonitor&#039;])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar interfaces are available for MATLAB and Julia with minor differences in APMonitor syntax between the languages. APMonitor is freely available as a web service or a locally installed web server for Linux or Windows.&lt;br /&gt;
&lt;br /&gt;
== Supported Problem Classes ==&lt;br /&gt;
&lt;br /&gt;
* NLP, LP, QP, MILP, MINLP&lt;br /&gt;
* Optimal Control Problems with ODEs or DAEs&lt;br /&gt;
* Minimum Time Problems&lt;br /&gt;
* Optimal Design&lt;br /&gt;
* Model Calibration&lt;br /&gt;
* Parameter Estimation&lt;br /&gt;
&lt;br /&gt;
== Algorithms ==&lt;br /&gt;
&lt;br /&gt;
Dynamic optimization uses direct collocation solved with large-scale nonlinear programming solvers. APMonitor provides exact first and second derivatives of continuous functions to the solvers through automatic differentiation and in sparse matrix form.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* [https://apmonitor.com APMonitor Optimization Suite]&lt;br /&gt;
* [https://apmonitor.com/do Dynamic Optimization Course]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/APMonitor APMonitor (Wikipedia)]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., APMonitor for APMonitor model) here --&amp;gt;&lt;br /&gt;
[[Category: Implementation]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Category:APMonitor&amp;diff=2150</id>
		<title>Category:APMonitor</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Category:APMonitor&amp;diff=2150"/>
		<updated>2017-11-20T21:40:26Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: Creation of APMonitor page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Advanced process monitor (APMonitor)&#039;&#039;&#039;, is a modeling language for mixed integer and differential algebraic equations. It is a free web-service or locally installed service for solving this class of problems.  APMonitor is suited for large-scale problems and allows solutions of linear programming, integer programming, nonlinear programming, nonlinear mixed integer programming, dynamic simulation, moving horizon estimation, and nonlinear model predictive control. APMonitor does not solve the problems directly, but calls nonlinear programming solvers such as APOPT, BPOPT, IPOPT, MINOS, and SNOPT.&lt;br /&gt;
&lt;br /&gt;
==Programming Language Integration==&lt;br /&gt;
&lt;br /&gt;
Julia, MATLAB, and Python are mathematical programming languages that have APMonitor integration through web-service APIs. The interfaces are built-in optimization toolboxes or modules to both load and process solutions of optimization problems. APMonitor is an object-oriented modeling language and optimization suite that relies on programming languages to load, run, and retrieve solutions. APMonitor models and data are compiled at run-time and translated into objects that are solved by an optimization engine such as APOPT (MINLP) or IPOPT (NLP). The optimization engine is not specified by APMonitor, allowing several different optimization engines to be switched out. The simulation or optimization mode is also configurable to reconfigure the model for dynamic simulation, nonlinear model predictive control, moving horizon estimation or general problems in mathematical optimization.&lt;br /&gt;
&lt;br /&gt;
==High Index DAEs==&lt;br /&gt;
&lt;br /&gt;
The highest order of a derivative that is necessary to return a DAE to ODE form is called the &#039;&#039;differentiation index&#039;&#039;. A standard way for dealing with high-index DAEs is to differentiate the equations to put them in index-1 DAE or ODE form with Pantelides algorithm. However, this approach can cause a number of undesirable numerical issues such as instability.  While the syntax is similar to other modeling languages, APMonitor solves DAEs of any index without rearrangement or differentiation.&lt;br /&gt;
&lt;br /&gt;
== Availibility ==&lt;br /&gt;
The APMonitor Python package can be installed with &#039;&#039;&#039;pip install APMonitor&#039;&#039;&#039; or from the following Python code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Install APMonitor&lt;br /&gt;
import pip&lt;br /&gt;
pip.main([&#039;install&#039;,&#039;APMonitor&#039;])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar interfaces are available for MATLAB and Julia with minor differences in syntax between the languages. APMonitor is freely available as a web service or a locally installed web server for Linux or Windows.&lt;br /&gt;
&lt;br /&gt;
== Supported Problem Classes ==&lt;br /&gt;
&lt;br /&gt;
* NLP, LP, QP, MILP, MINLP&lt;br /&gt;
* Optimal Control Problems with ODEs or DAEs&lt;br /&gt;
* Minimum Time Problems&lt;br /&gt;
* Optimal Design&lt;br /&gt;
* Model Calibration&lt;br /&gt;
* Parameter Estimation&lt;br /&gt;
&lt;br /&gt;
== Algorithms ==&lt;br /&gt;
&lt;br /&gt;
Dynamic optimization uses direct collocation solved with large-scale nonlinear programming solvers. APMonitor provides exact first and second derivatives of continuous functions to the solvers through automatic differentiation and in sparse matrix form.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* [https://apmonitor.com APMonitor Optimization Suite]&lt;br /&gt;
* [https://apmonitor.com/do Dynamic Optimization Course]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/APMonitor APMonitor (Wikipedia)]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, or presence of implementation details (e.g., APMonitor for APMonitor model) here --&amp;gt;&lt;br /&gt;
[[Category: Implementation]]&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem&amp;diff=2149</id>
		<title>Lotka Volterra fishing problem</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Lotka_Volterra_fishing_problem&amp;diff=2149"/>
		<updated>2017-11-20T20:39:13Z</updated>

		<summary type="html">&lt;p&gt;JohnHedengren: /* Source Code */ Added APMonitor, alphebetized list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Dimensions&lt;br /&gt;
|nd        = 1&lt;br /&gt;
|nx        = 3&lt;br /&gt;
|nw        = 1&lt;br /&gt;
|nre       = 3&lt;br /&gt;
}}&amp;lt;!-- Do not insert line break here or Dimensions Box moves up in the layout...&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;The &#039;&#039;&#039;Lotka Volterra fishing problem&#039;&#039;&#039; looks for an optimal fishing strategy to be performed on a fixed time horizon to bring the biomasses of both predator as prey fish to a prescribed steady state. The problem was set up as a small-scale benchmark problem. &lt;br /&gt;
The well known [http://en.wikipedia.org/wiki/Lotka_volterra Lotka Volterra equations] for a predator-prey system have been augmented by an additional linear term, relating to fishing by man. The control can be regarded both in a relaxed, as in a discrete manner, corresponding to a part of the fleet, or the full fishing fleet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The mathematical equations form a small-scale [[:Category:ODE model|ODE model]]. The interior point equality conditions fix the initial values of the differential states.&lt;br /&gt;
&lt;br /&gt;
The optimal integer control functions shows [[:Category:Chattering|chattering]] behavior, making the Lotka Volterra fishing problem an ideal candidate for benchmarking of algorithms.&lt;br /&gt;
&lt;br /&gt;
== Mathematical formulation ==&lt;br /&gt;
&lt;br /&gt;
The mixed-integer optimal control problem is given by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{llclr}&lt;br /&gt;
 \displaystyle \min_{x, w} &amp;amp; x_2(t_f)   \\[1.5ex]&lt;br /&gt;
 \mbox{s.t.} &lt;br /&gt;
 &amp;amp; \dot{x}_0 &amp;amp; = &amp;amp;  x_0 - x_0 x_1 - \; c_0 x_0 \; w, \\&lt;br /&gt;
 &amp;amp; \dot{x}_1 &amp;amp; = &amp;amp; - x_1 + x_0 x_1 - \; c_1 x_1 \; w,  \\&lt;br /&gt;
 &amp;amp; \dot{x}_2 &amp;amp; = &amp;amp; (x_0 - 1)^2 + (x_1 - 1)^2,  \\[1.5ex]&lt;br /&gt;
 &amp;amp; x(0) &amp;amp;=&amp;amp; (0.5, 0.7, 0)^T, \\&lt;br /&gt;
 &amp;amp; w(t) &amp;amp;\in&amp;amp;  \{0, 1\}.&lt;br /&gt;
\end{array} &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the differential states &amp;lt;math&amp;gt;(x_0, x_1)&amp;lt;/math&amp;gt; describe the biomasses of prey and predator, respectively. The third differential state is used here to transform the objective, an integrated deviation, into the Mayer formulation &amp;lt;math&amp;gt;\min \; x_2(t_f)&amp;lt;/math&amp;gt;. The decision, whether the fishing fleet is actually fishing at time &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is denoted by &amp;lt;math&amp;gt;w(t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
These fixed values are used within the model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{rcl}&lt;br /&gt;
[t_0, t_f] &amp;amp;=&amp;amp; [0, 12],\\&lt;br /&gt;
(c_0, c_1) &amp;amp;=&amp;amp; (0.4, 0.2).&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference Solutions ==&lt;br /&gt;
&lt;br /&gt;
If the problem is relaxed, i.e., we demand that &amp;lt;math&amp;gt;w(t)&amp;lt;/math&amp;gt; be in the continuous interval &amp;lt;math&amp;gt;[0, 1]&amp;lt;/math&amp;gt; instead of the binary choice &amp;lt;math&amp;gt;\{0,1\}&amp;lt;/math&amp;gt;, the optimal solution can be determined by means of [http://en.wikipedia.org/wiki/Pontryagin%27s_minimum_principle Pontryagins maximum principle]. The optimal solution contains a singular arc, as can be seen in the plot of the optimal control. The two differential states and corresponding adjoint variables in the indirect approach are also displayed. A different approach to solving the relaxed problem is by using a direct method such as collocation or Bock&#039;s direct multiple shooting method. Optimal solutions for different control discretizations are also plotted in the leftmost figure.&lt;br /&gt;
&lt;br /&gt;
The optimal objective value of this relaxed problem is &amp;lt;math&amp;gt;x_2(t_f) = 1.34408&amp;lt;/math&amp;gt;. As follows from MIOC theory &amp;lt;bib id=&amp;quot;Sager2011d&amp;quot; /&amp;gt; this is the best lower bound on the optimal value of the original problem with the integer restriction on the control function. In other words, this objective value can be approximated arbitrarily close, if the control only switches often enough between 0 and 1. As no optimal solution exists, two suboptimal ones are shown, one with only two switches and an objective function value of &amp;lt;math&amp;gt;x_2(t_f) = 1.38276&amp;lt;/math&amp;gt;, and one with 56 switches and &amp;lt;math&amp;gt;x_2(t_f) = 1.34416&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Reference solution plots&amp;quot; widths=&amp;quot;180px&amp;quot; heights=&amp;quot;140px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
 Image:lotkaRelaxedControls.png| Optimal relaxed control determined by an indirect approach and by a direct approach on different control discretization grids.&lt;br /&gt;
 Image:lotkaindirektStates.png| Differential states and corresponding adjoint variables in the indirect approach.&lt;br /&gt;
 Image:lotka2Switches.png| Control and differential states with only two switches.&lt;br /&gt;
 Image:lotka56Switches.png| Control and differential states with 56 switches.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
Model descriptions are available in&lt;br /&gt;
&lt;br /&gt;
* [[:Category:ACADO | ACADO code]] at [[Lotka Volterra fishing problem (ACADO)]]&lt;br /&gt;
* [[:Category:AMPL | AMPL code]] at [[Lotka Volterra fishing problem (AMPL)]]&lt;br /&gt;
* [[:Category:APMonitor | APMonitor code]] at [[Lotka Volterra fishing problem (APMonitor)]]&lt;br /&gt;
* [[:Category:Bocop | Bocop code]] at [[Lotka Volterra fishing problem (Bocop)]]&lt;br /&gt;
* [[:Category:Casadi | Casadi code]] at [[Lotka Volterra fishing problem (Casadi)]]&lt;br /&gt;
* [[:Category:JModelica | JModelica code]] at [[Lotka Volterra fishing problem (JModelica)]]&lt;br /&gt;
* [[:Category:Julia/JuMP | JuMP code]] at [[Lotka Volterra fishing problem (JuMP)]]&lt;br /&gt;
* [[:Category:Muscod | Muscod code]] at [[Lotka Volterra fishing problem (Muscod)]]&lt;br /&gt;
* [[:Category:switch | switch code]] at [[Lotka Volterra fishing problem (switch)]]&lt;br /&gt;
* [[:Category:TomDyn/PROPT | PROPT code]] at [[Lotka Volterra fishing problem (TomDyn/PROPT)]]&lt;br /&gt;
&lt;br /&gt;
== Variants ==&lt;br /&gt;
&lt;br /&gt;
There are several alternative formulations and variants of the above problem, in particular&lt;br /&gt;
&lt;br /&gt;
* a prescribed time grid for the control function &amp;lt;bib id=&amp;quot;Sager2006&amp;quot; /&amp;gt;, see also [[Lotka Volterra fishing problem (AMPL)]],&lt;br /&gt;
* a time-optimal formulation to get into a steady-state &amp;lt;bib id=&amp;quot;Sager2005&amp;quot; /&amp;gt;,&lt;br /&gt;
* the usage of a different target steady-state, as the one corresponding to &amp;lt;math&amp;gt; w(t) = 1&amp;lt;/math&amp;gt; which is &amp;lt;math&amp;gt;(1 + c_1, 1 - c_0)&amp;lt;/math&amp;gt;,&lt;br /&gt;
* different fishing control functions for the two species,&lt;br /&gt;
* different parameters and start values.&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and Further Reading ==&lt;br /&gt;
The Lotka Volterra fishing problem was introduced by Sebastian Sager in a proceedings paper &amp;lt;bib id=&amp;quot;Sager2006&amp;quot; /&amp;gt; and revisited in his PhD thesis &amp;lt;bib id=&amp;quot;Sager2005&amp;quot; /&amp;gt;. These are also the references to look for more details.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;biblist /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--List of all categories this page is part of. List characterization of solution behavior, model properties, ore presence of implementation details (e.g., AMPL for AMPL model) here --&amp;gt;&lt;br /&gt;
[[Category:MIOCP]]&lt;br /&gt;
[[Category:ODE model]]&lt;br /&gt;
[[Category:Tracking objective]]&lt;br /&gt;
[[Category:Chattering]]&lt;br /&gt;
[[Category:Sensitivity-seeking arcs]]&lt;br /&gt;
[[Category:Population dynamics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--Testing Graphviz&lt;br /&gt;
&amp;lt;graphviz border=&#039;frame&#039; format=&#039;svg&#039;&amp;gt;&lt;br /&gt;
digraph G {Hello-&amp;gt;World!}&lt;br /&gt;
&amp;lt;/graphviz&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
</feed>