<?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=Electric_car_problem_%28AMPL%29</id>
	<title>Electric car problem (AMPL) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mintoc.de/index.php?action=history&amp;feed=atom&amp;title=Electric_car_problem_%28AMPL%29"/>
	<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Electric_car_problem_(AMPL)&amp;action=history"/>
	<updated>2026-06-09T09:15:40Z</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=Electric_car_problem_(AMPL)&amp;diff=2079&amp;oldid=prev</id>
		<title>FelixMueller: Created page with &quot;This page contains a discretized version of the MIOCP Electric Car in [http://www.ampl.org AMPL] format. You should be aware of the comments regarding discretization made...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mintoc.de/index.php?title=Electric_car_problem_(AMPL)&amp;diff=2079&amp;oldid=prev"/>
		<updated>2016-07-10T19:00:49Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This page contains a discretized version of the MIOCP &lt;a href=&quot;/index.php?title=Electric_Car&quot; title=&quot;Electric Car&quot;&gt;Electric Car&lt;/a&gt; in [http://www.ampl.org AMPL] format. You should be aware of the comments regarding discretization made...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This page contains a discretized version of the MIOCP [[Electric Car]] in [http://www.ampl.org AMPL] format. You should be aware of the comments regarding discretization made on the [[:Category:AMPL|AMPL overview]] page. Note that you will need to include two generic [[support AMPL files]], ampl_general.mod and ampl_general.dat.&lt;br /&gt;
&lt;br /&gt;
=== AMPL ===&lt;br /&gt;
&lt;br /&gt;
The model in AMPL code for a fixed control discretization grid with a collocation method. We need a model file ampl_car.mod,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;AMPL&amp;quot;&amp;gt;&lt;br /&gt;
# ----------------------------------------------------&lt;br /&gt;
# Electric car problem with collocation (implicit Euler)&lt;br /&gt;
# (c) Sebastian Sager, Frederic Messine 2013&lt;br /&gt;
# ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
# Parameters&lt;br /&gt;
param mysum;&lt;br /&gt;
param mycounter;&lt;br /&gt;
param myeta;&lt;br /&gt;
&lt;br /&gt;
param R_bot;&lt;br /&gt;
param V_alim;&lt;br /&gt;
param R_m;&lt;br /&gt;
param K_m;&lt;br /&gt;
param L_m;&lt;br /&gt;
param r;&lt;br /&gt;
param K_r;&lt;br /&gt;
param M;&lt;br /&gt;
param g;&lt;br /&gt;
param K_f;&lt;br /&gt;
param rho;&lt;br /&gt;
param S;&lt;br /&gt;
param C_x;&lt;br /&gt;
param T    &amp;gt; 0;&lt;br /&gt;
param nt   &amp;gt; 0;&lt;br /&gt;
param ntperu &amp;gt; 0;&lt;br /&gt;
param dt := T / (nt-1);&lt;br /&gt;
&lt;br /&gt;
set I:= 0..nt;&lt;br /&gt;
set U:= 0..nt/ntperu-1;&lt;br /&gt;
set UI := 1..ntperu-1;&lt;br /&gt;
&lt;br /&gt;
# Variables&lt;br /&gt;
var x {I, 0..3};&lt;br /&gt;
var w {I} &amp;gt;= -1, &amp;lt;= 1;&lt;br /&gt;
&lt;br /&gt;
minimize Mayer: x[nt,3];&lt;br /&gt;
&lt;br /&gt;
subject to ODE_current {i in I diff {0}}:&lt;br /&gt;
   x[i,0] = x[i-1,0] + dt * ( (w[i-1]*V_alim - R_m*x[i,0] - K_m*x[i,1]) / L_m ) ;&lt;br /&gt;
&lt;br /&gt;
subject to ODE_angularvelocity {i in I diff {0}}:&lt;br /&gt;
   x[i,1] = x[i-1,1] + dt * ( K_r*K_r/(M*r*r) * ( K_m * x[i,0] - r/K_r * ( M*g*K_f + 0.5*rho*S*C_x * x[i,1]*x[i,1]*r*r / (K_r*K_r) ) ) ) ;&lt;br /&gt;
&lt;br /&gt;
subject to ODE_position {i in I diff {0}}:&lt;br /&gt;
   x[i,2] = x[i-1,2] + dt * ( x[i,1]*r / K_r ) ;&lt;br /&gt;
&lt;br /&gt;
subject to ODE_energyobjective {i in I diff {0}}:&lt;br /&gt;
#   x[i,3] = x[i-1,3] + dt * ( w[i-1] * x[i,0] * V_alim + R_bot * w[i-1]*w[i-1]*x[i,0]*x[i,0] ) ;&lt;br /&gt;
   x[i,3] = x[i-1,3] + dt * ( w[i-1] * x[i,0] * V_alim + R_bot * x[i,0]*x[i,0] ) ;&lt;br /&gt;
&lt;br /&gt;
subject to initialvalues {j in {0..3}}:&lt;br /&gt;
   x[0,j] = 0;&lt;br /&gt;
&lt;br /&gt;
subject to boundedcurrentU {i in I}:&lt;br /&gt;
   x[i,0] &amp;lt;= 150;&lt;br /&gt;
&lt;br /&gt;
subject to boundedcurrentL {i in I}:&lt;br /&gt;
   x[i,0] &amp;gt;= -150;&lt;br /&gt;
&lt;br /&gt;
subject to endvalues:&lt;br /&gt;
   x[nt,2] = 100;&lt;br /&gt;
&lt;br /&gt;
subject to couple_controls {j in U, i in UI}:&lt;br /&gt;
   w[j*ntperu+i] = w[j*ntperu];&lt;br /&gt;
&lt;br /&gt;
subject to couple_last_control:&lt;br /&gt;
   w[nt] = w[nt-1];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
a data file ampl_car.dat,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;AMPL&amp;quot;&amp;gt;&lt;br /&gt;
# ----------------------------------------------------&lt;br /&gt;
# Electric car problem with collocation&lt;br /&gt;
# (c) Sebastian Sager, Frederic Messine 2013&lt;br /&gt;
# ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
# Algorithmic parameters&lt;br /&gt;
param nt := 1000;&lt;br /&gt;
param ntperu := 1;&lt;br /&gt;
&lt;br /&gt;
# Problem parameters&lt;br /&gt;
param R_bot := 0.05;&lt;br /&gt;
param V_alim := 150;&lt;br /&gt;
param R_m := 0.03;&lt;br /&gt;
param K_m := 0.27;&lt;br /&gt;
param L_m := 0.05;&lt;br /&gt;
param r := 0.33;&lt;br /&gt;
param K_r := 10;&lt;br /&gt;
param M := 250;&lt;br /&gt;
param g := 9.81;&lt;br /&gt;
param K_f := 0.03;&lt;br /&gt;
param rho := 1.293;&lt;br /&gt;
param S := 2;&lt;br /&gt;
param C_x := 0.4;&lt;br /&gt;
param T := 10.0;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and a running script ampl_car.run,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;AMPL&amp;quot;&amp;gt;&lt;br /&gt;
# ----------------------------------------------------&lt;br /&gt;
# Electric car problem with collocation&lt;br /&gt;
# (c) Sebastian Sager, Frederic Messine 2013&lt;br /&gt;
# ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
model ampl_car.mod;&lt;br /&gt;
data ampl_car.dat;&lt;br /&gt;
&lt;br /&gt;
options solver ipopt;&lt;br /&gt;
solve;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:AMPL]]&lt;/div&gt;</summary>
		<author><name>FelixMueller</name></author>
	</entry>
</feed>