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

Optimizer API for Python - Documentation - Mosek Optimizer API for Python - Documentation - Mosek

25.11.2015 Views

76 CHAPTER 5. BASIC API TUTORIAL • An array argument did not have the right type and could not be converted. • An array was expected, but the argument was not an array and not a list-compatible object. Furthermore, please note that mosek.array module only supports a limited set of array types: int32, int64, float64 and bool. The numerical types support normal simple mathematical operation (addition, subtraction, multiplication etc.) 5.14 The license system By default a license token is checked out when Task.optimize is first called and is returned when the MOSEK environment is deleted. Calling Task.optimize from different threads using the same MOSEK environment only consumes one license token. To change the license systems behavior to returning the license token after each call to Task.optimize set the parameter iparam.cache license to onoffkey.off. Please note that there is a small overhead associated with setting this parameter, since checking out a license token from the license server can take a small amount of time. Additionally license checkout and checkin can be controlled manually with the functions Env.checkinlicense and Env.checkoutlicense. 5.14.1 Waiting for a free license By default an error will be returned if no license token is available. By setting the parameter iparam.license waitMOSEK can be instructed to wait until a license token is available.

Chapter 6 Nonlinear API tutorial This chapter provides information about how to solve general convex nonlinear optimization problems using MOSEK. By general nonlinear problems it is meant problems that cannot be formulated as a conic quadratic optimization or a convex quadratically constrained optimization problem. In general it is recommended not to use nonlinear optimizer unless needed. The reasons are • MOSEK has no way of checking whether the formulated problem is convex and if this assumption is not satisfied the optimizer will not work. • The nonlinear optimizer requires 1st and 2nd order derivative information which is hard to provide correctly i.e. it is nontrivial to program the code that computes the derivative information. • The specification of nonlinear problems requires C function callbacks. Such C function callbacks cannot be dump to disk and that makes it hard to report issues to MOSEK support. • The algorithm employed for nonlinear optimization problems is not as good as the one employed for conic problems i.e. conic problems has special that can be exploited to make the optimizer faster and more robust. This leads to following advices in decreasing order of importance. • Consider reformulating the problem to a conic quadratic optimization problem if at all possible. In particular many problems involving polynomial terms can easily be reformulated to conic quadratic form. • Consider reformulating the problem to a separable optimization problem because that simplifies the issue with verifying convexity and computing 1st and 2nd order derivatives significantly. In most cases problems on separable form also solves faster because of the simpler structure of the functions. In Section 6.1 some utility code that makes it easy to solve separable problems is discussed. • Finally, if the problem cannot be reformulated to separable form then use a modelling language like AMPL or GAMS. The reason is the modeling language will do all the computing of function 77

Chapter 6<br />

Nonlinear <strong>API</strong> tutorial<br />

This chapter provides information about how to solve general convex nonlinear optimization problems<br />

using <strong>MOSEK</strong>. By general nonlinear problems it is meant problems that cannot be formulated as a<br />

conic quadratic optimization or a convex quadratically constrained optimization problem.<br />

In general it is recommended not to use nonlinear <strong>optimizer</strong> unless needed. <strong>The</strong> reasons are<br />

• <strong>MOSEK</strong> has no way of checking whether the formulated problem is convex and if this assumption<br />

is not satisfied the <strong>optimizer</strong> will not work.<br />

• <strong>The</strong> nonlinear <strong>optimizer</strong> requires 1st and 2nd order derivative information which is hard to provide<br />

correctly i.e. it is nontrivial to program the code that computes the derivative information.<br />

• <strong>The</strong> specification of nonlinear problems requires C function callbacks. Such C function callbacks<br />

cannot be dump to disk and that makes it hard to report issues to <strong>MOSEK</strong> support.<br />

• <strong>The</strong> algorithm employed for nonlinear optimization problems is not as good as the one employed<br />

for conic problems i.e. conic problems has special that can be exploited to make the <strong>optimizer</strong><br />

faster and more robust.<br />

This leads to following advices in decreasing order of importance.<br />

• Consider reformulating the problem to a conic quadratic optimization problem if at all possible.<br />

In particular many problems involving polynomial terms can easily be reformulated to conic<br />

quadratic form.<br />

• Consider reformulating the problem to a separable optimization problem because that simplifies<br />

the issue with verifying convexity and computing 1st and 2nd order derivatives significantly. In<br />

most cases problems on separable form also solves faster because of the simpler structure of the<br />

functions. In Section 6.1 some utility code that makes it easy to solve separable problems is<br />

discussed.<br />

• Finally, if the problem cannot be reformulated to separable form then use a modelling language<br />

like AMPL or GAMS. <strong>The</strong> reason is the modeling language will do all the computing of function<br />

77

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

Saved successfully!

Ooh no, something went wrong!