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.

6.1. SEPARABLE CONVEX (SCOPT) INTERFACE 83<br />

Separable function Operator name<br />

fxln(x) scopr.ent Convex within safe bounds.<br />

fe gx+h scopr.exp Convex for all x.<br />

fln(gx + h) scopr.log Concave within safe bounds.<br />

f(x + h) g scopr.pow If g is even integer: convex within safe bounds.<br />

If g is odd integer: concave (−∞, −h), convex (−h, ∞).<br />

If 0 < g < 1: concave within safe bounds.<br />

Otherwise: convex within safe bounds.<br />

6.1.4 SCopt Reference<br />

Functions used to manipulate separable terms:<br />

(opro, oprjo, oprfo, oprgo, oprho, oprc, opric, oprjc, oprfc, oprgc, oprhc)<br />

Replace all current non-linear separable terms with a new set.<br />

opro<br />

List of function indicators defining the objective terms; see scopr.<br />

oprjo<br />

List of variable indexes for the objective terms.<br />

oprfo<br />

List of f values for the objective terms<br />

oprgo<br />

List of g values for the objective terms<br />

oprho<br />

List of h values for the objective terms<br />

oprc<br />

List of function indicators defining the constraint terms; see scopr.<br />

opric<br />

List of variable indexes for the constraint terms.<br />

oprjc<br />

List of constraint indexes for the constraint terms.<br />

oprfc<br />

List of f values for the constraint terms<br />

oprgc<br />

List of g values for the constraint terms<br />

oprhc<br />

List of h values for the constraint terms<br />

()<br />

Remove all non-linear separable terms from the task.

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

Saved successfully!

Ooh no, something went wrong!