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

82 CHAPTER 6. NONLINEAR API TUTORIAL 76 77 oprc = [ mosek.scopr.exp, mosek.scopr.exp ] 78 opric = [ 0, 0 ] 79 oprjc = [ 4, 5 ] 80 oprfc = [ 1.0, 1.0 ] 81 oprgc = [ 1.0, 1.0 ] 82 oprhc = [ 0.0, 0.0 ] 83 84 task.putSCeval(opro, oprjo, oprfo, oprgo, oprho, 85 oprc, opric, oprjc, oprfc, oprgc, oprhc) 86 87 task.optimize() 88 89 res = [ 0.0 ] * numvar 90 task.getsolutionslice( 91 mosek.soltype.itr, 92 mosek.solitem.xx, 93 0, numvar, 94 res) 95 96 print ( "Solution is: %s" % res ) 97 98 main() 6.1.3 Ensuring convexity and differentiability Some simple rules can be set up to ensure that the problem satisfies MOSEK’s convexity and differentiability requirements. First of all, for any variable x i used in a separable term, the variable bounds must define a range within which the function is twice differentiable. We can define these bounds as follows: Separable function Operator name Safe x bounds fxln(x) scopr.ent 0 < x. fe gx+h scopr.exp −∞ < x < ∞. fln(gx + h) scopr.log If g > 0: −h/g < x. If g < 0: x < −h/g. f(x + h) g scopr.pow If g > 0 and integer: −∞ < x < ∞. If g < 0 and integer: either −h < x or x < −h. Otherwise: −h < x. To ensure convexity, we require that each z i (x) is either a sum of convex terms or a sum of concave terms. The following table lists convexity for the relevant ranges for f > 0 — changing the sign of f switches concavity/convexity.

6.1. SEPARABLE CONVEX (SCOPT) INTERFACE 83 Separable function Operator name fxln(x) scopr.ent Convex within safe bounds. fe gx+h scopr.exp Convex for all x. fln(gx + h) scopr.log Concave within safe bounds. f(x + h) g scopr.pow If g is even integer: convex within safe bounds. If g is odd integer: concave (−∞, −h), convex (−h, ∞). If 0 < g < 1: concave within safe bounds. Otherwise: convex within safe bounds. 6.1.4 SCopt Reference Functions used to manipulate separable terms: (opro, oprjo, oprfo, oprgo, oprho, oprc, opric, oprjc, oprfc, oprgc, oprhc) Replace all current non-linear separable terms with a new set. opro List of function indicators defining the objective terms; see scopr. oprjo List of variable indexes for the objective terms. oprfo List of f values for the objective terms oprgo List of g values for the objective terms oprho List of h values for the objective terms oprc List of function indicators defining the constraint terms; see scopr. opric List of variable indexes for the constraint terms. oprjc List of constraint indexes for the constraint terms. oprfc List of f values for the constraint terms oprgc List of g values for the constraint terms oprhc List of h values for the constraint terms () Remove all non-linear separable terms from the task.

82 CHAPTER 6. NONLINEAR <strong>API</strong> TUTORIAL<br />

76<br />

77 oprc = [ mosek.scopr.exp, mosek.scopr.exp ]<br />

78 opric = [ 0, 0 ]<br />

79 oprjc = [ 4, 5 ]<br />

80 oprfc = [ 1.0, 1.0 ]<br />

81 oprgc = [ 1.0, 1.0 ]<br />

82 oprhc = [ 0.0, 0.0 ]<br />

83<br />

84 task.putSCeval(opro, oprjo, oprfo, oprgo, oprho,<br />

85 oprc, opric, oprjc, oprfc, oprgc, oprhc)<br />

86<br />

87 task.optimize()<br />

88<br />

89 res = [ 0.0 ] * numvar<br />

90 task.getsolutionslice(<br />

91 mosek.soltype.itr,<br />

92 mosek.solitem.xx,<br />

93 0, numvar,<br />

94 res)<br />

95<br />

96 print ( "Solution is: %s" % res )<br />

97<br />

98 main()<br />

6.1.3 Ensuring convexity and differentiability<br />

Some simple rules can be set up to ensure that the problem satisfies <strong>MOSEK</strong>’s convexity and differentiability<br />

requirements. First of all, for any variable x i used in a separable term, the variable bounds<br />

must define a range within which the function is twice differentiable.<br />

We can define these bounds as follows:<br />

Separable function Operator name Safe x bounds<br />

fxln(x) scopr.ent 0 < x.<br />

fe gx+h scopr.exp −∞ < x < ∞.<br />

fln(gx + h) scopr.log If g > 0: −h/g < x.<br />

If g < 0: x < −h/g.<br />

f(x + h) g scopr.pow If g > 0 and integer: −∞ < x < ∞.<br />

If g < 0 and integer: either −h < x or x < −h.<br />

Otherwise: −h < x.<br />

To ensure convexity, we require that each z i (x) is either a sum of convex terms or a sum of concave<br />

terms. <strong>The</strong> following table lists convexity for the relevant ranges for f > 0 — changing the sign of f<br />

switches concavity/convexity.

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

Saved successfully!

Ooh no, something went wrong!