In order to superimpose information on variable declarations, two new attributes are introduced for the built-in type Real.
Firstly, it should be possible to specify that a variable, or parameter, is free in the optimization. Modelica parameters
are normally considered to be fixed after the initialization step, but in the case of optimization, some parameters may rather
be considered to be free. In optimal control formulations, the control inputs should be marked as free, to indicate that they
are indeed optimization variables. For these reasons, a new attribute for the built-in type Real,
free, of boolean type is introduced. By default, this attribute is set to
Secondly, an attribute,
initialGuess, is introduced to enable the user to provide an initial guess for variables and parameters. In the case of free optimization
initialGuess attribute provides an initial guess to the optimization algorithm for the corresponding parameter. In the case of variables,
initialGuess attribute is used to provide the numerical solver with an initial guess for the entire optimization interval. This is particularly
important if a simultaneous or multiple-shooting algorithm is used, since these algorithms introduce optimization variables
corresponding to the values of variables at discrete points over the interval. Notice that such initial guesses may be needed
both for control and state variables. For such variables, however, the proposed strategy for providing initial guesses may
sometimes be inadequate. In some cases, a better solution is to use simulation data to initialize the optimization problem.
This approach is also supported by the Optimica compiler. In the double integrator example, the control variable u is a free optimization variable, and accordingly, the
free attribute is set to
true. Also, the
initialGuess attribute is set to 0.0.
optimization DIMinTime DoubleIntegrator di(u(free=true, initialGuess=0.0)); input Real u = di.u; end DIMinTime;