The following conventions apply in the syntax description of DYNA and DYNA2GAMS:
A DYNA model comprises a set of sections, which can be mixed and repeated. Only a few of them are mandatory. Their order is relatively free. Yet there are a few exceptions. As a rule of the thumb, a section that declares an object must appear before the sections that use the said object.
The grammar and the input format are close to the one of GAMS.
A paragraph of free text.
###: <free-text>
The same with some care to properly format the content with Html tags.
rem: <free-text>
Creation of files.
run: Notes: <file> < L|{<string>} (1) <file> << L|{<string>} (2)
Notes:
Parameters
run: Default values: COLLOCATION-FAMILY | CF = <c-family> default-collocation-family COLLOCATION-METHOD | CM = <c-method>[/<c-family>] default-collocation-method DEFAULT-COLLOCATION-FAMILY = <c-family> IL DEFAULT-COLLOCATION-METHOD = <c-method>[/<c-family>] L3A4 DEFAULT-ITERATIONS-NUMBER = <number> 4 DEFAULT-QUADRATURE-METHOD = Rectangle | Trapeze Trapeze DEFAULT-SIMULATION-FAMILY = <s-family> SH DEFAULT-SIMULATION-METHOD = <s-method>[/<s-family>] DP853 DEFAULT-TIME-STEPS-NUMBER = <number> 48 DEFAULT-VARIABLE = L|{<var>=<string>} DEFAULT-VARIABLES = L|{<var>=<string>} DELETE-FIRST-GDX = YES | NO Yes FINAL-TIME-SYMBOL = <ident> tf GAMS-OPTION = L|{<option>=<option-value>} GAMS-OPTIONS = L|{<option>=<option-value>} INCLUDE-LIBRARIES = Chebyshev | Chebyshev-Smolyak | Legendre | Hermite | Tauchen INCLUDE-LIBRARY = Chebyshev | Chebyshev-Smolyak | Legendre | Hermite | Tauchen INITIAL-TIME-SYMBOL = <ident> "" ITERATIONS-NUMBER | IN = <number> default-iterations-number MODEL-NAME = <ident> input file name MODEL-OPTION = L|{<option>=<option-value>} MODEL-OPTIONS = L|{<option>=<option-value>} QUADRATURE-METHOD | QM = Rectangle | Trapeze default-quadrature-method SAMPLING-TIME-SYMBOL = <ident> ts SEARCH-STRING | SS = <string> "" SIMULATION-FAMILY | SF = <s-family> default-simulation-family SIMULATION-LOOPS-NUMBER = <number> 1 SIMULATION-METHOD | SM = <s-method>[/<s-family>] default-simulation-method SIMULATION-REORDER-EQUATIONS = YES | NO Yes SIMULATION-TOLERANCE-ABSOLUTE = <val> 1e-6 SIMULATION-TOLERANCE-RELATIVE = <val> 1e-6 SMART-DUPLICATION = YES | NO Yes STEADY-STATE = YES | NO No SUBSTITUTE-CHARACTER = L|{iC|iHH|iDDD>oC|oHH|oDDD} SUBSTITUTE-CHARACTERS = L|{iC|iHH|iDDD>oC|oHH|oDDD} SUBSTITUTE-SYMBOL = L|{isymbol>osymbol} SUBSTITUTE-SYMBOLS = L|{isymbol>osymbol} TABULATION-KNOTS-NUMBER = <number> 256 TIME-MODEL = Continuous | Discrete | None Continuous TIME-STEPS-NUMBER | N = <number> default-time-steps-number TRANSFER-FUNCTION-SYNTAX = EQU | SIM EQU VARIABLE = L|{<var>=<string>} VARIABLES = L|{<var>=<string>} <c-family> :- IL|IR|IG|DL|DR|DG|NA <c-method> :- L3A2|L3A3|L3A4|L3A5|L3A6|L3A7|L3A8 when CF=IL|DL LGR2|LGR3|LGR4|LGR5|LGR6|LGR7|LGR8 when CF=IR|DR MP1|GL2|GL3|GL4|GL5|GL6|CN2|R1A3|R2A2|R2A3|L3A2|L3A3|L3A4|L3A5|L3B4|L3C4|RK4 when CF=IG MP1|GL2|GL3|GL4|GL5|GL6|R1A3|R2A2|R2A3|L3B4|L3C4|RK4 when CF=DG <s-family> :- SI|SH|SS|NA <s-method> :- NA|RK4|ODE23|ODE45|ODE78|F23|F34|F45|F56|F65|F78|DP54|DPS54|CK54|BS32|BS54| ... V56|V65|V67|V65E|V65R|V76E|V76R|V87E|V87R|V98E|V98R|T54|H65|M45|Z43|SDE when SF=SI NA|RK4HC|DP853 when SF=SH NA|SHAMP|GRK4A|GRK4T|VELDS|VELDD|LSTAB when SF=SS
fun: <ident> [<ident>] L{§<ident>} L{<val>} (*) §<ident> :: NLP | LIN | CUB | DNLP | DLIN | SP1 | SP2 §<ident> = GridXY | Spline3X | Spline3DX | PolyX | PolyDX @readcsv ifile=<ifile> @readxls ifile=<ifile>, range=<range>
(*) Notes regarding the numerical values:
set: <set>[(L,{<set>})] = [<l-delim>] <ident>:<ident> | <ident>*<ident> [<r-delim>] <set>[(L,{<set>})] = <l-delim> L,{<ident>|<ident>:<ident>|<ident>*<ident>} <r-delim> <set>[(L,{<set>})][[$<condition>] = <exp>] alias(L,{<set>},<set>) Note: the rightmost <set> must have been declared already <l-delim> :- ( | <[> | / | <|> <r-delim> :- ) | <]> | / | <|>
par: <par>[[$<condition>] = <exp>] <par> {+|-|*|/}= <exp> Compound assignment <par> = <l-delim> L,{L.{<ident>} <val>} <r-delim> Gams parameter format <par> = <ll-delim> [<EOL>] <Gams-table-data> [<EOL>] <rr-delim> Gams tabular format <par> = <[> L,{L{<exp>}} <]> Matlab-like syntax (with comma instead of semicolon) L{<par>} <exp> :- <val> | <par> | <expression-thereof> <l-delim> :- / | <|> <r-delim> :- / | <|> <ll-delim> :- // | <|><|> <rr-delim> :- // | <|><|>
tpa: <tpa> [= <tex>] <tpa> {+|-|*|/}= <tex> Compound assignment <tpa> = @readcsv ifile=<ifile> [,colval=<integer>] [,colset=L{<integer>}] [,skipheader=yes|NO] L{<tpa>} <tex> :- <val> | <exp> | <tpa> | <expression-thereof>
Static variables are not time dependent.
var: L{<var>}
Dynamic variables are time dependent.
dyn: L{<dyn>[:<decl>]} [:: <cast>] <decl> :- sos1 | sos2 | positive | negative | binary | integer <cast> :- control | controls | state | states | ancillary | ancillaries
By default, DYNA casts as state all the variables that are differentiated in the equations section.
obs: {T | Time | Tau} L{<dyn>} L{<val>} @readcsv ifile=<ifile> @readxls ifile=<ifile>, range=<range>
NA can be used as a numeric value to indicate a missing observation.
lim: <tex> <= <dyn>[$<condition>] <= <tex> <exp> <= <var>[$<condition>] <= <exp>
t=t0: Initial (or start) conditions t=tf: Final conditions k=k0: Initial (or start) conditions (discrete model) k=kf: Final conditions (discrete model) <dyn>[$<condition>] <relational-operator> <tex> <tex> <= <dyn>[$<condition>] <= <tex> <relational-operator> :- <= | = | >=
Formally, there is no difference between 't=t{0,f}' and 'k=k{0,f}'. The latter is perhaps visually more attractive for a time discrete model.
This section provides the solvers with choke values for the variables to optimize.
ini: <dyn>[$<condition>] = <tex> <var>[$<condition>] = <exp>
By default, the midpoint is used when finite lower and upper limits are set. In case of a semi-infinite interval, the lower or upper limit is used.
This section must appear after 'lim:' and 't=t{0,f}:' sections otherwise the initialization values are reset to their default.
Optional scaling of variables.
sca: <dyn>[$<condition>] = <tex> <var>[$<condition>] = <exp> %OBJECTIVE% = <exp>
Symbolic variables are shortcuts for algebraic expressions.
exp: <sym> == <expression> <expression> :- <val> | <par> | <tpa> | <var> | <dyn> | <expression-thereof>
tfm: <tfm-statement> <tfm-statement> :- Num = <polynomial>[*<polynomial>] Den = <polynomial>[*<polynomial>] Out = <dyn> [SSMF = Controllable | Observable | None] [Delay = <val>] [In = <dyn> | <val>] [Name = <ident>] [X0 = <val>] [CLTF = <ident> * <ident> | <ident> % <ident> | <ident> * <ident> % <ident>] <polynomial> :- [(]L{<val>}[)] | <indexed-parameter> Note: colon is allowed for a numeric range
For a continuous model, the polynomial gives the coefficients of \([s^n \, s^{n-1} \, ... \, s \, 1]\). For a discrete model, the transfer function is written in \(z\): \([z^n \, z^{n-1} \, ... \, z \, 1]\). Undeclared symbols at this stage will be declared as static or dynamic variables.
Model predictive control (MPC) is an effective means of dealing with large multivariable constrained control problems. The main idea is to choose the control action by repeatedly solving online an optimal control problem, aiming to minimize a performance criterion over a future horizon, possibly subject to constraints on the manipulated inputs and outputs. Future behavior is computed according to a model of the plant.
The cost function which DYNA actually minimizes is \[ J(k) = \sum_{i \in \mathbb{Q}} \|\hat{y}(k+i|k)-z(k+i)\|^2_{Q(i)} + \sum_{i \in \mathbb{R}} \|\hat{u}(k+i|k)\|^2_{R(i)} + \sum_{i \in \mathbb{R}} \|\Delta \hat{u}(k+i|k)\|^2_{R´(i)} \] under the constraints \[ x(k+1) = A x(k) + B u(k) + G w(k) \qquad \text{if linear} \\ x(k+1) = f \big(x(k),u(k),w(k)\big) \qquad \text{if non-linear} \\ y(k) = C x(k) + D u(k) \qquad \text{if linear} \\ y(k) = g \big(x(k),u(k))\big) \qquad \text{if non-linear} \\ \Delta \hat{u}(k+i|k) = \hat{u}(k+i|k) - \hat{u}(k+i-1|k) \\ z(k+i) = y_d(k+i) - \lambda^i \big(y_d(k+i)-\hat{y}(k+i|k)\big) \\ x_{\text{LB}} \leq x \leq x_{\text{UB}} \\ u_{\text{LB}} \leq u \leq u_{\text{UB}} \\ \Delta u_{\text{LB}} \leq \Delta u \leq \Delta u_{\text{UB}} \] where \(x\) is the vector of state variables, \(u\) is the vector of input variables, \(w\) is the vector of disturbances, \(y\) is the vector of output variables, \(y_d\) is the vector of desired outputs, \(\mathbb{Q}\) and \(\mathbb{R}\) are subsets of the controller horizon \(\mathbb{H}\), and \(\lambda\) is the decay factor.
mpc: <mpc-statement> <mpc-statement> :- [SAMPLING-TIME = <val>|<par>] Needed if predictive model is continuous. [STAGES = <val>|<par>] Number of stages for a continuous model. Default is 1. HORIZON = <set-definition> STATE|STATES = L{<dyn>} INPUT|INPUTS = L{<dyn>} [DISTURBANCE|DISTURBANCES = L{<dyn>|<tpa>}] OUTPUT|OUTPUTS = L{<dyn>} [ANCILLARY|ANCILLARIES = L{<dyn>}] EQUATION|EQUATIONS = L{<equ>} [A = <matrix>] Alternative definition of linear equations by the usual matrix notation. [B = <matrix>] [G = <matrix>] [C = <matrix>] [D = <matrix>] [LB = L{<var>[´] <val>}] Lower bound on variable [rate]. [UB = L{<var>[´] <val>}] Upper bound on variable [rate]. Q = <matrix> Weighting matrix for states. HORIZON-Q = <set-definition> R = <matrix> Weighting matrix for inputs. R´ = <matrix> Weighting matrix for derivatives of inputs. HORIZON-R = <set-definition> DECAY = <val>|<par>
The order in which the equations appear doesn’t matter.
equ: [[<equ>][$<condition>]..] <dyn>´ <relational-operator> <expression> [[<equ>][$<condition>]..] <expression> <relational-operator> <expression> [[<equ>][$<condition>]..] <expression> <= <expression> <= <expression> [[<equ>][$<condition>]..] <expression> :: <type>[(<exp>)] <tpa>[$<condition>] ~~ <stoch-cast> @tfm L,{<tfm-statement>} Transfer function model (see tfm section) @pid L,{<pid-statement>} Filtered PID transfer function model @linkphases [<phase-set> [-x L{<dyn>}]] Link dynamic variables across phases. -x means variables to exclude. <relational-operator> :- <= | == | >= <type> :- spline3[(arg)] | constant[(arg)] Default value for arg is -3 i.e. a sampling rate of 1 out of 3 knots <stoch-cast> :- Wiener | PJump(arg) | NPJump(arg1,arg2) | EPJump(arg1,arg2) <pid-statement> :- PID regulator K * (1 + 1/(s*Ti) + s*Td/(s*Td*Theta+1)) K = <val> | <par> | <var> Ti = <val> | <par> | <var> Td = <val> | <par> | <var> Out = <dyn> | <tex> In = <dyn> | <tex> [SSMF = Controllable | Observable] [Theta = <val> | <par> | <var>] Default value for Theta = 0.05
By default, DYNA declares equations with a default name and the same indices as the rightmost symbol of the left hand side of the '==' equation or the middle term of the box constraints ('.. ≤ .. ≤ ..'). Accordingly, equations can be implicitly declared time-dependent or not. Special keywords for $<condition>, $ONCE and $ALL, alter this behavior:
In addition, two keywords limit the scope of the time indexation:
Note 1: Unknown symbols in @pid will be declared as static or dynamic variables.
Note 2: @linkphases should ideally be placed after all the dot equations to benefit from the implicit declaration of state variables. If state variables have been explicitly declared (:: <cast>), its position doesn’t matter.
This section is similar to the 'equations' section but for a simulation. Contrary to the 'equation' section, this one is procedural i.e. the order of the equations matters. Unless required not to do so, DYNA sorts the equations in a way that all the variables listed on the right of the assignment operator (:=) have been defined already.
sim: [[$<condition>]..] <dyn>´ := <expression> [[$<condition>]..] <dyn> := <expression> [:+ L{<dyn>] [:- L{<dyn>}] <tpa>[$<condition>] ~~ <stoch-cast> @tfm L,{<tfm-statement>} Transfer function model @pid L,{<pid-statement>} PID function model @dcm L,{<dcm-statement>} Digital control model (for continuous model only) @newtonraphsonloop L,{<n-r-statement>} Newton-Raphson iteration to break a circularity <stoch-cast> :- Wiener | PJump(arg) | NPJump(arg1,arg2) | EPJump(arg1,arg2) <dcm-statement> :- The transfer function is written in polynomials of z Num = <polynomial>[*<polynomial>] Den = <polynomial>[*<polynomial>] Out = <dyn> | <exp> Unknown symbols will be declared as static or dynamic variables In = <dyn> | <exp> | <val> Ts = <val> | <par> [SSMF = Controllable | Observable] [Delay = <val>] [Name = <ident>] [X0 = <val>] <polynomial> :- [(]L{<val>}[)] | <indexed-parameter> Note: colon is allowed for a numeric range <n-r-statement> :- Var = <dyn> Ini = <val> [Tol = <val>] [MaxIter = <number>]
\(:-\) (\(:+\)) is a dummy operator that can be used to remove (add) an explicit (implicit) dependency of the assigned variable to other variables. This guarantees the execution of the assignment and all the following instructions when all the dependent variables are known.
Objective of optimization (when 'equ:' is present)
obj: minimize|maximize <expression> using <modeltype> [with {NONE | L|{<solver>}}] <modeltype> :- DNLP|EMP|LP|MINLP|MIP|MIQCP|NLP|QCP|RMINLP|RMIP|RMIQCP <solver> :- CONOPT|IPOPT|KNITRO|... See GAMS documentation for an exhaustive list
NONE suppresses the solve statement. The user has to optimize the model in the gms section.
mac: @<name>[(L,{<argument>})] <gams-code>
Implicit arguments are %1%, %2% ...
In case of explicitly named arguments, use &<argument> in the piece of GAMS code.
Caution:
gms: <gams-statement>; @abltimeput 'min|max' L/{var} L/{equ}; Put all but last dynamic variables and equations to file @alltimeput 'min|max' L/{var} L/{equ}; Put all dynamic variables and equations to file @costates [(POLY|ZERO|PREV)]; Costates calculation (must be used before any call to costate(.) function @csvmute L{<dyn>|<equ>}; Remove dynamic variables or equations from the CSV files @csvsave L{<dyn>}; Save dynamic variables in the CSV files @error [L{<dyn>}]; Estimate error of dynamic variables @export L,{<export-statement>}; Export a variable to a text file @gdxsave [<gdx-statement>]; Save objects to a GDX file for a later warm restart @observedrip L{<var>}; Insert report on identified parameters @par <par> [= <exp>]; Declare and instantiate parameter @rank L,{<rank-statement>}; Compute given percentiles of a single-index variable @seekcia L,{<seekcia-statement>}; Combinatorial Integral Approximation @seekmax L,{<seekm-statement>}; Section search maximum @seekmin L,{<seekm-statement>}; Section search minimum @seeksur L,{<seeksur-statement>}; Combinatorial Integral Approximation @setlim L,{<setlim-statement>}; Define lower and upper bound over the entire horizon @setlim0 L,{<setlim-statement>}; Define lower and upper bound on t=t0 @setlimf L,{<setlim-statement>}; Define lower and upper bound on t=tf @smooth L,{<smooth-statement>}; Smooth a variable or a parameter @solve [using <modeltype>] [with L|{<solver>}]; Reoptimize the model with new type or new solver @solveloop L,{<solveloop-statement>}; Iterative solve after smoothing of some variables @tpa <tpa> [= <tex>]; Declare and instantiate a time-dependent parameter @verbatim <gams-statement>; Instruct DYNA to keep statement untouched <export-statement> :- Grid = L{Time|<par>} The abscissas, up to four Var = <dyn>|<tpa>|<var>|<par> Indexed variable (or parameter) to export File = <file> File name [Every = <number>] A divisor of %N% (default is 1) <rank-statement> :- iVar = <dyn> Input variable (or parameter) oPar = <tpa> Output parameter Pctl = L{<number>} Percentiles of interest [Method = GDXRANK|HEAPSORT] <seekm-statement> :- Var = <par>|<var> Vlo = <val> Lower bound Vup = <val> Upper bound [Tol = <val>] Tolerance [Method = BRENT|GOLDEN] Method <seekcia-statement> :- ControlVar = <var> Control variable [SwitchVar = <var>|NA] Switching variable [SwitchMax = <par>|<val>|+INF] Maximum number of switching [CumulPar = <par>|NA] Upper bound on integral of control variable [optca = <par>|<val>] optca [optcr = <par>|<val>] optcr [cutoff = <par>|<val>|+INF] cutoff [Method = PLAIN|SHORT|ROUND] method <seeksur-statement> :- ControlVar = <var> Control variable [BinSize = <par>|+INF] Bin size (max number of variables to be fixed at once) <setlim-statement> :- Var = <dyn>|<var> [Vlo = <tex>|-INF] Lower bound [Vup = <tex>|+INF] Upper bound <smooth-statement> :- [Method = MOVAVG|MOVAVG-MP|BUTTERWORTH] Paraml = L{<number>} Parl|Varl = L{<tpa>}|L{<dyn>} <solveloop-statement>} :- Method = MOVAVG|BNDOBJ Paraml = L{<number>} Varl = L{<dyn>|<tpa>} [Target = OPTIM|INFES] [MaxIter = <number>|+INF]
gpl: <gnuplot-statement> @plotYT <yvar>, <title> [,<ylabel> [,<tlabel>]] @plotYYT n L,{<yvar>}, <title> [,<ylabel> [,<tlabel> [L,{<ytitle>}]]] @plotYX <yvar>, <xvar>, <title> [,<ylabel> [,<xlabel>]] @plotYYX n L,{<yvar>}, <xvar>, <title> [,<ylabel> [,<xlabel> [L,{<ytitle>}]]] @plotZXY <zvar>, <xvar>, <yvar>, <title> [,<zlabel> [,<xlabel> [,<ylabel>]]] @splotZXT <zvar>, <xtic>, <title> [,<zlabel> [,<xlabel>]]
DYNA will create an output file with the given or generated statements but will not dynamically invoke Gnuplot.
The PUT section writes its content to text files. Quoted strings are interpreted as follows:
put: "<file><[<]" Write or append following lines to <file> "<[<]" Close current file "<var>[<index>]['][:m]:[n][<c>]" Write the value of <var> with GAMS format :m:n. (defaults are m=13 and n=5) <c> is a one-character row delimiter (space by default) "{<file>|*}<[<][+]<var>[<index>]" Write or append <var> values to <file> in csv format * means previous csv <file> + requires adding labels for <var> name and indices "`<gams-code>`" Genuine GAMS code "" Quotation mark character @verbatim No prior DYNA translation of remaining string on this line
DYNA uses GAMS GDX files to save data or to load data from a previous run. By default, all the static and dynamic variables are involved in this process. The user can list here additional objects such time-dependent parameters, equations or variables created in a GAMS code section.
gdx: L{<tpa>|<gams-var>|<gams-equ>}
Actually two GDX files are created. A first one contains the required objects. A second one is created with the dynamic variables interpolated on a finer time grid, which will be used in a later run as a starting point.
If the user’s sole purpose is to create a GDX file with all the data regardless of the automated process of DYNA, the easiest way is to execute GAMS with the command-line option GDX=<ofile>.
DYNA works two ways: either in optimization mode or in simulation mode. In which case, the model consists of a different set of sections. The table here below sets forth which section is valid in which mode.
Sections | Optimization | Simulation |
---|---|---|
rem: | Yes | Yes |
###: | Yes | Yes |
run: | Yes | Yes |
fun: | Yes | Yes |
set: | Yes | Yes |
par: | Yes | Yes |
tpa: | Yes | Yes |
var: | Yes | - |
dyn: | Yes | Yes |
obs: | Yes | - |
lim: | Yes | - |
t=t0: | Yes | Yes |
t=tf: | Yes | - |
k=k0: | Yes | Yes |
k=kf: | Yes | - |
ini: | Yes | Yes(*) |
sca: | Yes | - |
exp: | Yes | Yes |
tfm: | Yes | Yes |
mpc: | - | Yes |
equ: | Yes | - |
sim: | - | Yes |
obj: | Yes | - |
mac: | Yes | Yes |
gms: | Yes | Yes |
gpl: | Yes | Yes |
put: | Yes | Yes |
gdx: | Yes | - |
(*) e.g., to define the control or the disturbance variables.
$<gams-$-directive>
The $ sign must be in column one.
@case <var> @cmd <line> @define <var> @dset <var>[=]<token> @echo <line> @else @endcase @endif @get <var>[<]<file> @ifdef L{<var>} @ifndef L{<var>} @macro <name>[(L,{<argument>})] <expression> @otherwise @set <var>[=]<token> @when L{[,]<token>} @whennset
The @ sign must be in column one.
Variables and their default values. Note they can be changed dynamically when invoking GAMS (--<var>=<val>).
%CF% IL %CM% L3A4 %DEBUG% 0 %DFGDX% 1 %DYNA_IFILE% filename.filetype %DYNA_IFNAM% filename %FN% filename %GOPT% "" %HOME% <user-defined> %IN% 4 %ITER% 1..%IN% Current iteration %ITERMAX% %IN% Is equivalent to %IN% %MODEL% filename with - translated as _ %MULTI% YES %N% 48 Is equivalent to card(N)-1 %OBJECTIVE% dyna_ksi %QM% 1 %SF% SH %SM% DP853 %SS% "" %TF% tf %TS% ts
DYNA system variables will be substituted by their value when reading the model. Their name is not case sensitive. Here follow the variables that are predefined.
@HOME@ @TITLE@ @IFNAM@
:+ L{<var>} Add an explicit dependence to <var> :- L{<var>} Remove an explicit dependence to <var>
In some cases it is useful to explicitly indicate the dependence to some variables to help DYNA to properly sort the equations of the simulation section. Such case occurs when a symbolic variable or a macro is called upon that uses implicit arguments or global variables.
Oper{a[[:b]:c],u{:}} will be translated as u<a> oper u<a+b> oper ... oper <c> where Oper :- sum | prod | comma | space oper :- + | * | , | <space>
Examples:
sum{1:2:5,x{:}} x1+x3+x5 space{1:3,x{:}} x1 x2 x3
{L{<word>}} As many lines will be generated as there are words, one for each word {<integer1>[[:<integer2>]:<integer3>]} Will be replaced by n, n being instantiated from integer-1 to integer-3 by integer-2
Examples:
{a b c} a b c x{1:2} x1 x2 x{1:10} x{01:10} x1 x01 x2 x02 ... x9 x09 x10 x10 x{1:3} = {0.47 0.87 0.34} x1 = 0.47 x2 = 0.87 x3 = 0.34 x{1 2 4} = x{3 5 6} x1 = x3 x2 = x5 x4 = x6
DYNA enquotes pure numeric index in bracketed variables/equations i.e. automatically replaces x[<digits>] by x['<digits>'].
# starts a comment - anything to the right will be ignored @ indicates a user/system macro \ is a line continuation character § indicates a tabulated function ´ indicates derivative ^ is translated as ** ¨ is translated as ^
dyna_eps machine precision dyna_iter %ITER% dyna_iter_max %IN% dyna_drk dyna_irk dyna_krd dyna_kri dyna_pi Pi
Note that Pi (\(\pi\)) is predefined in GAMS.
CartesianCoordinates /x,y,z/ SphericalCoordinates /rho,tta,phi/ Observation
Predefined variables are implemented as GAMS macros or variables.
Time The independent integration variable dTime Increment of the independent variable in equ section SimDT_ Increment of the independent variable in sim section dyna_ksi Same as %OBJECTIVE%, which reads better
Predefined functions are implemented as GAMS macros. Here follows the list of function classes.
AllTimeAvg(X) AllTimeMax(X) AllTimeMin(X) AllTimeSum(X) AllTimeAvgIF(X,Y) AllTimeMaxIF(X,Y) AllTimeMinIF(X,Y) AllTimeSumIF(X,Y) costate(X) curr(X) delay(X,tau) derivative(X) eval(X,tau) final(X) initial(X) integ(X) last(X) pred(X) slope(X) start(X) succ(X) TimeJump(tau) TimeIsEq(tau) TimeIsGT(tau) TimeIsGE(tau) TimeIsLT(tau) TimeIsLE(tau) TimeImpulse(tau) TimeStep(tau) TimeRamp(tau) linspace(a,b)
fractder(x,order) fractint(x,order)
poly1(x,a1,a0) poly2(x,a2,a1,a0) poly3(x,a3,a2,a1,a0) poly4(x,a4,a3,a2,a1,a0) poly5(x,a5,a4,a3,a2,a1,a0) poly6(x,a6,a5,a4,a3,a2,a1,a0) poly7(x,a7,a6,a5,a4,a3,a2,a1,a0) poly8(x,a8,a7,a6,a5,a4,a3,a2,a1,a0) poly9(x,a9,a8,a7,a6,a5,a4,a3,a2,a1,a0)
ObservedSSE(x) ObservedSSEC(x,mx) ObservedSXE(x,y) ObservedSXEC(x,y,mx,my) ObservedMSE(x) ObservedMSEC(x,mx) ObservedMAE(x) ObservedMAEC(x,mx) ObservedVal(x) ObservedMax(x) ObservedMin(x) ObservedNum(x) ObservedSet(x,i) ObservedGap(x,i) ObservedTau(x,i)
CartesianNorm(cc,u) CartesianDotProduct(cc,u,v) CartesianCrossProduct(cc,cc_,u,v) CartesianFromScalars(cc,u1,u2,u3) CartesianFromSphericalScalars(cc,u1,u2,u3) CartesianFromSpherical(cc,sc,u) SphericalNorm(sc,u) SphericalFromScalars(sc,u1,u2,u3) SphericalFromCartesianScalars(sc,u1,u2,u3) SphericalFromCartesian(sc,cc,u) XFromSphericalScalars(u1,u2,u3) YFromSphericalScalars(u1,u2,u3) ZFromSphericalScalars(u1,u2,u3) RhoFromCartesianScalars(u1,u2,u3) TtaFromCartesianScalars(u1,u2,u3) PhiFromCartesianScalars(u1,u2,u3)
Deg2Rad(x) Rad2Deg(x)
Wavesawtooth(x) Wavesquare(x) Wavetriangle(x)
smoothAbs(x) smoothEPS smoothHeaviside(x) smoothIfNeg(x,y,z) smoothIfPos(x,y,z) smoothMax(x,y) smoothMin(x,y) smoothSat(x,lo,up) smoothSgn(x)
Heaviside(x) midpoint(x,y)
interp(x,f1,f2,x1,x2) rectangle(x,x1,x2) interp0(x,f1,f2,x1,x2) interp1(x,i,tabf,tabx) interp2(x,i,tab,ff,xx) interp3(x,i,i_,tabf,tabx) interp9(x,i,s,i_,tabf,tabx)
dinterp0(x,f1,f2,x1,x2) dinterp1(x,i,tabf,tabx) dinterp2(x,i,tab,ff,xx) dinterp3(x,i,i_,tabf,tabx) dinterp9(x,i,s,i_,tabf,tabx)
spline0(x,c3,c2,c1,c0,x1,x2) spline9(x,i,n,i_,c3,c2,c1,c0,tabx) spline0d(x,c3,c2,c1,c0,x1,x2) spline9d(x,i,n,i_,c3,c2,c1,c0,tabx)
dspline0(x,c3,c2,c1,c0,x1,x2) dspline9(x,i,n,i_,c3,c2,c1,c0,tabx) dspline0d(x,c3,c2,c1,c0,x1,x2) dspline9d(x,i,n,i_,c3,c2,c1,c0,tabx)
quintic0(x,c3,c2,c1,c0,x1,x2) quintic9(x,i,n,i_,c3,c2,c1,c0,tabx) quintic0d(x,c3,c2,c1,c0,x1,x2) quintic9d(x,i,n,i_,c3,c2,c1,c0,tabx)
dquintic0(x,c5,c4,c3,c2,c1,c0,x1,x2) dquintic9(x,i,n,i_,c5,c4,c3,c2,c1,c0,tabx) dquintic0d(x,c5,c4,c3,c2,c1,c0,x1,x2) dquintic9d(x,i,n,i_,c5,c4,c3,c2,c1,c0,tabx)
interp2D0(x,y,f11,f12,f21,f22,x1,x2,y1,y2) interp2D1(x,y,i,j,tabf,tabx,taby) interp2D2(x,y,i,j,tab,ff,xx,yy)
dinterp2D0(x,y,f11,f12,f21,f22,x1,x2,y1,y2) dinterp2D1(x,y,i,j,tabf,tabx,taby) dinterp2D2(x,y,i,j,tab,ff,xx,yy)
TInterp0(x,f1,f2,x1,x2) TInterp1(x,i,tabf,tabx) TInterp2(x,i,tab,ff,xx) TInterpDot1(x,i,tabf,tabx) TInterpDot2(x,i,tab,ff,xx)
SeriesOf(f,x,a,i) SeriesOf0(f,x,a0) SeriesOf1(f,x,a1,a0) SeriesOf2(f,x,a2,a1,a0) SeriesOf3(f,x,a3,a2,a1,a0) SeriesOf4(f,x,a4,a3,a2,a1,a0) SeriesOf5(f,a5,a4,a3,a2,a1,a0) SeriesOf6(f,a6,a5,a4,a3,a2,a1,a0) SeriesOf7(f,a7,a6,a5,a4,a3,a2,a1,a0) SeriesOf8(f,a8,a7,a6,a5,a4,a3,a2,a1,a0) SeriesOf9(f,a9,a8,a7,a6,a5,a4,a3,a2,a1,a0)
ChebyshevQN(s) ChebyshevQW(s) Chebyshev(deg,x) dChebyshev(deg,x) SChebyshevDim(var,deg) SChebyshev2(deg,x1,x2,coe,ico) SChebyshev3(deg,x1,x2,x3,coe,ico) SChebyshev4(deg,x1,x2,x3,x4,coe,ico) d1SChebyshev2(deg,x1,x2,coe,ico) d2SChebyshev2(deg,x1,x2,coe,ico) d1SChebyshev3(deg,x1,x2,x3,coe,ico) d2SChebyshev3(deg,x1,x2,x3,coe,ico) d3SChebyshev3(deg,x1,x2,x3,coe,ico) d1SChebyshev4(deg,x1,x2,x3,x4,coe,ico) d2SChebyshev4(deg,x1,x2,x3,x4,coe,ico) d3SChebyshev4(deg,x1,x2,x3,x4,coe,ico) d4SChebyshev4(deg,x1,x2,x3,x4,coe,ico)
SmolyakDim(mu) SmolyakQN(s) SSmolyakDim(var,mu) SSmolyak2(mu,x1,x2,coe,ico) SSmolyak3(mu,x1,x2,x3,coe,ico) SSmolyak4(mu,x1,x2,x3,x4,coe,ico) SSmolyak5(mu,x1,x2,x3,x4,x5,coe,ico) SSmolyak6(mu,x1,x2,x3,x4,x5,x6,coe,ico) SSmolyak7(mu,x1,x2,x3,x4,x5,x6,x7,coe,ico) SSmolyak8(mu,x1,x2,x3,x4,x5,x6,x7,x8,coe,ico) SSmolyak9(mu,x1,x2,x3,x4,x5,x6,x7,x8,x9,coe,ico)
LegendreQN(s) LegendreQW(s) Legendre(deg,x) dLegendre(deg,x)
HermiteQN(s) HermiteQW(s) Hermite(deg,s) dHermite(deg,s)
TauchenAR1(i,j,grid,mu,rho,sigma)
Case sensitive (though not case sensitive in dyna-publish)
@SimEvent(<condition>[,<number>])
It is advisable not to use identifiers ended with '_' (underscore) as they may conflict with internal objects of DYNA. A similar restriction applies to identifiers starting with 'dyna_'. Otherwise some 'regular' identifiers are used by DYNA.
INTEGRAL N N0 NF NM1 NN NNZ
Should the user want to use any of those identifiers in his model, or any other identifier reserved by DYNA, it is suggested to use the 'SUBSTITUTE-SYMBOL' feature (see section runtime directives).
A config file consists of a set of sections. All of them are optional. So is the config file itself.
[system] Home = <path> [gams-options] <any-gams-option> [model-options] <any-model-option> [dyna-options] <any-dyna-runtime-directive> [solvers] <any-runtime-directive-dealing-with-files>
No default file is provided. Hereafter is an example.
[system] home = d:\dyna2gams [gams-options] limrow = 0 limcol = 0 solprint = off nlp = conopt minlp = bonmin threads = 0 [model-options] optfile = 0 [dyna-options] default-time-steps-number = 48 collocation-method = L3A4/IL quadrature-method = Trapeze iterations-number = 4 delete-first-gdx = Yes final-time-symbol = tf [solvers] knitro.opt < maxit 1000 | opttol 1e-8 | feastolabs 1e-5 ipopt.opt < max_iter 999 | acceptable_tol 1e-8 conopt.opt < lkdebg 0 | lfnicr 50
dyna-check-install.cmd Check DYNA2GAMS installation dyna-clean.cmd Delete working files in current directory dyna-compile.cmd Launch DYNA translation and GAMS compilation of the given file(s) dyna-csv-phases.cmd Reshape given csv result file(s) of a multi-phase problem dyna-execute.cmd Launch DYNA translation and GAMS execution of the given file(s) dyna-gather-nfo.cmd Gather run statistics of DYNA optimization models in one single CSV file dyna-gather-nfs.cmd Gather run statistics of DYNA simulation models in one single CSV file dyna-gnuplot.cmd Invoke Gnuplot with the results of a DYNA model dyna-publish.cmd DYNA syntax highlighting and conversion to html of the given file(s) dyna-setenv.cmd Set environment variables for DYNA2GAMS dyna-shell.cmd Start a new shell for DYNA2GAMS
Type in <cmd-file> --help to get a description of their usage.
GAMS-code files can be included in a 'gms:' section. They provide DYNA with features at an early development stage. Once judged useful and mature, they should be called upon through the @ syntax.
$LIBINCLUDE dyna-empmodel <emp-file> $LIBINCLUDE dyna-file2put <input-file> [<output-file>] $LIBINCLUDE dyna-fim-numeric EPS <value> | DF <value> | <set-of-to-be-identified-par> <par-statistics-table> L{<target-par>} $LIBINCLUDE dyna-fractder {JG|GL} L{<par>} $LIBINCLUDE dyna-fractint JG L{<par>} $LIBINCLUDE dyna-fractional-laplacian <xx> <DeltaX> <TickX> <s> <matrix-A> <matrix-B> [<xa> [<xb>]] $LIBINCLUDE dyna-hammersley <table-name> <nb-of-scen> <nb-of-var> <row-id-prefix> <col-id-prefix> [<row-first-index> [<col-first-index>]] $LIBINCLUDE dyna-pderiv-x <left-boundary-value> <right-boundary-value> <knots-number>