13. API developer guidelines


The purpose of this chapter is to present some guidelines for developing an application which uses the MOSEK API.

13.1. Turn on logging

While developing a new application it is beneficial to turn on logging so that error and diagnostics messages are displayed.

See the explained example in section 5.2 for instructions on turning log output on. You should also always cache and handle any exceptions thrown by MOSEK.

More log information can be obtained by modifying one or more of the parameters:

By default MOSEK will reduce the amount of log information after the first optimization on a given task. To get full log output on subsequent optimizations set:

mosek.iparam.log_cut_second_opt 0

13.2. Turn on data checking

In the development phase it is useful to use the parameter setting

mosek.iparam.data_check mosek.onoffkey.on

which forces MOSEK to check the input data. For instance, MOSEK looks for NANs in double numbers and outputs a warning if any are found.

13.3. Debugging an optimization task

If something is wrong with a problem or a solution, one option is to output the problem to an OPF file and inspect it by hand. Use the mosek.Task.writedata function to write a task to a file immediately before optimizing, for example as follows:

task.mosek.Task.writedata("taskdump.opf");
task.mosek.Task.optimize();

This will write the problem in task to the file taskdump.opf. Inspecting the text file taskdump.opf may reveal what is wrong in the problem setup.

13.4. Error handling

13.5. Check the problem status and solution status

If a problem is primal or dual infeasible and MOSEK detects this, it is not reported as an error. Therefore, it is important to check the problem status and solution status after the optimization optimization ended using the mosek.Task.getsolutionstatus function or the mosek.Task.getsolutioninf. function.

13.6. Important API limitations

13.6.1. Thread safety

The MOSEK API is thread safe in the sense that any number of threads may use it simultaneously. However, the individual tasks and environments may only be accessed from at most one thread at a time.

13.7. Bug reporting

If you think MOSEK is solving your problem incorrectly, please contact MOSEK support at support@mosek.com providing a detailed description of the problem. MOSEK support may ask for the task file which is produced as follows

task.mosek.Task.writedata("taskfile.mbt");
task.mosek.Task.optimize();

The task data will then be written to the taskfile.mbt file in binary form which is very useful when reproducing a problem.

Mon Sep 14 15:46:00 2009