Van der Pol Oscillator binary variant(AMPL)

From mintOC
Jump to: navigation, search

This page contains a discretized version of the MIOCP Van der Pol Oscillator (binary variant) 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 vanderpol.mod,

# -------------------------------
# Model: van der Pol model, Mintoc.de, Clemens Zeile 2017
# Outer Convexification version
# -------------------------------
 
 
 
# Problem specific functions
# Note: scaled to  \in {0,1}
var f {k in X,o in 0..no,i in I} = (
	if      (k==1 && o==0) then x[2,i] 
	else if (k==2 && o==0) then -x[1,i]
	else if (k==2 && o==1) then -1*(1-(x[1,i])^2)*x[2,i]
	else if (k==2 && o==2) then 0.75*(1-(x[1,i])^2)*x[2,i]
	else if (k==2 && o==3) then -2*(1-(x[1,i])^2)*x[2,i]
	else 0
);
 
var lagrange{i in IC} = (x[1,i]^2+x[2,i]^2); #+w[1,i]^2
 
 
var re{k in RE} = (
	if           (k==1)   then x[1,0]  - 1
	else if      (k==2)   then x[2,0]  - 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] - 0.8
	else if (k==2) then 1.4 - x[1,i]
);

the data file vanderpol.dat

# -------------------------------
# Data: van der Pol model, Mintoc.de, Clemens Zeile 2017
# -------------------------------
 
# Dimensions, all other 0 by default
param nxd := 2;
param no := 3;
param nre := 2;
param nc := 0;
 
 
# Algorithmic parameters
param nt := 3600;
param ntperu := 2;
 
# Problem parameters
 
let T := 20;
 
 
 
 
# Initial values control
#let {i in IU} wi[1,i] := 0.9;
option randseed 10;
let {i in IU} wi[1,i] := Uniform01();
 
# Plot names
let nplots := 2;
let filename_base := "vanderpol";
let plotx[1] := 1;
let plotx[2] := 1;
let plotw[1] := 1;
for {k in 1..nxd} { let plotlambda[k] := 2; }


and the run file

##############################
model ../mintocPre.mod;
model vanderpol.mod;
model ../mintocPost.mod;
data vanderpol.dat;
##############################
 
let isSOS1 := 1;
let integrator := "explicitEuler";
 
 
 
 
##############################
let integrator := "radau3";
let mode := "Relaxed";
include ../solve.run;
include ../plot1404.run;
include ../printOutput.run;
 
##############################
let mode := "CIA";
include ../solveMILP.run;
let mode := "Simulate";
include ../solve.run;
let filename_ext := "CIA";
include ../plot1404.run;
include ../printOutput.run;