0% found this document useful (0 votes)
79 views60 pages

Part2B LP Solvers

A clothing company makes coats and jackets using wool and labor. The problem is to maximize profit by deciding how many coats and jackets to make given constraints on materials and labor hours. The model was implemented in Microsoft Excel and Mosel to solve the linear programming problem. The Mosel implementation provides additional functionality like checking the problem status. Separating data from the model is better practice since it avoids having to find and replace hardcoded values if data changes.

Uploaded by

Pooja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views60 pages

Part2B LP Solvers

A clothing company makes coats and jackets using wool and labor. The problem is to maximize profit by deciding how many coats and jackets to make given constraints on materials and labor hours. The model was implemented in Microsoft Excel and Mosel to solve the linear programming problem. The Mosel implementation provides additional functionality like checking the problem status. Separating data from the model is better practice since it avoids having to find and replace hardcoded values if data changes.

Uploaded by

Pooja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 60

Solving LP Models

Paula Carroll,
Management Information Systems,
Q250, Belfield, UCD
[email protected]

MIS41160 1
Section Objectives

• At the end of this section each student should be able to:


• Understand the properties of LP problems;
• Implement and solve typical LP problems in:
• Microsoft Excel;
• Mosel – the XpressMP Modelling language.
• Understand LP solution Algorithms

2
LP Assumptions
When we use LP as an approximate representation of a real-life
situation, the following assumptions are inherent:
• Proportionality - The contribution of each decision variable
to the objective or constraint is directly proportional to the
value of the decision variable.
• Additivity - The contribution to the objective function or
constraint for any variable is independent of the values of the
other decision variables, and the terms can be added together.
• Divisibility - The decision variables are continuous and thus
can take on fractional values.
• Deterministic - All the parameters (objective function
coefficients, right-hand side coefficients, left-hand side, or
technology, coefficients) are known with certainty.
MIS41160 3
Linear Programming Solution Space
A polyhedron is the set of all points
that satisfy a finite set of m linear inequalities:

Recall the pottery problem:

4
MIS41160
Linear Programming Solution Space
A set is convex if the closed line segment joining any two
points in S belongs to the set

5
MIS41160
Fundamental Theorem of Linear Programming
We can see that the LP solution space is convex

Theorem: If an LP has a (bounded) optimal solution, then


there exists an extreme point of the feasible region which is
optimal.

The optima of a linear objective function over the convex


polyhedron P occurs at a corner point.

If an extreme value occurs at two corners, then it must also


occur everywhere on the line segment (face) between them.

MIS41160 6
LP Outcomes

• Normal outcome (we find optimum)


• Problem is infeasible
• Problem is unbounded
• Multiple equal optima
• Degeneracy (one constraint is redundant)

MIS41160 7
Special Cases; Infeasible Problem

Every possible solution


violates at least one constraint:
Maximise Z = 5x1 + 3x2
subject to: 4x1 + 2x2  8
x1 4
x2 6
x1, x2  0

Graph of an Infeasible Problem

MIS40520 8
Special Cases; Unbounded Problem

Value of objective function


increases indefinitely:
Maximise Z = 4x1 + 2x2
subject to: x1  4
x2  2
x1, x2  0

Graph of an Unbounded Problem

MIS40520 9
Special Cases; Degeneracy

MIS40520 10
Multiple Optimal Solutions

MIS40520 11
Some more Maths Revision

In our LP problems, we wish to find that optimises the objective


function f. We sometimes denote the optimal solution as x*

x represents a “vector” or array of n decision variable values, ,


the function f maps .

The idea of an algorithm/programme/structured method is to


find x* in a computationally efficient way.

MIS41160 Optimisation in Business 12


Solving with the MS Excel LP solver

Returning to the pottery problem, see Excel file on Brightspace.

Exhibit 3.1
Source, Taylor “Introduction to Management Science” Chapter 3 - Linear Programming:
13
Computer Solution and Sensitivity Analysis
MS Excel LP Solver
“Solver” Parameter Screen

Exhibit 3.2

14
MS Excel LP Solver
Adding Model Constraints

Exhibit 3.3

