You are on page 1of 8

IE301 Recitation 3

Questions & Solutions

1) Multi period Multi product production planning model


A factory wants to decide how to produce three items over the next 12 months with the minimum total
cost. The demand forecast for each item in each month is given in Table 1 and assumed to be
accurate.
Table 1: Demand over the planning horizon.
1 2 3 4 5 6 7 8 9 10 11 12
Item 1 100 140 101 55 40 90 44 15 20 33 45 100
Item 2 15 26 33 28 34 27 19 33 67 100 109 89
Item 3 27 45 59 80 78 67 43 14 23 87 90 18

The factory can either produce the items in-house or purchase from another factory by paying a price
higher than the unit production cost. The production capacity for each item is specified in the last
column of Table 2.
Table 2: Unit production cost and production capacity.
1 2 3 4 5 6 7 8 9 10 11 12 Capacity
Item 0.1 2 1 0.5 0.4 0.9 1.4 0.3 1 0.3 0.4 0.6 100
1
Item 4 2 4 3 2 3 4 3 1 4 2 4 80
2
Item 1.1 1.5 1.4 1.4 1.6 1.1 1.1 0.7 0.6 0.6 0.5 0.7 50
3

However, outsourcing is limited due to transportation restrictions and it should not be higher than 70
units/month for the first and third items, and 75 units/month for the second item.

Table 3: Purchasing cost per item.


1 2 3 4 5 6 7 8 9 10 11 12 Limit
Item 1 2 2 2 3 3 3 4 4 2 2 2 2 70
Item 2 5 5 5 5 5 5 5 5 5 5 5 5 75
Item 3 2 2 2 2 2 2 2 2 2 2 1 1 70

All unsold items are kept in the warehouse at a unit holding cost of $0.5/month for item 1, $0.8/month
for item 2, and $0.3/month for item 3. The total warehouse capacity shared by all items is 100 units.
Initially, 30 units of the first and second items and 20 units of the third item are in the warehouse.
Assume that the holding cost for these initial inventories is already paid.
a) Formulate a linear programming model to solve the company's problem.
b) Implement and solve the model in Cplex Studio. Your code should read the problem parameters
from a spreadsheet.
IE301 Recitation 3
Questions & Solutions

Solution:
a) Parameters:
hi = unit inventory holding cost per month for item i (time-independent)
oij = unit purchasing cost of item i in month j
cij = unit production cost of item i in month j
H = warehouse capacity shared by all items
Ui = monthly production capacity of item i (time-independent)
Li = monthly upper limit on the number of units of item i purchased (time-independent)
dij = demand of item i in month j
ii0= initial inventory level of item i

Decision Variables:
xij = number of units of item i=1, 2, 3, produced in month j=1, 2,, 12
yij = number of units of item i=1, 2, 3, purchased in month j=1, 2,, 12
Iij = number of units of item i=1, 2, 3, in inventory at the end of month j=1, 2,, 12
Model:
12 3
= ( + + )
=1 =1

Subject to:
= 1 + + i = 13, j = 112

0 = 0 i = 13
3=1 j = 112

0 i = 13, j = 112

0 i = 13, j = 112

0 i = 13, j = 112
IE301 Recitation 3
Questions & Solutions
b) Model file:
int items = ...;
int months = ...;

range item_range = 1..items;


range month_range = 1..months;

float holding_cost[item_range] = ...;


float purchasing_cost[item_range, month_range] = ...;
float prod_cost[item_range, month_range] = ...;
int H = ...;
int UB_X[item_range] = ...;
int UB_Y[item_range] = ...;
int demand[item_range, month_range] = ...;
int initial_inventory[item_range] = ...;

dvar float+ x[item_range, month_range];


dvar float+ y[item_range, month_range];
dvar float+ I[item_range, month_range];

dvar float+ ProductionCost;


dvar float+ PurchasingCost;
dvar float+ HoldingCost;
dvar float+ Z;
minimize Z;

