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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

102 CHAPTER 8. A CASE STUDY<br />

Variable Length Offset<br />

x n 1<br />

s 1 n+1<br />

t n n+2<br />

Figure 8.1: Storage layout of the ˆx variable.<br />

c = [ ]<br />

µ T 0 0 T<br />

[ n,1 ,<br />

]<br />

e<br />

T<br />

0 0<br />

A =<br />

n,1<br />

G T ,<br />

0 n,1 − I n<br />

l c = [ ]<br />

w + e T x 0 0 0 T<br />

1,n ,<br />

u c = [ ]<br />

w + e T x 0 0 0 T<br />

1,n ,<br />

l x = [ ]<br />

0 1,n γ − ∞ T n,1 ,<br />

u x = [ ]<br />

∞ n,1 γ ∞ T n,1 .<br />

<strong>The</strong> next step is to consider how the columns of A is defined. <strong>The</strong> following pseudo code<br />

for<br />

j = 1 : n<br />

ˆx j = x j<br />

A 1,j = 1.0<br />

A 2:(n+1),j = G T j,1:n<br />

ˆx n+1 = s<br />

for<br />

show how to construct each column of A.<br />

j = 1 : n<br />

ˆx n+1+j = t j<br />

A n+1+j,n+1+j = −1.0<br />

In the above discussion index origin 1 is employed, i.e., the first position in a vector is 1. <strong>The</strong> <strong>Python</strong><br />

programming language employs 0 as index origin and that should be kept in mind when reading the<br />

example code.<br />

1 """<br />

2 File : case portfolio 1.py<br />

3<br />

[ case portfolio 1.py ]<br />

4 Copyright : Copyright (c) <strong>MOSEK</strong> ApS, Denmark. All rights reserved.<br />

5<br />

6 Description : Implements a basic portfolio optimization model.<br />

7 """<br />

8<br />

10<br />

9 import mosek<br />

11 try:<br />

12 from numpy import zeros<br />

13 except ImportError:<br />

14 from mosek.array import zeros

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

Saved successfully!

Ooh no, something went wrong!