25.11.2015 Views

The MOSEK Python optimizer API manual Version 7.0 (Revision 141)

Optimizer API for Python - Documentation - Mosek

Optimizer API for Python - Documentation - Mosek

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

52 CHAPTER 5. BASIC <strong>API</strong> TUTORIAL<br />

139 print("Other solution status")<br />

140<br />

<strong>141</strong> # call the main function<br />

142 try:<br />

143 main ()<br />

144 except mosek.Exception as e:<br />

145 print ("ERROR: %s" % str(code))<br />

146 if msg is not None:<br />

147 print ("\t%s" % e.msg)<br />

148 sys.exit(1)<br />

149 except:<br />

150 import traceback<br />

151 traceback.print exc()<br />

152 sys.exit(1)<br />

153 sys.exit(0)<br />

<strong>The</strong> only new function introduced in this example is Task.putqconk, which is used to add quadratic<br />

terms to the constraints. While Task.putqconk add quadratic terms to a specific constraint, it is also<br />

possible to input all quadratic terms in all constraints in one chunk using the Task.putqcon function.<br />

5.6 <strong>The</strong> solution summary<br />

All computations inside <strong>MOSEK</strong> are performed using finite precision floating point numbers. This<br />

implies the reported solution isonly be an approximate optimal solution. <strong>The</strong>refore after solving an<br />

optimization problem it is important to investigate how good an approximation the solution is. This<br />

can easily be done using the function Task.solutionsummary which reports how much the solution<br />

violate the primal and dual constraints and the primal and dual objective values. Recall for a convex<br />

optimization problem the optimality conditions are:<br />

• <strong>The</strong> primal solution must satisfy all the primal constraints.<br />

• <strong>The</strong> dual solution much satisfy all the dual constraints.<br />

• <strong>The</strong> primal and dual objective values must be identical.<br />

Thus the solution summary reports information that makes it possible to evaluate the quality of the<br />

solution obtained.<br />

In case of a linear optimization problem the solution summary may look like<br />

Basic solution summary<br />

Problem status : PRIMAL AND DUAL FEASIBLE<br />

Solution status : OPTIMAL<br />

Primal. obj: -4.6475314286e+002 Viol. con: 2e-014 var: 0e+000<br />

Dual. obj: -4.6475316001e+002 Viol. con: 7e-009 var: 4e-016<br />

<strong>The</strong> summary reports information for the basic solution. In this case we see:<br />

• <strong>The</strong> problem status is primal and dual feasible which means the problem has an optimal solution.<br />

<strong>The</strong> problem status can be obtained using Task.getprosta.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!