Difference between revisions of "Support AMPL files"
From mintOC
m |
(AMPL/TACO header file) |
||
Line 28: | Line 28: | ||
</source> | </source> | ||
+ | == OptimalControl.mod == | ||
+ | <source lang="AMPL"> | ||
+ | suffix type symbolic 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 Prevent least-squares detection in an objective\ | ||
+ | '; | ||
+ | |||
+ | function diff; | ||
+ | function eval; | ||
+ | function integral; | ||
+ | </source> | ||
[[Category:AMPL]] | [[Category:AMPL]] |
Revision as of 23:02, 28 September 2011
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;
OptimalControl.mod
suffix type symbolic 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 Prevent least-squares detection in an objective\ '; function diff; function eval; function integral;