# MAT5OPT Assignment 2: MATLAB

## Get Expert's Help on Assessment Writing

MATLAB, row operations

1. Write a MATLAB function called pivot, which takes a matrix and  two  integers  i, j, where i    rj     k and r, k are respectively the number of rows and the number of columns of the matrix , and pivots the matrix 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.

1. 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)

x1 + 2x3 + x4 = 1

x2 + x3 = 2 5x2 + x5 = 3

(b)

x1 + 2x2 + x4 = 3 x1 + x2 + x3 = 1 x2 − x5 + x6 = 2

(c)

x2 + x5 = 2

x3 + 5x4 = 3

x1 + x2 + 3x4 = 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 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.

1. Solve the following LP problems using the simplex algorithm, or 2-phase method if
• minimize      = 4x2 − 2x1 subject to     x1 − 2x2 ⩽ 2

2x1 + 3x2 ⩽ 12

≥ 0.

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

• maximize x1 + 2x2 subject to     x1 + 4x2 ⩽ 12

x1 + x2 ⩾ 3

≥ 0.

This problem has a degeneracy.

• maximize x1 + 3x2 + 2x3 subject to     x1 + 2x2 + x3 ⩾ 1

x1 + 2x2 + x3 ⩽ 1 2x1 − x2 ⩾ 2

≥ 0.

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

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

maximize   x1 + x2

1

subject to

by using the 2-phase method.

(b) Next solve the related problem

x1 − x2 ≤ −1

1

x1 + x2 ≤ 4

3x1 + x2 ≥ 5

2x1 − x2 ≤ 2

≥ 0

minimize      x1 + x2

subject to

by using the 2-phase method.

Hire Expert

Get a Professional Help

200
Select FileChangeRemove

TOP

Limited Time Offer! - 20% OFF on all Services Get Expert Assistance Today!

X