# Double Tank multimode problem (AMPL)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page contains a discretized version of the MIOCP Double Tank multimode problem in AMPL format and with the package ampl_mintoc. You should be aware of the comments regarding discretization made on the AMPL overview page. Note that you will need to include two generic support AMPL files, mintocPre.mod and mintocPost.mod.

### AMPL

The model in AMPL code for a fixed control discretization grid with a collocation method. We need a model file mmdoubletank.mod,

```# Problem specific parameters and variables
param ref{X};
param p{Omega};

# Problem specific functions

var f {k in X,o in 0..no,i in I} = (
if      (k==1 && o==0) then 1- sqrt(x[1,i])
else if (k==2 && o==0) then sqrt(x[1,i]) - sqrt(x[2,i])
else if (k==1 && o==1) then 1
else if (k==1 && o==2) then 0.5
else if (k==1 && o==3) then 2
);

var lagrange{i in IC} = ref[1]*(x[2,i] - ref[2])^2;

var re{k in RE} = (
if      (k==1) then x[1,0] - 2.0
else if (k==2) then x[2,0] - 2.0
);

# -----------------------------------------
# Unused modeling parts
var mayer = 0;

var ri {k in RI} = (
if      (k==1) then x[1,0]
);

var xa {k in XA, i in I} = (
if      (k==1) then x[1,i]
);

var con {k in C, i in IC} = (
if      (k==1) then x[1,i]
);

var vcon {k in VC, o in 0..no, i in IC} = (
if      (k==1) then x[1,i]
);

var sw{o in Omega, i in IC diff {nt}, k in 1..nsw} = (
if      (k==1) then x[1,i]
);```

the data file mmdoubletank.dat

```# ------------------------------------
# Data: Double Tank Problem (from Mintoc.de)
# ------------------------------------

# Dimensions, all other 0 by default
param nxd := 2;
param no := 3;
param nre := 2;

# Algorithmic parameters
param nt := 4800;
param ntperu := 60;

# Problem parameters
let T := 10.0;
#let p[1] := 2;
#let p[2] := 3;
let ref[1] := 2.0;
let ref[2] := 3.0;

# Initial values control
let {i in IU} wi[1,i] := 0.3;

# Plot names
let nplots := 2;
let filename_base := "mmdoubletank";
let plotx_name[1] := "level 1";
let plotx_name[2] := "level 2";
#let plotw_name[1] := "Fishing control";
let plotx[1] := 1;
let plotx[2] := 1;
for {k in 1..no} { let plotw[k] := 1; }
for {k in 1..nxd} { let plotlambda[k] := 2; }```

and the run file

```##############################
model ../mintocPre.mod;
model mmdoubletank.mod;
model ../mintocPost.mod;
data mmdoubletank.dat;
##############################

let isSOS1 := 1;
let integrator := "explicitEuler";

##############################