ie 316 optimization models and applications part 1: linear ...• don’t forget to check the box...
TRANSCRIPT
IE 316 Optimization Models and Applications
Part 1: Linear Optimization
Instructor: Prof. Aurelie Thiele∗
Fall 2006
Contents
1 The Gemstone Tool Company (IE 220 Review) 3
1.1 The Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Graphical analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Sensitivity analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Solving this problem on the computer . . . . . . . . . . . . . . . . . . . . . 8
1.4.1 Using Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.2 Using AMPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Formulations with a lot of variables (two indices) 10
2.1 Production planning with 2 factories and 3 stores . . . . . . . . . . . . . . 10
2.2 General case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Solving the problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.1 With Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.2 With AMPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.3 Pros and cons of Excel vs AMPL . . . . . . . . . . . . . . . . . . . 13
2.4 Analyzing the results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5 Seat allocation at Lehigh Airlines . . . . . . . . . . . . . . . . . . . . . . . 17
2.6 Network optimization (Routing) . . . . . . . . . . . . . . . . . . . . . . . . 19
2.6.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.6.2 General case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3 Formulations with a lot of variables (three indices) 23
3.1 Example: Sytech International . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.2 General formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
∗[email protected] Mohler 329 Office hours: MW 3.30-5pm Phone: x82903
1
4 Optimization over Time (Multi-Period Problems) 27
4.1 Example: Supply Chain Management . . . . . . . . . . . . . . . . . . . . . 27
4.2 A more general formulation . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5 Piecewise linear functions 32
5.1 Example: Investment Management under Taxation . . . . . . . . . . . . . 32
5.2 Hidden linear problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3 Does any of this really happen in practice? . . . . . . . . . . . . . . . . . . 35
5.4 Inventory problem with backlogged demand . . . . . . . . . . . . . . . . . 37
5.5 Soft constraints and penalty functions . . . . . . . . . . . . . . . . . . . . . 38
5.5.1 Example 1: Additional raw material (or overtime) . . . . . . . . . . 38
5.5.2 Example 2: Penalty functions . . . . . . . . . . . . . . . . . . . . . 39
6 Optimization under Uncertainty 39
2
1 The Gemstone Tool Company (IE 220 Review)
DMD textbook Example 7.2
1.1 The Model
• The Gemstone Tool Company (GTC) plant produces wrenches and pliers.
• 1 wrench produced by GTC uses 1.5 lbs of steel, and spends 1.0 hour on the molding
machine and 0.3 hour on the assembly machine.
• 1 plier produced by GTC uses 1.0 lbs of steel, and spends 1.0 hour on the molding
machine and 0.5 hour on the assembly machine.
• Demand for wrenches is 15,000 per day. Demand for pliers is 16,000 per day.
• Every 1,000 wrenches produced and then sold contribute $130 to the earnings. Every
1,000 pliers produced and then sold contribute $100 to the earnings.
• The amount of steel available each day is 27,000 lbs. The amount of molding machine
capacity is 21,000 hours per day and the amount of assembly machine capacity is
9,000 hours per day.
• The plant manager would like to know how many wrenches and pliers GTC should
produce in order to maximize earnings.
Method to formulate an optimization problem:
1. Define the decision variables (=the quantities you have an influence on). Include
the units.
2. Write down the objective function, and decide if it should be minimized or maxi-
mized.
3. Write down each constraint. Don’t forget nonnegativity (if applicable).
3
Q1: The variables are:
Q2: The objective function is:
Q3: What are the constraints? (It helps to first write what the constraint is about in
words, for instance, “steel capacity”, and then to write it in mathematical terms.)
Q4a: Write the full problem formulation here. Is the problem linear?
Definition: A problem is said to be linear if:
1. The objective is linear in the decision variables (that is, the only thing you can do
4
with decision variables is to multiply them with constant parameters [numbers] and
sum everything).
2. Each constraint is linear in the decision variables.
3. Each constraint is “=”, “≤” or “≥”. < and > are NOT allowed. (The computer
will return an error if you try to solve your problem with < and >.)
Q4b: Rewrite the formulation, considering the number of wrenches and pliers in 1, 000s.
(Why would we want to do that?)
1.2 Graphical analysis
Q5: Plot the feasible set and the isoprofit lines.
Definition: An isoprofit line is a line on which the profit is constant. In minimization
problems, we talk about isocost lines.
5
Q6: Where is the optimal solution on the graph? Which constraints are tight at opti-
mality?
Definition: A constraint is tight (or active) at a point if the left-hand side (LHS) is
equal to the right-hand side (RHS) for that point.
Example: The constraint 3 x + y ≤ 4 is tight at (1, 1).
The fact that a capacity constraint is tight means that all the resource is used.
Equality constraints are always tight!
Geometrically, an active constraint is one that passes through the optimal solution.
Fact: For a linear problem, there is always an optimal solution at one of the corner points
of the feasible set.
Q7: Compute the optimal solution, using the constraints that are tight. What is the
optimal profit?
6
1.3 Sensitivity analysis
Q8: How would the optimal profit change if demand for the wrenches was actually 14,000?
13,000? 12,000? 11,000?
Q9: How would the optimal profit change if we were given an extra 1,000 lbs of steel?
Definition: The shadow price of a constraint is the amount of change in the optimal
objective as the RHS of that constraint is increased by 1 unit, and the rest of the data is
kept constant.
For the calculus-lovers out there, this means:
shadow price =∆(Change in Optimal Objective Value)
∆(RHS).
Definition: The allowable increase, resp. decrease of a constraint is the amount
by which the RHS of that constraint can increase, resp. decrease, without changing the
shadow price.
7
Q10: What is the shadow price of the demand constraint for the wrenches? What is the
shadow price of the steel constraint? What is the allowable decrease for the RHS of the
demand constraint for the wrenches?
1.4 Solving this problem on the computer
Files are posted on Blackboard.
1.4.1 Using Excel
Topics to be covered in class:
• Functions SUMPRODUCT, TRANSPOSE, MMULT (don’t forget to hit the Shift
and Ctrl keys together to fill all the cells you selected) They will really save you a
lot of time when you input constraints and objective.
• Don’t forget to check the box “nonnegative variables”!
• Don’t forget to check the box “assume linear model”! Otherwise Solver will assume
it is nonlinear. Not only will it then solve, or attempt to solve, the problem in a
very inefficient manner, but you won’t have the right sensitivity reports, which give
a lot more information when you tell the computer that the model is linear. If your
sensitivity reports use terms like Lagrangian multiplier and gradient, you forgot to
check that box.
• Solving using Excel Solver and generating sensitivity reports.
1.4.2 Using AMPL
Topics to be covered in class:
• To input the model: model MyModel.mod; (or model MODELS/MyModel.mod;) no
data file for this example
• to solve, type: solve; at the prompt
8
• to see the results: display W,P;
• to send the results to a text file that you can print: display W,P > MyTextFile.txt;
• to see the shadow price of a constraint: display Steel ; ( display Steel.dual;
also works)
• to see reduced cost of a variable (of no interest here) display W.rc;
• before rerunning the model: reset;
Here comes the model file (wrenchespliers.mod)
var W >=0;
var P >=0;
maximize Profit: 130*W+100*P;
subject to Steel: 1.5*W + P <= 27;
subject to Molding: W + P <= 21;
subject to Assembly: 0.3*W +0.5*P<= 9;
subject to WDemand: W <= 15;
subject to PDemand: P <= 16;
In other words, decision variables are defined using var, objective and constraints are
each given a specific name, and constraints are preceded by subject to. All lines end
with ;
By default, AMPL uses the MINOS solver, which only provides shadow prices (and
does not allow for integer variables, which will be useful to remember when we study
integer optimization.) To obtain range information, we need to type at the AMPL prompt:
option solver cplex;
option cplex_options ’sensitivity’;
model MODELS/wrenchespliers.mod;
solve;
assuming the file is saved with the other AMPL mod files. It is very important to type
the two lines with option before you type the one with model. Then the allowable
range for the rhs1 of the constraint named myconstraint is given by: [myconstraint.down,
myconstraint.up]. For instance, type:
1rhs=right-hand side. lhs=left-hand side of a constraint
9
display Steel.down, Steel.up;
at the prompt. Note that Excel gives you the allowable increase and decrease from the
current rhs, and AMPL/CPLEX gives you the allowable values of the rhs. We will give
the pros and cons of Excel vs Solver in Section 2 when we discuss problems of large size.
2 Formulations with a lot of variables (two indices)
Summations with multiple indices; examples on production planning and seat allocation.
2.1 Production planning with 2 factories and 3 stores
• Factory 1 has a supply of T-shirts (number of T-shirts they have already produced)
equal to 40. Factory 2 has a supply of T-shirts equal to 50. 3 stores need to re-stock
T-shirts: store 1 needs 30 T-shirts, store 2 needs 20, store 3 needs 20.
• Transportation costs to ship 1 T-shirt from factory 1 to store 1 is 1, to store 2 is 2,
to store 3 is 3. Transportation costs to ship 1 T-shirt from factory 2 to store 1 is 5,
to store 2 is 3, to store 3 is 2. You want to minimize transportation costs so that
demand at all the stores is met.
Q0: Any comment if factory 2 only has 10 T-shirts in stock instead of 50, and the other
data is left unchanged?
Q1: What are the decision variables?
Q2: What is the objective function?
10
Q3a: Write the constraint about demand at store 1 being met.
Q3b: Write the constraints about demand at stores 2 and 3. What do they have in
common?
Q4a: How is factory 1 constrained? Write the constraint about factory 1.
Q4b: Write the constraint about factory 2 and compare it with the constraint about
factory 1.
2.2 General case
There are m factories and n stores. Supply of T-shirts at factory i, i = 1, . . . ,m, is si.
Demand of T-shirts at store j, j = 1, . . . , n is dj. Unit transportation costs from factory
i to store j is cij.
Q5a: What is the objective function?
11
Q5b: What are the constraints about demand at store j being met, j = 1, . . . , n?
Q5c: What are the constraints about supply at factory i being met, i = 1, . . . ,m?
2.3 Solving the problem
2.3.1 With Excel
See file on Blackboard. To read the answer and sensitivity reports, it helps to have
renamed the cells, e.g., F1toS1 for x11 (amount shipped from factory 1 to store 1).
2.3.2 With AMPL
See files on Blackboard. Here I have used a data file. Files with ‘nosets’ in their title use
the previous formulation, files with ‘withsets’ in their title use the names of the factories
and the stores (can be useful if you don’t want to remember which number you assigned
to which store). Using the ‘withsets’ formulation, I’ve made a run file that solves the
problem and returns the solution and the information on the shadow prices, allowable
range and reduced costs in a text file. This way, if you ever have to solve a production
planning (with only one product, such as T-Shirts, and a linear cost structure), the only
thing you have to do is to change the .dat (data) file. Solve the problem by typing:
include MODELS/prodplanning.run;
assuming that all your files are in the MODELS folder of AMPL. Here is the .run file. The
file prodplanning.txt will be saved at the same level as ampl.exe (that is, the amplcml
folder).
12
# this is file prodplanning.run
option solver cplex;
option cplex_options ’sensitivity’;
model MODELS/prodplanning-withsets.mod;
data MODELS/prodplanning-withsets.dat;
solve;
# formatting the txt file
printf "Solution\n" > prodplanning.txt;
printf "--------\n" > prodplanning.txt;
display x > prodplanning.txt;
printf "Shadow price and allowable range\n" > prodplanning.txt;
printf "--------------------------------\n" > prodplanning.txt;
printf "(Dual var, current rhs, allowable range for rhs)\n" > prodplanning.txt;
display Supply, Supply.current, Supply.down, Supply.up > prodplanning.txt;
display Demand, Demand.current, Demand.down, Demand.up > prodplanning.txt;
printf "Reduced cost\n" > prodplanning.txt;
printf "------------\n" > prodplanning.txt;
display x.rc > prodplanning.txt;
2.3.3 Pros and cons of Excel vs AMPL
• Excel works for a specific instance of a problem, once you know the data (the value
taken by each parameter). If you want to change a number, you have to remember
where it is on the spreadsheet; for instance, if you want to change demand at store
2 from 20 to 25, you have to pay attention to which 20 you are changing (demand
at store 3 is also 20, but should be left unchanged). The major problem with Excel
is that you cannot add factories or stores easily. Adding a column is no big deal,
but then you also have to change ALL the formulas you had defined. 9 times out
of 10, students WILL forget to update one of the formulas. Since the formula will
remain well-defined, Solver will solve the problem but give a wrong solution.
• AMPL’s great advantage is that you can change the data without changing the
model file. Another advantage is that the model file is very close to what you would
write on a piece of paper, while with Excel you need to spend time defining the
functions (using sumproduct etc) properly.
• Another drawback of Excel is that you need to assign a physical location on the
spreadsheet to the data and the decision variables. This is all very nice when you
13
have rows, columns or tables of parameters, but becomes very painful when your
parameters and decision variables have three or more indices. And yes, this happens
all the time. For instance, you could consider the previous planning problem over
time, where the third index becomes the time period. Another extremely common
example is production planning with multiple products (rather than just T-Shirts);
then the third index is the product considered.
• An advantage of Excel is that it gives nice sensitivity reports. AMPL is supposed
to have a graphical interface now, but I haven’t seen it.
• Both AMPL and Excel solve linear problems quickly, but AMPL’s algorithms are
more cutting-edge (useful when you have large problems without hitting the limits
of the student edition, because AMPL will be faster), especially if you use the solver
CPLEX. You don’t want to solve discrete or quadratic problems with Excel. Solver
will in general stop with a solution that is close to optimal but not quite optimal,
and will be very slow. AMPL is fast and reliable.
• Excel solves generic nonlinear problems; AMP doesn’t. However, the solution given
by Excel might not be the true optimal one. More of that when we study nonlinear
optimization.
• Finally, AMPL has a special syntax that allows it to solve piecewise linear and
network problems efficiently using special-purpose formulations and algorithms, but
I don’t think I’ll cover those in much detail.
2.4 Analyzing the results
Solution and sensitivity reports are on next page.
Q6: What is the structure of the optimal solution? (Which factory supplies which store?)
Q7: You are very confident in your data, except unit transportation cost from factory 1
to store 1. What do you need to know about this parameter to be sure that the solution
you found is really the optimal one?
14
Figure 1: The solution of the production planning example.
Figure 2: The sensitivity report for the production planning example.
15
Definition: We have seen that all the regular (not about sign) constraints have a shadow
price, i.e., dual variable. The reduced costs are the shadow prices of the sign (nonneg-
ativity) constraints. (For variables without sign, they do not have much meaning.)
So if x ≥ 0 and x = 5, the constraint is inactive and the “shadow price” of the constraint
(reduced cost of x) is 0. Indeed, if you remember a little bit the simplex method, the
basic variables are strictly positive (unless degeneracy) and their reduced cost was 0.
If x = 0 and the reduced cost is 2, then if you want to force x = a with a very small, then
the change in objective value is 2 a.
In the simplex method, the nonbasic variables had nonzero reduced cost (unless there was
multiple solutions with the same cost) and the reduced cost was the slope of the change
in the objective function if x entered the basis.
More interpretation: The reduced cost of a nonnegative variable currently at zero is the
amount by which the cost coefficient should decrease before you would consider having
this variable non-zero (=enter the basis). (If the amount is negative, say −3, then the
cost coefficient should increase by 3. Would happen in profit maximization problems.)
Q8: By how much should the transportation cost from factory 2 to store 1 decrease before
you start considering factory 2 as a possible supplier for store 1?
Q9: Why is the shadow price of the supply constraint at factory 1 negative?
Q10: Allowable increase of the supply at factory 1 is 10. What do you think happens to
the optimal solution as the supply increases from 40 to 50?
16
Q11: The economy is not doing very well and you are revising your demand forecast.
What would happen to the optimal solution if all demands were decreased by 10?
The case study “Filatoi Riuniti” that starts on p.389 of the textbook provides a nice
illustration of a real-life production/transportation planning problem.
2.5 Seat allocation at Lehigh Airlines
The world-famous Lehigh Airlines operates a fleet of m planes. The planes depart or land
at Mohler International Airport and service n other airports, so that if someone wants
to go from city i to city j, that person has to fly from city i to Mohler and then from
Mohler to city j. (This is the well-known concept of hub-and-spoke in airline revenue
management. For a more realistic example, just think about Continental Airlines and
Newark Airport, or Delta Airlines and Atlanta Airport.)
Let’s call Mohler city 0. The plane from city i (i 6= 0) to the hub has a capacity of Ci0,
the plane from the hub to city j has a capacity of C0j (j 6= 0). There are dij people who
would like to go from city i to city j, i.e., requests for tickets (i, j) (i ≥ 0, j ≥ 0, as some
people might want to leave from or stop at the hub, for instance to go to class in-between
their travels.) The ticket price for these people is fij. As planes have only finite capacity,
you need to decide how many of these dij requests for (i, j) tickets you should accept, for
each pair (i, j).
Let xij for i ≥ 0 and j ≥ 0 be the number of (i, j) tickets you put on sale. The
objective is to maximize total revenue generated by selling the tickets.
Q12a: Let’s draw a graph representing the network.
17
Q12b: Compare number of seats allocated to travelers going from i to j and demand for
(i, j) tickets at optimality. (In other words: does it make sense to allocate more than the
demand?)
Q13: What resources does a ticket holder of type (i, j) use?
Q13: What is the objective function?
Q14: How many people will be on plane i0 (going from city i to the hub)?
Q15: How many people will be on plane 0j (going from the hub to city j)?
Q16: Write the capacity constraints.
18
Q17: Write the complete formulation of the problem.
2.6 Network optimization (Routing)
2.6.1 Example
Previously, we worked on minimizing transportation costs over a very simple network.
The problem was to find how many goods should travel from each factory to each store.
Factories supplied goods (sent goods through the system), stores received goods (took
goods out of the system). In practice, the transportation system might be such that you
need to drive by store 1 to go to store 2, and might be very complex. In this section, we
discuss more general network optimization problems, but still on an example. Hopefully
this is just a review of IE 220. We consider the following network:
Figure 3: A network with 5 nodes.
19
Nodes 1 and 5 are supply nodes and nodes 2, 3, 4 are demand nodes. Since supply is
equal to 5 + 7 = 12 and demand is equal to 3 + 4 + 5 = 12, all the goods in supply are
going to be sent through the network. If they weren’t, we would have to write constraints
at the supply nodes saying “items shipped out of supply node 1 (for instance) are at most
5.”
Q1: Let xij be the number of goods sent from i to j. (Obviously you only care about
(i, j) pairs that correspond to real arcs.) Write the objective function (total cost, which
must be minimized).
Q2: Write the constraints at the supply nodes 1 and 5. (Here, there is no edge going
towards the supply node, so you can just say “number of goods leaving supply node 1 is
equal to 5”, for instance.)
Q3: Write the constraints at the demand nodes 2, 3 and 4. (For instance, at node 2, you
need to write a balance equation: flow in = flow out. “What goes into node 2 must either
leave the network or stay in the network but leave node 2.”
20
2.6.2 General case
Here we consider the general model of network optimization. Such problems arise in
routing (road network, Internet, etc) Goods go through links (also called edge or arc) of
the network to meet demand/supply constraints at each node. Arcs are directed , i.e., on
arc (i, j) the flow can only go from i to j. (If you want to use a link (i, j) both ways, you
need to define an arc (i, j) going from node i to node j and an arc (j, i) going from node
j to node i. We had two types of constraints:
1. Constraints on the flow xij that can go through each edge (i, j). These constraints
are generally of the type: lij ≤ xij ≤ uij, where lij is a lower bound (often 0) and uij an
upper bound (capacity on the link).
2. Constraints on the flow going through each node i of the network. These constraints
are called “balance equations” or “flow conservation constraints” and state that what
flows into a node must equal what flows out of the node. Since what flows into a node
can either come from outside the network (supply) or from elsewhere in the network, and
what flows out of the node can either go out of the network (demand) or to elsewhere in
the network, this can be rewritten as:
flow from elsewhere in the network coming into node i + flow from outside the network
coming into node i (supply at i) = flow from node i going elsewhere in the network + flow
leaving the network at node i (demand at i)
or equivalently:
flow from elsewhere in the network into node i - flow from node i to elsewhere in the
network = demand - supply at i.
To write this in mathematical terms, we need to introduce the following notations. Let
I(i) be the set of nodes k such that (k, i) is an arc (i.e., there exists an arc going from
k to i). Let O(i) be the set of nodes k such that (i, k) is an arc (i.e., there exists an arc
going from i to k). Then the balance equation at node i is written as:
∑k∈I(i)
xki −∑
k∈O(i)
xik = di − si.
If demand and supply at node i are 0, then node i is called a transshipment node. If
demand at node i is > 0 (then supply is 0), node i is called a demand node or sink node.
If demand at node i is < 0 (then demand is 0), node i is called a supply node or source
node.
To use this formulation, supply must equal demand. Since demand must be met, if
supply is strictly less than demand then the problem is infeasible, and we don’t even
have to bother modeling it. If supply is strictly more than demand, then we have enough
21
to meet demand, and we add a fictitious node, say node 0, that is connected to the
supply nodes with edges of cost 0, and which has a demand equal to the excess supply∑ni=1 si −
∑ni=1 di. Then you can use the balance equations for that new network.
You might remember for IE 220 that linear problems defined on networks can be solved
more efficiently than generic linear problems, and there was a special algorithm designed
just for networks called the network simplex method. For our toy problems you don’t
care about efficiency and solving network linear problems as any other linear problems
will work just fine, but if you ever have to solve larger problems, you won’t want to wait
three hours for the solution. Of course you need to tell the software that there is a network
in there, otherwise it is not going to figure it out by itself. Excel Solver is not able to
understand there is a network, but AMPL can if you use the right syntax, based on some
node-arc terminology. When you use this terminology in AMPL, net in corresponds to
the left-hand side, and AMPL is able to determine the flow by itself using the definition
of the network.
As an intellectual curiosity2, here is the mod file corresponding to the network in the
previous section, to be solved using AMPL’s network simplex method. You need to use
the solver cplex for it to work. Files are posted on Blackboard, including dat file and mod
file to solve the network problem as any other linear problem. Again, if you wanted to
re-use them, you would just have to change the dat file.
set Nodes;
set Links within (Nodes cross Nodes);
param supply{Nodes} >=0;
param demand{Nodes}>=0;
param cost{Links} >=0;
minimize Total_Cost;
node Balance {k in Nodes}: net_in = demand[k]-supply[k];
arc Ship {(i,j) in Links} >=0, from Balance[i], to Balance[j],
obj Total_Cost cost[i,j];
2read: you don’t have to know this for the quiz
22
3 Formulations with a lot of variables (three indices)
Examples of problems that use three indices include production planning over time and
multi-commodity transportation problem (where you want to transport several types of
goods through a network.) In this section we focus on multi-commodity transportation
problems. Section 4 deals with multi-period problems in more detail.
3.1 Example: Sytech International
DMD textbook p.380.
• Sytech manufactures computers and peripheral equipment.
• It has plants in Burlington (MA), Taiwan and Ireland.
• 4 product types: MainFrame, MiniComputers, PCs, and Printers.
• It sells its products in 2 main markets: North America and Europe.
• The question is: how many products of each type should Sytech manufacture at
each plant for each market?
• Example: Sytech should manufacture 5,000 PCs in Taiwan for the North American
market.
• Three types of information: the type of product manufactured, the plant it is man-
ufactured in, the market where it is going to be sold. That gives us 3 things to keep
track of, i.e., 3 indices in our decision variables.
• Let xijk be the number of items of type i produced at plant j for market k.
• Students who don’t like 3 indices sometimes use notations like B12 for number of
products of type 1 (MainFrame) manufactured in Burlington for market 2 (Europe).
That’s fine on an example, but impossible to extend to the general case.
• You don’t manufacture more than the demand. Two types of capacities at each
plant: space and labor. Objective is to maximize profit, where profit depends on
product, plant that produced the product (due to for instance different wages) and
market (transportation costs).
Data is given below.
23
Product North America EuropeMainframe 962 321Mini 4,417 1,580PC 48,210 15,400Printer 15,540 6,850
Table 1: Forecast demand for each product in each market.
Square LaborPlant (1,000 sq.feet) (1,000 hours)Burlington 540.71 277.71Taiwan 201.00 499.24Ireland 146.90 80.17
Table 2: Plant capacities.
Product Space/Unit Labor Hours/UnitMainFrame 17.48 79.0Mini 17.48 31.5PC 3.00 6.9Printer 5.30 5.6
Table 3: Resource utilization rates.
MainFrame MiniNorth North
Plant America Europe America EuropeBurlington $16,136.46 $13,694.03 $8,914.47 $6,956.23Taiwan $17,358.14 $14,709.96 $9,951.04 $7,852.36Ireland $15,652.68 $13,216.34 $9,148.55 $7,272.89
PC PrinterNorth North
America Europe America EuropeBurlington $1,457.18 $1,037.57 $1,663.51 $1,345.43Taiwan $1,395.35 $1,082.49 $1,554.55 $1,270.16Ireland $1,197.52 $1,092.61 $1,478.90 $1,312.44
Table 4: Unit profit contributions.
24
Q0: If there was no (space and labor) capacity constraint, where would we manufacture
products of each type?
Q1: What is the objective function?
Q2: Write the space constraint at each plant.
Q3: Write the labor constraint at each plant.
Q4: Write the demand constraint for each product and each market.
25
MainFrame MiniNorth North
Plant America Europe America EuropeBurlington 0 0 1,683 0Taiwan 962 321 1,769 0Ireland 0 0 965 1,580
PC PrinterNorth North
America Europe America EuropeBurlington 14,395 0 15,540 6,850Taiwan 33,815 15,400 0 0Ireland 0 0 0 0
Table 5: Solution.
Q5: Solution is given in Table 5 (and on p.388.) Compare with ideal case of Q0 to check
that solution makes sense. (This is also known as sanity check and is very useful to see if
there are any obvious mistake in the model.)
3.2 General formulation
Q6: Write the general formulation corresponding to the multi-commodity problem in the
previous section when we have I product types, J plants and K markets.
26
4 Optimization over Time (Multi-Period Problems)
4.1 Example: Supply Chain Management
The exercise below is based on the case “Supply Chain Management at Dellmar, Inc.”,
DMD textbook Chapter 9 p.474-5, except that we assume that the fixed transportation
costs are zero. (To model fixed transportation costs we would need binary variables. We
will do that in the last part of the course when we work on integer optimization.)
• Dellmar manufactures the commercial air-conditioning system “Cushion-Air-Pro”
system at its manufacturing plant in New Hampshire. The plant has the capacity
to manufacture up to 50,000 Cushion-Air-Pro units a month.
• Dellmar has 3 sales regions (East Coast, West Coast, Midwest)
• Each region is served by a regional distribution center (DC): Wilmington, Delaware
serves the East Coast, Salinas, California serves the West Coast, and St Louis,
Missouri serves the Midwest.
• Dellmar operates 2 national distribution centers: 1 in Ohio (serves the Midwest and
the West Coast), and 1 in New Jersey (serves the Midwest and the East Coast).
• Completed Cushion-Air-Pro units are shipped from the plant in New Hampshire
to the two national distribution centers (in Ohio and New Jersey), where they are
stored for shipment to the 3 regional DCs.
• Shipments occur once a month. Dellmar keeps inventory both at the 2 national
distribution centers as well as the 3 regional sales distribution centers.
• Unit cost of shipping from plant to national DC or from a national DC to a regional
DC is $10.
• Unit inventory cost (of holding in inventory) at the national DCs in OH and NJ is
$5/unit/month. Unit inventory cost (of holding in inventory) at the regional DCs
is $10/unit/month.
• The goal is to minimize the total transportation and inventory costs over the months
of April and May.
• Forecasted demand and estimated inventories at the end of March are provided
below.
27
Sales Region Month Forecast Demand (units)West Coast April 20,000
May 20,000Midwest April 15,000
May 25,000East Coast April 25,000
May 30,000
Table 6: Forecasted demand.
Distribution center UnitsNational DCs Ohio 20,000
New Jersey 10,000Regional DCs West Coast 2,000
Midwest 1,000East Coast 2,000
Table 7: Estimated inventories at the end of March.
Q0: Let’s draw a graph of the network and put as much data as we can there.
Q1: What are the decision variables?
28
Q2: What is the inventory level at the end of April at each of the regional and national
distribution centers?
Q3: What is the inventory level at the end of May at each of the regional and national
distribution centers?
Q4: How do you model the fact that customer demand at the end of April and May must
be met? (Hint: we know the West Coast DC starts the month of April with an inventory
of 2,000. Can April demand be met if that DC receives 10,000 units during the month?
15,000 units? 18,000? 20,000?)
29
Q5: How do you model the fact that the national DCs cannot ship products they do not
have in inventory? (Hint: The DC in Ohio starts the month of April with 20,000 units.
Let’s say it receives 10,000 units during the month. What is the maximum number of
units it can ship during the month?)
Method: In inventory problems, the fact that a factory/warehouse/store in the network
cannot ship to the rest of the network more than what it has in inventory is modelled
by saying that inventory at that factory/warehouse/store must be nonnegative. That is
because inventory is measured right after everything has been received and shipped. For
end points in the network, the fact that customer demand must be met is also modelled
by saying that inventory at that point must be nonnegative.
Q6: What is the cost function?
Transportation Cost =
Inventory Cost =
Q6: What are the constraints?
Q7: How would you decide whether Dellmar should increase its production capacity by
10% if it was just for one month? And if it was for both months?
30
4.2 A more general formulation
A company must deliver di units of its product at the end of the i-th month. Material
produced during a month can be delivered either at the end of the same month or can
be stored as inventory and delivered later. There is a unit production cost of c per unit
produced and a unit holding cost of h per unit stored and per month stored. The year
begins with zero inventory. (During each time period, some amount is produced, then
products are shipped to the customers and the rest is put into, or remains in, storage.
Inventory holding costs are computed at the very end of the month.) The problem is to
find a production schedule to minimize total costs over T time periods.
Method: Define the control variables, then define the state variables (defining the state of
the system at time t). The true decision variables are the control variables (e.g., amount
we produced). State variables (e.g., amount in inventory) are auxiliary variables that we
could compute using the dynamics of the system (once you decide how much you produce
and the customers have taken the products they wanted, you don’t have any choice except
putting the remaining items in inventory), but it is more convenient to define them in
clear to avoid making mistakes. At that point you can use the same approach as for a
regular optimization problem: define the costs and constraints, without forgetting bounds
such as nonnegativity.
Q9: What are the decision variables? (control and state)
Q10: Write an equation linking what is in inventory at the beginning of time period t
with what is in inventory at the beginning of time period t + 1.
Q11: How do you model the fact that customer demand must be met at the end of each
month?
31
Q12: Write the full problem formulation.
5 Piecewise linear functions
5.1 Example: Investment Management under Taxation
(From DMD Exercise 7.15 p.409)
Last year, you purchased si of stock i at price qi, i = 1, . . . , n. The current price per
share of stock i is pi, and you expect it to be equal to ri next year, with i = 1, . . . , n.
You need to raise an amount C to pay your tuition at Lehigh this semester. However,
once you have sold any shares, you need to pay a transaction cost of 1% of the amount
transacted, and you must also pay a capital-gains tax at the rate of 30% on any capital
gains (measured on the value of the whole portfolio) at the time of the share. You do
not pay a tax in case of losses (measured on the value of the whole portfolio). You want
to formulate the problem of selecting how many shares of which stocks you need to sell
in order to generate the cash amount C, net of capital gains and transaction costs, while
maximizing the expected value of your portfolio next year.
Q13: What are the decision variables?
Q14: What is the objective function?
Q15: What is the total transaction cost?
32
Q16: What is the total capital-gain cost?
Q17: Write down the full (nonlinear) formulation of this problem.
Q18: Can we rewrite this problem as a linear one? If yes, how?
5.2 Hidden linear problems
As I have already mentioned and will mention again when we study nonlinear optimiza-
tion, nonlinear problems (which include piecewise linear problems) are A LOT harder to
solve than linear problems, and the algorithms available are less efficient. Therefore, if a
nonlinear problem can actually be rewritten as a linear one, we really want to be aware
of it and exploit that to solve the problem faster using linear optimization techniques.
Q19: Which ones of these constraints can be rewritten as linear constraints? For the
others, how can you solve the problem using two linear problems?
(a) max(3 x + 1,−5 x + 2) ≤ 10
33
(b) max(3 x + 1,−5 x + 2) ≥ 10
(c) min(3 x + 1,−5 x + 2) ≤ 10
(d) min(3 x + 1,−5 x + 2) ≥ 10
Remember:
1. A problem with either/or constraints cannot be reformulated as a single linear prob-
lem. You can reformulate it as a single problem with binary variables (more on that
when we study integer optimization) or you have to split the problem into 2n sub-
problems (where n is the number of either/or constraints you have in your original
formulation) and enumerate all the cases.
2. Whether a problem with min or max constraints is easy to reformulate depends on
the sign of the inequality in the constraint.
What about piecewise linear functions in the objective?
Method: The problem min f(x) (subject to whatever constraints) is equivalent to min Z
subject to Z ≥ f(x) and whatever constraints. That’s because you’ll want to decrease Z
as much as you can (since it is a minimization problem) until it hits its lower bound f(x),
so at optimality Z = f(x). Then if f(x) is piecewise linear, we just need to apply what
we have seen on piecewise linear constraints.
Similarly, solving the problem max f(x) (subject to whatever constraints) is equivalent
(in the sense that it gives the same x and the same objective value) to max Z subject to
Z ≤ f(x) and whatever constraints. Note that the sign of the inequality has changed.
That’s because you’ll want to increase Z as much as you can (since it is a maximization
problem) until it hits its upper bound f(x).
Q20: Which ones of these problems can be rewritten as one linear problem? For the
others, what would you do to solve the problem easily?
34
(a) min max(3 x + 1,−5 x + 2) s.t.− 10 ≤ x ≤ 10
(b) max max(3 x + 1,−5 x + 2) s.t.− 10 ≤ x ≤ 10
(c) min min(3 x + 1,−5 x + 2) s.t.− 10 ≤ x ≤ 10
(d) max min(3 x + 1,−5 x + 2) s.t.− 10 ≤ x ≤ 10
Remember: We “like” max min and min max problems (in the sense that they can
be rewritten as single linear problems if what was inside the min or max was linear in
the decision variables, in which case they are easy to solve because we can use linear
programming techniques), but neither min min nor max max.
5.3 Does any of this really happen in practice?
Assume that all the wrenches and pliers in our favorite example are sold to the same
customer. To maintain good business relations with him, you have decided to give him
a discount: you will sell wrenches at $130 per 1,000s if the total amount sold is below
10,000 (W ≤ 10) and $117 (10% discount) for the wrenches sold in excess of 10 units
(10,000 wrenches).
Q21a: Draw a graph representing the price as a function of the total number of wrenches
sold.
35
Q21b: Write the total profit from the wrenches as a piecewise linear function.
Q21c: Similarly, you will sell pliers at $100 per 1,000s if the total amount sold is below
7,000 (P ≤ 7) and $90 (10% discount) for all pliers sold once you have reached 7 units.
How would you model this, and is this problem easy or hard to solve? How would you
reformulate it as a linear problem?
Q22: What if we want to apply the discount to all the units (W ) once we have reached
the threshold (10 for W )? (Draw a graph representing the price as a function of the total
number of wrenches sold.)
Remember: Functions with jumps cannot be represented using linear constraints or ob-
36
jective. Statements using variables becoming 0 or 1 will be modelled using binary vari-
ables.
Q23: We now have two potential customers bidding for those highly fashionable items
that are wrenches and pliers. Customer 1 is willing to buy wrenches at a unit cost of $110
(per 1,000 units) and pliers at a unit cost of $120 (per 1,000 units). Customer 2 is willing
to buy wrenches at a unit cost of $120 (per 1,000 units) and pliers at a unit cost of $110
(per 1,000 units). The contract (i.e., all the wrenches and pliers produced) is awarded to
the highest-paying customer. What is the new objective function? Is this problem easy
or hard to solve?
5.4 Inventory problem with backlogged demand
Q24: We are considering the inventory example, except that demand does not have to
be met anymore. If there is not enough items in store, demand is backlogged, i.e., the
company would keep the order on its books and fill it as soon as items become available.
Explain why this means that we allow inventory to be negative.
Q25: Let b be the unit backorder cost. Inventory costs at each time period are now h y if
you hold y units in inventory at the end of the time period (y > 0 when you hold items)
and −b y if you are missing −y units (y < 0 when you are missing units). What is the
new objective function?
37
Q26: Formulate the problem as a linear one.
5.5 Soft constraints and penalty functions
So far we have seen constraints that must be enforced, e.g., we cannot use more steel
than is available. These constraints are called hard constraints (must hold no matter
what). In practice however, there might be constraints that the decision-maker would
rather enforce, but doesn’t find terribly important. These are called soft constraints.
You model these constraints by adding a penalty term to the objective function to account
for what happens when they are violated.
5.5.1 Example 1: Additional raw material (or overtime)
For instance, if you need more than the 27 units of steel you have on hand, you are willing
to order at most 5 more at a unit cost of 3 each. This would replace/modify the hard
constraint: 1.5W + P ≤ 27.
Q27: Write the new problem and either reformulate it as a single linear problem or
explain why it can’t be a single LP.
Important : When we say we like max min problems, there must be a positive coefficient
in front of the min (so that it remains a min problem if we bring everything inside the
min).
max −2 ·min(3 x+2,−2 x+1) is not a max min problem, because bringing the −2 inside
38
would yield max max(−2 (3 x + 2),−2 (−2 x + 1)), which is a max max problem.
5.5.2 Example 2: Penalty functions
A typical example of soft constraints is overbooking on airplanes. As you might have
noticed, airline executives don’t care much about making sure they don’t sell more than
capacity, because they hope people are not going to show up. In overbooking, you allow
the number of tickets sold to exceed the capacity of a plane, but factor in a penalty, say,
to buy food vouchers to the people who will be stranded at the airport.)
Q28: In the Lehigh Airlines example (Section 2.5), explain how you can change the model
to incorporate a penalty pi0 per passenger overbooked on flight (i, 0) and p0j per passenger
overbooked on flight (0, j).
6 Optimization under Uncertainty
DMD Section 7.7 (starts on page 367): Steel supply planning at Gemstone Tool Company
(GTC).
So far we have assumed that we had all the information we needed before taking
decisions. In practice, this is often an irrealistic assumption: for instance, we might need
to start production before we know the exact value taken by the demand. This section
shows to address decision-making under uncertainty using a technique called stochastic
programming.
We have seen in Section 1 that the production planning problem could be formulated
39
as:max 130 W + 100 P
s.t. 1.5 W + P ≤ 27,
W + P ≤ 21,
0.3 W + 0.5 P ≤ 9,
0 ≤ W ≤ 15,
0 ≤ P ≤ 16.
The optimal solution is W = 12, P = 9 with a contribution to earnings of $2, 460. For the
current quarter, GTC has contracted with a steel supplier for the delivery of 27,000lbs of
steel per day, which was incorporated in the model as:
1.5 W + P ≤ 27.
Now GTC is planning for next quarter, and would like to determine how much steel to
contract for with local suppliers for the next quarter.
• The market price for such contracts is $58.00/1,000lbs. Let S be the amount of
steel to contract for, in 1,000lbs/day.
• The assembly capacity is uncertain. GTC has ordered new machines, but it is not
known whether these machines will be delivered in time to be used next quarter. We
assume assembly machine capacity for next quarter will either be 8,000 hours/day
(with probability 0.5) or 10,000 hours/day (with probability 0.5).
• The unit contribution to earnings of production of wrenches next quarter is uncertain
due to fluctuations in the market for wrenches. We assume that this unit earnings
contribution will either be $90 (with probability 0.5) or $160 (with probability 0.5).
• The rest of the data is unchanged.
Data can be summarized as follows. GTC must first decide how much steel per day to
Wrenches Pliers AvailabilitySteel (lbs) 1.5 1.0 TBDMolding (hours) 1.0 1.0 21,000 hours/dayAssembly (hours) 0.3 0.5 either 8,000 hours/day
or 10,000 hours/dayDemand (tools/day) 15,000 16,000Contribution to either $160earnings ($/1,000 units) or $90 $100.
Table 8: Data for the production planning problem.
contract for, for next quarter. This is called a first-stage decision (decision you take
40
before seeing the value taken by the uncertain parameters.) Then uncertainty is revealed:
at the beginning of next quarter, the assembly machine capacity will become known, and
the unit earnings contribution of wrenches will become known. Then GTC will decide
how many wrenches and pliers to produce. These are called second-stage decisions
because they are taken after uncertain parameters have been observed.
Q1: What are the possible scenarios (“states of the world”) next quarter? What is the
probability of each?
Q2: What are the decision variables? (Hint: some decision variables depend on the
scenario we are in. That requires indexing them by the scenario number. For instance:
W1 is the number of wrenches produced in scenario 1.)
Q3: Formulate the problem faced by GTC (with an objective of maximizing expected
profit.) Is this problem linear?
41