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

112 CHAPTER 8. A CASE STUDY c j ≥ z p/q j where p and q are both integers and p ≥ q can be modelled using quadratic cones. See [7] for details. One more reformulation of (8.13) is needed, maximize µ T x subject to e T x + m T c = w + e T x 0 , G T x − t = 0, z j − x j ≥ − x 0 j, j = 1, . . . , n, z j + x j ≥ x 0 j, j = 1, . . . , n, [v j ; c j ; z j ] − f j,1:3 = 0, j = 1, . . . , n, [z j ; 0; v j ] − g j,1:3 = [0; −1/8; 0], j = 1, . . . , n, [s; t] ∈ Q n+1 , fj,1:3 T ∈ Q 3 r, j = 1, . . . , n, gj,1:3 T ∈ Q 3 r, j = 1, . . . , n, x ≥ 0, s = γ, (8.14) where f, g ∈ R n×3 . These additional variables f and g are only introduced to bring the problem on the API standard form. The formulation (8.14) is not the most compact possible. However, the MOSEK presolve will automatically make it more compact and since it is easier to implement (8.14) than a more compact form then the form (8.14) is preferred. The first step in developing the optimizer API implementation is to chose an ordering of the variables. In this case the ordering ⎡ ˆx = ⎢ ⎣ x s t c v z f T (:) g T (:) will be used. Note f T (:) means the rows of f are transposed and stacked on top of each other to form a long column vector. The Table 8.2 shows the mapping between the ˆx and the model variables. ⎤ ⎥ ⎦ The next step is to consider how the columns of A is defined. Reusing the idea in Section 8.1.2 then the following pseudo code describes the setup of A.

8.1. PORTFOLIO OPTIMIZATION 113 Variable Length Offset x n 1 s 1 n+1 t n n+2 c n 2n+2 v n 3n+2 z n 4n+2 f(:) T 3n 7n+2 g(:) T 3n 10n+2 Figure 8.2: Storage layout for the ˆx for j = 1 : n ˆx j = x j A 1,j = 1.0 A 2:n+1,j = G T j,1:n A n+1+j,j = −1.0 A 2n+1+j,j = 1.0 ˆx n+1 = s for for for for for for j = 1 : n ˆx n+1+j = t j A 1+j,n+1+j = −1.0 j = 1 : n ˆx 2n+1+j = c j A 1,2n+1+j = m j A 3n+1+3(j−1)+2,2n+1+j = 1.0 j = 1 : n ˆx 3n+1+j = v j A 3n+1+3(j−1)+1,3n+1+j = 1.0 A 6n+1+3(j−1)+3,3n+1+j = 1.0 j = 1 : n ˆx 4n+1+j = z j A 1+n+j,4n+1+j = 1.0 A 1+2n+j,4n+1+j = 1.0 A 3n+1+3(j−1)+3,4n+1+j = 1.0 A 6n+1+3(j−1)+1,4n+1+j = 1.0 j = 1 : n ˆx 7n+1+3(j−1)+1 = f j,1 A 3n+1+3(j−1)+1,7n+(3(j−1)+1 = −1.0 ˆx 7n+1+3(j−1)+2 = f j,2 A 3n+1+3(j−1)+2,7n+(3(j−1)+2 = −1.0 ˆx 7n+1+3(j−1)+3 = f j,3 A 3n+1+3(j−1)+3,7n+(3(j−1)+3 = −1.0 j = 1 : n ˆx 10n+1+3(j−1)+1 = g j,1 A 6n+1+3(j−1)+1,7n+(3(j−1)+1 = −1.0 ˆx 10n+1+3(j−1)+2 = g j,2 A 6n+1+3(j−1)+2,7n+(3(j−1)+2 = −1.0 ˆx 10n+1+3(j−1)+3 = g j,3 A 6n+1+3(j−1)+3,7n+(3(j−1)+3 = −1.0

112 CHAPTER 8. A CASE STUDY<br />

c j ≥ z p/q<br />

j<br />

where p and q are both integers and p ≥ q can be modelled using quadratic cones. See [7] for details.<br />

One more reformulation of (8.13) is needed,<br />

maximize µ T x<br />

subject to e T x + m T c = w + e T x 0 ,<br />

G T x − t = 0,<br />

z j − x j ≥ − x 0 j, j = 1, . . . , n,<br />

z j + x j ≥ x 0 j, j = 1, . . . , n,<br />

[v j ; c j ; z j ] − f j,1:3 = 0, j = 1, . . . , n,<br />

[z j ; 0; v j ] − g j,1:3 = [0; −1/8; 0], j = 1, . . . , n,<br />

[s; t] ∈ Q n+1 ,<br />

fj,1:3 T ∈ Q 3 r, j = 1, . . . , n,<br />

gj,1:3 T ∈ Q 3 r, j = 1, . . . , n,<br />

x ≥ 0,<br />

s = γ,<br />

(8.14)<br />

where f, g ∈ R n×3 . <strong>The</strong>se additional variables f and g are only introduced to bring the problem on<br />

the <strong>API</strong> standard form.<br />

<strong>The</strong> formulation (8.14) is not the most compact possible. However, the <strong>MOSEK</strong> presolve will automatically<br />

make it more compact and since it is easier to implement (8.14) than a more compact form<br />

then the form (8.14) is preferred.<br />

<strong>The</strong> first step in developing the <strong>optimizer</strong> <strong>API</strong> implementation is to chose an ordering of the variables.<br />

In this case the ordering<br />

⎡<br />

ˆx =<br />

⎢<br />

⎣<br />

x<br />

s<br />

t<br />

c<br />

v<br />

z<br />

f T (:)<br />

g T (:)<br />

will be used. Note f T (:) means the rows of f are transposed and stacked on top of each other to form<br />

a long column vector. <strong>The</strong> Table 8.2 shows the mapping between the ˆx and the model variables.<br />

⎤<br />

⎥<br />

⎦<br />

<strong>The</strong> next step is to consider how the columns of A is defined. Reusing the idea in Section 8.1.2 then<br />

the following pseudo code describes the setup of A.

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

Saved successfully!

Ooh no, something went wrong!