The MOSEK Python optimizer API manual Version 7.0 (Revision 141)
Optimizer API for Python - Documentation - Mosek Optimizer API for Python - Documentation - Mosek
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
- Page 47 and 48: 5.2. LINEAR OPTIMIZATION 25 and the
- Page 49 and 50: 5.2. LINEAR OPTIMIZATION 27 Load a
- Page 51 and 52: 5.2. LINEAR OPTIMIZATION 29 Optimiz
- Page 53 and 54: 5.2. LINEAR OPTIMIZATION 31 88 task
- Page 55 and 56: 5.2. LINEAR OPTIMIZATION 33 51 mose
- Page 57 and 58: 5.3. CONIC QUADRATIC OPTIMIZATION 3
- Page 59 and 60: 5.3. CONIC QUADRATIC OPTIMIZATION 3
- Page 61 and 62: 5.4. SEMIDEFINITE OPTIMIZATION 39 m
- Page 63 and 64: 5.4. SEMIDEFINITE OPTIMIZATION 41 4
- Page 65 and 66: 5.4. SEMIDEFINITE OPTIMIZATION 43 1
- Page 67 and 68: 5.5. QUADRATIC OPTIMIZATION 45 with
- Page 69 and 70: 5.5. QUADRATIC OPTIMIZATION 47 68 #
- Page 71 and 72: 5.5. QUADRATIC OPTIMIZATION 49 5.5.
- Page 73 and 74: 5.5. QUADRATIC OPTIMIZATION 51 81 a
- Page 75 and 76: 5.6. THE SOLUTION SUMMARY 53 • Th
- Page 77 and 78: 5.7. INTEGER OPTIMIZATION 55 21 # f
- Page 79 and 80: 5.7. INTEGER OPTIMIZATION 57 137 sy
- Page 81 and 82: 5.8. THE SOLUTION SUMMARY FOR MIXED
- Page 83 and 84: 5.9. RESPONSE HANDLING 61 Note that
- Page 85 and 86: 5.10. PROBLEM MODIFICATION AND REOP
- Page 87 and 88: 5.10. PROBLEM MODIFICATION AND REOP
- Page 89 and 90: 5.11. SOLUTION ANALYSIS 67 151 # Pu
- Page 91 and 92: 5.13. CONVENTIONS EMPLOYED IN THE A
- Page 93 and 94: 5.13. CONVENTIONS EMPLOYED IN THE A
- Page 95 and 96: 5.13. CONVENTIONS EMPLOYED IN THE A
- Page 97: 5.13. CONVENTIONS EMPLOYED IN THE A
- Page 101 and 102: 6.1. SEPARABLE CONVEX (SCOPT) INTER
- Page 103 and 104: 6.1. SEPARABLE CONVEX (SCOPT) INTER
- Page 105 and 106: 6.1. SEPARABLE CONVEX (SCOPT) INTER
- Page 107 and 108: Chapter 7 Advanced API tutorial Thi
- Page 109 and 110: 7.1. THE PROGRESS CALL-BACK 87 71 p
- Page 111 and 112: 7.2. SOLVING LINEAR SYSTEMS INVOLVI
- Page 113 and 114: 7.2. SOLVING LINEAR SYSTEMS INVOLVI
- Page 115 and 116: 7.2. SOLVING LINEAR SYSTEMS INVOLVI
- Page 117 and 118: 7.2. SOLVING LINEAR SYSTEMS INVOLVI
- Page 119 and 120: Chapter 8 A case study 8.1 Portfoli
- Page 121 and 122: 8.1. PORTFOLIO OPTIMIZATION 99 e T
- Page 123 and 124: 8.1. PORTFOLIO OPTIMIZATION 101 is
- Page 125 and 126: 8.1. PORTFOLIO OPTIMIZATION 103 15
- Page 127 and 128: 8.1. PORTFOLIO OPTIMIZATION 105 63
- Page 129 and 130: 8.1. PORTFOLIO OPTIMIZATION 107 8.1
- Page 131 and 132: 8.1. PORTFOLIO OPTIMIZATION 109 110
- Page 133 and 134: 8.1. PORTFOLIO OPTIMIZATION 111 z j
- Page 135 and 136: 8.1. PORTFOLIO OPTIMIZATION 113 Var
- Page 137 and 138: 8.1. PORTFOLIO OPTIMIZATION 115 56
- Page 139 and 140: 8.1. PORTFOLIO OPTIMIZATION 117 172
- Page 141 and 142: Chapter 9 Usage guidelines The purp
- Page 143 and 144: 9.3. WRITING TASK DATA TO A FILE 12
- Page 145 and 146: Chapter 10 Problem formulation and
- Page 147 and 148: 10.1. LINEAR OPTIMIZATION 125 be a
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