subject to
{
Z == ProductionCost + PurchasingCost + HoldingCost;

sum(i in item_range, j in month_range)


prod_cost[i,j] * x[i,j] == ProductionCost;

sum(i in item_range, j in month_range)


purchasing_cost[i,j] * y[i,j] == PurchasingCost;

sum(i in item_range, j in month_range)


holding_cost[i] * I[i,j] == HoldingCost;

forall(i in item_range, j in month_range)


ct_InventoryBalance:
{
if (j == 1)
initial_inventory[i] + x[i,j] + y[i,j] - demand[i,j] == I[i,j];
else
I[i,j-1] + x[i,j] + y[i,j] - demand[i,j] == I[i,j];
}

forall(i in item_range, j in month_range)


{
x[i,j] <= UB_X[i];
y[i,j] <= UB_Y[i];
}

forall(j in month_range)
ct_warehouse:
{
sum(i in item_range)(I[i,j]) <= H;
}
}
IE301 Recitation 3
Questions & Solutions
Data file:
items = 3;
months = 12;

H = 100;

SheetConnection sheet("Data.xlsx");
demand from SheetRead(sheet,"params!B3:M5");
prod_cost from SheetRead(sheet,"params!B10:M12");
purchasing_cost from SheetRead(sheet,"params!B17:M19");
holding_cost from SheetRead(sheet,"params!N3:N5");
initial_inventory from SheetRead(sheet,"params!O3:O5");
UB_X from SheetRead(sheet,"params!N10:N12");
UB_Y from SheetRead(sheet,"params!N17:N19");

The resulting optimal production and outsourcing plan is given in the following tables with a total
cost of $3003.4. The breakdown of the total cost is:
Total production cost = $2314.7,
Total purchasing cost = $522;
Total holding cost = $166.7;
Production quantities
1 2 3 4 5 6 7 8 9 10 11 12
Item 1 100 40 100 55 40 90 44 35 0 33 45 100
Item 2 0 44 0 28 80 0 0 40 80 80 80 80
Item 3 50 11 50 50 50 50 43 24 50 50 50 18

Outsourcing quantities
1 2 3 4 5 6 7 8 9 10 11 12
Item 1 0 70 1 0 0 0 0 0 0 0 0 0
Item 2 0 0 0 0 0 0 0 0 0 0 29 9
Item 3 0 0 0 30 28 17 0 0 0 0 40 0

Inventory levels
1 2 3 4 5 6 7 8 9 10 11 12
Item 1 30 0 0 0 0 0 0 20 0 0 0 0
Item 2 15 33 0 0 46 19 0 7 20 0 0 0
Item 3 43 9 0 0 0 0 0 10 37 0 0 0
IE301 Recitation 3
Questions & Solutions
2) Maximum flow through a network
When a network has capacity limitations on the flows through the arcs there is often interest in finding
the maximum flow of some commodity between a set of sources and sinks. Consider the following
network in Figure 1.

Figure 1. The graph of the network with 8 nodes and 11 arcs.

Suppose that the number on an arc denotes the maximum capacity of the corresponding pipe from the
tail to the head node. Formulate the problem of maximizing the total amount of flow from the sources
(nodes 0 and 1) to the sinks (nodes 5, 6, and 7) as an LP and solve it by CPLEX.
Solution:
Define xij as the flow on the arc from node i to node j. For ease of modeling, imagine that we
introduce one dummy source node and one dummy sink node. The dummy source node S is only
connected to the actual source nodes 0, 1, and the dummy sink node T is only connected to the actual
sink nodes 5, 6, and 7. Five new variables xS0, xS1, x5T, x6T and x7T are introduced representing the
flows on the dummy arcs into sources 0 and 1 and out of the sinks 5, 6, and 7, respectively. These five
arcs have infinite capacity.

The objective maximizes the total flow out of the dummy source node S, which eventually must flow
into the dummy sink node T. The first set of constraints are referred to as the flow balance
IE301 Recitation 3
Questions & Solutions
constraints they simply state that the total inflow minus the total outflow at a given node (0 through
7) must be equal to the demand of the node. In this particular application, the demands at all nodes are
equal to zero; therefore, we always have total inflow = total outflow. (In other network optimization
applications, node demands may be different from zero.) The second set of constraints specifies the
arc capacities. Note that non-negativity constraints must also be imposed on the x-variables.
They have been omitted from the formulation by mistake.
This type of model has the property that the optimal solution yields integer flows as long as the
capacities are integers; therefore, defining the decision variables as integer is not necessary. Try in
CPLEX!
CPLEX Code
int NumberOfArcs = 16; //the dummy arcs must be represented explicitly in
the model.
int NumberOfNodes = 8; //the dummy source and sink nodes do not have to be
introduced explicitly.
range arcs = 1..NumberOfArcs;
range nodes = 1.. NumberOfNodes;