15
MS Excel LP Solver
Solution Screen

Exhibit 3.4

16
MS Excel LP Solver
Answer Report

Exhibit 3.5
17
Class Exercise: Clothing Production
Problem
A clothing company makes coats and jackets using wool and
labour. There are 150 m2 of wool and 200 hours of labour
available. A coat takes 10 hours to make and uses 3 m2 of wool. A
a jacket takes 4 hours to make and uses 5 m2 of wool. Profit on a
coat is €50 and on a jacket is €40. Find the best combination of
coats and jackets to make to maximise profit.
• Return to your LP model of this problem. Create a
spreadsheet model in MS Excel;
• Solve the Excel LP model and compare the results wit the
solutions you created using the Graphical Solution
technique
• Interpret the MS Excel Answer report in full by writing a
short “aide memoir” to yourself in your Learning Journal.
MIS41160 Optimisation in Business 18
XpressMP Introduction

This section contains a brief overview of:


• linear programming in the Xpress-MP Product Suite;
• Mosel, the FICO XpressMP modelling language.

MIS41160 19
Xpress-MP Product Suite

GUI Xpress-IVE
Language Mosel
Mosel Solver Modules mmxprs, mmxslp, mmsp, mmquad
C, C++, Java Builder Component Libraries (BCL)
System mmsystem
Data Handling mmodbc, mmetc
Graphics mmive
MIS41160 20
Xpress-MP Product Suite

Xpress-IVE (Interactive Visual Environment) is a MS Windows


based development environment that facilitates editing,
debug and deployment of Mosel models.
Mosel is a high level (modelling and programming) language
that allows the user to define a model in a form similar to its
algebraic notation.
mmxprs is a solver engine (Xpress-Optimizer) that can be used to
solve LP, IP, MIP problems.

MIS41160 21
Xpress-IVE in action
Toolbar

Colour coded
development Output Window
Window

Explorer Window

MIS41160 22
Example – Chess Set Problem1

A small joinery makes two different sizes of boxwood chess sets.


The small set requires 3 hours of machining on a lathe, and the
large set requires 2 hours. There are four lathes with skilled
operators who each work a 40 hour week, so we have 160 lathe-
hours per week. The small chess set requires 1 kg of boxwood,
and the large set requires 3 kg. Unfortunately, boxwood is scarce
and only 200 kg per week can be obtained. When sold, each of
the large chess sets yields a profit of $20, and one of the small
chess set has a profit of $5. The problem is to decide how many
sets of each kind should be made each week so as to maximize
profit.

1
Taken from “FICO Xpress Optimization – User Guide”,

MIS41160 Optimisation in Business 23


First Taste of Mosel

Decision Variables; xs – small sets, xl – large sets

Maximise Profit:= 5*xs + 20*xl


Boxwood:= 1*xs + 3*xl <= 200 kg of boxwood
Lathe:= 3*xs + 2*xl <= 160 Lathe hours

MIS41160 Optimisation in Business 24


First Taste of Mosel
See examples\MoselUG\A1

MIS41160 Optimisation in Business 25


