8 Debugging Tutorials

This collection of tutorials contains basic techniques for debugging optimization problems using tools available in MOSEK: optimizer log, solution summary, infeasibility report, command-line tools. It is intended as a first line of technical help for issues such as: Why do I get solution status unknown and how can I fix it? Why is my model infeasible while it shouldn’t be? Should I change some parameters? Can the model solve faster? etc.

The major steps when debugging a model are always:

  • Enable log output. See Sec. 7.4.1 (Stream logging) for how to do it. In the simplest case:

    Create a log handler function:

    static void MSKAPI printstr(void       *handle,
                                const char *str)
    {
      printf("%s", str);
      fflush(stdout);
    }
    

    attach it to the log stream:

    MSK_linkfunctotaskstream(task, MSK_STREAM_LOG, NULL, printstr);
    

    and include solution summary after the optimization:

      res = MSK_optimize(task);
      MSK_solutionsummary(task, MSK_STREAM_LOG);
    
  • Run the optimization and analyze the log output, see Sec. 8.1 (Understanding optimizer log). In particular:

    • check if the problem setup (number of constraints/variables etc.) matches your expectation.

    • check solution summary and solution status.

  • Dump the problem to disk if necessary to continue analysis. See Sec. 7.4.3 (Saving a problem to a file).

    • use a human-readable text format, preferably *.ptf if you want to check the problem structure by hand. Assign names to variables and constraints to make them easier to identify.

          MSK_writedata(task,"data.ptf");
      
    • use the MOSEK native format *.task.gz when submitting a bug report or support question.

          MSK_writedata(task,"data.task.gz");
      
  • Fix problem setup, improve the model, locate infeasibility or adjust parameters, depending on the diagnosis.

See the following sections for details.