The MOSEK Python optimizer API manual Version 7.0 (Revision 141)
Optimizer API for Python - Documentation - Mosek Optimizer API for Python - Documentation - Mosek
24 CHAPTER 5. BASIC API TUTORIAL 51 task.writedata (sys.argv[2]) [ simple.py ] Similarly, controlled by iparam.read data format, the function Task.readdata can read a problem from a file: 33 task.readdata (sys.argv[1]) [ simple.py ] 5.1.2.2 Working with the problem data An optimization problem consists of several components; objective, objective sense, constraints, variable bounds etc. Therefore, the interface provides a number of methods to operate on the task specific data, all of which are listed under the Task class-specification. 5.1.2.3 Setting parameters Apart from the problem data, the task contains a number of parameters defining the behavior of MOSEK. For example the iparam.optimizer parameter defines which optimizer to use. There are three kinds of parameters in MOSEK • Integer parameters that can be set with Task.putintparam, • Double parameters that can be set with Task.putdouparam, and • string parameters that can be set with Task.putstrparam, The values for integer parameters are either simple integer values or enum values. A complete list of all parameters is found in Chapter B. 5.2 Linear optimization The simplest optimization problem is a purely linear problem. problem of the following form: Minimize or maximize the objective function A linear optimization problem is a subject to the linear constraints n−1 ∑ c j x j + c f (5.1) j=0 l c k ≤ n−1 ∑ a kj x j ≤ u c k, k = 0, . . . , m − 1, (5.2) j=0
5.2. LINEAR OPTIMIZATION 25 and the bounds lj x ≤ x j ≤ u x j , j = 0, . . . , n − 1, (5.3) where we have used the problem elements: m and n which are the number of constraints and variables respectively, x c which is the variable vector of length n, which is a coefficient vector of size n ⎡ c = ⎣ c 0 c n−1 ⎤ ⎦ , c f A which is a constant, which is a m×n matrix of coefficients is given by l c and u c ⎡ A = ⎣ a 0,0 · · · a 0,(n−1) ⎤ · · · ⎦ , which specify the lower and upper bounds on constraints respectively, and l x and u x which specifies the lower and upper bounds on variables respectively. Please note the unconventional notation using 0 as the first index rather than 1. Hence, x 0 is the first element in variable vector x. This convention has been adapted from Python arrays which are indexed from 0. 5.2.1 Example: Linear optimization The following is an example of a linear optimization problem:
- Page 1 and 2: The MOSEK Python optimizer API manu
- Page 3 and 4: Contents 1 Changes and new features
- Page 5 and 6: CONTENTS v 8 A case study 97 8.1 Po
- Page 7 and 8: CONTENTS vii 14.2.1 Caveats . . . .
- Page 9 and 10: CONTENTS ix A.2.70 Task.getdviolvar
- Page 11 and 12: CONTENTS xi A.2.162Task.isdouparnam
- Page 13 and 14: CONTENTS xiii A.2.254Task.readparam
- Page 15 and 16: CONTENTS xv B.1.45 dparam.mio near
- Page 17 and 18: CONTENTS xvii B.2.68 iparam.log sim
- Page 19 and 20: CONTENTS xix B.2.160iparam.sim refa
- Page 21 and 22: CONTENTS xxi D.18 Long integer info
- Page 23 and 24: Contact information Phone +45 3917
- Page 25 and 26: License agreement Before using the
- Page 27 and 28: Chapter 1 Changes and new features
- Page 29 and 30: 1.4. API CHANGES 7 1.3.3 Mixed-inte
- Page 31 and 32: 1.10. SUMMARY OF API CHANGES 9 •
- Page 33 and 34: 1.10. SUMMARY OF API CHANGES 11 •
- Page 35 and 36: 1.10. SUMMARY OF API CHANGES 13 •
- Page 37 and 38: Chapter 2 About this manual This ma
- Page 39 and 40: Chapter 3 Getting support and help
- Page 41 and 42: Chapter 4 Testing installation and
- Page 43 and 44: Chapter 5 Basic API tutorial In thi
- Page 45: 5.1. THE BASICS 23 5 # 6 # Purpose:
- 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
24 CHAPTER 5. BASIC <strong>API</strong> TUTORIAL<br />
51 task.writedata (sys.argv[2])<br />
[ simple.py ]<br />
Similarly, controlled by iparam.read data format, the function Task.readdata can read a problem<br />
from a file:<br />
33 task.readdata (sys.argv[1])<br />
[ simple.py ]<br />
5.1.2.2 Working with the problem data<br />
An optimization problem consists of several components; objective, objective sense, constraints, variable<br />
bounds etc. <strong>The</strong>refore, the interface provides a number of methods to operate on the task specific<br />
data, all of which are listed under the Task class-specification.<br />
5.1.2.3 Setting parameters<br />
Apart from the problem data, the task contains a number of parameters defining the behavior of<br />
<strong>MOSEK</strong>. For example the iparam.<strong>optimizer</strong> parameter defines which <strong>optimizer</strong> to use. <strong>The</strong>re are<br />
three kinds of parameters in <strong>MOSEK</strong><br />
• Integer parameters that can be set with Task.putintparam,<br />
• Double parameters that can be set with Task.putdouparam, and<br />
• string parameters that can be set with Task.putstrparam,<br />
<strong>The</strong> values for integer parameters are either simple integer values or enum values.<br />
A complete list of all parameters is found in Chapter B.<br />
5.2 Linear optimization<br />
<strong>The</strong> simplest optimization problem is a purely linear problem.<br />
problem of the following form:<br />
Minimize or maximize the objective function<br />
A linear optimization problem is a<br />
subject to the linear constraints<br />
n−1<br />
∑<br />
c j x j + c f (5.1)<br />
j=0<br />
l c k ≤<br />
n−1<br />
∑<br />
a kj x j ≤ u c k, k = 0, . . . , m − 1, (5.2)<br />
j=0