In the optimization formulation above, there are elements that occur only once, i.e., the cost function and the optimization interval. These elements are intrinsic properties of the respective optimization formulations, and should be specified, once, by the user. In this respect the cost function and optimization interval differ from, for example, constraints, since the user may specify zero, one or more of the latter.
In order to encode these elements, class attributes are introduced. A class attribute is an intrinsic element of a specialized class, and may be modified in a class declaration without the need to explicitly extend from a built-in class. In the Optimica extension, four class attributes are introduced for the specialized class
optimization. These are
objective, which defines the cost function,
startTime, which defines the start of the optimization interval,
finalTime, which defines the end of the optimization interval, and
static, which indicates whether the class defines a static or dynamic optimization problem. The proposed syntax for class attributes is shown in the following
optimization DIMinTime ( objective=finalTime, startTime=0, finalTime(free=true,initialGuess=1)) DoubleIntegrator di(u(free=true, initialGuess=0.0)); input Real u = di.u; end DIMinTime;
The default value of the class attribute
false, and accordingly, it does not have to be set in this case. In essence, the keyword
extends and the reference to the built-in class have been eliminated, and the modification construct is instead given directly after the name of the class itself. The class attributes may be accessed and modified in the same way as if they were inherited.