Commit 8f02460f by Christian Kirches

TACO initial commit

0 parents
Showing with 4770 additions and 0 deletions
# Solving ODE/DAE optimal control problems with AMPL and MUSCOD-II
# Christian Kirches, Sven Leyffer
# July 2011
option presolve 0;
suffix scale IN >= 0;
suffix interp_to IN;
suffix type symbolic IN;
suffix slope_min IN;
suffix slope_max IN;
option type_table '\
1 u0 piecewise constant control\
2 u1 piecewise linear control\
3 u1c piecewise linear continuous control\
4 u3 piecewise cubic control\
5 u3c piecewise cubic continuous control\
6 dae DAE algebraic state variable\
7 Lagrange Force a least-squares objective to be treated as a Lagrange type one\
8 dpc Treat ODE initial value constraint as decoupled point constraint\
';
function diff;
function eval;
function integral;
#
# Batch distillation model
# See Diehl'2006
#
include OptimalControl.mod;
# time and free end-time
var t;
var tf := 2.5, >= 0.5, <= 10.0;
# constant parameters
param Pur := 0.99; # percent
param V := 100.0; # mol/h
param m := 0.1; # mol
param mC := 0.1; # mol
# control
var R := 8.0, >= 0.0, <= 15.0;
let R.type := "u1";
let R.scale := 0.1;
# differential states
param NDIS := 5; # PDE discretization points
var M0;
var x{0..NDIS+1};
var MD;
var xD;
var alpha;
# algebraic expressions eliminated by AMPL's presolve
var L = R/(1+R)*V;
var y{i in 0..NDIS} = (1+alpha)*x[i]/(alpha+x[i]);
var dot0 = ( L*x[1] - V*y[0] + (V-L)*x[0] ) / M0;
var dot{i in 1..NDIS} = ( L*x[i+1] - V*y[i] + V*y[i-1] - L*x[i] )/m;
var dotNDISp1 = V/mC * (-x[NDIS+1] + y[NDIS]);
# objective function
minimize Compromise:
eval (t - MD, tf);
# terminal constraint
subject to Purity_Constraint:
eval(xD, tf) >= Pur;
# ODE system
subject to ODE_M0:
diff(M0, t) = -V+L;
subject to ODE_x_0:
diff(x[0], t) = dot0;
subject to ODE_x{i in 1..NDIS}:
diff(x[i], t) = dot[i];
subject to ODE_x_NDISp1:
diff(x[NDIS+1], t) = dotNDISp1;
subject to ODE_MD:
diff(MD, t) = V-L;
subject to ODE_xD:
diff(xD, t) = (V-L) * (x[NDIS] - xD)/MD;
subject to ODE_alpha:
diff(alpha, t) = 0.0;
# Initial value constraints
subject to IVC_M0:
eval(M0, 0) = 100.0;
subject to IVC_x_0:
eval(x[0], 0) = 0.5;
subject to IVC_x{i in 1..NDIS+1}:
eval(x[i], 0) = 1;
subject to IVC_MD:
eval(MD, 0) = 0.1;
subject to IVC_xD:
eval(xD, 0) = 1;
subject to IVC_alpha:
eval(alpha, 0) = 0.2;
option solver muscod;
option muscod_options "solve=solve_tbox deriv=sparse";
option muscod_auxfiles "cr";
problem batchdist: Compromise,
Purity_Constraint, ODE_M0, ODE_x_0, ODE_x, ODE_x_NDISp1, ODE_MD, ODE_xD, ODE_alpha,
IVC_M0, IVC_x_0, IVC_x, IVC_MD, IVC_xD, IVC_alpha,
R, M0, x, MD, xD, alpha, t, tf;
solve batchdist;
#
# The classical brachistochrone problem
#
# see e.g. Betts'93
#
# Christian Kirches
# July 2011
#include OptimalControl.mod;
option presolve 0;
suffix scale IN >= 0;
suffix interp_to IN;
suffix type symbolic IN;
suffix slope_min IN;
suffix slope_max IN;
option type_table '\
1 u0 piecewise constant control\
2 u1 piecewise linear control\
3 u1c piecewise linear continuous control\
4 u3 piecewise cubic control\
5 u3c piecewise cubic continuous control\
6 dae DAE algebraic state variable\
7 Lagrange Force a least-squares objective to be treated as a Lagrange type one\
8 dpc Treat ODE initial value constraint as decoupled point constraint\
';
function diff;
function eval;
function grid;
function integral;
var t;
var tf := 1.0, >= 0.1, <= 1.0;
let tf.scale := 0.5; # improves convergence
var x := 0, >= 0, <= 1;
var y := 0, >= 0, <= 1;
var v := 0, >= 0, <= 8;
var a := 0.5, >= 0, <= 1.57079327;
let a.type := "u1";
let a.slope_min := -10.0;
let a.slope_max := +10.0;
param gravity := 32.174;
minimize
EndTime: eval (t,tf);
let EndTime.scale := 0.1;
subject to
ODE_x: diff(x,t) = v*cos(a);
ODE_y: diff(y,t) = v*sin(a);
ODE_v: diff(v,t) = gravity*sin(a);
IVC_x: eval(x,0) = 0;
IVC_y: eval(y,0) = 0;
IVC_v: eval(v,0) = 0;
TC_x: eval(x,tf) = 1.0;
# treating IVCs as boundary constraints improves convergence
let IVC_x.type := "dpc";
let IVC_y.type := "dpc";
let IVC_v.type := "dpc";
option solver muscod;
option muscod_options "nshoot=20 hess=hess_update stiff=0 atol=1e-6 itmax=20";
problem brac: EndTime, ODE_x, ODE_y, ODE_v, IVC_x, IVC_y, IVC_v, TC_x, t, tf, x, y, v, a;
option muscod_auxfiles "cr";
solve;
# Set the design parameters
param bc :=
1 1
2 0;
# Catalyst Mixing Problem
# Collocaction formulation
# COPS 3.0 - November 2002
# COPS 3.1 - March 2004
include OptimalControl.mod;
param ne := 2; # number of differential equations
var tf := 1; # Final time
var t;
param bc {1..ne}; # Boundary conditions for x
var u;
let u.type := "u1";
var v {1..ne};
minimize objective: eval (-1 + v[1] + v[2], tf);
let objective.scale := 0.01;
subject to u_bounds: 0.0 <= u <= 1.0;
subject to de1:
diff(v[1],t) = u*(10*v[2] - v[1]);
subject to de2:
diff(v[2],t) = u*(v[1] - 10*v[2]) - (1 - u)*v[2];
subject to b_eqn {s in 1..ne}: eval(v[s],0) = bc[s];
option solver muscod;
option muscod_options "deriv=dense stiff=0 hess=hess_limitedmemoryupdate nshoot=100 atol=1e-6 levmar=1e-8";
problem catmix: objective, u_bounds, de1, de2, b_eqn, t, tf, u, v;
fix tf;
solve;
#
# COPS problem 7 (Fluid Flow in a Channel)
# Christian Kirches
# July/August 2011
#
include OptimalControl.mod
var t;
var u{1..4} := 0;
param R := 10000;
subject to
d1: diff(u[1],t) = u[2];
d2: diff(u[2],t) = u[3];
d3: diff(u[3],t) = u[4];
d4: diff(u[4],t) = R*(u[2]*u[3] - u[1]*u[4]);
u1s: eval(u[1],0) = 0;
u2s: eval(u[2],0) = 0;
u1e: eval(u[1],1) = 1;
u2e: eval(u[2],1) = 0;
let u[3].scale := 2*sqrt(R);
let u[4].scale := 2*R;
option solver muscod;
option muscod_options "stiff=1 atol=1e-10";
option muscod_auxfiles "acfrsu";
problem fluidflow: d1, d2, d3, d4, u1s, u2s, u1e, u2e, u, t;
solve fluidflow;
param nm := 21;
# Time measurements
param tau :=
1 0
2 0.025
3 0.05
4 0.075
5 0.10
6 0.125
7 0.150
8 0.175
9 0.20
10 0.225
11 0.250
12 0.30
13 0.35
14 0.40
15 0.45
16 0.50
17 0.55
18 0.65
19 0.75
20 0.85
21 0.95;
# Concentrations
param z: 1 2 :=
1 1.0000 0
2 0.8105 0.2000
3 0.6208 0.2886
4 0.5258 0.3010
5 0.4345 0.3215
6 0.3903 0.3123
7 0.3342 0.2716
8 0.3034 0.2551
9 0.2735 0.2258
10 0.2405 0.1959
11 0.2283 0.1789
12 0.2071 0.1457
13 0.1669 0.1198
14 0.1530 0.0909
15 0.1339 0.0719
16 0.1265 0.0561
17 0.1200 0.0460
18 0.0990 0.0280
19 0.0870 0.0190
20 0.0770 0.0140
21 0.0690 0.0100;
param bc := 1 1 2 0;
# Catalytic Cracking of Gas Oil Problem
# Collocation formulation
# Michael Merritt - Summer 2000
# COPS 2.0 - September 2000
# COPS 3.0 - November 2002
# COPS 3.1 - March 2004
#
# AMPL/OCP Reformulation
# Christian Kirches, July/August 2011
#
include OptimalControl.mod;
var t;
param ne := 2; # number of differential equations
param np := 3; # number of ODE parameters
param nm > 0, integer; # number of measurements
param bc {1..ne}; # ODE initial conditions
param tau {1..nm}; # times at which observations made
param z {1..nm, 1..ne}; # observations
var theta {1..np} >= 0, <= 20; # ODE parameters
var u {s in 1..ne};
minimize l2error{j in 1..nm}:
eval ( sum {s in 1..ne}(u[s] - z[j,s])^2, tau[j] );
subject to theta_bounds {i in 1..np}: theta[i] >= 0.0;
subject to bc_cond {s in 1..ne}: eval (u[s], 0) = bc[s];
subject to de1:
diff(u[1],t) = - (theta[1]+theta[3])*u[1]^2;
subject to de2:
diff(u[2],t) = theta[1]*u[1]^2 - theta[2]*u[2];
option solver muscod;
option muscod_options "stiff=0 deriv=finitediff itmax=1000 hess=hess_gaussnewton atol=1e-12";
problem gasoil: l2error, theta_bounds, bc_cond, de1, de2, theta, u, t;
solve;
#
# COPS problem 10 (Goddart Rocket)
#
# Christian Kirches
# July/August 2011
#
include OptimalControl.mod;
var t;
var tf := 1.0, >= 0.01, <= 1;
param v0 := 0.0;
param m0 := 1.0;
param g0 := 1.0;
param h0 := 1.0;
param hc := 500.0;
param vc := 620.0;
param mc := 0.6;
param Tmax := 3.5*g0*m0;
param c := 0.5*sqrt(g0*h0);
param mf := mc*m0;
var h >= h0, := 1;
let h.interp_to := h0;
var v >= v0;
let v.interp_to := v0;
var m <= m0;
let m.interp_to := mf;
var T >= 0, <= Tmax, := Tmax/2;
let T.type := "u0";
param Dc := 0.5*vc*m0/g0;
var D = Dc*v^2*exp(-hc*(h-h0)/h0);
var g = g0*(h0/h)^2;
maximize FinalHeight: eval(h,tf);
let FinalHeight.scale := 0.01;
subject to
dh: diff(h,t) = v;
dv: diff(v,t) = (T - D)/m - g;
dm: diff(m,t) = -T/c;
ih: eval(h,0) = h0;
iv: eval(v,0) = v0;
im: eval(m,0) = m0;
fm: eval(m,tf) = mf;
\ No newline at end of file
option solver muscod;
option muscod_options "nshoot=80 sspec=1 stiff=0 hess=hess_limitedmemoryupdate solve=solve_slse deriv=finitediff atol=1e-9 itmax=300";
option muscod_auxfiles "rc";
problem goddart: FinalHeight, dh, dv, dm, ih, iv, im, fm, h, v, m, t, tf, T, tf;
solve;
#
# COPS problem 4 (Hanging Chain)
# Christian Kirches
# July/August 2011
#
include OptimalControl.mod;
var t;
var tf := 1;
var x >= 0, <= 10;
var L >= 0, <= 10;
var E >= 0, <= 10;
var u >= -10, <= 20;
let u.type := "u1";
param a := 1;
param b := 3;
param Lp := 4;
minimize energy: eval(E,tf);
subject to
dx: diff(x,t) = u;
dE: diff(E,t) = x*sqrt(1+u^2);
dL: diff(L,t) = sqrt(1+u^2);
x0: eval(x,0) = a;
x1: eval(x,1) = b;
E0: eval(E,0) = 0;
L0: eval(L,0) = 0;
L1: eval(L,1) = Lp;
option solver muscod;
option muscod_options "stiff=0 deriv=finitediff hess=hess_finitediff solve=solve_tbox atol=1e-10 nshoot=20";
problem hangchain: energy, dx, dE, dL, x0, x1, E0, L0, L1, u, x, L, E, t;
solve;
param ne := 8;
param nm := 21;
# Time measurements
param tau :=
1 0.0
2 0.5
3 1.0
4 1.5
5 2.0
6 2.5
7 3.0
8 3.5
9 4.0
10 4.5
11 5.0
12 5.5
13 6.0
14 6.5
15 7.0
16 7.5
17 8.0
18 8.5
19 9.0
20 9.5
21 10.0;
# Measurements
param z:
1 2 3 4 5 6 7 8 :=
1 20000.0 17000.0 10000.0 15000.0 12000.0 9000.0 7000.0 3000.0
2 12445.0 15411.0 13040.0 13338.0 13484.0 8426.0 6615.0 4022.0
3 7705.0 13074.0 14623.0 11976.0 12453.0 9272.0 6891.0 5020.0
4 4664.0 8579.0 12434.0 12603.0 11738.0 9710.0 6821.0 5722.0
5 2977.0 7053.0 11219.0 11340.0 13665.0 8534.0 6242.0 5695.0
6 1769.0 5054.0 10065.0 11232.0 12112.0 9600.0 6647.0 7034.0
7 943.0 3907.0 9473.0 10334.0 11115.0 8826.0 6842.0 7348.0
8 581.0 2624.0 7421.0 10297.0 12427.0 8747.0 7199.0 7684.0
9 355.0 1744.0 5369.0 7748.0 10057.0 8698.0 6542.0 7410.0
10 223.0 1272.0 4713.0 6869.0 9564.0 8766.0 6810.0 6961.0
11 137.0 821.0 3451.0 6050.0 8671.0 8291.0 6827.0 7525.0
12 87.0 577.0 2649.0 5454.0 8430.0 7411.0 6423.0 8388.0
13 49.0 337.0 2058.0 4115.0 7435.0 7627.0 6268.0 7189.0
14 32.0 228.0 1440.0 3790.0 6474.0 6658.0 5859.0 7467.0
15 17.0 168.0 1178.0 3087.0 6524.0 5880.0 5562.0 7144.0
16 11.0 99.0 919.0 2596.0 5360.0 5762.0 4480.0 7256.0
17 7.0 65.0 647.0 1873.0 4556.0 5058.0 4944.0 7538.0
18 4.0 44.0 509.0 1571.0 4009.0 4527.0 4233.0 6649.0
19 2.0 27.0 345.0 1227.0 3677.0 4229.0 3805.0 6378.0
20 1.0 20.0 231.0 934.0 3197.0 3695.0 3159.0 6454.0
21 1.0 12.0 198.0 707.0 2562.0 3163.0 3232.0 5566.0;
# Initial values
# let {i in 1..itau[1], s in 1..ne} v[i,s] := z[1,s];
# let {j in 2..nm, i in itau[j-1]+1..itau[j], s in 1..ne} v[i,s] := z[j,s];
# let {i in itau[nm]+1..nh, s in 1..ne} v[i,s] := z[nm,s];
# let {i in 1..nh, j in 1..nc, s in 1..ne} w[i,j,s] := 0;
# Marine Population Dynamics Problem
# Collocation formulation
# Alexander S. Bondarenko - Summer 1998
# COPS 2.0 - September 2000
# COPS 3.0 - November 2002
# COPS 3.1 - March 2004
#
# AMPL/OCP Formulation
# Christian Kirches, July/August 2011
#
include OptimalControl.mod;
var t;
param ne > 0, integer; # number of differential equations
param nm > 0, integer; # number of measurements
param tau {1..nm}; # times at which observations made
param tf := tau[nm]; # ODEs defined in [0,tf]
param z {1..nm,1..ne}; # observations
var g {1..ne-1} >= 0, <= 1; # growth rates
var m {1..ne} >= 0, <= 1; # mortality rates
var u {1..ne};
minimize l2error{j in 1..nm}:
eval ( sum {s in 1..ne} (u[s] - z[j,s])^2, tau[j] );
subject to g_bounds {s in 1..ne-1}: g[s] >= 0;
subject to m_bounds {s in 1..ne}: m[s] >= 0;
subject to de_1:
diff(u[1],t) = -(m[1]+g[1])*u[1];
subject to de_s {s in 2..ne-1}:
diff(u[s],t) = g[s-1]*u[s-1] - (m[s]+g[s])*u[s];
subject to de_ne:
diff(u[ne],t) = g[ne-1]*u[ne-1] - m[ne]*u[ne];
option solver muscod;
option muscod_options "nshoot=2 stiff=0 deriv=finitediff hess=hess_gaussnewton atol=1e-6";
option muscod_auxfiles "cr";
problem marine: l2error, g_bounds, m_bounds, de_1, de_s, de_ne, g, m, u, t;
solve;
param nm := 17;
# Time measurements
param tau :=
1 0
2 0.050
3 0.065
4 0.080
5 0.123
6 0.233
7 0.273
8 0.354
9 0.397
10 0.418
11 0.502
12 0.553
13 0.681
14 0.750
15 0.916
16 0.937
17 1.122;
# Concentrations
param z: 1 2 3 :=
1 1.0000 0 0
2 0.7085 0.1621 0.0811
3 0.5971 0.1855 0.0965
4 0.5537 0.1989 0.1198
5 0.3684 0.2845 0.1535
6 0.1712 0.3491 0.2097
7 0.1198 0.3098 0.2628
8 0.0747 0.3576 0.2467
9 0.0529 0.3347 0.2884
10 0.0415 0.3388 0.2757
11 0.0261 0.3557 0.3167
12 0.0208 0.3483 0.2954
13 0.0085 0.3836 0.2950
14 0.0053 0.3611 0.2937
15 0.0019 0.3609 0.2831
16 0.0018 0.3485 0.2846
17 0.0006 0.3698 0.2899;
param bc := 1 1 2 0 3 0;
# Methanol-to-Hydrocarbons Problem
# Collocation formulation
# Michael Merritt - Summer 2000
# COPS 2.0 - September 2000
# COPS 3.0 - November 2002
# COPS 3.1 - March 2004
#
# AMPL/OCP Reformulation
# Christian Kirches - July/August 2011
include OptimalControl.mod;
var t;
param ne := 3; # number of differential equations
param np := 5; # number of ODE parameters
param nm > 0, integer; # number of measurements
param bc {1..ne}; # ODE initial conditions
param tau {1..nm}; # times at which observations made
param z {1..nm, 1..ne}; # observations
var theta {1..np} := 1.0; # ODE parameters
var u {s in 1..ne};
minimize l2error{j in 1..nm}:
eval (sum {s in 1..ne}(u[s] - z[j,s])^2, tau[j]);
subject to theta_bounds {i in 1..np}: theta[i] >= 0.0;
subject to bc_cond {s in 1..ne}: eval (u[s], 0) = bc[s];
subject to eqn1:
diff(u[1],t) = - (2*theta[2] -
(theta[1]*u[2])/((theta[2]+theta[5])*u[1]+u[2]) +
theta[3] + theta[4])*u[1];
subject to eqn2:
diff(u[2],t) = (theta[1]*u[1]*(theta[2]*u[1]-u[2]))/
((theta[2]+theta[5])*u[1]+u[2]) +
theta[3]*u[1];
subject to eqn3:
diff(u[3],t) = (theta[1]*u[1]*(u[2]+theta[5]*u[1]))/
((theta[2]+theta[5])*u[1]+u[2]) +
theta[4]*u[1];
option solver muscod;
option muscod_options "hess=hess_gaussnewton stiff=0 deriv=finitediff atol=1e-12";
problem methanol: l2error, theta_bounds, bc_cond, eqn1, eqn2, eqn3, t, theta, u;
solve;
#
# COPS Problem 9 (Particle Steering)
#
# Christian Kirches
# July/August 2011
#
include OptimalControl.mod;
param Pi := 3.14159265358979;
param a := 100.0;
var t;
var tf := 1, >= 0, <=10;
var y{1..4};
var u >= -Pi/2, <= +Pi/2;
let u.type := "u1";
minimize time:
eval(t,tf);
subject to
dy1: diff (y[1],t) = y[2];
dy2: diff (y[2],t) = a*cos(u);
dy3: diff (y[3],t) = y[4];
dy4: diff (y[4],t) = a*sin(u);
ivc{i in 1..4}: eval(y[i],0) = 0;
by1d: eval(y[2],tf) = 45;
by2: eval(y[3],tf) = 5;
by2d: eval(y[4],tf) = 0;
option solver muscod;
option muscod_options "stiff=0 nshoot=40";
option muscod_auxfiles "rc";
problem particle: time, dy1, dy2, dy3, dy4, ivc, by1d, by2, by2d, y, u, t, tf;
solve;
param ne := 5;
param np := 5;
param nm := 8;
# Time measurements
param tau :=
1 1230.0
2 3060.0
3 4920.0
4 7800.0
5 10680.0
6 15030.0
7 22620.0
8 36420.0;
# Concentrations
param z :
1 2 3 4 5 :=
1 88.35 7.3 2.3 0.4 1.75
2 76.4 15.6 4.5 0.7 2.8
3 65.1 23.1 5.3 1.1 5.8
4 50.4 32.9 6.0 1.5 9.3
5 37.5 42.7 6.0 1.9 12.0
6 25.9 49.1 5.9 2.2 17.0
7 14.0 57.4 5.1 2.6 21.0
8 4.5 63.1 3.8 2.9 25.7;
param bc :=
1 100.0
2 0.0
3 0.0
4 0.0
5 0.0;
# Initial values
let {i in 1..np} theta[i] := 0.0;
# Isomerization of Alpha-Pinene Problem
# Collocation formulation
# Alexander S. Bondarenko - Summer 1998
# COPS 2.0 - September 2000
# COPS 3.0 - November 2002
# COPS 3.1 - March 2004
#
# Reformulation using AMPL/OCP
# Christian Kirches, July/August 2011
#
include OptimalControl.mod
param ne > 0, integer; # number of differential equations
param np > 0, integer; # number of ODE parameters
param nm > 0, integer; # number of measurements
param bc {1..ne}; # boundary conditions
param tau {1..nm}; # times at which observations made
var t;
var tf := tau[nm];
param z {1..nm,1..ne}; # observations
var theta {1..np} >= 0, <= 100; # ODE parameters
var u{1..ne} >= 0, <= 200;
minimize l2error{i in 1..nm}:
eval ( sum {s in 1..ne} (u[s] - z[i,s])^2, tau[i] );
subject to theta_bounds {i in 1..np}: theta[i] >= 0.0;
subject to ode_bc {s in 1..ne}: eval(u[s], 0.0) = bc[s];
subject to de1:
diff (u[1], t) = - (theta[1]+theta[2])*u[1];
subject to de2:
diff (u[2], t) = theta[1]*u[1];
subject to de3:
diff (u[3], t) = theta[2]*u[1] - (theta[3]+theta[4])*u[3] + theta[5]*u[5];
subject to de4:
diff (u[4], t) = theta[3]*u[3];
subject to de5:
diff (u[5], t) = theta[4]*u[3] - theta[5]*u[5];
option muscod_auxfiles "cr";
option solver muscod;
option muscod_options "stiff=0 deriv=finitediff nshoot=2 atol=1e-12 hess=hess_gaussnewton";
problem pinene: l2error, theta_bounds, ode_bc, de1, de2, de3, de4, de5, theta, u, t;
solve;
param max_u_rho := 1;
param max_u_the := 1;
param max_u_phi := 1;
param L := 5;
let tf := 1.0;
let rho := 4.5;
let the := 0;
let phi := pi/4;
let rho_dot := 0.0;
let the_dot := 0;
let phi_dot := 0.0;
let u_rho := 0.0;
let u_the := 0.0;
let u_phi := 0.0;
#
# COPS Problem 8 (Robot Arm)
#
# David Bortz - Summer 1998
# COPS 2.0 - September 2000
# COPS 3.0 - November 2002
# COPS 3.1 - March 2004
#
# AMPL/OCP formulation
# Christian Kirches - July/August 2011
#
include OptimalControl.mod;
# Final positions of the length and the angles for the robot arm
param L; # total length of arm
param pi := 4*atan(1);
# Upper bounds on the controls
param max_u_rho;
param max_u_the;
param max_u_phi;
# Initial positions of the length and the angles for the robot arm
param rho_0;
param the_0;
param phi_0;
# Final positions of the length and the angles for the robot arm
param rho_n;
param the_n;
param phi_n;
# The length and the angles theta and phi for the robot arm.
var rho >=0, <= L;
var the >= -pi, <= pi;
var phi >=0, <= pi;
# The derivatives of the length and the angles.
var rho_dot;
var the_dot;
var phi_dot;