Model class is also a proxy for input/output operations related to an optimization model.
8.3.1 Stream logging¶
By default the solver runs silently and does not produce any output to the console or otherwise. However, the log output can be redirected to a user-defined output stream or stream callback function. The log output is analogous to the one produced by the command-line version of MOSEK.
To redirect all log messages use the method
Model.setLogHandler. For instance, we can use the standard output:
A log stream can be detached by passing NULL.
8.3.2 Log verbosity¶
The logging verbosity can be controlled by setting the relevant parameters, as for instance
Each parameter controls the output level of a specific functionality or algorithm. The main switch is
log which affect the whole output. The actual log level for a specific functionality is determined as the minimum between
log and the relevant parameter. For instance, the log level for the output produce by the interior-point algorithm is tuned by the
logIntpnt; the actual log level is defined by the minimum between
Tuning the solver verbosity may require adjusting several parameters. It must be noticed that verbose logging is supposed to be of interest during debugging and tuning. When output is no more of interest, the user can easily disable it globally with
log. Larger values of
log do not necessarily result in increased output.
By default MOSEK will reduce the amount of log information after the first optimization on a given problem. To get full log output on subsequent re-optimizations set
logCutSecondOpt to zero.
8.3.3 Saving a problem to a file¶
An optimization model defined in Fusion can be dumped to a file using the method
Model.writeTask. The file format will be determined from the filename’s extension. Supported formats are listed in Sec. 15 (Supported File Formats) together with a table of problem types supported by each.
For instance the problem can be written to a human-readable PTF file (see Sec. 15.5 (The PTF Format)) with
All formats can be compressed with
gzip by appending the
.gz extension, and with
ZStandard by appending the
.zst extension, for example
The problem is written to the file as it is represented in the underlying optimizer task, that is including transformations performed by Fusion, if any.
Unnamed variables are given generic names. It is therefore recommended to use meaningful variable names if the problem file is meant to be human-readable.
taskformat is MOSEK’s native file format which contains all the problem data as well as solver settings.
8.3.4 Reading a problem from a file¶
It is not possible to read a file saved with
Model.writeTask back into Fusion because the structure of the high-level optimization model is not saved. However, such problem files can be solved with the command-line tool or read by the low-level Optimizer API if necessary. See the documentation of those interfaces for details.