25.11.2015 Views

The MOSEK Python optimizer API manual Version 7.0 (Revision 141)

Optimizer API for Python - Documentation - Mosek

Optimizer API for Python - Documentation - Mosek

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

44 CHAPTER 5. BASIC <strong>API</strong> TUTORIAL<br />

<strong>The</strong> second argument specify the semidefinite variable index j; in this example there is only a single<br />

variable, so the index is 0. <strong>The</strong> next three arguments give the number of matrices used in the linear<br />

combination, their indices (as returned by Task.appendsparsesymmat), and the weights for the individual<br />

matrices, respectively. In this example, we form the objective matrix coefficient directly from a<br />

single symmetric matrix.<br />

Similary, a constraint matrix coefficient A ij is setup by the function Task.putbaraij:<br />

123 task.putbaraij(0, 0, [syma0], [1.0])<br />

124 task.putbaraij(1, 0, [syma1], [1.0])<br />

[ sdo1.py ]<br />

where the second argument specifies the constraint number (the corresponding row of A), and the<br />

third argument specifies the semidefinite variable index (the corresponding column of A). <strong>The</strong> next<br />

three arguments specify a weighted combination of symmetric matrices used to form the constraint<br />

matrix coefficient.<br />

After the problem is solved, we read the solution using Task.getbarxj:<br />

146 task.getbarxj(mosek.soltype.itr, 0, barx)<br />

[ sdo1.py ]<br />

<strong>The</strong> function returns the half-vectorization of x j (the lower triangular part stacked as a column vector),<br />

where the semidefinite variable index j is given in the second argument, and the third argument is a<br />

pointer to an array for storing the numerical values.<br />

5.5 Quadratic optimization<br />

<strong>MOSEK</strong> can solve quadratic and quadratically constrained convex problems. This class of problems<br />

can be formulated as follows:<br />

1<br />

minimize<br />

2 xT Q o x + c T x + c f<br />

subject to lk c ≤ 1 n−1<br />

∑<br />

2 xT Q k x + a k,j x j ≤ u c k, k = 0, . . . , m − 1,<br />

j=0<br />

l x j ≤ x j ≤ u x j , j = 0, . . . , n − 1.<br />

(5.7)<br />

Without loss of generality it is assumed that Q o and Q k are all symmetric because<br />

x T Qx = 0.5x T (Q + Q T )x.<br />

This implies that a non-symmetric Q can be replaced by the symmetric matrix 1 2 (Q + QT ).<br />

<strong>The</strong> problem is required to be convex. More precisely, the matrix Q o must be positive semi-definite<br />

and the kth constraint must be of the form

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

Saved successfully!

Ooh no, something went wrong!