JModelica.org provides a method for DAE initialization that is based on IPOPT, the mathematical formulation of the algorithm can be found in the JMI API documentation. Notice that this algorithm does not rely on the causalization procedure (in particular the BLT transformation) which is common. Instead, the DAE residual is introduced as an equality constraint when solving an optimization problem where the squared difference between the non-fixed start values and their corresponding variables are minimized. As a consequence, the algorithm relies on decent start values for all variables. This approach is generally more sensitive to lacking initial guesses for start values than are algorithms based on causalization.
The algorithm provides the options summarized in Table 6.1.
Table 6.1. Options for the collocation-based optimization algorithm
| Option | Default | Description |
|---|---|---|
result_file_name |
Empty string (default generated file name will be used) | Specifies the name of the file where the optimization result is written. Setting this option to an empty string results in a default file name that is based on the name of the optimization class. |
result_format |
'txt' | Specifies in which format to write the result. Currently only textual mode is supported. |
write_scaled_result |
False | Write the scaled optimization result if set to true. This option is only applicable when automatic variable scaling is enabled. Only for debugging use. |
In addition to the options for the collocation algorithm, IPOPT options can also be set by modifying the dictionary IPOPT_options contained in the collocation algorithm options object. Here, all valid IPOPT options can be specified, see the IPOPT documentation for further information. For example, setting the option max_iter:
opts['IPOPT_options']['max_iter'] = 300
makes IPOPT terminate after 300 iterations even if no optimal solution has been found.
Some statistics from IPOPT can be obtained by issuing the command:
>>> res_init.solver.init_opt_ipopt_get_statistics()
The return argument of this function can be found by using the interactive help:
>>> help(res_init.solver.init_opt_ipopt_get_statistics)
Get statistics from the last optimization run.
Returns::
return_status --
The return status from IPOPT.
nbr_iter --
The number of iterations.
objective --
The final value of the objective function.
total_exec_time --
The execution time.
JModelica.org also provides a method for DAE initialization based on the non-linear equaion solver KINSOL from the SUNDIALS suite. KINSOL is currently comprised in the Assimulo package, included when installing JModelica.org. KINSOL is based on Newtons method for solving non-linear equations and is thus locally convergent. Attempts are made to make KInitSolveAlg as robust as possible but the possibility of finding a local minimum instead of the solution still remains. If the solution found by KInitSolveAlg is a local minimum a warning will be printed. The initial guesses passed to KINSOL are the ones supplied as start attributes in the current Modelica model.
KInitSolveAlg also implements an improved linear solver connected to KINSOL. This linear solver implements Tikhonov regularization to handle the problems of singular Jacobiansas well as support for SuperLU, an efficient sparse linear solver.
The options providable are summarized in Table 6.2.
Table 6.2. Options for KInitSolveAlg
| Option | Default | Description |
|---|---|---|
use_constraints |
False | A flag indicating whether constraints are to be used during initialization. Further explained in Section 3.2.1. |
constraints |
None | A numpy.array containing floats that, when supplied, defines the constraints on the variables. Further explained in Section 3.2.1.
|
result_format |
'txt' | Specifies in which format to write the result. Currently only textual mode is supported. |
result_file_name |
Empty string (default generated file name will be used) | Specifies the name of the file where the optimization result is written. Setting this option to an empty string results in a default file name that is based on the name of the optimization class. |
KINSOL_options |
A dictionary with the defalt KINSOL options | These are the options sent to the KINSOL solver. These are reviewed in detail in Table 6.3. |
Table 6.3. Options for KINSOL contained in the KINSOL_options dictionary
| Options | Default | Descriptions |
|---|---|---|
use_jac |
True | Flag indicating whether or not KINSOL uses the jacobian supplied by JModelica.org (True) or if KINSOL evaluates the Jacobian through finite differences (False). Finite differences is currently not available in sparse mode. |
| sparse | False | Flag indicating whether the problem should be treated as sparse (True) or dense (False). |
| verbosity | 0 | An integer regulating the level of output from KINSOL. Further explained in Section 3.2.2. |
KINSOL, and hence also KInitSolvAlg, only support simple unilateral constraints, that is constraining a variable to being
positive or negative. If the option use_constraints is set to True, constraints are use. What constraints that are used depends
on whether or not the user has supplied constraints with the constraints option. If set, these will be used otherwise constraints will be computed by reading the min and max attributes from the
Modelica file. How the constraint array is written is summarized in Table 6.4.
Table 6.4. Values allowed in the constraints array
| Value | Constraint |
|---|---|
| 0.0 | Unconstrained. |
| 1.0 | Greater than, or equal to, zero. |
| 2.0 | Greater than zero. |
| -1.0 | Less than, or equal to, zero. |
| -2.0 | Less than zero. |
When the constraints are read from the Modelica file the value from Table 6.4 most fitting to the min and max values is chosen. For example a variable with min set to 3.2 and max set to 5.6 is constrained to be greater than zero. When the algorithm is finished however the result will be compared with the min and max values from the model testing if the solution fulfills the constraints set by the Modelica file.
There are four different levels of verbosity in KINSOL with 0 being "silent" and 3 being the "loudest". What is output is reviewed in Table 6.5.
Table 6.5. Verbosity levels in KINSOL
| Verbosity level | Output |
|---|---|
| 0 | No information displayed. |
| 1 | In each nonlinear iteration the following information is displayed: the scaled Euclidean norm of the residual at the current iterate, the scaled Euclidian norm of the Newton step as well as the number of function evaluations performed so far. |
| 2 | Level 1 output as well as the Euclidian and in finity norm of the scaled residual at the current iterate |
| 3 | Level 2 output plus additional values used by the global strategy as well as statistical information from the linear solver. |