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

88 CHAPTER 7. ADVANCED API TUTORIAL 7.2 Solving linear systems involving the basis matrix A linear optimization problem always has an optimal solution which is also a basic solution. In an optimal basic solution there are exactly m basic variables where m is the number of rows in the constraint matrix A. Define B ∈ R m×m as a matrix consisting of the columns of A corresponding to the basic variables. The basis matrix B is always non-singular, i.e. det(B) ≠ 0 or equivalently that B −1 exists. This implies that the linear systems and B¯x = w (7.1) each has a unique solution for all w . B T ¯x = w (7.2) MOSEK provides functions for solving the linear systems (7.1) and (7.2) for an arbitrary w-¿. 7.2.1 Identifying the basis To use the solutions to (7.1) and (7.2) it is important to know how the basis matrix B is constructed. Internally MOSEK employs the linear optimization problem where maximize c T x subject to Ax − x c = 0, l x ≤ x ≤ u x , l c ≤ x c ≤ u c . (7.3) x c ∈ R m and x ∈ R n . The basis matrix is constructed of m columns taken from [ A − I ]. If variable x j is a basis variable, then the j ’th column of A denoted a :,j will appear in B. Similarly, if x c i is a basis variable, then the i ’th column of −I will appear in the basis. The ordering of the

7.2. SOLVING LINEAR SYSTEMS INVOLVING THE BASIS MATRIX 89 basis variables and therefore the ordering of the columns of B is arbitrary. The ordering of the basis variables may be retrieved by calling the function task.initbasissolve(basis) where basis is an array of variable indexes. This function initializes data structures for later use and returns the indexes of the basic variables in the array basis. The interpretation of the basis is as follows. If basis[i] < numcon, then the i’th basis variable is x c i . Moreover, the i ’th column in B will be the i’th column of −I. On the other hand if then the i ’th basis variable is variable basis[i] ≥ numcon, and the i ’th column of B is the column x basis[i]−numcon A :,(basis[i]−numcon) . For instance if basis[0] = 4 and numcon = 5 , then since basis[0] < numcon , the first basis variable is x c 4. Therefore, the first column of B is the fourth column of −I. Similarly, if basis[1] = 7, then the second variable in the basis is x basis[1]−numcon = x 2 . Hence, the second column of B is identical to a :,2 . 7.2.2 An example Consider the linear optimization problem: minimize x 0 + x 1 subject to x 0 + 2x 1 ≤ 2, x 0 + x 1 ≤ 6, x 0 , x 1 ≥ 0. (7.4) Suppose a call to Task.initbasissolve returns an array basis so that basis[0] = 1, basis[1] = 2. Then the basis variables are x c 1 and x 0 and the corresponding basis matrix B is [ 0 1 − 1 1 ] .

7.2. SOLVING LINEAR SYSTEMS INVOLVING THE BASIS MATRIX 89<br />

basis variables and therefore the ordering of the columns of B is arbitrary. <strong>The</strong> ordering of the basis<br />

variables may be retrieved by calling the function<br />

task.initbasissolve(basis)<br />

where basis is an array of variable indexes.<br />

This function initializes data structures for later use and returns the indexes of the basic variables in<br />

the array basis. <strong>The</strong> interpretation of the basis is as follows. If<br />

basis[i] < numcon,<br />

then the i’th basis variable is x c i . Moreover, the i ’th column in B will be the i’th column of −I. On<br />

the other hand if<br />

then the i ’th basis variable is variable<br />

basis[i] ≥ numcon,<br />

and the i ’th column of B is the column<br />

x basis[i]−numcon<br />

A :,(basis[i]−numcon) .<br />

For instance if basis[0] = 4 and numcon = 5 , then since basis[0] < numcon , the first basis variable<br />

is x c 4. <strong>The</strong>refore, the first column of B is the fourth column of −I. Similarly, if basis[1] = 7, then the<br />

second variable in the basis is x basis[1]−numcon = x 2 . Hence, the second column of B is identical to a :,2 .<br />

7.2.2 An example<br />

Consider the linear optimization problem:<br />

minimize x 0 + x 1<br />

subject to x 0 + 2x 1 ≤ 2,<br />

x 0 + x 1 ≤ 6,<br />

x 0 , x 1 ≥ 0.<br />

(7.4)<br />

Suppose a call to Task.initbasissolve returns an array basis so that<br />

basis[0] = 1,<br />

basis[1] = 2.<br />

<strong>The</strong>n the basis variables are x c 1 and x 0 and the corresponding basis matrix B is<br />

[<br />

0 1<br />

− 1 1<br />

]<br />

.

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

Saved successfully!

Ooh no, something went wrong!