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.

96 CHAPTER 7. ADVANCED <strong>API</strong> TUTORIAL<br />

147 if name == " main ":<br />

148 try:<br />

149 main()<br />

150 except:<br />

151 import traceback<br />

152 traceback.print exc()<br />

<strong>The</strong> most important step in the above example is the definition of the basic solution using the<br />

Task.putsolutioni function, where we define the status key for each variable. <strong>The</strong> actual values<br />

of the variables are not important and can be selected arbitrarily, so we set them to zero. All variables<br />

corresponding to columns in the linear system we want to solve are set to basic and the slack variables<br />

for the constraints, which are all non-basic, are set to their bound.<br />

<strong>The</strong> program produces the output:<br />

Solution to Bx = b:<br />

x1 = 1<br />

x0 = 3<br />

Solution to Bx = b:<br />

x1 = 7<br />

x0 = 7<br />

and we can verify that x 0 = 2, x 1 = −4 is indeed a solution to (7.5).

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

Saved successfully!

Ooh no, something went wrong!