Support AMPL files
From mintOC
Revision as of 16:21, 9 July 2009 by SebastianSager (Talk | contribs)
The following files are useful for several discretized control problems listed on the AMPL Category page. They need to be saved to the same directory.
ampl_general.mod
param T > 0; # End time param nt > 0; # Number of discretization points in time param nu > 0; # Number of control discretization points param nx > 0; # Dimension of differential state vector param ntperu > 0; # nt / nu set I:= 0..nt; set U:= 0..nu-1; param uidx {I}; param fix_w; param fix_w; var w {U} >= 0, <= 1 binary; # control function var dt {U} >= 0, <= T; # stage length vector
ampl_general.dat
if ( fix_w > 0 ) then { for {i in U} { fix w[i]; } } if ( fix_dt > 0 ) then { for {i in U} { fix dt[i]; } } # Set indices of controls corresponding to time points for {i in 0..nu-1} { for {j in 0..ntperu-1} { let uidx[i*ntperu+j] := i; } } let uidx[nt] := nu-1;