*MATLAB, row operations*

- Write a MATLAB function called pivot, which takes a matrix
*M*and two integers*i, j*, where*i r*,*j k*and*r, k*are respectively the number of rows and the number of columns of the matrix*M*, and pivots the matrix*M*on the element (*i, j*), e. it uses row operations to turn the (*i, j*)^{th}element into a 1, and then use that 1 to clear out the column it is in.

Do not use the function addRow from the solutions to Workshop 4 question 10, but write your own code, e.g. using a for statement which runs thought the rows.

If you don’t succeed in this question, then you may use the code provided in Workshop 4 question 10 in subsequent questions of this assignment.

*Canonical form, basic solutions.*

- Decide which of the following systems are in canonical form. For those that are, say what the basic variables are and write down the basic

(a)

*x*_{1} + 2*x*_{3} + *x*_{4} = 1

*x*_{2} + *x*_{3} = 2 5*x*_{2} + *x*_{5} = 3

(b)

*x*_{1} + 2*x*_{2} + *x*_{4} = 3 *x*_{1} + *x*_{2} + *x*_{3} = 1 *x*_{2} *− **x*_{5} + *x*_{6} = 2

(c)

*x*_{2} + *x*_{5} = 2

*x*_{3} + 5*x*_{4} = 3

*x*_{1} + *x*_{2} + 3*x*_{4} = 1

Consider the augmented matrix

*M** *=

1 | 2 | 3 | 4 | 5 | 6 |

1 | 0 | 1 | 0 | 1 | 0 |

5 | 4 | 3 | 2 | 1 | 0 |

- Use the MATLAB program pivot from question 1 to bring
*M*into canonical form, where columns 2, 4 and 5 are - Is the matrix you found in (a) unique? If not, write down another matrix, which is also canonical with basic columns 2, 4 and 5.

*Simplex algorithm, 2-phase method.*

- Solve the following LP problems using the simplex algorithm, or 2-phase method if
- minimize
*z*= 4*x*_{2}*−*2*x*_{1}subject to*x*_{1}*−*2*x*_{2}⩽ 2

- minimize

2*x*_{1} + 3*x*_{2} ⩽ 12

**x ***≥ ***0***.*

Notice this is a minimisation problem and the solution is not unique. Give all solutions.

- maximize
*z*=*x*_{1}+ 2*x*_{2}subject to*x*_{1}+ 4*x*_{2}⩽ 12

*x*_{1} + *x*_{2} ⩾ 3

**x ***≥ ***0***.*

This problem has a degeneracy.

- maximize
*z*=*x*_{1}+ 3*x*_{2}+ 2*x*_{3}subject to*x*_{1}+ 2*x*_{2}+*x*_{3}⩾ 1

*x*_{1} + 2*x*_{2} + *x*_{3} ⩽ 1 2*x*_{1} *− **x*_{2} ⩾ *−*2

**x ***≥ ***0***.*

Here, you can combine two constraint equations and you need to deal with a negative resource value.

- (a) Use MATLAB and the function pivot from question 1 to solve the problem from assignment 1 question 2, e.

maximize *z *= *x*_{1} + *x*_{2}

1

subject to

by using the 2-phase method.

(b) Next solve the related problem

2 *x*_{1} *− **x*_{2} *≤ −*1

1

2 *x*_{1} + *x*_{2} *≤ *4

3*x*_{1} + *x*_{2} *≥ *5

2*x*_{1} *− **x*_{2} *≤ *2

**x ***≥ ***0**

minimize *z *= *x*_{1} + *x*_{2}

subject to

by using the 2-phase method.