# [Ipopt] Maximun number of iterations exceeded problem.

Pablo Perez pabloperez555 at hotmail.com
Thu Sep 29 12:03:24 EDT 2016

```Dear all,

I am having a problem using Ipopt: After having modelling a simple dynamic system based on newton rules and discretize it, I am getting a maximun number of iterations exceeded problem. I am not sure if the problem is due to the discretization method (a leapfrog integration method), because using a simple Euler method (look for "##" in the code below) the system convergency is got in a few iterations.

Does someone understand where the problem is? It is worth the extra precission of having into acount the aceleration for calculating the space or the euler method would be good enought for prototyping?

Please, I copy the AMPL code I am using. Take into account that the low number of steps is due to the restricted version of AMPL. Anyway, using a bigger number in Neos server does not solve the problem.

I am not sure if this mailling list is for this kind of questions. If it is not I would be sorry, please, could someone tell me about any forum of Ipopt in particular and optimal control in general?

Pablo

# We have a train hat is at position x=0 at time t=0, and we can
# control the acceleration, a, (which includes braking as well).
#
# N:  Number of iterations.
# L:  Path length.
# T:  Travel time initial guess.
# aU: Upper bound on acceleration.
# aL: Lower bound on acceleration.
# jU: Upper bound on jerk.
# jL: Lower bound on jerk.
# Ra: Drag coeficient (independent).
# Rb: Drag coeficient (v dependant).
# Rc: Drag coeficient (v^2 dependant).
#
# The overall optimal control problem is therefore:
#
# min  tf
# s.t. dx/dt(t) = v(t)                               for t in [0,tf]
#      dv/dt(t) = a(t) - Ra - Rb*v(t) - Rc*v(t)^2    for t in [0,tf]
#      aL   <= dv/dt(t)   <=  aU                     for t in [0,tf]
#      jL   <= d2v/dt2(t) <=  jU                     for t in [0,tf]
#      v(t) <= Vmax(x)                               for t in [0,tf]
#
#      x(0)  = 0; v(0)  = 0
#      x(tf) = L; v(tf) = 0
#
# Leapfrog discretization.
# With this, we can state the overall optimization problem below:

option solver ipopt;

# Number of discretization intervals
param N := 1000;

# Final position
param L := 1000;

# Final time
param T := 50;

# Upper and lower bound on acceleration
param aU := 1.15;
param aL := -1.2;

# Upper and lower bound on jerk
param jU := 0.8;
param jL := -0.8;

# Drag factors
param Ra := 5.71428/322;
param Rb := 0.11688/322;
param Rc := 0.00842/322;

# Size of discretization intervals
var tf >= 0 := T;

var h = tf/N;

# Velocity
var x{i in 0..N} >= 0, := i*(L/N);

# Time
var v{i in 0..N} >= 0, := L/T;

# Acceleration
var a{i in 0..N} := 0;

# Objective function
minimize time:
tf;

subject to Amax {i in 0..N}:
a[i] <= if (v[i] <= 11) then (343/322) else (343/322)*(11/v[i]);
subject to Dmax {i in 0..N}:
a[i] >= if (v[i] <= 19) then -(327/322) else -(327/322)*(19/v[i]);

# Differential equation for velocity
subject to dx {i in 0..N-1}:
(x[i+1]-x[i])/h = v[i] + 0.5*(a[i] - Ra - Rb*v[i] - Rc*v[i]^2)*h;
##(x[i+1]-x[i])/h = v[i];

# Differential equation for time
subject to dv {i in 0..N-1}:
(v[i+1]-v[i])/h = a[i] - Ra - Rb*v[i] - Rc*v[i]^2;

# Confort constraints
subject to acel {i in 0..N-1}:
aL <= (v[i+1]-v[i])/h <= aU;

subject to jerk {i in 1..N-1}:
jL <= (v[i+1]-2*v[i]+v[i-1])/h^2 <= jU;

# Boundary conditions for position
subject to x0:
x[0] = 0;
subject to xf:
x[N] = L;

# Boundary conditions for velocity
subject to v0:
v[0] = 0;
subject to vf:
v[N] = 0;

# Speed limit
subject to limit {i in 1..N-1}:
v[i] <= if (x[i] <= 250) then 45/3.6 else if (x[i] <= 700) then 70/3.6 else 30/3.6;

# Solve the optimization problem
solve;

# write the data into a file for gnuplot
for {i in 0..N}
printf : "%16.4e %16.4e %16.4e %16.4e \n", i*h, x[i], 3.6*v[i], 10*a[i] > ..\gnuplot.dat;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20160929/8851d1bc/attachment.html>
```