The MOSEK Python optimizer API manual Version 7.0 (Revision 141)
Optimizer API for Python - Documentation - Mosek Optimizer API for Python - Documentation - Mosek
34 CHAPTER 5. BASIC API TUTORIAL 109 xx = zeros(numvar, float) 110 task.getxx(mosek.soltype.bas, 111 xx) 112 113 if solsta == mosek.solsta.optimal or solsta == mosek.solsta.near optimal: 114 print("Optimal solution: %s" % xx) 115 elif solsta == mosek.solsta.dual infeas cer: 116 print("Primal or dual infeasibility.\n") 117 elif solsta == mosek.solsta.prim infeas cer: 118 print("Primal or dual infeasibility.\n") 119 elif solsta == mosek.solsta.near dual infeas cer: 120 print("Primal or dual infeasibility.\n") 121 elif solsta == mosek.solsta.near prim infeas cer: 122 print("Primal or dual infeasibility.\n") 123 elif mosek.solsta.unknown: 124 print("Unknown solution status") 125 else: 126 print("Other solution status") 127 128 # call the main function 129 try: 130 main () 131 except mosek.Exception as e: 132 print ("ERROR: %s" % str(e.code)) 133 if msg is not None: 134 print ("\t%s" % e.msg) 135 sys.exit(1) 136 except: 137 import traceback 138 traceback.print exc() 139 sys.exit(1) 140 sys.exit(0) 5.3 Conic quadratic optimization Conic optimization is a generalization of linear optimization, allowing constraints of the type x t ∈ C t , where x t is a subset of the problem variables and C t is a convex cone. Actually, since the set R n of real numbers is also a convex cone, all variables can in fact be partitioned into subsets belonging to separate convex cones, simply stated x ∈ C. MOSEK can solve conic quadratic optimization problems of the form minimize c T x + c f subject to l c ≤ Ax ≤ u c , l x ≤ x ≤ u x , x ∈ C, where the domain restriction, x ∈ C, implies that all variables are partitioned into convex cones (5.4)
5.3. CONIC QUADRATIC OPTIMIZATION 35 x = (x 0 , x 1 , . . . , x p−1 ), with x t ∈ C t ⊆ R nt . For convenience, the user only specify subsets of variables x t belonging to cones C t different from the set R nt of real numbers. These cones can be a: • Quadratic cone: ⎧ ⎨ Q n = ⎩ x ∈ Rn : x 0 ≥ √ n−1 ∑ j=1 x 2 j ⎫ ⎬ ⎭ . • Rotated quadratic cone: ⎧ ⎨ Q r n = ⎩ x ∈ Rn : 2x 0 x 1 ≥ ⎫ n−1 ∑ ⎬ x 2 j, x 0 ≥ 0, x 1 ≥ 0 ⎭ . j=2 From these definition it follows that (x 4 , x 0 , x 2 ) ∈ Q 3 , is equivalent to x 4 ≥ √ x 2 0 + x2 2 . Furthermore, each variable may belong to one cone at most. The constraint x i −x j = 0 would however allow x i and x j to belong to different cones with same effect. 5.3.1 Example: Conic quadratic optimization The problem minimize x 3 + x 4 + x 5 subject to x 0 + x 1 + 2x 2 = 1, x 0 √ , x 1 , x 2 ≥ 0, x 3 ≥ x 2 0 + x2 1 , 2x 4 x 5 ≥ x 2 2. (5.5) is an example of a conic quadratic optimization problem. The problem includes a set of linear constraints, a quadratic cone and a rotated quadratic cone.
- 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 and 46: 5.1. THE BASICS 23 5 # 6 # Purpose:
- 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: 5.2. LINEAR OPTIMIZATION 33 51 mose
- 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 and 98: 5.13. CONVENTIONS EMPLOYED IN THE A
- Page 99 and 100: Chapter 6 Nonlinear API tutorial Th
- 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
34 CHAPTER 5. BASIC <strong>API</strong> TUTORIAL<br />
109 xx = zeros(numvar, float)<br />
110 task.getxx(mosek.soltype.bas,<br />
111 xx)<br />
112<br />
113 if solsta == mosek.solsta.optimal or solsta == mosek.solsta.near optimal:<br />
114 print("Optimal solution: %s" % xx)<br />
115 elif solsta == mosek.solsta.dual infeas cer:<br />
116 print("Primal or dual infeasibility.\n")<br />
117 elif solsta == mosek.solsta.prim infeas cer:<br />
118 print("Primal or dual infeasibility.\n")<br />
119 elif solsta == mosek.solsta.near dual infeas cer:<br />
120 print("Primal or dual infeasibility.\n")<br />
121 elif solsta == mosek.solsta.near prim infeas cer:<br />
122 print("Primal or dual infeasibility.\n")<br />
123 elif mosek.solsta.unknown:<br />
124 print("Unknown solution status")<br />
125 else:<br />
126 print("Other solution status")<br />
127<br />
128 # call the main function<br />
129 try:<br />
130 main ()<br />
131 except mosek.Exception as e:<br />
132 print ("ERROR: %s" % str(e.code))<br />
133 if msg is not None:<br />
134 print ("\t%s" % e.msg)<br />
135 sys.exit(1)<br />
136 except:<br />
137 import traceback<br />
138 traceback.print exc()<br />
139 sys.exit(1)<br />
140 sys.exit(0)<br />
5.3 Conic quadratic optimization<br />
Conic optimization is a generalization of linear optimization, allowing constraints of the type<br />
x t ∈ C t ,<br />
where x t is a subset of the problem variables and C t is a convex cone. Actually, since the set R n of<br />
real numbers is also a convex cone, all variables can in fact be partitioned into subsets belonging to<br />
separate convex cones, simply stated x ∈ C.<br />
<strong>MOSEK</strong> can solve conic quadratic optimization problems of the form<br />
minimize<br />
c T x + c f<br />
subject to l c ≤ Ax ≤ u c ,<br />
l x ≤ x ≤ u x ,<br />
x ∈ C,<br />
where the domain restriction, x ∈ C, implies that all variables are partitioned into convex cones<br />
(5.4)