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.

5.1. THE BASICS 23<br />

5 #<br />

6 # Purpose: Demonstrates a very simple example using <strong>MOSEK</strong> by<br />

7 # reading a problem file, solving the problem and<br />

8 # writing the solution to a file.<br />

9 #<br />

10<br />

11 import mosek<br />

12 import sys<br />

13<br />

14 def streamprinter(msg):<br />

15 sys.stdout.write (msg)<br />

16 sys.stdout.flush ()<br />

17<br />

18 if len(sys.argv) = 3:<br />

43 # We define the output format to be OPF, and tell <strong>MOSEK</strong> to<br />

44 # leave out parameters and problem data from the output file.<br />

45 task.putintparam (mosek.iparam.write data format, mosek.dataformat.op)<br />

46 task.putintparam (mosek.iparam.opf write solutions, mosek.onoffkey.on)<br />

47 task.putintparam (mosek.iparam.opf write hints, mosek.onoffkey.off)<br />

48 task.putintparam (mosek.iparam.opf write parameters, mosek.onoffkey.off)<br />

49 task.putintparam (mosek.iparam.opf write problem, mosek.onoffkey.off)<br />

50<br />

51 task.writedata (sys.argv[2])<br />

5.1.2.1 Reading and writing problems<br />

Use the Task.writedata function to write a problem to a file. By default, when not choosing any<br />

specific file format for the parameter iparam.write data format, <strong>MOSEK</strong> will determine the output<br />

file format by the extension of the file name:

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

Saved successfully!

Ooh no, something went wrong!