<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mintoc.de/index.php?action=history&amp;feed=atom&amp;title=Time_optimal_car_problem_%28GEKKO%29</id>
	<title>Time optimal car problem (GEKKO) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mintoc.de/index.php?action=history&amp;feed=atom&amp;title=Time_optimal_car_problem_%28GEKKO%29"/>
	<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;action=history"/>
	<updated>2026-06-09T09:26:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2343&amp;oldid=prev</id>
		<title>JohnHedengren: Update with latest Gekko v1.0.5</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2343&amp;oldid=prev"/>
		<updated>2022-08-28T13:23:10Z</updated>

		<summary type="html">&lt;p&gt;Update with latest Gekko v1.0.5&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:23, 28 August 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot;&gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Z1 = m.Var(value=0, ub=330, lb=0)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Z1 = m.Var(value=0, ub=330, lb=0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Z2 = m.Var(value=0, ub=33, lb=0)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Z2 = m.Var(value=0, ub=33, lb=0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;m.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;fix&lt;/del&gt;(Z2&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, len(m.time)-1&lt;/del&gt;, 0)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;m.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;fix_final&lt;/ins&gt;(Z2, 0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;m.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;fix&lt;/del&gt;(Z1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, len(m.time)-1&lt;/del&gt;, 300)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;m.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;fix_final&lt;/ins&gt;(Z1, 300)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# set up the value we modify over the horizon&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# set up the value we modify over the horizon&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2267&amp;oldid=prev</id>
		<title>JohnHedengren at 19:42, 13 March 2019</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2267&amp;oldid=prev"/>
		<updated>2019-03-13T19:42:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:42, 13 March 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l60&quot;&gt;Line 60:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 60:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Results with APOPT (MINLP) ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Results with APOPT (MINLP) ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&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;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&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;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. Thanks to [https://www.linkedin.com/in/tjasperson/ Tanner Jasperson] for providing a solution&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:Time_optimal_car_GEKKO.png]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:Time_optimal_car_GEKKO.png]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Gekko]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Gekko]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JohnHedengren</name></author>
	</entry>
	<entry>
		<id>https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2265&amp;oldid=prev</id>
		<title>JohnHedengren: Create results page with Python GEKKO</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Time_optimal_car_problem_(GEKKO)&amp;diff=2265&amp;oldid=prev"/>
		<updated>2019-03-13T19:36:27Z</updated>

		<summary type="html">&lt;p&gt;Create results page with Python GEKKO&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&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 &amp;#039;&amp;#039;&amp;#039;pip install gekko&amp;#039;&amp;#039;&amp;#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&amp;#039;$Z_1$&amp;#039;)&lt;br /&gt;
plt.plot(np.linspace(0,1,100)*tf.NEWVAL, Z2, label=r&amp;#039;$Z_2$&amp;#039;)&lt;br /&gt;
plt.ylabel(&amp;#039;Z&amp;#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&amp;#039;$u$&amp;#039;)&lt;br /&gt;
plt.ylabel(&amp;#039;u&amp;#039;)&lt;br /&gt;
plt.xlabel(&amp;#039;Time&amp;#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>
</feed>