Professional Documents
Culture Documents
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.
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 = ...;
subject to
{
Z == ProductionCost + PurchasingCost + HoldingCost;
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.
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 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
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];
}