7.3.1 Stream logging¶
By default the solver prints a log output analogous to the one produced by the command-line version of MOSEK. Logging may be turned off using the command
echo(0), for example:
[r, res] = mosekopt('minimize echo(0)', prob);
Log output may be redirected to a file using the command
log, for example:
[r, res] = mosekopt('minimize log(fileName.txt)', prob);
Note that in recent versions of MATLAB the log is not displayed on screen until optimization is completed, which may be an inconvenience for longer tasks. The log written to a file does not have this issue.
Note also that leaving log output on can lead to a dramatic slowdown, visible especially on very small problems.
7.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
MSK_IPAR_LOG which affect the whole output. The actual log level for a specific functionality is determined as the minimum between
MSK_IPAR_LOG and the relevant parameter. For instance, the log level for the output produce by the interior-point algorithm is tuned by the
MSK_IPAR_LOG_INTPNT; 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
MSK_IPAR_LOG. Larger values of
MSK_IPAR_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
MSK_IPAR_LOG_CUT_SECOND_OPT to zero.
7.3.3 Saving a problem to a file¶
An optimization problem can be dumped to a file using the command
write. The file format will be determined from the filename’s extension. Supported formats are listed in Sec. 16 (Supported File Formats) together with a table of problem types supported by each.
For instance the problem can be written to an OPF file with
[r, res] = mosekopt('write(dump.opf)', prob);
All formats can be compressed with
gzip by appending the
.gz extension, for example
[r, res] = mosekopt('write(dump.task.gz)', prob);
When using MATLAB-like functions the file name can be set using the
options structure, for example:
opt.Write = 'problem.opf'; linprog(f,A,b,,,,,opt);
The problem is written to the file as it is represented in the underlying optimizer task, that is including any auxiliary variables introduced by the MATLAB-to-C interface, if applicable.
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.
7.3.4 Reading a problem from a file¶
A problem saved in any of the supported file formats can be read directly into a
prob structure using the command
read. Afterwards the problem can be optimized, modified, etc.
[r, res] = mosekopt('read(dump.opf.gz)'); prob = res.prob;