You are on page 1of 23

Matrix Form Review +

ortools
IE 142: OPERATIONS RESEARCH II

P RE P ARE D B Y C A S O N DAY
Consider this LP
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 ≤ 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 2


What do we call the encircled parts?

1
5

2
3 4

What is the solution being described in the tableau?


(z, x1, x2, x3, s1, s2, s3)

9/14/2023 PREPARED BY CASONDAY 3


Answers
1 – Basic Variables
2 – Reduce Costs
◦ Decrease in Z per unit increase in the variable concerned

3 – Shadow Price/Dual Values


◦ Amount of increase in Z if the RHS of the corresponding constraint is
increased by 1 unit

4 – Z – Row
5 – RHS

(z, x1, x2, x3, s1, s2, s3) = (12, 10/3, 2/3, 0, 0, 2/3, 0)

9/14/2023 PREPARED BY CASONDAY 4


Is the solution optimal?
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 ≤ 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 5


Is the solution optimal?
YES.
The optimality condition is as follows
◦ For MAX, all values in the z-row must be at least 0 (non-negative)
◦ For MIN, all values in the z-row must be at most 0 (non-positive)

9/14/2023 PREPARED BY CASONDAY 6


Is the solution feasible?
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 ≤ 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 7


Is the solution feasible?
YES.
The feasibility condition is as follows
◦ All RHS must be non-negative since tableaus assume that all variables
are >= 0

9/14/2023 PREPARED BY CASONDAY 8


Matrix Form of LP
We can express any LP using matrices

Let 𝑿 be decision variables

𝑀𝑎𝑥/𝑀𝑖𝑛 𝑍 = 𝑐𝑋
Such that
𝐴𝑋 ≤ 𝑏
𝑋≥0

Where
A = matrix for the constraint coefficients
b = column of constraint RHS
c = row vector of objective function coefficients
X = a matrix for decision variables

9/14/2023 PREPARED BY CASONDAY 11


Matrix Form of Simplex Tableau

Decision Variables Slack Variables RHS


𝑍 𝑐𝐵 𝐵 −1 𝐴 − 𝐶 𝑐𝐵 𝐵−1 𝑐𝐵 𝐵−1 𝑏
𝑋𝐵 𝐵 −1 𝐴 𝐵 −1 𝐵 −1 𝑏

Where
cB = objective function coefficients of basic variables
B = constraint coefficients for basic variables

9/14/2023 PREPARED BY CASONDAY 12


Determine A, b, and c
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 ≤ 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 13


Determine A, b, and c
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 ≥ 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 14


Determine A, b, and c
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 = 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 15


OR Tools Solving

9/14/2023 PREPARED BY CASONDAY 16


OR Tools Solving

9/14/2023 PREPARED BY CASONDAY 17


OR Tools Solving

9/14/2023 PREPARED BY CASONDAY 18


OR Tools Solving

9/14/2023 PREPARED BY CASONDAY 19


Execute the code via Terminal
Go to the terminal section of VS Code

9/14/2023 PREPARED BY CASONDAY 20


Execute the code via Terminal
Click the + button to open a new terminal

9/14/2023 PREPARED BY CASONDAY 21


Execute the code via Terminal
Copy the location of your code from file explorer

Type on the terminal cd <location of code>

9/14/2023 PREPARED BY CASONDAY 22


Execute the code via Terminal
Type py <name of py file>

9/14/2023 PREPARED BY CASONDAY 23


Solve This
Max 3X1 + 2X2 + X3
Such that 2X1 - X2 + 3X3 ≤ 6
2X1 + X2 - X3 ≤ 8
X1 + X2 +2X3 ≤ 4
X 1 , X2 , X3 ≥ 0

9/14/2023 PREPARED BY CASONDAY 24


Thank you for coming to
class! Have a nice day!

9/14/2023 PREPARED BY CASONDAY 25

You might also like