Class Exercise
Task 1
Install the XpressMP package (See Appendix folder for details);
Locate and run the Chess problem (depending on where you
installed, it may be: C:\xpressmp\examples\mosel\UG\A1
Run the Chess model

Task 2
Using the Chess model as a template, amend it to implement the
Pottery problem in Mosel;
Verify the LP solution form you Mosel implementation is the
same as you graphical and MS Excel solutions;
Write the steps and your observations as part of your Learning
Reflection.
MIS41160 26
Class Exercise
Add the following Mosel code to your pottery Mosel model:
!procedure to check problem status
procedure print_status
declarations
status: string
end-declarations
case getprobstat of
XPRS_OPT: status:="LP Optimum found"
XPRS_UNF: status:="Unfinished"
XPRS_INF: status:="Infeasible"
XPRS_UNB: status:="Unbounded"
XPRS_OTH: status:="Failed"
else status:="???"
end-case
writeln("Problem status: ", status)
end-procedure

What does it do?


MIS41160 27
Why should we separate the data from
the model?
If we hard code the parameters into our implementation, we
have to find each occurrence and replace it if the parameter
changes.

For example, the VAT rate was 23%.


As part of the Covid response, it has been reduced to 21%

It’s better practice to declare a variable, and assign it a value


at run time.

MIS41160 28
A Product Mix Example Problem
• Four-product T-shirt/sweatshirt manufacturing company.
 Must complete production within 72 hours
 Truck capacity = 1,200 standard sized boxes.
 Standard size box holds 12 T-shirts.
 One-dozen sweatshirts box is three times size of standard box.
 €25,000 available for a production run.
 500 dozen blank T-shirts and sweatshirts in stock.
 How many dozens (boxes) of each type of shirt to produce?

MIS41160 29
Product Mix Example - Data

Processing Cost Profit


Time (hr) (€) (€)
Per dozen per dozen per dozen
Sweatshirt - F 0.10 36 90

Sweatshirt – B/F 0.25 48 125

T-shirt - F 0.08 25 45

T-shirt - B/F 0.21 35 65

MIS41160 30
A Product Mix Example - Model Construction
Decision Variables:
x1 = sweatshirts, front printing
x2 = sweatshirts, back and front printing
x3 = T-shirts, front printing
x4 = T-shirts, back and front printing
Model:
Maximise Z := €90x1 + €125x2 + €45x3 + €65x4
Such that:
0.10x1 + 0.25x2+ 0.08x3 + 0.21x4  72 hr
3x1 + 3x2 + x3 + x4  1,200 boxes
36x1 + 48x2 + 25x3 + 35x4  €25,000
x1 + x2  500 doz. Sw/shirts
x3 + x4  500 dozen T-shirts
MIS41160 31
Anything else?
Diet Mix Example - Data and Problem Definition
Design a minimum cost breakfast to include at least 420 calories,
5 milligrams of iron, 400 milligrams of calcium, 20 grams of
protein, 12 grams of fibre, and must have no more than 20 grams
of fat and 30 milligrams of cholesterol.

Breakfast Food Fat Cholesterol Iron Calcium Protein Fibre Cost


Cal (g) (mg) (mg) (mg) (g) (g) (€)
1. Bran cereal (cup) 90 0 0 6 20 3 5 0.18
2. Dry cereal (cup) 110 2 0 4 48 4 2 0.22
3. Oatmeal (cup) 100 2 0 2 12 5 3 0.10
4. Oat bran (cup) 90 2 0 3 8 6 4 0.12
5. Egg 75 5 270 1 30 7 0 0.10
6. Bacon (slice) 35 3 8 0 0 2 0 0.09
7. Orange 65 0 0 1 52 1 1 0.40
8. Milk-2% (cup) 100 4 12 0 250 9 0 0.16
9. Orange juice (cup) 120 0 0 0 3 1 0 0.50
10. Wheat toast (slice) 65 1 0 1 26 3 3 0.07

MIS41160 32
Diet Example Model Construction – Decision
Variables
!Try the Xpress Wizards to
Let create more complicated models
x1 = cups of bran cereal, x2 = cups of dry cereal
x3 = cups of oatmeal, x4 = cups of oat bran
x5 = eggs, x6 = slices of bacon
x7 = oranges, x8 = cups of milk
x9 = cups of orange juice, x10 = slices of wheat toast.
The cost is a linear combination:
Z = 0.18x1 + 0.22x2 + 0.10x3 +…..
Similarly, the constraints are linear combinations of the decision
variables.
MIS41160 33
Diet Example Model Summary
Minimise Z = 0.18x1 + 0.22x2 + 0.10x3 + 0.12x4 + 0.10x5 + 0.09x6 + 0.40x7 +
0.16x8 + 0.50x9 + 0.07x10
subject to:
90x1 + 110x2 + 100x3 + 90x4 + 75x5 + 35x6 + 65x7 + 100x8 + 120x9 + 65x10  420 Cal
2x2 + 2x3 + 2x4 + 5x5 + 3x6 + 4x8 + x10  20 Fat
Chol
270x5 + 8x6 + 12x8  30
Iron
6x1 + 4x2 + 2x3 + 3x4+ x5 + x7 + x10  5
Calc
20x1 + 48x2 + 12x3 + 8x4+ 30x5 + 52x7 + 250x8 + 3x9 + 26x10  400
Prot
3x1 + 4x2 + 5x3 + 6x4 + 7x5 + 2x6 + x7 + 9x8+ x9 + 3x10  20
Fibre
5x1 + 2x2 + 3x3 + 4x4+ x7 + 3x10  12
xi  0
• Notice the relationship between columns and constraint limits.
• Check out CAMP (computer assisted Menu Planning)
• Write the algebraic form of this model
34
MIS41160
Class Exercise

1. Compile and run clothing_sweatshirt.mos to solve the


clothing product mix problem
2. Add comments to the model explaining the use of:
• Arrays
• Data assignment
• The Sum construct
• The For loop used to display the optimal decision
variable values.
3. Give at least one suggestion on how the model could
be improved.

MIS41160 35
Mosel Model General Structure

model name !This is a comment


uses "mmxprs" ! Call optimizer

declarations
x1,x2: mpvar
j: integer
S = “Hello World” !could be done outside declarations since it is unambiguous
p: real
end-declarations

!Do stuff
end-model
MIS41160 36
Mosel Basics
• Case Sensitive
• No end-of-line marker
• Restricted Keywords
• declarations, array, of, real, sum, forall
• etc – See Mosel Language Guide
• Elementary Data Types
• integer, boolean, real, string
• mpvar, linctr
• Additional Data Types
• set (collection of elements of a given type)
• array (collection of labelled elements of a given type)
• All objects (scalars and arrays) declared in Mosel are always
initialised with a default value:
real, integer: 0
boolean: false
string: ''
37
MIS41160
Mosel Basics
• Constants:
Note: Anything that is given a value in a declarations block is a constant.
maxIter = 100 declares a constant called maxIter, and gives it the
value 100, implicitly an integer. Note the syntax.
• Ranges:
ITEMS = 1..10 defines a range set, that is, a set of consecutive
integers from 1 to 10, used as an index set for data arrays
• Arrays:
myArr: array (ITEMS) of real defines a one-dimensional array of real
values indexed by the range set ITEMS.
A1: array(ITEMS, 1..20) of real is an example of a 2-dimensional 10
by 20 array of real values.
• Assigning values:
A2D(1):= 5 assigns the value of 5.0 to the first component of the array
A2D.

MIS41160 38
Modelling with Mosel
• Constructs: Summations:

Z:= sum(i in 1..10) myArr(i)*x(i) defines a linear expression called Z.

Naming constraints: Constraints may be named. However, the objective


function must be named (e.g. Z) — so that we can refer to it in the call to
the solver, for example: maximize(Z).
• Simple looping:
• forall(i in ITEMS) x(i) is_binary
• do ….end-do

MIS41160 39
More Mosel

• Data I/O: *.dat (simple text file)


• initializations from ‘myData.dat‘
• end-initializations
• readln and writeln functions,
• SQL/ODBC or Excel Interface

• Logic constructs
• if-then-else … end-if
• if-then-elif …. end-if
• Case …………end-if
• User defined Subroutines
• procedure/end-procedure !No Arguments
• Function/end-function!takes arguments

MIS41160 40
Mosel - Putting it all together!

!Sample forall loop


declarations
team: array(1..10) of integer
end-declarations

forall (i in 1..10) do
writeln( “Index i is ", i)
writeln( "Value of ",i,"th item in array is ", team(i))
end-do

MIS41160 41
Mosel – Where to next?
• Documents
– Mosel Language Reference Manual
– Mosel Users Guide
– Getting Started
– Applications of Optimization with Xpress-MP
• Examples
– Getting Started examples
– Mosel Users Guide
– Applications of Optimization with Xpress-MP

MIS41160 42
Class Exercise
1. Compile and run diet.mos to solve the diet mix problem
– Add comments to the model to explain the syntax used
to initialise the data.
– Add comments to the model to explain the syntax used
to create the constraints.
2. If you’re interested in this area, review the sample
journal articles in the area of LP diet and nutrition
applications:
1. Rodin, E. Y., Donaldson, J., Hammann, M., Kittrell, M., & Mindlin, B. (1990).
Optimal nutrition through linear programming. Mathematical and Computer
Modelling, 13(2), 93-104.
2. Skau, J. K., Bunthang, T., Chamnan, C., Wieringa, F. T., Dijkhuizen, M. A., Roos,
N., & Ferguson, E. L. (2014). The use of linear programming to determine whether
a formulated complementary food product can ensure adequate nutrients for 6-to
11-month-old Cambodian infants. The American journal of clinical nutrition, ajcn-
073700.
MIS41160 43
LP Solution Algorithms
In this section we’ll look at the underlying LP solution
algorithms.

Some Algorithmic approaches exploit the Fundamental


Theorem of Linear programming and explore Boundary
Methods
– Simplex
– Dual Simplex !This is the default method in XpressMP
The number of iterations required for the Simplex Algorithm
increases with model size, usually slightly faster than the
number of constraints.
Other solvers use Interior Point Methods such as the Central
Path Method
MIS41160 44
LP Formats
Standard Form - An LP is in standard form if it reads as;
Find { x i}
n'
To Max z c x
i 1
i i

n'
Subject to: a x  b
i 1
ij i j
j  {1, 2, … , m}

and {xi}  0
The standard form of an LP problem as:
• One whose objective function is maximisation
• One whose constraints are expressed as equations and whose right hand
side (RHS) is non-negative (after the introduction of slack and surplus
variables)
• One in which all the decision variables are non-negative
MIS41160 45
The Simplex Method
The Simplex Method is an algebraic, iterative method to solve linear
programming problems.
– Identify an initial basic solution (Corner point),
– Systematically move to an adjacent basic solution, which improves the value of
the objective function. Eventually, this new basic solution will be the optimal
solution.
• The simplex method requires that the problem is expressed as a
standard LP problem. This implies that all the constraints are
expressed as equations by adding slack or surplus variables.
• The method uses Gaussian elimination (sweep out method) to solve
the linear simultaneous equations generated in the process.

• Simplex is an intelligent hill climbing search procedure which only


investigates some of the basic feasible solutions to find the optimal
solution.

MIS41160 46
Steps of the Simplex Algorithm
Step 0: Using the standard form, determine a starting basic
feasible solution by setting n-m variables to zero (non-basic).
Step 1: Select an entering variable from among the current
non-basic variables, which gives the largest per-unit
improvement in the value of the objective function.
If none exists, stop; the current basic solution is optimal.
Otherwise go to Step 2.
Step 2: Select a leaving variable from among the current
basic variables that must now be set to zero (become non-
basic) when the entering variable becomes basic.
Step 3: Determine the new basic solution by making the
entering variable basic; and the leaving variable non-basic,
and return to Step 1.

MIS41160 47
Simplex Method in Tableau Format
The tableau format allows us to represent the problem compactly
and solve it more easily.
We merely record the coefficients of the problem.
In order to use the Tableau Method, we need to do three things:
1. Represent the LP problem in standard form;
2. Represent the objective function as an equation:
n
z c x
i 1
i i 0

where z is the value of the objective function;


3. Determine the initial basic solution.

MIS41160 48
Example: Setting up the Problem
For instance, the Maximisation Problem: In standard form:
Maximise z = 3x1 + 2x2 z – 3x1 – 2x2 - 0s1 – 0s2 – 0s3- 0s4 = 0

Subject to: Subject to:

x1 + 2x2  6 (1) x1 + 2x2 + 1s1 + 0s2 + 0s3+ 0s4 = 6

(1)
2x1 + x2  8 (2)
2x1 + x2 + 0s1 + 1s2 + 0s3+ 0s4 = 8
-x1 + x2  1 (3) (2)

x2 2 (4) -x1 + x2 + 0s1 + 0s2 + 1s3+ 0s4 = 1

x1 , x 2  0 (3) by the (+1)z since it is the


Maximisation is implied
objective function of the standard form.
x2 + 0s1 + 0s2 + 0s3+ 1s4 = 2
Because they provide an immediate basic feasible solution we choose the slack variables as the
(4)
initial basic variables, and let each xi = 0.
MIS41160 x1, x2, s1, s2, s3, s4  0 49
Maximisation Example
Max z = 3x1 + 2x2
st:
x1 + 2x2  6 (1) 8

Ctr2
2x1 + x2  8 (2) x2
-x1 + x2  1 (3)
6
x2  2 (4)
We select to
x1, x2,  0 Increasing x1 increase the
Increasing x2
Ctr3 by one unit value of x1
by one unit results in an
4
results in an increase of Z
increase of Z Ctr1
of 3 units
of 2 units How much can
we increase x1?
2
Ctr4
x1 =0 The amount of the
x2 =0 increase is limited by
the constraints (One
s1 =6 of the slack variables
s2 =8 2 4 6 x1 becomes zero or non-
s3 =1 MIS41160 basic) 50
s4 =2
Maximisation Example

• We have moved from the original corner-point feasible


solution to another with a higher objective function
8
x2 Z = 12
x1 =4
6
x2 =0
s1 =2
s2 =0
4
s3 =5
Z=0 s4 =2
x1 =0 2

x2 =0
s1 =6
s2 =8 2 4 6 x1
s3 =1 MIS41160 51
s4 =2
Simplex Tableau
The tabular form of the simplex method uses a simplex tableau to
display the system of equations yielding the current basic feasible
solution
There are different ways to design the tableau, a common design is
as follows:
Initial Tableau for the Max problem (Iteration 0)
Header Basic Eq. Z x1 x2 s1 s2 s3 s4 Rt Side
Var. (Sol)
Objective Function z 0 1 -3 -2 0 0 0 0 0
s1 1 0 1 2 1 0 0 0 6
s2 2 0 2 1 0 1 0 0 8
Constraints
s3 3 0 -1 1 0 0 1 0 1
s4 4 0 0 1 0 0 0 1 2

MIS41160 52
Iteration 0 (Steps 0,1,2)
Iter- Basic Eq. Z x1 x2 s1 s2 s3 s4 RHS
ation Var. (Sol)
z 0 1 -3 -2 0 0 0 0 0
s1 1 0 1 2 1 0 0 0 6 6/1

0 s2 2 0 2 1 0 1 0 0 8 8/2
s3 3 0 -1 1 0 0 1 0 1
s4 4 0 0 1 0 0 0 1 2

Pivot
Element
Entering Variable: Select the variable with Leaving Variable: Smallest
the most negative coefficient in the ratio obtained by dividing
objective function the RHS of each row by the
positive coefficients of the
entering variable (Column)
MIS41160 53
Iteration 0 (Step 3)
• To get the new BFS we perform the following steps:
1. Divide the pivot row by the pivot element and call it the “new pivot row.”
Copy the result in the tableau for the next iteration.
2. For every row of the current tableau (excluding the pivot row), subtract the
product of its pivot-column coefficient times the new pivot row. Copy the
result in the corresponding row of the next-iteration tableau. Make sure to
properly identify the new basic variable.

Iter- Basic Eq. Z x1 x2 s1 s2 s3 s4 RHS


ation Var. (Sol)
z 0 1
s1 1 0
1 x1 2 0 1 1/2 0 1/2 0 0 8/2
s3 3 0
s4 4 0

MIS41160 54
Max Example: New Row 1
Basic Eq. Z x1 x2 s1 s2 s3 s4 RHS
Var. (Sol)
Original Equation 1 s1 1 0 1 2 1 0 0 0 6
Minus (1) times new pivot row s2 2 0 1 1/2 0 1/2 0 0 8/2 (-1)

New Equation 1 s1 1 0 0 1.5 1 -0.5 0 0 2

Resulting Tableau (Partial)


Iter- Basic Eq. Z x1 x2 s1 s2 s3 s4 RHS
ation Var. (Sol)
z 0 1
s1 1 0 0 1.5 1 -0.5 0 0 2
x1 2 0 1 0.5 0 0.5 0 0 4
1 s3 3 0
s4 4 0
MIS41160 55
Max example
The operations needed to complete the first iteration are shown:
Initial Tableau
z x1 x2 s1 s2 s3 s4 soln Row ratio workings
X0 1 -3 -2 0 0 0 0 0 R0
s1 0 1 2 1 0 0 0 6 R1 6
s2 0 2 1 0 1 0 0 8 R2 4 min ratio
s3 0 -1 1 0 0 1 0 1 R3
s4 0 0 1 0 0 0 1 2 R4

Leaving Var; most negative co-eff.;x1, Entering Var; Min ratio s2


Create new pivot row R2(1) as R2(0)/pivot element. Add multiples of R2(1) to each Ri(0) to generate next iteration

Iteration 1
z x1 x2 s1 s2 s3 s4 soln Row ratio workings
z 1 0 -0.5 0 1.5 0 0 12 R0
s1 0 0 1.5 1 -0.5 0 0 2 R1 1.333333 min ratio
x1 0 1 0.5 0 0.5 0 0 4 R2 8
s3 0 0 1.5 0 0.5 1 0 5 R3 3.333333
s4 0 0 1 0 0 0 1 2 R4 2

Leaving Var; most negative co-eff.;x2, Entering Var; Min ratio s1

See workings in Excel file on Brightspace.

MIS41160 56
Max example
• On this iteration, what does it mean when there is no negative z
coefficient?
Iteration 2
z x1 x2 s1 s2 s3 s4 soln Row
z 1 0 0 0.333333 1.333333 0 0 12.66667 R0
x2 0 0 1 0.666667 -0.33333 0 0 1.333333 R1
x1 0 1 0 -0.33333 0.666667 0 0 3.333333 R2
s3 0 0 0 -1 1 1 0 3 R3
s4 0 0 0 -0.66667 0.333333 0 1 0.666667 R4

• The optimal solution is Z = 12.67 when x1 = 3.33 and x2 = 1.33.


• Note the slack values s3 and s4.

MIS41160 57
Class Exercise
1. Recall the pottery problem from week 1.

Resource Availability: 40 hrs of labour, 120 lbs of clay.


2. Review the Simplex Algorithm tableaux for the pottery
example (simplex_work Excel spreadsheet on Brightspace),
3. Interpret the values in the tableaux.
4. Rerun your Mosel pottery model (created in part 2):
1. Click the Stats and Matrix tabs in the output widow.
2. Interpret these outputs

MIS41160 58
Class Exercise, pottery; Simplex iterations
Initial Tableau
X0 X1 X2 S1 S2 soln Row ratio workings
X0 1 -40 -50 0 0 0 R0
S1 0 1 2 1 0 40 R1 20 min ratio
S2 0 4 3 0 1 120 R2 40

Leaving Var; most negative co-eff.;X2, Entering Var; Min ratio S1


Create new pivot row. Add multiples of new pivot row to each Ri(0) to generate next iteration

Iteration 1
X0 X1 X2 S1 S2 soln Row ratio workings
X0 1 -15 0 25 0 1000 R0
X2 0 0.5 1 0.5 0 20 R1 40
S2 0 2.5 0 -1.5 1 60 R2 24 min ratio

Iteration 2 No negative z-row coeff;STOP


X0 X1 X2 S1 S2 soln Row
X0 1 0 0 16 6 1360 R0
X2 0 0 1 0.8 -0.2 8 R1
X1 0 1 0 -0.6 0.4 24 R2

See simplex_work Excel file on Brightspace


Summary – What do we know now!
We know how to:
1. Formulate LP problems (algebraically);
2. Solve small LP problems using graphical approach;
3. Interpret the solution from the graphical approach;
4. Use MS Excel to implement small LP models;
5. Use Mosel to formulate and solve small LP problems;
6. Use Mosel language constructs;
• Differentiate between the data types supported;
• Create and use variables and constants;
• Create and use an array of variables;
• Use sum, forall and if statements;
• Read in data from a file.
7. Where to get Mosel sample code and documentation
MIS41160 60

You might also like