An important component of some dynamic optimization problems, in particular parameter estimation problems where measurement data is available, is variable access at discrete time instants. For example, if a measurement data value, yi, has been obtained at time ti, it may be desirable to penalize the deviation between yi and a corresponding variable in the model, evaluated at the time instant ti. In Modelica, it is not possible to access the value of a variable at a particular time instant in a natural way, and a new construct therefore has to be introduced.
All variables in Modelica are functions of time. The variability of variables may be different-some are continuously changing,
whereas others can change value only at discrete time instants, and yet others are constant. Nevertheless, the value of a
Modelica variable is defined for all time instants within the simulation, or optimization, interval. The time argument of
variables are not written explicitly in Modelica, however. One option for enabling access to variable values at specified
time instants is therefore to associate an implicitly defined function with a variable declaration. This function can then
be invoked by the standard Modelica syntax for function calls,
y(t_i). The name of the function is identical to the name of the variable, and it has one argument; the time instant at which the
variable is evaluated. This syntax is also very natural since it corresponds precisely to the mathematical notation of a function.
Note that the proposed syntax
y(t_i) makes the interpretation of such an expression context dependent. In order for this construct to be valid in standard Modelica,
y must refer to a function declaration. With the proposed extension,
y may refer either to a function declaration or a variable declaration. A compiler therefore needs to classify an expression
y(t_i) based on the context, i.e., what function and variable declarations are visible. This feature of Optimica is used in the
constraint section of the double integrator example, and is described below.