//The order of the arcs in the following data structures is:


//x_{S0}, x_{S1}, x_{02}, x_{13}, x_{23}, x_{24}, x_{25}, x_{34}, x_{37}, x_{42},
//x_{45}, x_{46}, x_{76}, x_{5T}, x_{6T}, x_{7T}.
float c[arcs] = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
float A[nodes, arcs] = [ [1, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0,-1,-1,-1, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0,-1,-1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 1, 0,-1,-1,-1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,-1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,-1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,-1, 0, 0,-1]
];
float UB[arcs] = [infinity, infinity, 12, 20, 6, 3, 6, 7, 9, 2, 5,
8, 4, infinity, infinity, infinity];

dvar float+ x[arcs]; //arc flows

maximize sum(i in arcs)c[i]*x[i];//total outflow out of the dummy source node S


subject to
{
forall(j in nodes) sum(i in arcs)A[j, i]* x[i] == 0; //these are the
flow balance equations at nodes 0, 1, ..., 7
forall(i in arcs) x[i] <= UB[i]; //upper bounds on the arc flows
}

The maximum flow from the source to the sink nodes is 25 with the following solution vector:

Variables xs0 xs1 x02 x13 x23 x24 x25 x34 x37 x42 x45 x46 x76 x5T x6T x7T
Value 9 16 9 16 0 3 6 7 9 0 5 5 0 11 5 9
IE301 Recitation 3
Questions & Solutions
3) Facility location (p-Median) problem
As an officer of the local UNICEF office, your task is to manage the administration of the next
vaccine shots. In particular, you are in charge of an area where there are || number of settlements
(such as towns, villages, etc.) in which there are kids to be vaccinated. However, only some of the
settlements are accessible by vehicles and only these can be used as distribution points since the
vaccines need to be transported via special trucks. The set of such candidate distribution points is
denoted by where denotes the set of settlements and you have only < || number of these
special trucks at your disposal.
Moreover, you want to assign each settlement to a specific distribution point in order to prevent a
potential clutter. The distance between settlement and candidate distribution point is
units and this distance has to be traveled on foot by the villagers. The estimated number of villagers in
settlement who will need to visit a distribution center is denoted by .
At the end of the day, you need to decide on the destination of the trucks (i.e., the locations of the
distribution points) and the assignment of the settlements to the distribution points in order to
minimize the total walking distance of the villagers. Formulate this problem as an integer linear
programming problem. Hint: Some decisions can only be represented by using binary variables.

Solution:
We have two sets of binary variables representing the two types of decisions we need to make. The
binary variable takes the value 1 if a distribution point is located in settlement and is 0
otherwise. The binary variable takes the value 1 if settlement is assigned to distribution point
and is 0 otherwise. The formulation of the problem is given by

minimize ,

s. t. ,

= 1, ,

, , ,

{0,1}, , ,

{0,1}, .

The first constraint ensures that the number of distribution points opened is not greater than the
number of trucks. The second and third sets of constraints, together, guarantee that each settlement is
assigned to exactly one open distribution point to get the vaccination service.
IE301 Recitation 3
Questions & Solutions
Model file:
int T = 8; // number of available trucks

int Nsettlements = 80; // |I|: number of settlements


range I = 1 .. Nsettlements; // set of settlements
range J = 1 .. Nsettlements; // set of candidate distribution points
// For simplicity, we assume here that I = J.

int p[i in I] = ; // number of visitors from the settlements


// to be read from the data file
int d[i in I, j in J] = ; // distances to be read from the data file

dvar boolean y[j in J]; // distribution point locations


dvar boolean x[i in I, j in J];// settlement distn point assignments

minimize
sum ( i in I, j in J ) p[i] * d[i, j] * x[i, j];

subject to {
sum ( j in J ) y[j] <= T;

forall ( i in I )
sum ( j in J ) x[i, j] == 1;

forall ( i in I, j in J )
x[i, j] <= y[j];
}

You might also like