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.

11.6. SOLVING PROBLEMS IN PARALLEL 151<br />

task.readdata(args[0])<br />

task.putintparam(mosek.iparam.<strong>optimizer</strong>,<br />

mosek.<strong>optimizer</strong>type.concurrent)<br />

task.putintparam(mosek.iparam.concurrent num <strong>optimizer</strong>s, 2)<br />

task.optimize()<br />

task.solutionsummary(mosek.streamtype.msg)<br />

# call the main function<br />

try:<br />

main (sys.argv[1:])<br />

except mosek.Exception as e:<br />

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

if msg is not None:<br />

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

sys.exit(1)<br />

except:<br />

import traceback<br />

traceback.print exc()<br />

sys.exit(1)<br />

sys.exit(0)<br />

11.6.4 A more flexible concurrent <strong>optimizer</strong><br />

<strong>MOSEK</strong> also provides a more flexible method of concurrent optimization by using the function<br />

Task.optimizeconcurrent. <strong>The</strong> main advantages of this function are that it allows the calling application<br />

to assign arbitrary values to the parameters of each tasks, and that call-back functions can<br />

be attached to each task. This may be useful in the following situation: Assume that you know the<br />

primal simplex <strong>optimizer</strong> to be the best <strong>optimizer</strong> for your problem, but that you do not know which of<br />

the available selection strategies (as defined by the iparam.sim primal selection parameter) is the<br />

best. In this case you can solve the problem with the primal simplex <strong>optimizer</strong> using several different<br />

selection strategies concurrently.<br />

An example demonstrating the usage of the Task.optimizeconcurrent function is included below.<br />

<strong>The</strong> example solves a single problem using the interior-point and primal simplex <strong>optimizer</strong>s in parallel.<br />

##<br />

# Copyright: Copyright (c) <strong>MOSEK</strong> ApS, Denmark. All rights reserved.<br />

#<br />

# File: concurrent2.py<br />

#<br />

# Purpose: To demonstrate a more flexible interface for concurrent optimization.<br />

##<br />

import sys<br />

import mosek<br />

from mosek.array import array<br />

# Since the actual value of Infinity is ignores, we define it solely

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

Saved successfully!

Ooh no, something went wrong!