The MOSEK Python optimizer API manual Version 7.0 (Revision 141)
Optimizer API for Python - Documentation - Mosek Optimizer API for Python - Documentation - Mosek
194 CHAPTER 15. SENSITIVITY ANALYSIS 83 1.0,1.0,1.0,1.0,1.0,1.0,1.0 ] 84 85 numcon = len(bkc) 86 numvar = len(bkx) 87 numanz = len(val) 88 89 # Input linear data 90 task.inputdata(numcon,numvar, 91 c,0.0, 92 ptrb, ptre, sub, val, 93 bkc, blc, buc, 94 bkx, blx, bux) 95 # Set objective sense 96 task.putobjsense(mosek.objsense.minimize) 97 98 # Optimize 99 task.optimize(); 100 101 # Analyze upper bound on c1 and the equality constraint on c4 102 subi = [ 0, 3 ] 103 marki = [ mosek.mark.up, mosek.mark.up ] 104 105 # Analyze lower bound on the variables x12 and x31 106 subj = [ 1, 4 ] 107 markj = [ mosek.mark.lo, mosek.mark.lo ] 108 109 leftpricei = zeros(2,float) 110 rightpricei = zeros(2,float) 111 leftrangei = zeros(2,float) 112 rightrangei = zeros(2,float) 113 leftpricej = zeros(2,float) 114 rightpricej = zeros(2,float) 115 leftrangej = zeros(2,float) 116 rightrangej = zeros(2,float) 117 118 119 task.primalsensitivity( subi, 120 marki, 121 subj, 122 markj, 123 leftpricei, 124 rightpricei, 125 leftrangei, 126 rightrangei, 127 leftpricej, 128 rightpricej, 129 leftrangej, 130 rightrangej) 131 132 print (’Results from sensitivity analysis on bounds:’) 133 print (’\tleftprice | rightprice | leftrange | rightrange ’ ) 134 print (’For constraints:’) 135 136 for i in range(2): 137 print (’\t%10f %10f %10f %10f’ % (leftpricei[i], 138 rightpricei[i], 139 leftrangei[i], 140 rightrangei[i]))
15.6. SENSITIVITY ANALYSIS WITH THE COMMAND LINE TOOL 195 141 142 print (’For variables:’) 143 for i in range(2): 144 print (’\t%10f %10f %10f %10f’ % (leftpricej[i], 145 rightpricej[i], 146 leftrangej[i], 147 rightrangej[i])) 148 149 150 leftprice = zeros(2,float) 151 rightprice = zeros(2,float) 152 leftrange = zeros(2,float) 153 rightrange = zeros(2,float) 154 subc = array([ 2, 5 ]) 155 156 task.dualsensitivity( subc, 157 leftprice, 158 rightprice, 159 leftrange, 160 rightrange) 161 162 print (’Results from sensitivity analysis on objective coefficients:’) 163 164 for i in range(2): 165 print (’\t%10f %10f %10f %10f’ % (leftprice[i], 166 rightprice[i], 167 leftrange[i], 168 rightrange[i])) 169 170 return None 171 172 # call the main function 173 try: 174 main () 175 except mosek.Exception as e: 176 print ("ERROR: %s" % str(e.errno)) 177 if e.msg is not None: 178 print ("\t%s" % e.msg) 179 sys.exit(1) 180 except: 181 import traceback 182 traceback.print exc() 183 sys.exit(1) 15.6 Sensitivity analysis with the command line tool A sensitivity analysis can be performed with the MOSEK command line tool using the command mosek myproblem.mps -sen sensitivity.ssp where sensitivity.ssp is a file in the format described in the next section. The ssp file describes which parts of the problem the sensitivity analysis should be performed on. By default results are written to a file named myproblem.sen. If necessary, this filename can be
- Page 165 and 166: 11.2. LINEAR OPTIMIZATION 143 11.2.
- Page 167 and 168: 11.2. LINEAR OPTIMIZATION 145 • R
- Page 169 and 170: 11.5. NONLINEAR CONVEX OPTIMIZATION
- Page 171 and 172: 11.6. SOLVING PROBLEMS IN PARALLEL
- Page 173 and 174: 11.6. SOLVING PROBLEMS IN PARALLEL
- Page 175 and 176: 11.6. SOLVING PROBLEMS IN PARALLEL
- Page 177 and 178: Chapter 12 The optimizers for mixed
- Page 179 and 180: 12.3. THE MIXED-INTEGER CONIC OPTIM
- Page 181 and 182: 12.5. TERMINATION CRITERION 159 •
- Page 183 and 184: 12.7. UNDERSTANDING SOLUTION QUALIT
- Page 185 and 186: Chapter 13 The analyzers 13.1 The p
- Page 187 and 188: 13.1. THE PROBLEM ANALYZER 165 Cons
- Page 189 and 190: 13.2. ANALYZING INFEASIBLE PROBLEMS
- Page 191 and 192: 13.2. ANALYZING INFEASIBLE PROBLEMS
- Page 193 and 194: 13.2. ANALYZING INFEASIBLE PROBLEMS
- Page 195 and 196: 13.2. ANALYZING INFEASIBLE PROBLEMS
- Page 197 and 198: 13.2. ANALYZING INFEASIBLE PROBLEMS
- Page 199 and 200: Chapter 14 Primal feasibility repai
- Page 201 and 202: 14.2. AUTOMATIC REPAIR 179 One way
- Page 203 and 204: 14.3. FEASIBILITY REPAIR IN MOSEK 1
- Page 205 and 206: 14.3. FEASIBILITY REPAIR IN MOSEK 1
- Page 207 and 208: Chapter 15 Sensitivity analysis 15.
- Page 209 and 210: 15.4. SENSITIVITY ANALYSIS FOR LINE
- Page 211 and 212: 15.4. SENSITIVITY ANALYSIS FOR LINE
- Page 213 and 214: 15.4. SENSITIVITY ANALYSIS FOR LINE
- Page 215: 15.5. SENSITIVITY ANALYSIS FROM THE
- Page 219 and 220: 15.6. SENSITIVITY ANALYSIS WITH THE
- Page 221 and 222: Appendix A API reference This chapt
- Page 223 and 224: 201 • Task.relaxprimal Obtain inf
- Page 225 and 226: A.1. EXCEPTIONS 203 • Task.putvar
- Page 227 and 228: A.2. CLASS TASK 205 Arguments which
- Page 229 and 230: A.2. CLASS TASK 207 See also • Ro
- Page 231 and 232: A.2. CLASS TASK 209 Description: Ap
- Page 233 and 234: A.2. CLASS TASK 211 Description: If
- Page 235 and 236: A.2. CLASS TASK 213 A.2.16 Task.com
- Page 237 and 238: A.2. CLASS TASK 215 subj : int[] In
- Page 239 and 240: A.2. CLASS TASK 217 firsti : int In
- Page 241 and 242: A.2. CLASS TASK 219 A.2.27 Task.get
- Page 243 and 244: A.2. CLASS TASK 221 valijkl : Descr
- Page 245 and 246: A.2. CLASS TASK 223 A.2.33 Task.get
- Page 247 and 248: A.2. CLASS TASK 225 idx : long Inde
- Page 249 and 250: A.2. CLASS TASK 227 A.2.41 Task.get
- Page 251 and 252: A.2. CLASS TASK 229 i : int Index o
- Page 253 and 254: A.2. CLASS TASK 231 A.2.49 Task.get
- Page 255 and 256: A.2. CLASS TASK 233 conetype : cone
- Page 257 and 258: A.2. CLASS TASK 235 Description: Ob
- Page 259 and 260: A.2. CLASS TASK 237 sub : int[] Ind
- Page 261 and 262: A.2. CLASS TASK 239 A.2.64 Task.get
- Page 263 and 264: A.2. CLASS TASK 241 Computes the vi
- Page 265 and 266: A.2. CLASS TASK 243 A.2.71 Task.get
15.6. SENSITIVITY ANALYSIS WITH THE COMMAND LINE TOOL 195<br />
<strong>141</strong><br />
142 print (’For variables:’)<br />
143 for i in range(2):<br />
144 print (’\t%10f %10f %10f %10f’ % (leftpricej[i],<br />
145 rightpricej[i],<br />
146 leftrangej[i],<br />
147 rightrangej[i]))<br />
148<br />
149<br />
150 leftprice = zeros(2,float)<br />
151 rightprice = zeros(2,float)<br />
152 leftrange = zeros(2,float)<br />
153 rightrange = zeros(2,float)<br />
154 subc = array([ 2, 5 ])<br />
155<br />
156 task.dualsensitivity( subc,<br />
157 leftprice,<br />
158 rightprice,<br />
159 leftrange,<br />
160 rightrange)<br />
161<br />
162 print (’Results from sensitivity analysis on objective coefficients:’)<br />
163<br />
164 for i in range(2):<br />
165 print (’\t%10f %10f %10f %10f’ % (leftprice[i],<br />
166 rightprice[i],<br />
167 leftrange[i],<br />
168 rightrange[i]))<br />
169<br />
170 return None<br />
171<br />
172 # call the main function<br />
173 try:<br />
174 main ()<br />
175 except mosek.Exception as e:<br />
176 print ("ERROR: %s" % str(e.errno))<br />
177 if e.msg is not None:<br />
178 print ("\t%s" % e.msg)<br />
179 sys.exit(1)<br />
180 except:<br />
181 import traceback<br />
182 traceback.print exc()<br />
183 sys.exit(1)<br />
15.6 Sensitivity analysis with the command line tool<br />
A sensitivity analysis can be performed with the <strong>MOSEK</strong> command line tool using the command<br />
mosek myproblem.mps -sen sensitivity.ssp<br />
where sensitivity.ssp is a file in the format described in the next section. <strong>The</strong> ssp file describes<br />
which parts of the problem the sensitivity analysis should be performed on.<br />
By default results are written to a file named myproblem.sen.<br />
If necessary, this filename can be