nicolai n. pisaruk mixed integer programming in operations ... · mixed integer programming in...

101
Nicolai N. Pisaruk Mixed Integer Programming in Operations Management (MIPCL-PY manual) MINSK 2018

Upload: nguyenngoc

Post on 20-Jul-2018

261 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Nicolai N. Pisaruk

Mixed Integer Programmingin

Operations Management(MIPCL-PY manual)

MINSK 2018

Page 2: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

N.N. Pisaruk. Mixed Integer Programming in operations management (MIPCL-PY manual).

The goal of operations managers is to efficiently use raw materials, human resources, equipment, andfacilities in supplying quality goods or services. Entry-level operations managers determine how bestto design, supply, and run business processes. Senior operations managers are responsible for settingstrategic decisions from an operations standpoint, deciding what technologies should be used, wherefacilities should be located, and managing the facilities making products or providing services.

This manual discusses diverse applications of optimization in operations management. We do notrestrict ourselves to formulating mathematical models. Anyone who has ever attempted to apply math-ematical programming in practice knows that it is usually not a simple and straightforward exercise. Tofacilitate this task, optimization modeling languages were designed to easily implement optimizationproblems as computer programs. All the models considered in the manual are converted into Python pro-grams using the MIPCL-PY module that facilitates modeling and solving mixed-integer programmingproblems with MIPCL (Mixed-Integer Programming Class Library). These simplified but practical com-puter programs can be used as templates for developing applications that support particular operationsmanagement decisions.

Aimed at undergraduates, postgraduates, research students and managers, this manual shows howoptimization is used in operations management.

This manual may be copied, printed, and distributed in unaltered form both on paper and electronicmedia. It may be included in archives and on web sites. You are not allowed to make any changes tothe file or to reverse engineer its source; you are not allowed to charge for its distribution — whether inphysical or electronic form — beyond reasonable material costs.

c©N.N. Pisaruk, 2018

Page 3: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii

1 Aggregate Production Planning 11.1 Single Product Lot-Sizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.1.1 Basic Single Product Lot-Sizing Problem . . . . . . . . . . . . . . . . . . . . . 11.1.2 Lot-Sizing With Backordering . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.3 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1.4 Aggregate Planning Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.2 Multiproduct Lot-Sizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.2.1 Mixed-Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . 71.2.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.2.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2 Operations Scheduling 152.1 Scheduling Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.1.1 Time-Index Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.1.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.1.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.2 Electricity Generation Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.2.1 Mixed-Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . 202.2.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.3 Short-Term Scheduling in Chemical Industry . . . . . . . . . . . . . . . . . . . . . . . 242.3.1 Mixed-Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . 262.3.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.3.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2.4 Project Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.4.1 Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 322.4.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.4.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3 Facility Layout 413.1 Process Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

3.1.1 Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 423.1.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.1.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

3.2 Balancing Assembly Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

i

Page 4: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

ii Contents

3.2.1 Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 473.2.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483.2.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

4 Service Management 514.1 Service Facility Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4.1.1 Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 514.1.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524.1.3 Examples of Usage: Locating Two Medical Clinics . . . . . . . . . . . . . . . . 53

4.2 Data Envelopment Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544.2.1 Linear Programming Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 544.2.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564.2.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

4.3 Yield management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.3.1 Yield Management In Airline Industry . . . . . . . . . . . . . . . . . . . . . . . 604.3.2 Mixed-Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . 614.3.3 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634.3.4 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

5 Logistics management 715.1 Fixed Charge Network Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

5.1.1 Mixed-Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . 725.1.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.1.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

5.2 Single Depot Vehicle Routing problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 755.2.1 Mixed Integer Programming Formulation . . . . . . . . . . . . . . . . . . . . . 765.2.2 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775.2.3 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

5.3 Multi-Dimensional Packing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805.3.1 Integer Programming Formulation of m-KP . . . . . . . . . . . . . . . . . . . . 815.3.2 Tightening Basic Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835.3.3 MIPCL-PY Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845.3.4 Example of Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

Bibliography 91

Index 93

Page 5: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Preface

Operations management may be defined as the design, operation, and improvement of the production sys-tems that create the firm’s primary products and services. A production system uses operations resourcesto transform inputs (raw materials, customer demands, or finished products from another productionsystem) into outputs (finished products or services). Operations resources include people, plants, parts,processes, and planning and control systems (five P’s of operations management).

• People are the direct and indirect workforce.

• Plants include the factories or service units where production is carried out.

• Parts comprise the materials or supplies.

• Processes include equipment and technological processes.

• Planning and control systems perform procedures and information management to operate theproduction system.

Operations decisions are made in the context of the firm as a whole (see Figure 1). Starting fromits marketplace (the firms’s customers for its products and services), the firm determines its corporatestrategy. This strategy is based on the corporate mission, and in essence, it reflects how the firm plansto use all its resources and functions (marketing, finance, and operations) to gain competitive advantage.The operations strategy specifies how the firm will employ its production capabilities to support itscorporate strategy. The marketing strategy addresses how the firm will sell and distribute its goods andservices, and the finance strategy identifies how best to utilize the firm’s financial resources.

Operations management decisions can be divided into three broad categories:

• strategic (long-term) decisions;

• tactical (intermediate-term) decisions;

• operational planning and control (short-term) decisions.

Strategic issues usually address such questions as:

• How will we make the product?

• Where do we locate the facilities and what are their capacities?

• Where do we sell our products and services?

iii

Page 6: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

iv Preface

Marketplace

?Corporate Strategy

?? ?

?

Finance Strategy Operations Strategy Marketing Strategy

Operations Management

?? ? ? ?

People Plants Parts Processes

Planning and Control Systems

Production System

Inputs-

MaterialsCustomers

Outputs-

ProdutsServices

Figure 1: Firm’s decision chart

The time horizon for strategic decisions is typically very long. These decisions impact firm’s long-rangeeffectiveness in terms of how it can address its customer’s needs. Thus, for the firm to succeed, strategicdecisions must be consistent with firm’s corporate strategy. These decisions become operating constraintsunder which firm’s decisions are made in both the intermediate and short term.

At the next level in the decision-making process, tactical planning primarily addresses how to effi-ciently use materials and labor within the constraints of previously made strategic decisions. Issues to bemanaged on this level are:

• How many workers do we need, and when do we need them?

• Should we work overtime or put a second shift?

• When should we have material delivered?

• Should we have raw materials and finished products inventory?

Tactical decisions, in turn, become the operating constraints for making operational planning andcontrol decisions. Issues at this level include:

• What jobs be done today or this week?

• Who is assigned to a particular task?

• What jobs are most urgent?

All example applications considered in this manual (and many more) are included into the MIPCL-PY installation bundle. Specifically, the python modules are in the mipcl-py/models folder, while

Page 7: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Preface v

examples of usage of those modules are in the mipcl-py/tests folder. Here mipcl-py stands forthe installation directory of MIPCL-PY. For example, the module multlotsize, which implementsthe multiproduct lot-sizing problem, is in mipcl-py/models, and an example, testMultLotSi-ze.py, of its usage is in mipcl-py/test/multlotsize.

Page 8: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management
Page 9: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Chapter 1

Aggregate Production Planning

Aggregate production planning is intermediate-range planning (usually covers a planning horizon fromone to several months) that is concerned with determining production rates for some product groups. Anaggregate plan is to find an optimal trade off of production rates, used resources, and inventory1 levels.In this chapter we consider aggregate production planning models of different complexity. Usually, thesemodels are integrated into supply chain systems that manage the flows of information, materials, andservices from raw material supplies through factories and warehouses to the end customers.

1.1 Single Product Lot-Sizing

Simple inventory models, such as EOQ and its extensions, are based on the assumption that the con-sumption is instantaneous and the demand for product is constant per time unit These assumptions aretoo ideal, and, therefore, may be too restrictive in practice. The demand for a product is rarely constantbecause of season fluctuations and many other reasons. The product production and storage costs alsodepends on the season. In this section we consider a few more realistic model.

1.1.1 Basic Single Product Lot-Sizing Problem

The problem is to decide on a production plan for a single product within a T -period horizon. For eachperiod t the following parameters are known:

ft: fixed production setup cost;

pt: unit production cost;

ht: unit inventory cost (includes storage cost, insurance, taxes, and the cost of capital tied up in inven-tory);

dt: product demand;

ut: production (or transportation) capacity.

The problem is to determine the amounts of the product to be produced in each of T periods so that thedemands in all periods are fully satisfied, the production (transportation) capacities are not violated, andthe total cost of producing and storing the product is minimum.

To formulate this problem as a mixed-integer program (MIP), we introduce the following variables:1Inventories are stocks of goods being held for future use or sale.

1

Page 10: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2 Chapter 1. Aggregate Production Planning

xt: amount of product produced in period t;

st: stock at the end of period t;

yt: with yt = 1 if production occurs in period t, and yt = 0 otherwise.

With these variables the problem is formulated as follows:

T∑t=1

ptxt +

T∑t=1

htyt +

T∑t=1

ftyt → min (1.1a)

st−1 + xt = dt + st, t = 1, . . . , T, (1.1b)

xt ≤ utyt, t = 1, . . . , T, (1.1c)

st, xt ≥ 0, yt ∈ {0, 1}, t = 1, . . . , T. (1.1d)

Let us note that the initial stock, s0, is not a variable but an input parameter.The balancing constraints (1.1b) ensure a proper transition from any period to the next one: the

inventory from period t− 1 plus the production in period t equals the demand (sales) in period t plus theinventory to the next period.

The capacity constraints (1.1c) (such constraints are also called variable upper bounds) require thatin any period t the product is produced only if the production occurs in this period (yt = 1), and theamount produced, xt, does not exceed the production capacity for this period.

The objective (1.1a) is to minimize the total production cost.

1.1.2 Backordering and Overtime Production

When production capacities are not sufficient to meet all demands in required terms, sometimes it isallowed that a product demanded in period τ can be delivered in later period t (τ < t) with a discount ofbtτ that includes cost of expediting, loss of customer goodwill (usually hard to measure), and a possiblediscount. This is called backordering or backlogging.

In some cases it is also convenient to divide each time period into a number of production periods.For example, we may produce in regular time and in overtime. Overtime production is, of course, moreexpensive. Therefore, let us assume that there are Tp production periods, and fτ , pτ , uτ are, respectively,fixed production cost, unit production cost, and production capacity in production period τ = 1, . . . , Tp.As before, ht and dt denote the unit storage cost and demand in period t = 1, . . . , T .

To model backordering, we use the following variables:

xτt: amount of product produced in production period τ to satisfy demand of period t;

yτ = 1 if production occurs in production period τ , and yτ = 0 otherwise.

With these variables the model (1.1) is extended as follows:

Tp∑τ=1

T∑t=1

cτtxτt +

Tp∑τ=1

fτyτ → min , (1.2a)

Tp∑τ=1

xτt = dt, t = 1, . . . , T, (1.2b)

Page 11: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

1.1. Single Product Lot-Sizing 3

T∑t=1

xτt ≤ uτyτ , τ = 1, . . . , Tp, (1.2c)

xτt ≥ 0, τ = 1, . . . , Tp, t = 1, . . . , T, (1.2d)

yτ ∈ {0, 1}, τ = 1, . . . , Tp. (1.2e)

Here the costs cτt are defibed by the rule:

cτtdef=

pτ , t = T (τ),

pτ + bτt, t < T (τ),

pτ +∑τ−1

t̄=t ht̄, t > T (τ),

(1.3)

where T (τ) denote the time period that contains production period τ .The formulation (1.2) does not take into account the initial stock. But we can correct this by intro-

ducing in the first time period a production period, say indexed by 0, with production capacity u0 equalto the initial stock, and production cost p0 = 0.

In the conclusion, let us note that the famous transportation problem is a special case of MIP (1.2)when all fixed costs fτ are zeroes (what implies that all yτ may be fixed to 1).

1.1.3 MIPCL-PY Implementation

Our implementation of MIP (1.2) in Listing 1.1 is straightforward.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s B a c k l o g l o t s i z e ( Problem ) :d e f model ( s e l f , d , u , f , c ) :

s e l f . f , s e l f . c = f , cT , Tp = l e n ( d ) , l e n ( u )s e l f . x = x = VarVec to r ( ( Tp , T ) , ” x ” )s e l f . y = y = VarVec to r ( [ Tp ] , ” y ” , BIN )

min imize (sum ( c [ t a u ] [ t ]∗ x [ t a u ] [ t ] f o r t a u i n r a n g e ( Tp ) \

f o r t i n r a n g e ( T ) i f c [ t a u ] [ t ] >= 0) +\sum ( f [ t a u ]∗ y [ t a u ] f o r t a u i n r a n g e ( Tp ) )

)

f o r t i n r a n g e ( T ) :sum ( x [ t a u ] [ t ] f o r t a u i n r a n g e ( Tp ) ) == d [ t ]

f o r t a u i n r a n g e ( Tp ) :sum ( x [ t a u ] [ t ] f o r t i n r a n g e ( T ) ) <= u [ t a u ]∗ y [ t a u ]

f o r t a u i n r a n g e ( Tp ) :f o r t i n r a n g e ( T ) :

i f c [ t a u ] [ t ] < 0 :x [ t a u ] [ t ] == 0 ;

Listing 1.1: MIPCL-PY implementation of lot-sizing with backordering: model

Page 12: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4 Chapter 1. Aggregate Production Planning

Input parameters:

• d: list, where d[t] is demand for product in period t;

• u: list, where u[t] is is production capacity in period t;

• f: list, where f[t] is fixed cost of starting production in period t;

• c: list of lists, where c[tau][t] is cost of producing one unit of product in period t, and thensupplying that unit to meet demand for period tau.

When a solution is found, one may want to print it in a readable way. Listing 3.6 presents a procedure— which is a member of Backloglotsize — that does this job.

d e f p r i n t S o l u t i o n ( s e l f ) :f , c = s e l f . f , s e l f . cx , y = s e l f . x , s e l f . yTp , T = l e n ( x ) , l e n ( x [ 0 ] )

prodCos t , f x C o s t = 0 , 0p r i n t ( ’ ’ )p r i n t ( ’ | Prod . | p r o d u c e s | f o r demand | ’ )p r i n t ( ’ | p e r i o d | ( u n i t s ) | p e r i o d | ’ )

f o r t a u i n r a n g e ( Tp ) :prod =k =0;i f y [ t a u ] . v a l > 0 . 5 :

p r i n t ( ’|−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|’ )f x C o s t += f [ t a u ]

f o r t i n r a n g e ( T ) :v a l = i n t ( x [ t a u ] [ t ] . v a l )i f v a l > 0 :

prod += v a l

p r o d Co s t += c [ t a u ] [ t ]∗ v a li f k > 0 :

s t r = ’ | | ’e l s e :

s t r = ’ | { : 4 d} | ’ . f o r m a t ( t a u )p r i n t ( s t r + ’ { : 8 d} | { : 4 d} | ’ . f o r m a t ( va l , t +1) )k += 1

p r i n t ( ’ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ’ )p r i n t ( ’ P r o d u c t i o n c o s t − ’ + r e p r ( p r o d Co s t ) )p r i n t ( ’ F ixed c o s t − ’ + r e p r ( f x C o s t ) )

Listing 1.2: MIPCL-PY implementation of lot-sizing with backordering: printSolution

1.1.4 Aggregate Planning Example

A plant producing vehicles is to elaborate an aggregate plan for a month divided into four weeks withdemand forecast as 1000 units in each. The capacity available is 4400 units per month:

• weeks 1 and 4: 600 in regular time and 200 in overtime;

Page 13: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

1.1. Single Product Lot-Sizing 5

Table 1.1: Aggregate planning data

Production Sales periods Fixed Totalperiods 1 2 3 4

Stock costs capacity

Stock 0 50 100 150 200 0 100

Reg. time 1500 1550 1600 1650 1700 0 6001Overtime 2000 2050 2100 2150 2200 100000 200

Reg. time 2000 1500 1550 1600 1650 0 10002Overtime 2500 2000 2050 2100 2150 100000 400

Reg. time — 2000 1500 1550 1600 0 1000003Overtime — 2500 2000 2050 2100 100000 400

Reg. time — — 2000 1500 1550 0 6004Overtime — — 2500 2000 2050 100000 200

Demand 1000 1000 1000 1000 200 4500

• weeks 2 and 3: 1000 in regular time and 400 in overtime.

At the beginning of the month there are 100 cars in inventory. Therefore an excess capacity is 500(100 + 2 · 1400 + 2 · 800− 4 · 1000). However, it is highly desired to have 200 units in inventory at theend of the month. The inventory cost (holding cost + insurance + lost revenue) of one unit is $50 for eachweek. The average workforce cost per car is $1500 in regular time, and $2000 in overtime. Overtime is,of course, more expensive to start with; therefore there is an additional fixed cost of $10000 to organizeovertime production in each week.

Table 1.1 presents our example as an instance of the lot-sizing problem (1.2). Here we have

• 9 production periods: one artificial period represents the initial stock, the other 8 correspond toregular time and overtime production in each of four weeks;

• 5 consumption periods: each of four weeks is a consumption period, and one artificial periodrepresents the stock at the end of the month.

The numbers in four columns marked as ”Sales periods” are the costs cτ,t, calculated by the rule (1.3).A dash in a cell indicates that a car produced in the period that corresponds to the cell row cannot bedelivered to a customer that ordered a car to be delivered in the period that corresponds to the cell column.

To solve this example, we wrote the program presented in Listing 1.3.

# ! / u s r / b i n / py thonfrom b a c k l o g l o t s i z e i m p o r t B a c k l o g l o t s i z e

d = [ 1 0 0 0 , 1000 , 1000 , 1000 , 200]u = [ 1 0 0 , 600 , 200 , 1000 , 400 , 1000 , 400 , 600 , 200]f = [ 0 , 0 , 100000 , 0 , 100000 , 0 , 100000 , 0 , 100000]c = [

[ 0 , 50 , 100 , 150 , 2 0 0 ] ,[ 1 5 0 0 , 1550 , 1600 , 1650 , 1 7 0 0 ] ,[ 2 0 0 0 , 2050 , 2100 , 2150 , 2 2 0 0 ] ,

Page 14: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

6 Chapter 1. Aggregate Production Planning

[ 2 0 0 0 , 1500 , 1550 , 1600 , 1 6 5 0 ] ,[ 2 5 0 0 , 2000 , 2050 , 2100 , 2 1 5 0 ] ,[ −1, 2000 , 1500 , 1550 , 1 6 0 0 ] ,[ −1, 2500 , 2000 , 2050 , 2 1 0 0 ] ,[ −1, −1, 2000 , 1500 , 1 5 5 0 ] ,[ −1, −1, 2500 , 2000 , 2 0 5 0 ] ,

]p rob = B a c k l o g l o t s i z e ( ” t e s t 1 ” )prob . model ( d , u , f , c )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 1.3: Example of usage of class Backloglotsize

If we run the above program, we get the following result.

| Prod . | p r o d u c e s | f o r demand || p e r i o d | ( u n i t s ) | p e r i o d ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 0 | 100 | 1 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 1 | 600 | 1 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 2 | 200 | 1 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 3 | 800 | 2 || | 200 | 5 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 4 | 100 | 1 || | 200 | 2 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 5 | 600 | 3 || | 400 | 4 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 6 | 400 | 3 ||−−−−−−−−+−−−−−−−−−−+−−−−−−−−−−−−|| 7 | 600 | 4 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

P r o d u c t i o n c o s t − 6700000 , F ixed c o s t − 300000

Listing 1.4: Output of program from Listing 1.3

1.2 Multiproduct Lot-Sizing

We need to work out an aggregate production plan for n different products processed on a number ofmachines of m types for a planning horizon that extends over T periods.

Inputs parameters:

• lt: duration (length) of period t;

• mit: number of machines of type i available in period t;

• fit: fixed cost of producing on machine of type i in period t;

• Tmini , Tmax

i : minimum and maximum working time of one machine of type i;

Page 15: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

1.2. Multiproduct Lot-Sizing 7

• cjt: per unit production cost of product j in period t;

• hjt: inventory holding cost per unit of product j in period t;

• djt: demand for product j in period t;

• ρjk: number of units of product j used for producing one unit of product k;

• τij : per unit production time of product j on machine of type i;

• sij : initial stock of product j at the beginning of the planning horizon.

• sfj : final stock of product j at the end of the planning horizon.

The goal is to determine the production levels for each product and each period so that to minimizethe total production and inventory expenses over planing horizon.

1.2.1 Mixed-Integer Programming Formulation

We introduce the following variables

xjt: amount of product j, produced in period t;

sjt: amount of product j in stock at the end of period t;

yit: number of machines of type i working in period t.

Now we formulate the problem as follows:

T∑t=1

n∑j=1

(hjt sjt + cjt xjt) +T∑t=1

m∑i=1

fit yit → min, (1.4a)

sij + xj1 = dj1 + sj1 +n∑k=1

ρjk xk,1, j = 1, . . . , n, (1.4b)

sj,t−1 + xjt = djt + sjt +n∑k=1

ρjk xk,t, j = 1, . . . , n; t = 2, . . . , T, (1.4c)

n∑j=1

τij xjt ≤ ltyit, i = 1, . . . ,m; t = 1, . . . , T, (1.4d)

sjT = sfj , j = 1, . . . , n, (1.4e)

0 ≤ sjt ≤ uj , xjt ≥ 0, j = 1, . . . , n; t = 1, . . . , T, (1.4f)

0 ≤ yit ≤ mit, yit ∈ Z, i = 1, . . . ,m; t = 1, . . . , T. (1.4g)

The objective (1.4a) prescribes to minimize the total production and inventory expenses. The balanceequations (1.4b) and (1.4c) join two adjacent periods: product in stock in period t− 1 plus that producedin period t equals the demand in period t plus the amount of product used when producing other products,and plus the amount in stock in period t. The inequalities (1.4d) require that the working times of allmachines be withing given limits; besides, if machine i does not work in period t (yit = 0), then noproduct is produced by this machine (all xjt = 0).

Page 16: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

8 Chapter 1. Aggregate Production Planning

1.2.2 MIPCL-PY Implementation

We implemented our multiproduct lot-sizing application as a class named MultLotSize, which de-scription is given in listings 1.5–1.7. The function that implements MIP (1.4), as usually, is calledmodel. Its imlementation is given in listings 1.5 and 1.6.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s M u l t L o t S i z e ( Problem ) :d e f model ( s e l f , l , p r o d u c t s , machines ) :

d e f s0 ( j ) : r e t u r n p r o d u c t s [ j ] [ 0 ] [ 0 ]d e f s f ( j ) : r e t u r n p r o d u c t s [ j ] [ 0 ] [ 1 ]d e f u ( j ) : r e t u r n p r o d u c t s [ j ] [ 0 ] [ 2 ]d e f d ( j , t ) : r e t u r n p r o d u c t s [ j ] [ 1 ] [ t ]d e f c ( j , t ) : r e t u r n p r o d u c t s [ j ] [ 2 ] [ t ]d e f h ( j , t ) : r e t u r n p r o d u c t s [ j ] [ 3 ] [ t ]d e f rho ( j , k ) : r e t u r n p r o d u c t s [ j ] [ 4 ] [ k ]d e f mn( i , t ) : r e t u r n machines [ i ] [ 0 ] [ t ]d e f f ( i , t ) : r e t u r n machines [ i ] [ 1 ] [ t ]d e f t a u ( i , j ) : r e t u r n machines [ i ] [ 2 ] [ j ]

s e l f . p r o d u c t s , s e l f . machines = p r o d u c t s , machinesm, n , T = l e n ( machines ) , l e n ( p r o d u c t s ) , l e n ( l )

Listing 1.5: MIPCL-PY implementation of multiproduct lot-sizing: model (part 1)

Input parameters:

• l: list, where l[t] is duration of period t;

• products: list of lists, where product = products[j] has the following fields:

– product[0][0]: initial stock of product j;

– product[0][1]: final stock of product j;

– product[0][2]: storage capacity for product j;

– products[1][t]: demand in period t for product j;

– products[2][t]: unit production cost in period t for product j;

– product[3][t]: unit holding cost in period t for product j;

– product[4][k]: quantity of product j used in production of one unit of product k;

• machines: list of lists, where machine = machines[i] has the following fields:

– machine[0][t]: number of machines of type i available in period t;

– machine[1][t]: fixed cost of running one machine of type i in period t;

– machine[2][j]: time needed to produce one unit of product j on machine i.

To keep our MIPCL-PY-model closely consistent with the MIP (1.4), we define a number of single-line local functions that extract the values of model parameters from input data. With those functionsimplementation of (1.4) is straightforward.

Page 17: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

1.2. Multiproduct Lot-Sizing 9

s e l f . s = s = VarVec to r ( [ n , T ] , ” s ” )s e l f . x = x = VarVec to r ( [ n , T ] , ” x ” , INT )s e l f . y = y = VarVec to r ( [m, T ] , ” y ” , INT )

min imize (sum ( c ( j , t ) ∗x [ j ] [ t ] + h ( j , t ) ∗ s [ j ] [ t ] f o r j i n r a n g e ( n ) f o r t i n r a n g e ( T ) )

+ sum ( f ( i , t ) ∗y [ i ] [ t ] f o r i i n r a n g e (m) f o r t i n r a n g e ( T ) ))f o r j i n r a n g e ( n ) :

s0 ( j ) + x [ j ] [ 0 ] == d ( j , 0 ) + s [ j ] [ 0 ] \+ sum ( rho ( j , k ) ∗x [ k ] [ 0 ] f o r k i n r a n g e ( n ) i f rho ( j , k ) > ZERO)

f o r t i n r a n g e ( 1 , T ) :f o r j i n r a n g e ( n ) :

s [ j ] [ t −1] + x [ j ] [ t ] == d ( j , t ) + s [ j ] [ t ]\+ sum ( rho ( j , k ) ∗x [ k ] [ t ] f o r k i n r a n g e ( n ) i f rho ( j , k ) > ZERO)

f o r i i n r a n g e (m) :f o r t i n r a n g e ( T ) :

sum ( t a u ( i , j ) ∗x [ j ] [ t ] f o r j i n r a n g e ( n ) i f t a u ( i , j ) > ZERO) \<= l [ t ]∗ y [ i ] [ t ]

y [ i ] [ t ] <= mn( i , t )f o r j i n r a n g e ( n ) :

f o r t i n r a n g e ( T−1) :s [ j ] [ t ] <= u ( j )

s [ j ] [ T−1] == s f ( j )

Listing 1.6: MIPCL-PY implementation of multiproduct lot-sizing: model (part 2)

Let us note that the value of ZERO is defined in the mipshall.py module to be 1.0e-12.

Printing schedules

When a solution is found, one may want to print it in a readable way. Listing 1.7 presents a procedure,named printSolution, — which is a member of MultLotSize — that does this job. This proce-dure displays three tables named ”Production”, ”Stock”, and ”Machines”. All these tables are printed bythe printTbl procedure, which implementation is given in Listing 1.7 as well.

d e f p r i n t T b l ( s e l f , tblName , r o w T i t l e , c o l T i t l e , x ) :n , T = l e n ( x ) , l e n ( x [ 0 ] )p r i n t ( ’\n ’ + tblName + ’ : ’ )p r i n t ( ’ ’ + ’ ’ ∗ (10∗ n +8) )p r i n t ( ’ | | ’ + r o w T i t l e . c e n t e r (10∗n−1) + ’ | ’ )p r i n t ( ’ | ’ + ’− ’ ∗ (10∗ n +8) + ’ | ’ )s t r = ’ | ’ + c o l T i t l e . c e n t e r ( 6 ) + ’ | ’f o r j i n r a n g e ( n ) :

s t r += r e p r ( j +1) . c e n t e r ( 8 ) + ’ | ’p r i n t ( s t r )p r i n t ( ’|−−−−−−−−+’ + ’−−−−−−−−−+’ ∗ ( n−1) + ’−−−−−−−−−| ’ )f o r t i n r a n g e ( T ) :

s t r = ’ | ’ + r e p r ( t +1) . c e n t e r ( 6 ) + ’ | ’f o r j i n r a n g e ( n ) :

s t r += f o r m a t ( x [ j ] [ t ] . va l , ’ . 2 f ’ ) . r j u s t ( 8 ) + ’ | ’p r i n t ( s t r )

p r i n t ( ’ ’ + ’− ’ ∗ (10∗ n +8) )

d e f p r i n t S o l u t i o n ( s e l f ) :p r i n t ( ’ O b j e c t i v e v a l u e = { : . 4 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )

Page 18: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

10 Chapter 1. Aggregate Production Planning

s e l f . p r i n t T b l ( ’ P r o d u c t i o n ’ , ’ P r o d u c t s ’ , ’ P e r i o d ’ , s e l f . x )s e l f . p r i n t T b l ( ’ S tock ’ , ’ P r o d u c t s ’ , ’ P e r i o d ’ , s e l f . s )s e l f . p r i n t T b l ( ’ Machines ’ , ’ Machines ’ , ’ P e r i o d ’ , s e l f . y )

Listing 1.7: MIPCL-PY implementation of multiproduct lot-sizing: auxiliary procedures

1.2.3 Example of Usage

An engineering factory makes seven products (numbered from 1 to 7) on the following machines: fourgrinders, two vertical drills, three horizontal drills, one borer, one planer, and two packing devices.Products 5 and 7 are complete sets: one unit of product 5 comprises one unit of product 1 and one unitsof product 3, and one unit of product 7 comprises one unit of product 1 and two unit of product 6. Unitproduction times (in hours) required on each process are given in Table 1.2. A dash indicates that aproduct does not require a process. All required processes on each product unit can be applied in anyorder. So, no sequencing problem need to be considered.

The planning horizon consists of six months from January to June. The demands for products aregiven in Table 1.3. The factory works a 5 day week with two shifts of 8 hours each day. The number ofworking days in each month is also presented in Table 1.3.

During the planning horizon some machines will be down for maintenance. The setup cost of amachine mainly is the fixed salary of an operator. As the planer needs two operators, its setup cost istwo times bigger than the setup costs of the other machines. Machine setup costs, and the numbers ofmachines of each type available in each month are given in Table 1.4.

Unit production costs depend on the production period. These costs are given in Table 1.5. We seethat it is more expensive to produce in the cold months (January, February, and March) than in the warmones (April, May, and June).

It is possible to store up to 100 units of each product at a cost of $1 per unit per month. There is notany unit of any product in stock at the beginning of the planning horizon but it is decided to have a stockof 50 units of each product at the end of June.

When and what should the factory produce to maximize the total profit?To get an answer to the above question, we wrote the program displayed in Listing 1.8.

# ! / u s r / b i n / py thonfrom m u l t l o t s i z e i m p o r t M u l t L o t S i z e

Table 1.2: Unit Production Times

ProductsProcesses

1 2 3 4 5 6 7

Grinding 0.5 0.7 — — 0.3 0.2 0.5Vertical drilling 0.1 0.2 — 0.3 — 0.6 —Horizontal drilling 0.2 — 0.8 — — — 0.6Boring 0.05 0.03 — 0.07 0.01 — 0.08Planing — — 0.01 — 0.05 — 0.05Packing 0.1 0.1 0.1 0.1 0.1 0.1 0.15

Page 19: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

1.2. Multiproduct Lot-Sizing 11

Table 1.3: Demands for Products

Working ProductsMonths days 1 2 3 4 5 6 7

January 19 500 1000 300 300 800 200 100February 19 600 700 200 0 400 300 150March 22 300 600 0 0 500 400 100April 22 200 300 400 500 200 0 100May 21 0 100 500 100 1000 300 0June 21 500 500 100 300 1100 500 60

Table 1.4: Machines Available and their Setup Costs

Setup Available machinesMachine cost Jan Feb Mar Apr May Jun

Grinder 500 6 5 5 6 5 5Ver. driller 450 3 3 2 2 3 3Hor. driller 450 5 3 5 5 5 5Borer 550 2 2 1 2 1 2Planer 1000 1 2 2 1 2 2Packing dev. 400 2 2 2 2 2 2

Table 1.5: Production Costs

ProductsPeriods

1 2 3 4 5 6 7

January, February, March 17 19 16 8 9 16 25April, May, June 16 17 15 7 8 14 22

Page 20: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

12 Chapter 1. Aggregate Production Planning

l = [ 3 0 4 , 304 , 352 , 352 , 336 , 336] # d u r a t i o n s o f a l l p e r i o d s

p r o d u c t s = [[

( 0 , 50 , 100) ,[ 500 , 600 , 300 , 200 , 0 , 5 0 0 ] ,[ 1 7 , 17 , 17 , 16 , 16 , 1 6 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 1 , 0 , 1 ]

] ,[

( 0 , 50 , 100) ,[ 1 0 0 0 , 700 , 600 , 300 , 100 , 5 0 0 ] ,[ 1 9 , 19 , 19 , 17 , 17 , 1 7 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 0 , 0 , 0 ]

] ,[

( 0 , 50 , 100) ,[ 3 0 0 , 200 , 0 , 400 , 500 , 1 0 0 ] ,[ 1 6 , 16 , 16 , 15 , 15 , 1 5 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 1 , 0 , 0 ]

] ,[

( 0 , 50 , 100) ,[ 3 0 0 , 0 , 0 , 500 , 100 , 3 0 0 ] ,[ 8 , 8 , 8 , 7 , 7 , 7 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 0 , 0 , 0 ]

] ,[

( 0 , 50 , 100) ,[ 8 0 0 , 400 , 500 , 200 , 1000 , 1 1 0 0 ] ,[ 9 , 9 , 9 , 8 , 8 , 8 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 0 , 0 , 0 ]

] ,[

( 0 , 50 , 100) ,[ 2 0 0 , 300 , 400 , 0 , 300 , 5 0 0 ] ,[ 1 6 , 16 , 16 , 14 , 14 , 1 4 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 0 , 0 , 1 ]

] ,[

( 0 , 50 , 100) ,[ 1 0 0 , 150 , 100 , 100 , 0 , 6 0 ] ,[ 2 5 , 25 , 25 , 22 , 22 , 2 2 ] ,[ 1 , 1 , 1 , 1 , 1 , 1 ] ,[ 0 , 0 , 0 , 0 , 0 , 0 , 0 ]

]]

machines = [[

Page 21: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

1.2. Multiproduct Lot-Sizing 13

[ 6 , 5 , 4 , 5 , 3 , 5 ] ,[ 5 0 0 , 500 , 500 , 500 , 500 , 5 0 0 ] ,[ 0 . 5 , 0 . 7 , 0 . 0 , 0 . 0 , 0 . 3 , 0 . 2 , 0 . 5 ]

] ,[

[ 4 , 5 , 6 , 4 , 5 , 3 ] ,[ 4 5 0 , 450 , 450 , 450 , 450 , 4 5 0 ] ,[ 0 . 1 , 0 . 2 , 0 . 0 , 0 . 3 , 0 . 0 , 0 . 6 , 0 . 0 ]

] ,[

[ 5 , 3 , 5 , 6 , 5 , 4 ] ,[ 4 5 0 , 450 , 450 , 450 , 450 , 4 5 0 ] ,[ 0 . 2 , 0 . 0 , 0 . 8 , 0 . 0 , 0 . 0 , 0 . 0 , 0 . 6 ]

] ,[

[ 8 , 6 , 7 , 8 , 7 , 6 ] ,[ 5 5 0 , 550 , 550 , 550 , 550 , 5 5 0 ] ,[ 0 . 0 5 , 0 . 0 3 , 0 . 0 , 0 . 0 7 , 0 . 0 1 , 0 . 0 , 0 . 0 8 ]

] ,[

[ 3 , 2 , 2 , 2 , 3 , 3 ] ,[ 6 0 0 , 600 , 600 , 600 , 600 , 6 0 0 ] ,[ 0 . 0 , 0 . 0 , 0 . 0 1 , 0 . 0 , 0 . 0 5 , 0 . 0 , 0 . 0 5 ]

] ,[

[ 4 , 3 , 4 , 4 , 3 , 4 ] ,[ 4 0 0 , 400 , 400 , 400 , 400 , 4 0 0 ] ,[ 0 . 1 , 0 . 1 , 0 . 1 , 0 . 1 , 0 . 1 , 0 . 1 , 0 . 1 5 ]

]]

prob = M u l t L o t S i z e ( ” t e s t 1 ” )prob . model ( l , p r o d u c t s , machines )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 1.8: Example of usage of class MultLotSize

The above program describes our example via a number of arrays. Next, an object, named prob, ofthe MultLotSize class is created. Calling prob.model() and prob.optimize(), we solve ourexample. To display the result, we call prob.printSolution().

If we run the program from Listing 1.8, we get the following result.O b j e c t i v e v a l u e = 396464.0000

P r o d u c t i o n :

| | P r o d u c t s ||−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| P e r i o d | 1 | 2 | 3 | 4 | 5 | 6 | 7 ||−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−|| 1 | 1438 .00 | 1000 .00 | 1100 .00 | 300 .00 | 800 .00 | 479 .00 | 138 .00 || 2 | 1246 .00 | 800 .00 | 700 .00 | 0 . 0 0 | 500 .00 | 539 .00 | 121 .00 || 3 | 802 .00 | 500 .00 | 536 .00 | 0 . 0 0 | 436 .00 | 642 .00 | 91 .00 || 4 | 572 .00 | 304 .00 | 662 .00 | 500 .00 | 264 .00 | 140 .00 | 100 .00 || 5 | 1000 .00 | 96 .00 | 1355 .00 | 100 .00 | 908 .00 | 592 .00 | 100 .00 || 6 | 1702 .00 | 550 .00 | 1247 .00 | 350 .00 | 1142 .00 | 478 .00 | 10 .00 |

Page 22: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

14 Chapter 1. Aggregate Production Planning

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Stock :

| | P r o d u c t s ||−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| P e r i o d | 1 | 2 | 3 | 4 | 5 | 6 | 7 ||−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−|| 1 | 0 . 0 0 | 0 . 0 0 | 0 . 0 0 | 0 . 0 0 | 0 . 0 0 | 3 . 0 0 | 38 .00 || 2 | 25 .00 | 100 .00 | 0 . 0 0 | 0 . 0 0 | 100 .00 | 0 . 0 0 | 9 . 0 0 || 3 | 0 . 0 0 | 0 . 0 0 | 100 .00 | 0 . 0 0 | 36 .00 | 60 .00 | 0 . 0 0 || 4 | 8 . 0 0 | 4 . 0 0 | 98 .00 | 0 . 0 0 | 100 .00 | 0 . 0 0 | 0 . 0 0 || 5 | 0 . 0 0 | 0 . 0 0 | 45 .00 | 0 . 0 0 | 8 . 0 0 | 92 .00 | 100 .00 || 6 | 50 .00 | 50 .00 | 50 .00 | 50 .00 | 50 .00 | 50 .00 | 50 .00 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Machines :

| | Machines ||−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| P e r i o d | 1 | 2 | 3 | 4 | 5 | 6 ||−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−|| 1 | 6 . 0 0 | 3 . 0 0 | 5 . 0 0 | 1 . 0 0 | 1 . 0 0 | 2 . 0 0 || 2 | 5 . 0 0 | 2 . 0 0 | 3 . 0 0 | 1 . 0 0 | 1 . 0 0 | 2 . 0 0 || 3 | 3 . 0 0 | 2 . 0 0 | 2 . 0 0 | 1 . 0 0 | 1 . 0 0 | 1 . 0 0 || 4 | 2 . 0 0 | 1 . 0 0 | 2 . 0 0 | 1 . 0 0 | 1 . 0 0 | 1 . 0 0 || 5 | 3 . 0 0 | 2 . 0 0 | 4 . 0 0 | 1 . 0 0 | 1 . 0 0 | 2 . 0 0 || 6 | 5 . 0 0 | 2 . 0 0 | 4 . 0 0 | 1 . 0 0 | 1 . 0 0 | 2 . 0 0 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Listing 1.9: Output of program from Listing 1.8

Page 23: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Chapter 2

Operations Scheduling

In poorly scheduled job shops, it is not at all uncommon for jobs to wait for 95 percent of their totalproduction cycle. This results in a long work flow cycle. Add inventory time and receivables collectiontime to this and you get a long cash flow cycle. Thus, work flow equals cash flow, and work flow is drivenby the schedule.

A schedule is a timetable for performing activities, utilizing resources, or allocating facilities. In thischapter, we discuss modeling aspects of some short-term scheduling of jobs and processes.

2.1 Scheduling Problems

In a scheduling problem we have to fulfill a set of jobs on a number of processors using other resourcesunder certain constraints such as restrictions on the job completion times, priorities between jobs (onejob cannot start until another one is finished), and etc. The goal is to optimize some criterion, e.g, tominimize the total processing time, which is the completion time of the last job (assuming that the firstjob starts at time 0); or to maximize the number of processed jobs.

Next we formulate a very general scheduling problem which subsumes as special cases a great dealof scheduling problems studied in the literature. We are given n jobs to be processed on m processors(machines). LetMj ⊆ P

def= {1, . . . ,m} denote the subset of processors that can fulfill job j ∈ J def

={1, . . . , n}.

Each job j is characterized by the following parameters:

• wj : weight;

• rj , dj : release and due dates (the job must be processed during the time interval [rj , dj ]);

• pji: processing time on processor i ∈Mj .

Precedence relations between jobs are given by an acyclic digraph G = (J , E) defined on the set Jof jobs: for any arc (j1, j2) ∈ J , job j2 cannot start until job j1 is finished.

In general not all jobs can be processed. For a given schedule, let Uj = 0 if job j is processed, andUj = 1 otherwise. Then the problem is to find such a schedule for which the weighted number of notprocessed jobs,

∑nj=1wjUj , is minimum. Alternatively, we can say that our goal is to maximize the

weighted sum of processed jobs, which is∑n

j=1wj(1− Uj).

15

Page 24: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

16 Chapter 2. Operations Scheduling

2.1.1 Time-Index Formulation

A time-index formulation is based on time-discretization, i.e., the planning horizon — from timeRmin =min1≤j≤n rj to timeDmax = max1≤j≤n dj — is divided into periods, and period t starts at time t−1 andends at time t. We represent a schedule by a family of decision binary variables {xjit}, where xjit takesvalue 1 if job j starts in period t on processor i; otherwise, xjit = 0. To formulate precedence relationswe need three families of auxiliary variables, which are uniquely defined by the decision variables xjit:

• yj = 1 if job j is processed; otherwise, yj = 0;

• sj : start time of job j;

• ptj : processing time (duration) of job j.

We consider the following time-index formulation1:

n∑j=1

wjyj → max, (2.1a)

∑1≤j≤n:

rj≤t≤dj−pji

min{t,dj−pji}∑τ=max{t−pji,rj}

xjiτ ≤ 1, t = Rmin, . . . , Dmax; i = 1, . . . ,m, (2.1b)

yj =∑i∈Mj

dj−pji∑t=rj

xjit, j = 1, . . . , n, (2.1c)

sj =∑i∈Mj

dj−pji∑t=rj

t · xjit, j = 1, . . . , n, (2.1d)

ptj =∑i∈Mj

dj−pji∑t=rj

pji · xjit, j = 1, . . . , n, (2.1e)

yj1 − yj2 ≥ 0, (j1, j2) ∈ E, (2.1f)

sj2 − sj1 ≥ ptj1 , (j1, j2) ∈ E, (2.1g)

xjit ∈ {0, 1}, i ∈Mj ; t = rj , . . . , dj − pji; j = 1, . . . , n, (2.1h)

yj ∈ {0, 1}, j = 1, . . . , n. (2.1i)

The objective (2.1a) is to maximize the weighted number of processed jobs.The capacity constraints (2.1b) state that any processor fulfills at most one job during any time period.The equations (2.1c), (2.1d), and (2.1e) determine the values of all auxiliary variables, yj , sj , and ptj .

Simultaneously, the equations (2.1c) imply that each job can start only once (because yj ∈ {0, 1}).The precedence relations are expressed by the inequalities (2.1f) and (2.1g). For each pair of related

jobs (j1, j2) ∈ E, (2.1f) requires that j2 is not processed if j1 is not processed, while (2.1g) requires that,if both jobs, j1 and j2, are processed, then j1 must be finished when j2 starts.

1 M.E. Dyer, L.A. Wolsey. Formulating the single-machine sequencing problem with release dates as a mixed integerprogram. Discrete Appl. Math. (1990) 26 255–270.

Page 25: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.1. Scheduling Problems 17

The time-index formulation can be easily modified to model many other types of scheduling prob-lems, which is its important advantage. For example, if we set yj = 1 for all j, and redefine the objectiveas follows

n∑j=1

∑i∈Mj

uj−pji∑t=lj

(t+ pji)xjit → min,

we get the problem of scheduling jobs with release and due dates on m machines to minimize weightedcompletion time, denoted as m|rj , dj |

∑wjCj .

In addition, the optimal objective value of the LP-relaxation of the time-index formulation providesa strong bound for the scheduling objective value: it dominates the bounds provided by other IP formu-lations. This is because the LP-relaxations of the time-index formulations are non-preemptive. That is,the relaxation is obtained by slicing jobs into pieces so that each piece is processed without interruption.

The main disadvantage of the time-index formulation is its size: even for one machine problems,there are n + T constraints and there may be up to nT variables. As a consequence, for instances withmany jobs and large processing intervals [rj , dj ], the LP’s will be very big in size, and their solutiontimes will be large.

2.1.2 MIPCL-PY Implementation

Our MIPCL-PY implementation of IP (2.1) is presented in Listing2.1.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s S c h e d u l e ( Problem ) :d e f model ( s e l f , j o b s ) :

d e f r ( j ) : r e t u r n j o b s [ j ] [ 0 ]d e f d ( j ) : r e t u r n j o b s [ j ] [ 1 ]d e f w( j ) : r e t u r n j o b s [ j ] [ 2 ]d e f p ( j , i ) : r e t u r n j o b s [ j ] [ 3 ] [ i ]d e f M( j ) : r e t u r n j o b s [ j ] [ 3 ] . keys ( )d e f p r e c ( j ) : r e t u r n j o b s [ j ] [ 4 ]

s e l f . j o b s = j o b sn = l e n ( j o b s )s e l f .m = m = 1 + max ( i f o r j i n r a n g e ( n ) f o r i i n M( j ) )Rmin = min ( r ( j ) f o r j i n r a n g e ( n ) )Dmax = 1 + max ( d ( j ) f o r j i n r a n g e ( n ) )

s = VarVec to r ( [ n ] , ’ s ’ )p t = VarVec to r ( [ n ] , ’ p t ’ )y = VarVec to r ( [ n ] , ’ y ’ , BIN )s e l f . x = x = { ( j , i , t ) : Var ( ’ x ’ + s t r ( ( j , i , t ) ) , BIN ) \

f o r j i n r a n g e ( n ) f o r i i n M( j ) \f o r t i n r a n g e ( r ( j ) , d ( j )−p ( j , i ) +1)}

maximize ( sum (w[ j ]∗ y [ j ] f o r j i n r a n g e ( n ) ) )

f o r i i n r a n g e (m) :f o r t i n r a n g e ( Rmin , Dmax) :

sum ( x [ j , i , t a u ] f o r j i n r a n g e ( n ) i f i i n M( j ) \f o r t a u i n r a n g e ( max ( t−p ( j , i ) , r ( j ) ) , min ( t +1 , d ( j )−p ( j , i ) +1) ) ) <= 1

Page 26: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

18 Chapter 2. Operations Scheduling

f o r j i n r a n g e ( n ) :y [ j ] == sum ( x [ j , i , t ] f o r i i n M( j ) f o r t i n r a n g e ( r ( j ) , d ( j )−p ( j , i ) +1) )s [ j ] == sum ( t ∗x [ j , i , t ] f o r i i n M( j ) \

f o r t i n r a n g e ( r ( j ) , d ( j )−p ( j , i ) +1) )p t [ j ] == sum ( p ( j , i ) ∗x [ j , i , t ] f o r i i n M( j ) \

f o r t i n r a n g e ( r ( j ) , d ( j )−p ( j , i ) +1) )f o r j 1 i n p r e c ( j ) :

y [ j ] <= y [ j 1 ]s [ j ] >= s [ j 1 ] + p t [ j 1 ]

Listing 2.1: MIPCL-PY implementation of scheduling problem: model

Input parameters:

• jobs: list of integers, where, for each task j=1,...,n=size(jobs),

– r(j)=tasks[j][0] and d(j)=tasks[j][1] are release and due dates;

– w(j)=tasks[j][2] weight;

– tasks[j][3] is a dictionary, where

∗ M(j)=tasks[j][3].keys() is a subset of machines (processors) that are able to processtask j;∗ p(j,i)=tasks[j][3][i] is processing time of task j on machine i;∗ prec(j)=tasks[j][4] is a subset of preceding tasks.

In our implementation we define variables in somewhat unusual way. Starting from an empty dictio-nary (x = {}), for any feasible tuple (j,i,t) of indices, we add to the dictionary a binary (of type”BIN”) variable x[j,i,t] named as x(j,i,t) (this name is only used when printing the solution).Alternatively, we could first determine a set

J IT = ( ( j , i , t ) f o r j i n r a n g e ( T ) f o r i i n M( j ) f o r t i n r a n g e ( r ( j ) , d ( j )−p ( j , i ) +1) )

of tuples for compatible indices, and then define an array of binary variables as follows:

x = VarArray ( JIT , ” x ” , BIN )

Definitely, the latter approach is clearer but less efficient than the former one.When a solution has been found, we can print it in a readable way by calling the procedure printSchedule()

— which is a member of Schedule) — from Listing 2.2.

d e f p r i n t S o l u t i o n ( s e l f ) :d e f r ( j ) :

r e t u r n j o b s [ j ] [ 0 ]d e f d ( j ) :

r e t u r n j o b s [ j ] [ 1 ]d e f p ( j , i ) :

r e t u r n j o b s [ j ] [ 3 ] [ i ]d e f M( j ) :

r e t u r n j o b s [ j ] [ 3 ] . keys ( )

j o b s = s e l f . j o b sx = s e l f . xn = l e n ( j o b s )

Page 27: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.1. Scheduling Problems 19

p r i n t ( ’ S h e d u l i n g c o s t = { : . 4 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )p r i n t ( ’ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−’ )p r i n t ( ’ | Job | P r o c e s s o r | S t a r t s | Ends | ’ )p r i n t ( ’+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+’ )f o r j i n r a n g e ( n ) :

f o r i i n M( j ) :f o r t i n r a n g e ( r ( j ) , d ( j )−p ( j , i ) +1) :

i f x [ j , i , t ] . v a l > 0 . 5 :p r i n t ( ’ | { : 4 d} | { : 9 d} | { : 6 d} | { : 6 d} | ’ . f o r m a t (

j +1 , i +1 , t , t +p ( j , i ) ) )b r e a k

p r i n t ( ’ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−’ )

Listing 2.2: MIPCL-PY implementation of scheduling problem: auxiliary procedures

2.1.3 Example of Usage

A firm provides copy services. Ten customers submitted their orders at the beginning of the week.Specific scheduling data are as follows:

Processing Due dateName time (days) (days) Profit

1 3 5 32 4 6 43 2 7 24 6 7 55 1 2 26 1 4 17 2 6 28 3 7 39 4 7 3

10 3 3 4

There are only two copy machines. The firm must decide which orders to process to maximize itstotal profit.

This is an instance of 2|dj |∑wjCj which is a special case of 2|rj , dj |

∑wjCj when all release

dates are zeroes. To solve this instance, we prepared the program presented in Listing 2.3.

# ! / u s r / b i n / py thonfrom s c h e d u l e i m p o r t S c h e d u l e

j o b s = {0 : [ 0 , 4 , 2 , {0 : 2 , 1 : 3} , ( ) ] ,1 : [ 0 , 6 , 1 , {0 : 1 , 1 : 4} , ( ) ] ,2 : [ 0 , 5 , 3 , {0 : 2 , 1 : 2} , ( ) ] ,3 : [ 3 , 7 , 1 , {0 : 2 , 1 : 1} , ( ) ] ,4 : [ 2 , 8 , 3 , {0 : 4 , 1 : 3} , ( ) ] ,5 : [ 6 , 12 , 2 , {0 : 3 , 1 : 4} , ( ) ] ,6 : [ 1 , 10 , 4 , {0 : 5 , 1 : 4} , ( ) ] ,7 : [ 2 , 8 , 2 , {0 : 4 , 1 : 2} , ( ) ] ,8 : [ 0 , 9 , 1 , {0 : 1 , 1 : 3} , ( ) ] ,9 : [ 5 , 12 , 3 , {0 : 5 , 1 : 5} , ( ) ]

Page 28: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

20 Chapter 2. Operations Scheduling

}

prob = S c h e d u l e ( ” t e s t 1 ” )prob . model ( j o b s )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 2.3: Example of usage of class Schedule

If we run the program from Listing 2.3, we get the following result.

S h e d u l i n g c o s t = 1 7 . 0−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Job | P r o c e s s o r | S t a r t s | Ends |

+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+| 1 | 1 | 0 | 2 || 3 | 2 | 0 | 2 || 5 | 2 | 3 | 6 || 6 | 1 | 9 | 12 || 7 | 1 | 3 | 8 || 10 | 2 | 7 | 12 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Listing 2.4: Output of program from Listing 2.3

2.2 Electricity Generation Planning

The unit commitment problem is to develop an hourly (or half-hourly) electricity production schedulespanning some planning horizon (a day or a week) so as to decide which generators will be producingand at what levels. The very essence of this problem is to appropriately balance of using generators withdifferent capacities: it is cheaper to produce electricity on more powerful generators while less powerfuland smaller generators take less time to switch on or off in case of necessity.

Let T be the number of periods in the planning horizon. Period 1 follows period T . We know thedemand dt for each period t. In each period the capacity of the active generators must be at least q timesof the demand (q is a level of reliability).

Let n be the number of generators, and let generator i have the following characteristics:

• li, ui: minimum and maximum levels of production per period;

• r1i , r

2i : ramping parameters (when a generator is on in two successive periods, its output cannot

decrease by more than r1i , and increase by more than r2

i );

• gi: start-up cost (if a generator is off in some period, it costs gi to start it in the next period);

• fi, pi: fixed and variable costs (if in some period a generator is producing at level v, it costsfi + piv).

2.2.1 Mixed-Integer Programming Formulation

With a natural choice of variables

xit = 1 if generator i produces in period t, and xit = 0, otherwise;

Page 29: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.2. Electricity Generation Planning 21

zit = 1 if generator i is switched on in period t, and zit = 0, otherwise;

yit: amount of electricity produced by generator i in period t,

we get the following formulation:

n∑i=1

T∑t=1

(gizit + fixit + piyit)→ min (2.2a)

n∑i=1

yit = dt, t = 1, . . . , T, (2.2b)

n∑i=1

uixit ≥ q dt, t = 1, . . . , T, (2.2c)

lixit ≤ yit ≤ uixit, i = 1, . . . , n; t = 1, . . . , T, (2.2d)

−r1i ≤ yit − yi,((t−2+T ) mod T )+1 ≤ r2

i , i = 1, . . . , n; t = 1, . . . , T, (2.2e)

xit − xi,((t−2+T ) mod T )+1 ≤ zit, i = 1, . . . , n; t = 1, . . . , T, (2.2f)

zit ≤ xit, , i = 1, . . . , n; t = 1, . . . , T, (2.2g)

xit, zit ∈ {0, 1}, i = 1, . . . , n; t = 1, . . . , T, (2.2h)

yit ∈ R+, i = 1, . . . , n; t = 1, . . . , T. (2.2i)

Let us note that period ((t− 2 + T ) mod T ) + 1 is immediately followed by period t.Here the objective (2.2a) is to minimize the total (for all n generators in all T periods) cost of of

producing electricity plus the sum of start-up costs. The equations (2.2b) ensure that, for each period,the total amount of electricity produced by all working generators meets the demand at that period. Theinequalities (2.2c) require that, in any period, the total capacity of all working generators is at least qtimes of the demand at that period. The lower and upper bounds (2.2d) impose the capacity restrictionsfor each generator in each period; simultaneously, these constrains ensure that non-working generatorsdo not produce electricity. The two sided inequalities (2.2e) guarantee that generators cannot increase(ramp up) or decrease (ramp down) their outputs by more than the values of their ramping parameters.The inequalities (2.2g) reflect the fact that any generator is working in a given period only if it has beenswitched on in this period or it was working in the preceding period.

2.2.2 MIPCL-PY Implementation

A MIPCL-PY implementation of MIP model (2.2) is given in Listing 2.5.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s Unitcom ( Problem ) :d e f model ( s e l f , q , d , u n i t s ) :

d e f l ( i ) :r e t u r n u n i t s [ i ] [ 0 ]

d e f u ( i ) :r e t u r n u n i t s [ i ] [ 1 ]

d e f r1 ( i ) :r e t u r n u n i t s [ i ] [ 2 ]

d e f r2 ( i ) :

Page 30: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

22 Chapter 2. Operations Scheduling

r e t u r n u n i t s [ i ] [ 3 ]d e f g ( i ) :

r e t u r n u n i t s [ i ] [ 4 ]d e f f ( i ) :

r e t u r n u n i t s [ i ] [ 5 ]d e f p ( i ) :

r e t u r n u n i t s [ i ] [ 6 ]

s e l f . u n i t s = u n i t sT , n = l e n ( d ) , l e n ( u n i t s )

x = VarVec to r ( [ n , T ] , ” x ” , BIN )s e l f . y = y = VarVec to r ( [ n , T ] , ” y ” )z = VarVec to r ( [ n , T ] , ” z ” , BIN )

min imize (sum ( g ( i ) ∗z [ i ] [ t ] + f ( i ) ∗x [ i ] [ t ] + p ( i ) ∗y [ i ] [ t ] \

f o r i i n r a n g e ( n ) f o r t i n r a n g e ( T ) ))

f o r t i n r a n g e ( T ) :sum ( y [ i ] [ t ] f o r i i n r a n g e ( n ) ) == d [ t ]sum ( u ( i ) ∗x [ i ] [ t ] f o r i i n r a n g e ( n ) ) >= q∗d [ t ]f o r i i n r a n g e ( n ) :

y [ i ] [ t ] >= l ( i ) ∗x [ i ] [ t ]y [ i ] [ t ] <= u ( i ) ∗x [ i ] [ t ]−r1 ( i ) <= y [ i ] [ t ] − y [ i ] [ ( t−1+T ) % T ] <= r2 ( i )x [ i ] [ t ] − x [ i ] [ ( t−1+T ) % T ] <= z [ i ] [ t ]z [ i ] [ t ] <= x [ i ] [ t ]

Listing 2.5: MIPCL-PY implementation of unit commitment problem: model

Input parameters:

• d: list of demands, where d[t] is demand in period t;

• units: list of tuples of size 7, where, for each unit i,

– l(i) = units[i][0] and u(i) = units[i][1] are minimum and maximum lev-els of per period production;

– r1(i) = units[i][2] and r2(i) = units[i][3] are ramping parameters;

– g(i) = units[i][4] is start-up cost;

– f(i) = units[i][5] and p(i) = units[i][6] are fixed and variable costs.

When a solution has been found, we can print the result using the procedure printSolution()— which is a member of Unitcom — from Listing 2.6.

d e f p r i n t S o l u t i o n ( s e l f ) :y = s e l f . yn , T = l e n ( y ) , l e n ( y [ 0 ] )p r i n t ( ’ Opt imal o b j e c t i v e v a l u e : { : . 4 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )p r i n t ( ’\n G e n e r a t o r powers : ’ )p r i n t ( ’ ’ + ’ ’ ∗ (10∗ n +9) )

Page 31: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.2. Electricity Generation Planning 23

p r i n t ( ’ | | ’ + ’ G e n e r a t o r s ’ . c e n t e r (10∗n−1) + ’ | ’ )p r i n t ( ’+ ’ + ’− ’ ∗ (10∗ n +9) + ’+ ’ )s t r = ’ | ’ + ’ P e r i o d s ’ . c e n t e r ( 7 ) + ’ | ’f o r i i n r a n g e ( n ) :

s t r += r e p r ( i +1) . c e n t e r ( 8 ) + ’ | ’p r i n t ( s t r )p r i n t ( ’+ ’ + ’−−−−−−−−−+’ ∗ ( n +1) )f o r t i n r a n g e ( T ) :

s t r = ’ | ’ + r e p r ( t +1) . c e n t e r ( 7 ) + ’ | ’f o r i i n r a n g e ( n ) :

s t r += f o r m a t ( y [ i ] [ t ] . va l , ’ . 2 f ’ ) . r j u s t ( 8 ) + ’ | ’p r i n t ( s t r )

p r i n t ( ’ ’ + ’− ’ ∗ (10∗ n +9) )

Listing 2.6: MIPCL-PY implementation of unit commitment problem: printSolution

2.2.3 Example of Usage

To test our model, we wrote the following program:

# ! / u s r / b i n / py thonfrom uni tcom i m p o r t Unitcom

q = 1 . 2d = [ 5 0 , 60 , 50 , 100 , 120 , 90 , 90 , 100 , 90 , 120 , 110 , 70]u n i t s = [[ 2 , 12 , 12 , 12 , 100 , 1 , 1 0 ] ,[ 2 , 12 , 12 , 12 , 100 , 1 , 1 0 ] ,[ 5 , 35 , 35 , 35 , 300 , 5 , 4 ] ,[ 2 0 , 50 , 50 , 50 , 400 , 10 , 3 ] ,[ 4 0 , 75 , 15 , 20 , 800 , 15 , 2 ]]

prob = Unitcom ( ” t e s t 1 ” )prob . model ( q , d , u n i t s )prob . o p t i m i z e ( F a l s e )prob . p r i n t S o l u t i o n ( )

Listing 2.7: Example of usage of class Unitcom

Here we want to schedule n = 5 generators over T = 12 time periods of 2-hours each. The level ofreliability is q = 1.2.

If we run the program from Listing 2.7, it prints an optimal schedule presented in the followinglisting.

Opt imal o b j e c t i v e v a l u e : 3170 .0000

G e n e r a t o r powers :

| | G e n e r a t o r s |+−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+| P e r i o d s | 1 | 2 | 3 | 4 | 5 |+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+−−−−−−−−−+| 1 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 0 . 0 0 | 45 .00 || 2 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 0 . 0 0 | 55 .00 || 3 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 0 . 0 0 | 45 .00 |

Page 32: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

24 Chapter 2. Operations Scheduling

| 4 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 30 .00 | 65 .00 || 5 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 40 .00 | 75 .00 || 6 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 20 .00 | 65 .00 || 7 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 20 .00 | 65 .00 || 8 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 20 .00 | 75 .00 || 9 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 20 .00 | 65 .00 || 10 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 40 .00 | 75 .00 || 11 | 0 . 0 0 | 0 . 0 0 | 5 . 0 0 | 30 .00 | 75 .00 || 12 | 0 . 0 0 | 0 . 0 0 | 10 .00 | 0 . 0 0 | 60 .00 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Listing 2.8: Output of program from Listing 2.7

2.3 Short-Term Scheduling in Chemical Industry

It is easier to start with an example2. Two products, 1 and 2, are produced from three different feed-stocksA,B, and C according to the following recipe:

1. Heating: Heat A for 1 h.

2. Reaction 1: Mix 50% feed B and 50% feed C and let them for 2 h to form intermediate BC.

3. Reaction 2: Mix 40% hot A and 60% intermediate BC and let them react for 2 h to form interme-diate AB (60%) and product 1 (40%).

4. Reaction 3: Mix 20% feed C and 80% intermediate AB and let them react for 1 h to form impure E.

5. Separation: Distill impure E to separate pure product 2 (90%, after 1 h) and pure intermediateAB (10% after 2 h). Discard the small amount of residue remaining at the end of the distillation.Recycle the intermediate AB.

The above process is represented by the State-Task-Network (STN) shown in Figure 2.1.The following processing equipment and storage capacity are available.

• Equipment:

– Heater: Capacity 100 kg, suitable for task 1;

– Reactor 1: Capacity 80 kg, suitable for tasks 2,3,4;

– Reactor 2: Capacity 50 kg, suitable for tasks 2,3,4;

– Still: Capacity 200 kg, suitable for task 5.

• Storage capacity:

– For feeds A,B,C: unlimited;

– For hot A: 100 kg;

– For intermediate AB: 200 kg;

– For intermediate BC: 150 kg;2 E. Kondili, C.C. Pantelides, and R.W.H. Sargent. A general algorithm for short-term scheduling of batch operations — I.

MILP formulation. Computers chem. Engng. 17 (1993) 211–227.

Page 33: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.3. Short-Term Scheduling in Chemical Industry 25

����

Reaction 1 Reaction 3

6

FeedC

����

FeedB

����

IntBC

6

6

-

6

Reaction 2����

HotA

����Prod.

1

6

--Heating

����

FeedA ��

��Imp.

E

6

Separation-

����

IntAB

?

- �60%2 h

10% 2 h6

����Prod.

2

?

1 h 40%

80%60%

50%

2 h

50% 20%

1 h 90% 1 h

40% 2 h

Figure 2.1: State-task network for example process

– For intermediate E: 100 kg;

– For products 1,2: unlimited.

A number of parameters are associated with the tasks and the states defining the STN and with theavailable equipment items. More specifically:

• Task i is defined by:

Ui: set of units capable of performing task i;

Sini : set of states that feed task i;

Souti : set of states that task i produces as its outputs;

ρinis: proportion of input of task i from state s ∈ Sin

i ;∑

s∈Siniρinis = 1;

ρoutis : proportion of output of task i to state s ∈ Sout

i ;∑

s∈Soutiρoutis = 1;

pis: processing time for output of task i to state s ∈ Souti ;

di: duration (completion time) for task i, didef= maxs∈Sout

ipis;

• State s is defined by:

T outs : set of tasks receiving material from state s;

T ins : set of tasks producing material in state s;

z0s : initial stock in state s;

us: storage capacity dedicated to state s;

Page 34: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

26 Chapter 2. Operations Scheduling

cs: unit cost (price) of product produced in state s;

hs: cost of storing a unit amount of material in state s.

• Unit j is characterized by:

Ij: set of tasks that can be performed by unit j;

V maxij , V min

ij : respectively, maximum and minimum load of unit j when used for performing task i.

Let n, q,m denote, respectively, the number of tasks, states, and units. The scheduling problem forbatch processing system is stated as:

Given: the STN of a batch process and all the information associated with it, as well as a time horizonof interest.

Determine: the timing of the operations for each unit (i.e. which task, if any, the unit performs at anytime during the time horizon); and the flow of materials through the network.

Goal: maximize the total cost of the products produced minus the total storage cost during the timehorizon.

2.3.1 Mixed-Integer Programming Formulation

Our formulation is based on a discrete time representation. The time horizon of interest is divided intoa number of intervals of equal duration. We number the intervals from 1 to H , and assume that intervalt starts at time t − 1 and ends at time t. Events of any type — such as the start or end of processingindividual batches of individual tasks, changes in the availability of processing equipment and etc. —are only happen at the interval boundaries.

Pre-emptive operations are not allowed and materials are transferred instantaneously from states totasks and from tasks to states.

We introduce the following variables:

xijt = 1 if unit j starts processing task i at the beginning of time period t; xijt = 0 otherwise;

yijt: amount of material (batch size) that starts undergoing task i in unit j at the beginning of timeperiod t;

zst: amount of material stored in state s, at the beginning of time period t.

To simplify presentation, we introduce an additional time interval H + 1 that represents the end of thetime horizon. Then the value of zs,H+1 is the amount of material in state s produced during the timehorizon.

Now the MIP model is written as follows:

q∑s=1

cszs,H+1 −q∑s=1

H∑t=1

hszst → max, (2.3a)∑i∈Ij

xijt ≤ 1, j = 1, . . . ,m; t = 1, . . . ,H, (2.3b)

Page 35: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.3. Short-Term Scheduling in Chemical Industry 27

∑i∈Ij

min{t,H−di}∑τ=max{0,t−di+1}

xijτ ≤ 1, j = 1, . . . ,m; t = 1, . . . ,H, (2.3c)

V minij xijt ≤ yijt ≤ V min

ij xijt, j = 1, . . . ,m; i ∈ Ij ; t = 1, . . . ,H, (2.3d)

0 ≤ zst ≤ us, s = 1, . . . , q; t = 1, . . . ,H, (2.3e)

zs,t−1 +∑

i∈T outs : t>pis

ρoutis

∑j∈Ui

yij,t−pis = zst +∑i∈T in

s

ρinis

∑j∈Ui

yijt,

s = 1, . . . , q; t = 1, . . . ,H, (2.3f)

zs,H +∑

i∈T outs :H>pis

ρoutis

∑j∈Ui

yij,H−pis = zs,H+1, s = 1, . . . , q, (2.3g)

xijt = 0, t > H − di, j = 1, . . . ,m; i ∈ Ij , (2.3h)

xijt ∈ {0, 1}, yijt ∈ R+, j = 1, . . . ,m; i ∈ Ij ; t = 1, . . . ,H, (2.3i)

zst ∈ R+, s = 1, . . . , q; t = 1, . . . ,H + 1. (2.3j)

The objective (2.3a) is to maximize the total profit that equals the total cost of the produced materialsminus the expenses for storing materials during the time horizon. The inequalities (2.3b) enforce that atany time t, an idle unit j can start only one task. The constraints (2.3c) impose the requirement that atany time any unit processes only one task. The constraints (2.3d) enforce that the batch size of any taskmust be within the minimum and maximum capacities of the unit performing the task. The constraints(2.3e) impose stock limitations: the amount of material stored in any state s must not exceed the storagecapacity for this state. Material balance constraints (2.3f) require that, for any state s at each period t,the amount of material entering the state (the stock from the previous period plus the input deliveredfrom the tasks that finished at period t) equals the amount of material leaving the state (the stock at tplus the amount of material consumed by the tasks that started at t). Note that zs0 is not a variable but aconstant z0

s , the initial stock at state s. The constraints (2.3g) are specializations of the balance relationsfor period H + 1, at this period no task starts. The constraints (2.3h) enforce the tasks to finish withinthe time horizon.

2.3.2 MIPCL-PY Implementation

Our MIPCL-Py implementation of MIP (2.3) is given in Listing 2.9.i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s Batch ( Problem ) :d e f model ( s e l f , H, t a s k s , s t a t e s , u n i t s ) :

d e f u ( s ) : r e t u r n s t a t e s [ s ] [ 0 ]d e f z0 ( s ) : r e t u r n s t a t e s [ s ] [ 1 ]d e f h ( s ) : r e t u r n s t a t e s [ s ] [ 2 ]d e f c ( s ) : r e t u r n s t a t e s [ s ] [ 3 ]d e f J ( i ) : r e t u r n t a s k s [ i ] [ 0 ]d e f inS ( i ) : r e t u r n t a s k s [ i ] [ 1 ] . i t e m s ( )d e f ou tS ( i ) : r e t u r n t a s k s [ i ] [ 2 ] . i t e m s ( )d e f dur ( i ) : r e t u r n t a s k s [ i ] [ 3 ]d e f I ( j ) : r e t u r n u n i t s [ j ] [ 0 ]

Page 36: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

28 Chapter 2. Operations Scheduling

s e l f .H = Hs e l f . t a s k s , s e l f . s t a t e s , s e l f . u n i t s = t a s k s , s t a t e s , u n i t sSTATES , TASKS , UNITS = s t a t e s . keys ( ) , t a s k s . keys ( ) , u n i t s . keys ( )

s e l f . z = z = { ( s , t ) : Var ( ’ z ’ + s t r ( ( s , t ) ) ) \f o r s i n STATES f o r t i n r a n g e (H+1)}

s e l f . x = x = { ( i , j , t ) : Var ( ’ x ’ + s t r ( ( i , j , t ) ) , BIN ) \f o r i i n TASKS f o r j i n J ( i ) f o r t i n r a n g e (H−dur ( i ) +1)}

s e l f . y = y = { ( i , j , t ) : Var ( ’ y ’ + s t r ( ( i , j , t ) ) ) \f o r i i n TASKS f o r j i n J ( i ) f o r t i n r a n g e (H−dur ( i ) +1)}

maximize (sum ( c ( s ) ∗z [ s ,H] f o r s i n STATES)− sum ( h ( s ) ∗z [ s , t ] f o r s i n STATES f o r t i n r a n g e (H) )

)

f o r t i n r a n g e (H) :f o r j i n UNITS :

sum ( x [ i , j , t ] f o r i i n I ( j ) i f t + t a s k s [ i ] [ 3 ] <= H) <= 1

f o r j i n UNITS :Vmin , Vmax = u n i t s [ j ] [ 1 ] [ 0 ] , u n i t s [ j ] [ 1 ] [ 1 ]f o r i i n I ( j ) :

f o r t i n r a n g e (H−dur ( i ) +1) :y [ i , j , t ] >= Vmin∗x [ i , j , t ]y [ i , j , t ] <= Vmax∗x [ i , j , t ]

f o r t i n r a n g e (H) :sum ( x [ i , j , t a u ] f o r i i n I ( j ) \

f o r t a u i n r a n g e ( max ( 0 , t−dur ( i ) +1) , min ( t , H−dur ( i ) ) ) ) <= 1

f o r s i n STATES :f o r t i n r a n g e (H) :

z [ s , t ] <= u ( s )z [ s , 0 ] + sum ( rho ∗y [ i , j , 0 ] f o r i i n TASKS f o r j i n J ( i ) \

f o r s1 , rho i n inS ( i ) i f s1 == s ) == z0 ( s )f o r t i n r a n g e ( 1 ,H+1) :

z [ s , t −1] + sum ( rho ∗y [ i , j , t−d ] f o r i i n TASKS f o r j i n J ( i ) \f o r s1 , ( rho , d ) i n outS ( i ) i f s1 == s and t >= d ) == \

z [ s , t ] + sum ( rho ∗y [ i , j , t ] f o r i i n TASKS f o r j i n J ( i ) \f o r s1 , rho i n inS ( i ) i f s1 == s and t + dur ( i ) <= H)

Listing 2.9: MIPCL-PY implementation of batch scheduling problem: model

Input parameters:

• H: length of planning horizon (integer);

• tasks: list of tasks, where task i is characterized as follows:

– J(i)=tasks[i][0]: set of units that can process task i;

– tasks[i][1]: dictionary that describes states feeding task i,we define inS(i)=tasks[i][1].items();

– tasks[i][2]: dictionary that describes states to which task i sends its outputs,we define outS(i)=tasks[i][2].items();

Page 37: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.3. Short-Term Scheduling in Chemical Industry 29

– dur(i)=tasks[i][3]: duration of task i (integer);

• states: list of states, where state s is defined by the following parameters:

– u(s)=states[s][0]: storage capacity;

– z0(s)=states[s][1]: initial stock;

– h(s)=states[s][2]: cost of storing one unit of product;

– c(s)=states[s][3]: price of product produced in state s;

• units: list of units, where each unit j is characterized as follows:

– I(j)=units[j][0]: set of tasks that can be performed by unit j;

– units[j][1][0] and units[j][1][1]: minimum and maximum loads for unit j.

When a solution has been found, one may want to print it in a readable format. Listing 2.10 presentsa procedure — which is a member of Batch — that does this job.

d e f p r i n t S o l u t i o n ( s e l f ) :d e f dur ( i ) :

r e t u r n t a s k s [ i ] [ 3 ]d e f I ( j ) :

r e t u r n u n i t s [ j ] [ 0 ]

H = s e l f .Hs t a t e s , t a s k s , u n i t s = s e l f . s t a t e s , s e l f . t a s k s , s e l f . u n i t sz , y = s e l f . z , s e l f . yp r i n t ( ’ O b j e c t i v e v a l u e = { 0 : . 4 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )p r i n t ( ’\ n P r o d u c t s p roduced : ’ )f o r s i n s t a t e s . keys ( ) :

p r i n t ( ’ { 0 : . 4 f } i n s t a t e {1} ’ . f o r m a t ( z [ s ,H ] . va l , r e p r ( s ) ) )

p r i n t ( ’\ nSchedu le : ’ )f o r j i n u n i t s . keys ( ) :

p r i n t ( ’\n ’ + r e p r ( j ) + ’ : ’ )f o r t i n r a n g e (H) :

f o r i i n I ( j ) :i f t + dur ( i ) <= H:

i f y [ i , j , t ] . v a l > 1 . 0 e−6:p r i n t ( ’ b a t c h o f t a s k {0} s t a r t s a t {1} , s i z e = { 2 : . 4 f } ’ .

f o r m a t ( r e p r ( i ) , r e p r ( t ) , y [ i , j , t ] . v a l ) )

Listing 2.10: MIPCL-PY implementation of batch scheduling problem: printSolution

2.3.3 Example of Usage

To optimize our test STN over a horizon of 9 hours, we wrote the program presented in Listing 2.11.

# ! / u s r / b i n / py thonfrom b a t c h i m p o r t Batch

H = 9 # t ime h o r i z o n

t a s k s = {

Page 38: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

30 Chapter 2. Operations Scheduling

’ H e a t i n g ’ : ({ ’ H e a t e r ’ } ,{ ’ Fead A ’ : 1 . 0} ,{ ’ Hot A ’ : ( 1 . 0 , 1 ) } ,1

) ,’ R e a c t i o n 1 ’ : (

{ ’ R e a c t o r 1 ’ , ’ R e a c t o r 2 ’ } ,{ ’ Fead B ’ : 0 . 5 , ’ Fead C ’ : 0 . 5} ,{ ’ In t BC ’ : ( 1 . 0 , 2 ) } ,2

) ,’ R e a c t i o n 2 ’ : (

{ ’ R e a c t o r 1 ’ , ’ R e a c t o r 2 ’ } ,{ ’ Hot A ’ : 0 . 4 , ’ In t BC ’ : 0 . 6} ,{ ’ In t AB ’ : ( 0 . 6 , 2 ) , ’ P rod 1 ’ : ( 0 . 4 , 2 ) } ,2

) ,’ R e a c t i o n 3 ’ : ({ ’ R e a c t o r 1 ’ , ’ R e a c t o r 2 ’ } ,{ ’ Fead C ’ : 0 . 2 , ’ In t AB ’ : 0 . 8} ,{ ’ Impure E ’ : ( 1 . 0 , 1 ) } ,1

) ,’ S e p a r a t i o n ’ : (

{ ’ S t i l l ’ } ,{ ’ Impure E ’ : 1 . 0} ,{ ’ In t AB ’ : ( 0 . 1 , 2 ) , ’ P rod 2 ’ : ( 0 . 9 , 1 ) } ,1

)}

# Numbers i n t h e fou r−t u p l e s a r e :# 0 ) s t o r a g e c a p a c i t y ,# 1 ) i n i t i a l s t o c k ,# 2 ) c o s t o f s t o r i n g a u n i t amount o f m a t e r i a l ,# 3 ) p r i c e o f p r o d u c t p roduced i n t h e s t a t e .s t a t e s = {

’ Fead A ’ : ( 1 0 0 0 , 1000 , 0 . 0 , 0 . 0 ) ,’ Fead B ’ : ( 1 0 0 0 , 1000 , 0 . 0 , 0 . 0 ) ,’ Fead C ’ : ( 1 0 0 0 , 1000 , 0 . 0 , 0 . 0 ) ,’ Hot A ’ : ( 100 , 0 . 0 , 0 . 1 , −1.0) ,’ In t AB ’ : ( 200 , 0 . 0 , 0 . 1 , −1.0) ,’ In t BC ’ : ( 150 , 0 . 0 , 0 . 1 , −1.0) ,’ Impure E ’ : ( 100 , 0 . 0 , 0 . 1 , −1.0) ,’ P rod 1 ’ : ( 1 0 0 0 , 0 . 0 , 0 . 0 , 1 0 . 0 ) ,’ P rod 2 ’ : ( 1 0 0 0 , 0 . 0 , 0 . 0 , 1 0 . 0 )

}

# Each u n i t i s d e s c r i b e d by :# 1 ) t h e s e t o f t a s k s t h a t t h i s u n i t i s c a p a b l e t o f u l f i l l ,# 2 ) t h e 2− t u p l e which numbers a r e minimum and maximum u n i t l o a d s .u n i t s = {

’ H e a t e r ’ : ({ ’ H e a t i n g ’ } , ( 0 , 100) ) ,’ R e a c t o r 1 ’ : ({ ’ R e a c t i o n 1 ’ , ’ R e a c t i o n 2 ’ , ’ R e a c t i o n 3 ’ } , ( 0 , 80) ) ,’ R e a c t o r 2 ’ : ({ ’ R e a c t i o n 1 ’ , ’ R e a c t i o n 2 ’ , ’ R e a c t i o n 3 ’ } , ( 0 , 50) ) ,

Page 39: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.3. Short-Term Scheduling in Chemical Industry 31

’ S t i l l ’ : ({ ’ S e p a r a t i o n ’ } , ( 0 , 200) )}

prob = Batch ( ”STN1” )prob . model (H, t a s k s , s t a t e s , u n i t s )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 2.11: Example of usage of class Batch

If we run the program from Listing 2.11, we get the following result.

O b j e c t i v e v a l u e = 4700 .0333

P r o d u c t s p roduced :803 .0000 i n s t a t e ’ Fead C ’870 .0000 i n s t a t e ’ Fead B ’826 .6667 i n s t a t e ’ Fead A ’0 .0000 i n s t a t e ’ Impure E ’12 .5000 i n s t a t e ’ In t AB ’173 .3333 i n s t a t e ’ P rod 1 ’0 .0000 i n s t a t e ’ Hot A ’301 .5000 i n s t a t e ’ P rod 2 ’0 .0000 i n s t a t e ’ In t BC ’

S c h e d u l e :

’ R e a c t o r 2 ’ :b a t c h o f t a s k ’ R e a c t i o n 1 ’ s t a r t s a t 0 , s i z e = 50 .0000b a t c h o f t a s k ’ R e a c t i o n 1 ’ s t a r t s a t 1 , s i z e = 50 .0000b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 2 , s i z e = 50 .0000b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 3 , s i z e = 43 .3333b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 4 , s i z e = 50 .0000b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 5 , s i z e = 50 .0000b a t c h o f t a s k ’ R e a c t i o n 3 ’ s t a r t s a t 6 , s i z e = 50 .0000b a t c h o f t a s k ’ R e a c t i o n 3 ’ s t a r t s a t 7 , s i z e = 50 .0000

’ H e a t e r ’ :b a t c h o f t a s k ’ H e a t i n g ’ s t a r t s a t 1 , s i z e = 52 .0000b a t c h o f t a s k ’ H e a t i n g ’ s t a r t s a t 2 , s i z e = 49 .3333b a t c h o f t a s k ’ H e a t i n g ’ s t a r t s a t 3 , s i z e = 20 .0000b a t c h o f t a s k ’ H e a t i n g ’ s t a r t s a t 4 , s i z e = 52 .0000

’ R e a c t o r 1 ’ :b a t c h o f t a s k ’ R e a c t i o n 1 ’ s t a r t s a t 0 , s i z e = 80 .0000b a t c h o f t a s k ’ R e a c t i o n 1 ’ s t a r t s a t 1 , s i z e = 80 .0000b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 2 , s i z e = 80 .0000b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 3 , s i z e = 80 .0000b a t c h o f t a s k ’ R e a c t i o n 3 ’ s t a r t s a t 4 , s i z e = 80 .0000b a t c h o f t a s k ’ R e a c t i o n 2 ’ s t a r t s a t 5 , s i z e = 80 .0000b a t c h o f t a s k ’ R e a c t i o n 3 ’ s t a r t s a t 6 , s i z e = 75 .0000b a t c h o f t a s k ’ R e a c t i o n 3 ’ s t a r t s a t 7 , s i z e = 80 .0000

’ S t i l l ’ :b a t c h o f t a s k ’ S e p a r a t i o n ’ s t a r t s a t 5 , s i z e = 80 .0000b a t c h o f t a s k ’ S e p a r a t i o n ’ s t a r t s a t 7 , s i z e = 125 .0000

Page 40: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

32 Chapter 2. Operations Scheduling

b a t c h o f t a s k ’ S e p a r a t i o n ’ s t a r t s a t 8 , s i z e = 130 .0000

Listing 2.12: Output of program from Listing 2.11

2.4 Project Scheduling

Let us consider a project that consists of n jobs. There are qr renewable3 (non-perishable) resources,with, respectively, Rri units of resource i available per unit of time. There are also qn nonrenewable4

(perishable) resources, with, respectively, Rni units of resource i available for the entire project. It isassumed that all resources are available when the project starts.

Jobs can be processed in different modes. Execution of any job cannot be interrupted, thus, if pro-cessing of a job once started in some mode, it has to be completed in the same mode. If job j is processedin mode m (m = 1, . . . ,Mj), then it takes pmj units of time to process the job, ρrjmi units of renewableresource i (i = 1, . . . , qr) are used each period when job j is processed, and ρnjmi units of nonrenewableresource i (i = 1, . . . , qn) are totally consumed.

Precedence relations between jobs are given by an acyclic digraph G = ({1, . . . , n},R) defined onthe set of jobs: for any arc (j1, j2) ∈ R, job j2 cannot start until job j1 is finished.

The goal is to find a schedule5 with the minimal makespan. The makespan of a schedule is definedto be the end time of the lastly finished job.

2.4.1 Integer Programming Formulation

Let us assume that we know an upper bound, H , on the optimal makespan value. We can take as Hthe makespan of a schedule produced by one of numerous project scheduling heuristics. The planninghorizon is divided into H periods numbered from 1 to H , and period t starts at time t − 1 and ends attime t.

To tighten our formulation, we can estimate (say, by the critical path method) the earliest, efj andlatest, lfj , finish times of all jobs j.

First, we define the family of decision binary variables:

• xjmt = 1 if job j is processed in mode m and completed at the end of period t (at time t);otherwise, xjmt = 0.

For modeling purposes, we also need the following families of auxiliary variables:

• T : schedule makespan;

• dj ∈ R: duration of job j (dj depends on the mode in which job j is processed);

• ej ∈ R: end time of job j.

3 Renewable resources are available in the same quantities at any period. Manpower, machines, storage spaces are renewableresources.

4 In contrast to a renewable resource, which consumption is limited in each period, overall consumption of a nonrenewableresource is limited for the entire project. Money, energy, and raw materials are nonrenewable resources.

5A schedule specifies when each job starts and in which mode it is processed.

Page 41: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.4. Project Scheduling 33

In these variables the model is written as follows:

T → min, (2.4a)Mj∑m=1

lfj∑t=efj

xjmt = 1, j = 1, . . . , n, (2.4b)

ej =

Mj∑m=1

lfj∑t=efj

txjmt, j = 1, . . . , n, (2.4c)

dj =

Mj∑m=1

lfj∑t=efj

pmj xjmt, j = 1, . . . , n, (2.4d)

T ≥ ej , j = 1, . . . , n, (2.4e)

n∑j=1

Mj∑m=1

min(τ+pmj ,lfj)∑t=max(τ,efj)

ρrjmixjmt ≤ Rri , i = 1, . . . , qr, τ = 1, . . . ,H, (2.4f)

n∑j=1

Mj∑m=1

lfj∑t=efj

ρnjmixjmt ≤ Rni , i = 1, . . . , qn, (2.4g)

ej2 − ej1 ≥ dj2 , (j1, j2) ∈ R, (2.4h)

ej ≥ dj , j = 1, . . . , n, (2.4i)

xjmt ∈ {0, 1}, t = 0, . . . ,H, m = 1, . . . ,Mj , j = 1, . . . , n, (2.4j)

dj , ej ∈ R, j = 1, . . . , n. (2.4k)

The objective (2.4a) is to minimize the makespan. The equations (2.4b) impose the requirement thateach job is processed only in one mode, and it finishes (and starts) only once. For the schedule given bythe values of xjmt variables, the equations (2.4c) and (2.4d) calculate the end times, ej , and durations, dj ,of all jobs. The inequalities (2.4e) imply that, being minimized, T is the makespan of the schedule givenby the values of xjmt variables. The inequalities (2.4f) and (2.4g) impose the limitations, respectively,on the renewable and nonrenewable resources. The precedence relations between jobs are given by theinequalities (2.4h). The constraints in (2.4i) are important only for jobs without predecessors; otherwise,starting times of such jobs could be negative.

2.4.2 MIPCL-PY Implementation

To solve instances of the project scheduling problem, we developed a Python class, named prodSche-dule and presented in listings 2.13, 2.14 and 2.15.

Listing 2.13 describes the constructor and an implementation of IP (2.4), which is, as usually, donein the function named model.

from m i p c l p y . m i p s h e l l . m i p s h e l l i m p o r t ∗

c l a s s p r o j e c t S c h e d u l e ( Problem ) :d e f i n i t ( s e l f , p r o j e c t ) :

Problem . i n i t ( s e l f , p r o j e c t [ ’Name ’ ] )

Page 42: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

34 Chapter 2. Operations Scheduling

s e l f . p r o j e c t = p r o j e c t

d e f model ( s e l f ) :renRes , nonRenRes = s e l f . p r o j e c t [ ’ r enRes ’ ] , s e l f . p r o j e c t [ ’ nonRenRes ’ ]j o b s = s e l f . p r o j e c t [ ’ Jobs ’ ]H = s e l f . p r o j e c t [ ’ Hor izon ’ ]s e l f . mcp (H)

T = Var ( ’T ’ , INT )e = VarVec to r ( [ l e n ( j o b s ) ] , ’ e ’ , INT )d = VarVec to r ( [ l e n ( j o b s ) ] , ’ d ’ , INT )s e l f . x = x = [ ]f o r j , j o b i n enumera t e ( j o b s ) :

ef , l f = j o b [ ’EF ’ ] , j o b [ ’LF ’ ]+1x . append ( [ ] )f o r m i n r a n g e ( l e n ( j o b [ ’ Modes ’ ] ) ) :

x [ j ] . append ({} )f o r t i n r a n g e ( ef , l f ) :

x [ j ] [m] [ t ] = Var ( ’ x ( { : d } ,{ : d } ,{ : d } ) ’ . f o r m a t ( j ,m, t ) , BIN )

min imize ( T )

f o r j , j o b i n enumera t e ( j o b s ) :ef , l f = j o b [ ’EF ’ ] , j o b [ ’LF ’ ]+1

# each j o b s t a r t s on ly i n one mode and f i n i s h e s on ly oncesum ( x [ j ] [m] [ t ] f o r m i n r a n g e ( l e n ( j o b [ ’ Modes ’ ] ) ) f o r t i n r a n g e ( ef , l f ) )

== 1d [ j ] == sum (M[ ’ D u r a t i o n ’ ]∗ x [ j ] [m] [ t ] \

f o r m,M i n enumera t e ( j o b [ ’ Modes ’ ] ) f o r t i n r a n g e ( ef , l f ) )e [ j ] == sum ( t ∗x [ j ] [m] [ t ] f o r m i n r a n g e ( l e n ( j o b [ ’ Modes ’ ] ) ) \

f o r t i n r a n g e ( ef , l f ) )T >= e [ j ]

# r e n e w a b l e r e s o u r c e l i m i t sf o r t a u i n r a n g e ( 1 ,H+1) :

f o r r , R i n enumera t e ( renRes ) :sum (M[ ’ renRes ’ ] [ r ]∗ x [ j ] [m] [ t ] f o r j , j o b i n enumera t e ( j o b s ) \

f o r m,M i n enumera t e ( j o b [ ’ Modes ’ ] ) \f o r t i n r a n g e ( max ( tau , j o b [ ’EF ’ ] ) , \

min ( t a u +M[ ’ D u r a t i o n ’ ] , j o b [ ’LF ’ ] ) +1) ) <= R[ ’ Q u a n t i t y ’ ]

# nonrenewab le r e s o u r c e l i m i t sf o r r , R i n enumera t e ( nonRenRes ) :

sum (M[ ’ nonRenRes ’ ] [ r ]∗ x [ j ] [m] [ t ] f o r j , j o b i n enumera t e ( j o b s ) \f o r m,M i n enumera t e ( j o b [ ’ Modes ’ ] ) \f o r t i n r a n g e ( j o b [ ’EF ’ ] , j o b [ ’LF ’ ] + 1 ) ) <= R[ ’ Q u a n t i t y ’ ]

# p r e c e d e n c e r e l a t i o n sf o r j2 , j o b i n enumera t e ( j o b s ) :

i f l e n ( j o b [ ’ P rec ’ ] ) > 0 :f o r j 1 i n j o b [ ’ P rec ’ ] :

e [ j 2 ] − e [ j 1 ] >= d [ j 2 ]e l s e : # j 2 has n o t p r e d e c e s s o r s

Page 43: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.4. Project Scheduling 35

e [ j 2 ] >= d [ j 2 ]

Listing 2.13: MIPCL-PY implementation of project scheduling problem: constructor and model

The only parameter of the constructor is

• project: data structure that describes a project, its members are

– Name: project name;

– Horizon: length of the planning horizon (an upper bound on the minimum makespanvalue);

– renRes: list of limits on renewable resources, were

∗ renRes[r][’Name’] is the name of resource r,∗ renRes[r][’Quantity’] gives the available quantity of resource r;

– nonrenRes: list of limits on nonrenewable resources, were

∗ nonRenRes[r][’Name’] is the name of resource r,∗ nonRenRes[r][’Quantity’] gives the available quantity of resource r;

– Jobs: list of jobs, each job is described by the structure with the following members:

∗ Name: name, which is used when displaying the schedule;∗ Modes: list of modes, each mode M = Modes[m] is given by the data structure with

the following fields:· M[’Duration’]: processing time;· M[’renRes’]: list of limits on renewable resources;· M[’nonRenRes’]: list of limits on non-renewable resources;

∗ Prec: list of preceding jobs.

Listing 2.14 presents an auxiliary procedure, mcp, that implements the critical path method.

d e f mcp ( s e l f , H) :jobs , r enRes = s e l f . p r o j e c t [ ’ Jobs ’ ] , s e l f . p r o j e c t [ ’ r enRes ’ ]

f o r j o b i n j o b s :e s = 0f o r j i n j o b [ ’ P rec ’ ] :

e f = j o b s [ j ] [ ’EF ’ ]i f e s < e f :

e s = e fj o b [ ’EF ’ ] = es + min ( mode [ 0 ] f o r mode i n j o b [ ’ Modes ’ ] )j o b [ ’LF ’ ] = H

# p r i n t ( r e p r ( j o b [ ’ Job ’ ] ) + ’ e a r l y s t a r t a t ’ + r e p r ( e s ) )

f o r j o b i n r e v e r s e d ( j o b s ) :l s = j o b [ ’LF ’ ] − min ( mode [ 0 ] f o r mode i n j o b [ ’ Modes ’ ] )f o r j i n j o b [ ’ P rec ’ ] :

i f j o b s [ j ] [ ’LF ’ ] > l s :j o b s [ j ] [ ’LF ’ ] = l s

Listing 2.14: MIPCL-PY implementation of project scheduling problem: mcp

Page 44: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

36 Chapter 2. Operations Scheduling

For each job ∈ project[′Jobs′], mcp computes the early, job[′EF′], and late, job[′EF′] finish timesof this job under the assumptions that all resources are unlimited, and the project has to be fulfilled withinthe time horizon of H periods, where H is the second input parameter.

When an optimal solution has been found, we can extract the schedule from the values of variablesx[j][m][t] by calling the procedure getSchedule, presented in Listing 2.15. This procedure builds adata structure that is passed to printSchedule to display the schedule.

d e f g e t S c h e d u l e ( s e l f ) :s c h e d u l e = Nonei f s e l f . i s s o l u t i o n i s n o t None :

i f s e l f . i s s o l u t i o n == True :j o b s = s e l f . p r o j e c t [ ’ Jobs ’ ]q r = l e n ( s e l f . p r o j e c t [ ’ r enRes ’ ] )x = s e l f . xs c h e d u l e = {}s c h e d u l e [ ’ MakeSpan ’ ] = T = i n t ( s e l f . ge tOb jVa l ( ) + 0 . 5 )s c h e d u l e [ ’ renRes ’ ] = renRes = \

[ [ 0 f o r i i n r a n g e ( q r ) ] f o r t i n r a n g e ( T+1) ]s c h e d u l e [ ’Mode ’ ] = mode = [ ]s c h e d u l e [ ’ S t a r t ’ ] = s t a r t = [ ]s c h e d u l e [ ’ End ’ ] = end = [ ]f o r j , j o b i n enumera t e ( j o b s ) :

s t o p = F a l s ef o r m,M i n enumera t e ( j o b [ ’ Modes ’ ] ) :

f o r t i n r a n g e ( j o b [ ’EF ’ ] , j o b [ ’LF ’ ] + 1 ) :i f x [ j ] [m] [ t ] . v a l > 0 . 5 :

e = ts = e − M[ ’ D u r a t i o n ’ ]mode . append (m)s t a r t . append ( s )end . append ( e )f o r t a u i n r a n g e ( s , e +1) :

f o r r i n r a n g e ( q r ) :r enRes [ t a u ] [ r ] += M[ ’ renRes ’ ] [ r ]

s t o p = Trueb r e a k

i f s t o p :b r e a k

r e t u r n s c h e d u l e

d e f p r i n t S c h e d u l e ( s e l f , s c h e d u l e ) :j o b s = s e l f . p r o j e c t [ ’ Jobs ’ ]q r = l e n ( s e l f . p r o j e c t [ ’ r enRes ’ ] )mode , s t a r t , end = s c h e d u l e [ ’Mode ’ ] , s c h e d u l e [ ’ S t a r t ’ ] , s c h e d u l e [ ’ End ’ ]rRes = s c h e d u l e [ ’ renRes ’ ]p r i n t ( ’ Job s c h e d u l e : ’ )p r i n t ( ’ ’ )p r i n t ( ’ | Job | Mode | S t a r t | End | ’ )p r i n t ( ’|−−−−−−−−+−−−−−−+−−−−−−−−+−−−−−−−−|’ )f o r j , j o b i n enumera t e ( j o b s ) :

p r i n t ( ’ | { ! s} | { : 4 d} | { : 6 d} | { : 6 d} | ’ . f o r m a t ( j o b [ ’Name ’ ] . r j u s t ( 6 )[ : 6 ] , mode [ j ] , s t a r t [ j ] , end [ j ] ) )

p r i n t ( ’ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−’ )#

p r i n t ( ’\ nResource usage : ’ )T = s c h e d u l e [ ’ MakeSpan ’ ]

Page 45: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.4. Project Scheduling 37

p r i n t ( ’ ’ + ’ ’ ∗ (9∗ qr ) )s t r = ’ | t | ’f o r R i n s e l f . p r o j e c t [ ’ r enRes ’ ] :

s t r += ’ { ! s} | ’ . f o r m a t (R[ ’Name ’ ] . r j u s t ( 5 ) [ : 5 ] )p r i n t ( s t r )p r i n t ( ’|−−−−−−− ’ + ’+−−−−−−−’∗ qr ) + ’ | ’f o r t i n r a n g e ( 1 , T+1) :

s t r = ’ | { : 5 d} | ’ . f o r m a t ( t )f o r i i n r a n g e ( q r ) :

s t r += ’ { : 5 d} | ’ . f o r m a t ( rRes [ t ] [ i ] )p r i n t ( s t r )

p r i n t ( ’ −−−−’ + ’− ’ ∗ (9∗ qr ) )

Listing 2.15: MIPCL-PY implementation of project scheduling problem: auxiliary procedures

2.4.3 Example of Usage

The program presented below uses our projectScheduling class to solve an instance of the projectscheduling problem encoded in the data structure (dictionary) named project.# ! / u s r / b i n / py thonfrom p r o j e c t S c h e d u l i n g i m p o r t p r o j e c t S c h e d u l i n g

p r o j e c t = {’Name ’ : ’ p r o j e c t 0 ’ ,’ Hor izon ’ : 36 ,’ renRes ’ : (

{ ’Name ’ : ” 1 ” , ’ Q u a n t i t y ’ : 6} ,{ ’Name ’ : ” 2 ” , ’ Q u a n t i t y ’ : 7} ,{ ’Name ’ : ” 3 ” , ’ Q u a n t i t y ’ : 6}

) ,’ nonRenRes ’ : ({ ’ Nane ’ : ” 1 ” , ’ Q u a n t i t y ’ : 3} , ) ,’ Jobs ’ : (

{’Name ’ : ” 0 ” ,’ Modes ’ : (

{ ’ D u r a t i o n ’ : 3 , ’ r enRes ’ : ( 3 , 2 , 1 ) , ’ nonRenRes ’ : ( 0 , ) } ,{ ’ D u r a t i o n ’ : 2 , ’ r enRes ’ : ( 3 , 2 , 4 ) , ’ nonRenRes ’ : ( 1 , ) }

) ,’ P r ec ’ : ( )

} ,{

’Name ’ : ” 1 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 5 , ’ r enRes ’ : ( 2 , 4 , 2 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( )

} ,{

’Name ’ : ” 2 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 6 , ’ r enRes ’ : ( 3 , 1 , 2 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( 0 , )

} ,{

’Name ’ : ” 3 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 2 , ’ r enRes ’ : ( 4 , 3 , 1 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( 0 , )

} ,

Page 46: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

38 Chapter 2. Operations Scheduling

{’Name ’ : ” 4 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 3 , ’ r enRes ’ : ( 2 , 0 , 3 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( 3 , )

} ,{

’Name ’ : ” 5 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 3 , ’ r enRes ’ : ( 1 , 1 , 1 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( 3 , )

} ,{

’Name ’ : ” 6 ” ,’ Modes ’ : (

{ ’ D u r a t i o n ’ : 4 , ’ r enRes ’ : ( 3 , 1 , 1 ) , ’ nonRenRes ’ : ( 0 , ) } ,{ ’ D u r a t i o n ’ : 3 , ’ r enRes ’ : ( 3 , 2 , 1 ) , ’ nonRenRes ’ : ( 1 , ) }

) ,’ P r ec ’ : ( 1 , )

} ,{

’Name ’ : ” 7 ” ,’ Modes ’ : (

{ ’ D u r a t i o n ’ : 4 , ’ r enRes ’ : ( 3 , 2 , 3 ) , ’ nonRenRes ’ : ( 0 , ) } ,{ ’ D u r a t i o n ’ : 2 , ’ r enRes ’ : ( 3 , 3 , 3 ) , ’ nonRenRes ’ : ( 1 , ) }

) ,’ P r ec ’ : ( 2 , )

} ,{

’Name ’ : ” 8 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 2 , ’ r enRes ’ : ( 4 , 1 , 0 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( 4 , 7 )

} ,{

’Name ’ : ” 9 ” ,’ Modes ’ : (

{ ’ D u r a t i o n ’ : 5 , ’ r enRes ’ : ( 2 , 2 , 2 ) , ’ nonRenRes ’ : ( 0 , ) } ,{ ’ D u r a t i o n ’ : 3 , ’ r enRes ’ : ( 3 , 2 , 3 ) , ’ nonRenRes ’ : ( 1 , ) }

) ,’ P r ec ’ : ( 5 , 6 )

} ,{

’Name ’ : ” 10 ” ,’ Modes ’ : ({ ’ D u r a t i o n ’ : 3 , ’ r enRes ’ : ( 5 , 4 , 2 ) , ’ nonRenRes ’ : ( 0 , ) } , ) ,’ P r ec ’ : ( 8 , )

})

}

prob = p r o j e c t S c h e d u l i n g ( p r o j e c t )prob . model ( )prob . o p t i m i z e ( F a l s e , 3 6 0 0 )s c h e d u l e = prob . g e t S c h e d u l e ( )i f s c h e d u l e i s n o t None :

prob . p r i n t S c h e d u l e ( s c h e d u l e )e l s e :

Page 47: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

2.4. Project Scheduling 39

p r i n t ( ’No s c h e d u l e has been found ’ )

Listing 2.16: Example of usage of class projectScheduling

If we run the above program, it prints two tables: one presents an optimal job schedule, the other oneshows the usage of resources in all periods of the planning horizon.

Job s c h e d u l e :

| Job | Mode | S t a r t | End ||−−−−−−−−+−−−−−−+−−−−−−−−+−−−−−−−−|| 0 | 1 | 0 | 2 || 1 | 0 | 0 | 5 || 2 | 0 | 7 | 13 || 3 | 0 | 3 | 5 || 4 | 0 | 10 | 13 || 5 | 0 | 11 | 14 || 6 | 1 | 6 | 9 || 7 | 1 | 14 | 16 || 8 | 0 | 17 | 19 || 9 | 0 | 14 | 19 || 10 | 0 | 20 | 23 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Resource usage :

| t | 1 | 2 | 3 ||−−−−−−−+−−−−−−−+−−−−−−−+−−−−−−−|| 1 | 5 | 6 | 6 || 2 | 5 | 6 | 6 || 3 | 6 | 7 | 3 || 4 | 6 | 7 | 3 || 5 | 6 | 7 | 3 || 6 | 3 | 2 | 1 || 7 | 6 | 3 | 3 || 8 | 6 | 3 | 3 || 9 | 6 | 3 | 3 || 10 | 5 | 1 | 5 || 11 | 6 | 2 | 6 || 12 | 6 | 2 | 6 || 13 | 6 | 2 | 6 || 14 | 6 | 6 | 6 || 15 | 5 | 5 | 5 || 16 | 5 | 5 | 5 || 17 | 6 | 3 | 2 || 18 | 6 | 3 | 2 || 19 | 6 | 3 | 2 || 20 | 5 | 4 | 2 || 21 | 5 | 4 | 2 || 22 | 5 | 4 | 2 || 23 | 5 | 4 | 2 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Listing 2.17: Output of program from Listing 2.16

Page 48: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

40 Chapter 2. Operations Scheduling

Page 49: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Chapter 3

Facility Layout

The formats by which departments are arranged in a facility are defined by the general pattern of workflow; there are three basic formats — process layout, product layout, and fixed-position layout — andone hybrid format called group technology or cellular layout.

A process layout (also called job-shop or functional layout) is a format in which similar equipmentor functions are grouped together, such as lathes in one area and all stamping machines in another. Apart being worked on then travels, according to the prescribed sequence of operations, from area to area,where the proper machines are located for each operation. This type of layout is typical, for examples,for hospitals, where areas dedicated to particular types of medical care, such as maternity wards andintensive care units.

A product layout (also called flow-shop layout) is one in which equipment or work processes arearranged according to the progressive steps by which the product is made. The path for each part is,very often, a straight line. Production lines for shoes, cars, watches, and chemical plants are all productlayouts.

A group technology (GT) layout (also called cellular layout) groups dissimilar machines into workcenters (or cells) to work on products that have similar shapes and processing requirements. A GT layoutis similar to process layout in that the cells are designed to perform a specific set of processes, and it issimilar to product layout in that the cells are dedicated to a limited range of products.

In a fixed-position layout, a product (because of its bulk or weight) remains at one location. Manu-facturing equipment is moved to the product rather vice versa. Shipyards, construction sites are examplesof this format.

3.1 Process Layout

The most common approach to developing a process layout is to arrange production (or service) depart-ments in a way that minimizes the movements of materials between the departments. In many situations,optimal placement often means placing departments with large amount of interdepartment traffic adjacentto one another.

Suppose that we want to arrange n departments among m sites to minimize the cost of movingdepartments to new places and the interdepartment material handling cost. Let pis denote the cost ofmoving department i to site s. Usually, pis = 0 if department i is currently situated at site s, and pis is arather big number (penalty) if department i cannot be moved to site s. Let us also assume that expectedexpenses on transporting materials between departments i and j, if they where situated at sites s and r,

41

Page 50: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

42 Chapter 3. Facility Layout

are cijsr during a planning horizon (cijsr depends on the material traffic between the departments as wellas the distance between the sites).

3.1.1 Integer Programming Formulation

We introduce two sets of binary variables:

xis = 1 if department i is allocated at site s ∈ Si, and xis = 0 otherwise;

yijsr = 1 only if xis = xjr = 1, and yijsr = 0 otherwise.

With these variables the problem is formulated as follows:

n∑i=1

m∑s=1

pisxis +

n−1∑i=1

n∑j=i+1

m∑s=1

m∑r=1

cijsryijsr → min, (3.1a)

m∑s=1

xis = 1, i = 1, . . . , n, (3.1b)

n∑i=1

xis ≤ 1, s = 1, . . . , n, (3.1c)

2yijsr ≤ xis + xjr, s, r = 1, . . . ,m, j = i+ 1, . . . , n, i = 1, . . . , n− 1, (3.1d)m∑s=1

m∑r=1

yijsr = 1, j = i+ 1, . . . , n, i = 1, . . . , n− 1, (3.1e)

xij ∈ {0, 1}, j = i+ 1, . . . , n, i = 1, . . . , n− 1, (3.1f)

yijsr ∈ {0, 1}, s, r = 1, . . . ,m, j = i+ 1, . . . , n, i = 1, . . . , n− 1. (3.1g)

The objective (3.1a) is to minimize the total expenses on moving the departments and the expenseson transporting materials between the departments. The equations (3.1b) require that each department bemoved to exactly one site, and the inequalities (3.1c) do not allow two departments to share one site. Theinequalities (3.1d) and (3.1e) impose the required relation between the x an y variables (see definition ofyijsr).

3.1.2 MIPCL-PY Implementation

Our implementation of the process layout problem is presented in Listing 3.1.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s P r o c l a y o u t ( Problem ) :d e f model ( s e l f , p , d i s t , f l o w s ) :

d e f c ( i , j , s , r ) :i f s == r : c o s t = 0e l s e :

i f s > r :k = ss = r

Page 51: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

3.1. Process Layout 43

r = kc o s t = d i s t [ s ] [ r−( s +1) ] ∗ f l o w s [ i ] [ j−( i +1) ]

r e t u r n c o s t

s e l f . d i s t , s e l f . f l o w s = d i s t , f l o w sn , m = l e n ( p ) , l e n ( p [ 0 ] )s e l f . x = x = VarVec to r ( [ n ,m] , ” x ” , BIN )y = VarVec to r ( [ n , n ,m,m] , ” y ” , BIN )

min imize (sum ( p [ i ] [ s ]∗ x [ i ] [ s ] f o r i i n r a n g e ( n ) f o r s i n r a n g e (m) ) +\sum ( c ( i , j , s , r ) ∗y [ i ] [ j ] [ s ] [ r ] f o r i i n r a n g e ( n−1) \

f o r j i n r a n g e ( i +1 , n ) \f o r s i n r a n g e ( 0 ,m) f o r r i n r a n g e ( 0 ,m) )

)

f o r i i n r a n g e ( n ) :sum ( x [ i ] [ s ] f o r s i n r a n g e (m) ) == 1

f o r s i n r a n g e (m) :sum ( x [ i ] [ s ] f o r i i n r a n g e ( n ) ) <= 1

f o r i i n r a n g e ( n−1) :f o r j i n r a n g e ( i +1 , n ) :

sum ( y [ i ] [ j ] [ s ] [ r ] f o r s i n r a n g e (m) f o r r i n r a n g e (m) ) == 1

f o r i i n r a n g e ( n−1) :f o r j i n r a n g e ( i +1 , n ) :

f o r s i n r a n g e (m) :f o r r i n r a n g e (m) :

2∗y [ i ] [ j ] [ s ] [ r ] − x [ i ] [ s ] − x [ j ] [ r ] <= 0

Listing 3.1: MIPCL-PY implementation of process layout problem: model

Input parameters:

• p: list of size n×m, where p[i][s] is cost of moving department i to site s;

• dist: list that represents an upper triangular square matrix of sizem, where dist[s][r-(s+1)]is distance between sites s and r, s < r;

• flows: list that represents an upper triangular square matrix of size n, where flows[i][j-(i+1)]is the volume of material moving between departments i and j, i < j.

When a solution has been found, one may want to print it in a readable way. Listing 3.2 presents aprocedure — which is a member of Proclayout — that does this job.

d e f p r i n t S o l u t i o n ( s e l f ) :x = s e l f . xn , m = l e n ( x ) , l e n ( x [ 0 ] )

p r i n t ( ’ T o t a l e x p e n s e s : { 0 : . 4 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )p r i n t ( ’ ’ )p r i n t ( ’ | D ep a r t . | S i t e | ’ )p r i n t ( ’|−−−−−−−−−+−−−−−−−−−| ’ )

Page 52: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

44 Chapter 3. Facility Layout

f o r i i n r a n g e ( n ) :f o r s i n r a n g e (m) :

i f x [ i ] [ s ] . v a l > 0 . 5 :p r i n t ( ’ | {0 :7 d} | {1 :7 d} | ’ . f o r m a t ( i +1 , s +1) )

p r i n t ( ’ −−−−−−−−−−−−−−−−−−−’ )

Listing 3.2: MIPCL-PY implementation of process layout problem: printSolution

3.1.3 Example of Usage

Consider a low-volume toy factory with eight departments:

1) shipping and receiving,

2) sewing,

3) metal forming,

4) plastic molding and stamping,

5) small toy assembly,

6) large toy assembly,

7) mechanism assembly,

8) painting.

Suppose that we want to arrange these eight departments of a toy factory to minimize the total cost ofmoving departments to new locations and the interdepartment material handling cost during planninghorizon of 5 years.

2

1

4

3

6

5

8

7

a)

}3}5

}2}1

}6}7

}4}8

b)

Figure 3.1: Plan of factory building and initial arrangement

To make presentation clearer, let us make some simplifying assumptions. The factory building has 8rooms of equal size, 10 m wide and 10 m long, that are arranged as in Figure 3.1 a). Initially department iis allocated in room i (i = 1, . . . , 8). The cost of moving any department to a new location is $200.Therefore, moving costs are defined by the rule: pii = 0, and pis = 200 for i 6= s.

All materials are transported in a standard-size crate by a forklift truck, one crate to a truck. Supposethat transportation costs are $1 to move one crate between adjacent departments and $1 extra for each

Page 53: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

3.1. Process Layout 45

Table 3.1: Flows between departments

2 3 4 5 6 7 81 0 60 150 40 180 30 202 20 100 20 7 23 03 0 90 125 178 984 75 90 95 805 0 182 1626 115 3257 8

department in between. The expected material flows between departments for one year of operation aregiven in Table 3.1.

The per year interdepartment material handling cost for the initial arrangement of departments iscalculated as follows:

0 · 1 + 60 · 1 + 150 · 2 + 40 · 2 + 180 · 3 + 30 · 3 + 20 · 4+ 20 · 2 + 100 · 1 + 20 · 3 + 7 · 2 + 23 · 4 + 0 · 3

+ 0 · 1 + 90 · 1 + 125 · 1 + 178 · 2 + 98 · 3+ 75 · 2 + 90 · 1 + 95 · 3 + 80 · 2

+ 0 · 1 + 182 · 1 + 162 · 2+ 115 · 2 + 325 · 1

+ 8 · 1 = 4075.

Thus, the material handling cost during the planning horizon is 5 · $4075 = $20375.To solve this instance of the process layout problem, we wrote the program presented in Listing 3.3.

# ! / u s r / b i n / py thonfrom p r o c l a y o u t i m p o r t P r o c l a y o u t

p = [[ 0 , 200 , 200 , 200 , 200 , 200 , 200 , 2 0 0 ] ,[ 2 0 0 , 0 , 200 , 200 , 200 , 200 , 200 , 2 0 0 ] ,[ 2 0 0 , 200 , 0 , 200 , 200 , 200 , 200 , 2 0 0 ] ,[ 2 0 0 , 200 , 200 , 0 , 200 , 200 , 200 , 2 0 0 ] ,[ 2 0 0 , 200 , 200 , 200 , 0 , 200 , 200 , 2 0 0 ] ,[ 2 0 0 , 200 , 200 , 200 , 200 , 0 , 200 , 2 0 0 ] ,[ 2 0 0 , 200 , 200 , 200 , 200 , 200 , 0 , 2 0 0 ] ,[ 2 0 0 , 200 , 200 , 200 , 200 , 200 , 200 , 0 ]

]

d i s t = [[ 1 , 1 , 2 , 2 , 3 , 3 , 4 ] ,[ 2 , 1 , 3 , 2 , 4 , 3 ] ,[ 1 , 1 , 2 , 2 , 3 ] ,[ 2 , 1 , 3 , 2 ] ,[ 1 , 1 , 2 ] ,[ 2 , 1 ] ,[ 1 ]

Page 54: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

46 Chapter 3. Facility Layout

]

f l o w s = [[ 0 , 300 , 750 , 200 , 900 , 150 , 1 0 0 ] ,[ 1 0 0 , 500 , 100 , 35 , 115 , 0 ] ,[ 0 , 450 , 625 , 890 , 4 9 0 ] ,[ 3 7 5 , 450 , 475 , 4 0 0 ] ,[ 0 , 910 , 8 4 0 ] ,[ 5 7 5 , 1 6 2 5 ] ,[ 4 0 ]

]

prob = P r o c l a y o u t ( ” t e s t 1 ” )prob . model ( p , d i s t , f l o w s )prob . o p t i m i z e ( F a l s e )prob . p r i n t S o l u t i o n ( )

Listing 3.3: Example of usage of class Proclayout

If we run this program, we get the following result.

T o t a l e x p e n s e s : 18500 .0000

| D ep a r t . | S i t e ||−−−−−−−−−+−−−−−−−−−|| 1 | 1 || 2 | 2 || 3 | 7 || 4 | 4 || 5 | 6 || 6 | 3 || 7 | 8 || 8 | 5 |−−−−−−−−−−−−−−−−−−−

Listing 3.4: Output of program from Listing 3.3

We see that, if the factory reallocates its departments as it is prescribed in the above table, it willprofit $20375− $18500 = $1875 during the planning horizon of five years.

3.2 Balancing Assembly Lines

Assembly lines are special product-layout production systems that are typical for the industrial produc-tion of high quantity standardized commodities. An assembly line consists of a number of work stationsarranged along a conveyor belt. The work pieces are consecutively launched down the conveyor belt andare moved from one station to the next. At each station, one or several operations, necessary to manufac-ture the product, are performed. The operations in an assembly process usually are interdependent, i.e.there may be precedence requirements that must be enforced. The problem of distributing the operationsamong the stations with respect to some objective function is called the assembly line balancing problem(ALBP). Various classes of assembly line balancing problems have been studied in the literature1. Wewill consider here the simple assembly line balancing problem which is the core of many other ALBP’s.

1 A. Scholl. Balancing and sequencing of assembly lines, Heidelberg: Physica-Verlag, 1999.

Page 55: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

3.2. Balancing Assembly Lines 47

-

-

-HH

HHj

- XXXXz

����:

-

HHHHj-

������

��:

@@@@Rm}116

m}225

m}313

m}49

m}5 8

m}67m}711 m}88

m}913

m}1015 m}11

9

Figure 3.2: Example of SALBP

The manufacturing of some product consists of a set of operations O = {1, . . . , n}. We denote byto the processing time of operation o ∈ O. There are precedence relations between the operations thatare represented by a digraph G = (O, E), where (o1, o2) ∈ E means that operation o1 must be finishedbefore operation o2 starts. Suppose that the demand for the product is such that the assembly line musthave a cycle time C. Thus the running time of each station must not exceed the cycle time.

The simple assembly line balancing problem (SALBP) is to decide what is the minimum number ofstations that is enough for the line running with the given cycle time to fulfill all the operations in anorder consistent with the precedence relation.

An example of SALBP is presented in Figure 3.2. Here the vertices represent operations, and thenumber over any vertex is the processing time of the corresponding operation.

3.2.1 Integer Programming Formulation

To formulate SALBP as an integer program (IP), we need to know an upper bound, m, of the number ofneeded stations. In particular, we can set m to be the the number of station in a solution build by one ofthe heuristics developed for solving SALBPs.

For example, let us consider the heuristic that assigns operations, respecting precedence relations,first to Station 1, then to Station 2, and so on until all the operations have been assigned to the stations.If we apply this heuristic to the example of Figure 3.2 when the cycling time is C = 45, we get thefollowing assignment:

• operations 1 and 2 are accomplished by Station 1,

• operations 3, 4, 5, and 6 — by Station 2,

• operations 7, 8, and 9 — by Station 3,

• operations 10 and 11 — by Station 4.

So in this example we can set m = 4.Let us also note that this heuristic solution is not optimal as there exists an assignment that uses only

three stations:

• operations 1, 3, 5, and 6 are accomplished by Station 1,

• operations 2, 4, and 7 — by Station 2,

Page 56: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

48 Chapter 3. Facility Layout

• operations 8, 9, 10, and 11 — by Station 3.

To write an IP formulation, we introduce the following variables:

ys = 1 if station s is open (in use), ys = 0 otherwise;

xso if operation o is assigned to station s, xso = 0 otherwise;

zo = s if operation o is assigned to station s.

With these variables the model ism∑s=1

ys → min (3.2a)

m∑s=1

xso = 1, o = 1, . . . , n, (3.2b)

n∑o=1

toxso ≤ Cys, s = 1, . . . ,m, (3.2c)

m∑s=1

s xso = zo, o = 1, . . . , n, (3.2d)

zo1 ≤ zo2 , (o1, o2) ∈ E, (3.2e)

ys−1 ≥ ys, s = 2, . . . ,m, (3.2f)

xso ≤ ys, o = 1, . . . , n; s = 1, . . . ,m, (3.2g)

xso ∈ {0, 1}, s = 1, . . . ,m; o = 1, . . . , n, (3.2h)

ys ∈ {0, 1}, s = 1, . . . ,m, (3.2i)

zo ∈ R+, o = 1, . . . , n. (3.2j)

The objective (3.2a) is to minimize the number of open stations. The constraints (3.2b) induce that eachoperation is assign to exactly one station. The capacity constraints (3.2c) enforce that the total runningtime of each open stations does not exceed the cycle time. The constraints (3.2d) establish the relationbetween the assignment variables, binary x and integer z. The precedence relation constraints (3.2e)induce that, for any pair (o1, o2) ∈ E of related operations, operation o1 is assigned to the same or anearlier station than operation o2; this guaranties that operation o1 can be processed before operation o2

starts. The constraints (3.2f) and (3.2g) enforce that earlier stations are opened first.

3.2.2 MIPCL-PY Implementation

A straightforward MIPCL-PY implementation of IP (3.2) is given in Listing 3.5.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s Assembly ( Problem ) :d e f model ( s e l f ,m, C , o p e r a t i o n s ) :

d e f t ( o ) :r e t u r n o p e r a t i o n s [ o ] [ 0 ]

d e f p r e c ( o ) :

Page 57: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

3.2. Balancing Assembly Lines 49

r e t u r n o p e r a t i o n s [ o ] [ 1 ]

n = l e n ( o p e r a t i o n s )s e l f . x = x = VarVec to r ( [m, n ] , ” x ” , BIN )y , z = VarVec to r ( [m] , ” y ” , BIN ) , VarVec to r ( [ n ] , ” z ” )

min imize ( sum ( y [ s ] f o r s i n r a n g e (m) ) )

f o r o i n r a n g e ( n ) :sum ( x [ s ] [ o ] f o r s i n r a n g e (m) ) == 1sum ( ( s +1)∗x [ s ] [ o ] f o r s i n r a n g e (m) ) == z [ o ]f o r o1 i n p r e c ( o ) :

z [ o1 ] <= z [ o ]

f o r s i n r a n g e (m) :sum ( t ( o ) ∗x [ s ] [ o ] f o r o i n r a n g e ( n ) ) <= C∗y [ s ]f o r o i n r a n g e ( n ) :

x [ s ] [ o ] <= y [ s ]

f o r s i n r a n g e ( 1 ,m) :y [ s−1] >= y [ s ]

Listing 3.5: MIPCL-PY implementation of SABL: model

Input parameters:

• m: maximum number of stations (integer);

• C: cycle time (integer);

• operations: dictionary of operations, which item operations[o] is a pair, (t,prec),that describes operation o:

– t: processing time (integer);

– prec: tuple (or list) of preceding operations.

When a solution has been found, one may want to print it in a readable format. Listing 3.6 presentsa procedure — which is a member of Assembly — that does this job.

d e f p r i n t S o l u t i o n ( s e l f ) :x = s e l f . xn = l e n ( x [ 0 ] )

k = i n t ( s e l f . ge tOb jVa l ( ) + 0 . 5 )p r i n t ( ’ Number o f s t a t i o n s = { : d} ’ . f o r m a t ( k ) )

p r i n t ( ’ S t a t i o n : a s s i g n e d o p e r a t i o n s ’ )f o r s i n r a n g e ( k ) :

s t r = r e p r ( s ) + ’ : ’f o r o i n r a n g e ( n ) :

i f x [ s ] [ o ] . v a l > 0 . 5 :s t r += ’ ’ + r e p r ( o )

Page 58: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

50 Chapter 3. Facility Layout

p r i n t ( s t r )

Listing 3.6: MIPCL-PY implementation of SABL: printSolution

3.2.3 Example of Usage

To test our MIPCL-PY model, we wrote a simple program (see Listing 3.7) to balance an assembly linewith at most m = 9 stations and cycling time C = 12, processing times of 17 operations, numberedfrom 0 to 16, are given by list t, and precedence relations are given by list prec.

# ! / u s r / b i n / py thonfrom assembly i m p o r t Assembly

m = 9C = 12

o p e r a t i o n s = {0 : ( 6 , ( ) ) , 1 : ( 7 , ( 0 , ) ) , 2 : ( 5 , ( ) ) ,3 : ( 3 , ( 2 , ) ) , 4 : ( 2 , ( ) ) , 5 : ( 5 , ( 3 , ) ) ,6 : ( 6 , ( 4 , ) ) , 7 : ( 3 , ( ) ) , 8 : ( 4 , ( ) ) ,9 : ( 3 , ( ) ) , 1 0 : ( 4 , ( 4 , 6 ) ) , 1 1 : ( 3 , ( 5 , ) ) ,

1 2 : ( 5 , ( 9 , ) ) , 1 3 : ( 2 , ( 6 , ) ) , 1 4 : ( 6 , ( ) ) ,1 5 : ( 8 , ( 1 4 , ) ) , 1 6 : ( 3 , ( 3 , 7 ) )

}

prob = Assembly ( ” t e s t 1 ” )prob . model (m, C , o p e r a t i o n s )prob . o p t i m i z e ( F a l s e )prob . p r i n t S o l u t i o n ( )

Listing 3.7: Example of usage of class Assembly

If we run the above program, we get the following result.

Number o f s t a t i o n s = 7S t a t i o n : a s s i g n e d o p e r a t i o n s0 : 0 7 91 : 4 6 102 : 1 123 : 13 144 : 8 155 : 2 36 : 5 11 16

Listing 3.8: Output of program from Listing 3.7

Page 59: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Chapter 4

Service Management

Most authorities consider services as economic activities whose output is not a physical product but atime-perishable, intangible process performed to a customer acting in the role of co-producer (JamesFitzsimmons). In services, location of the service facility and direct customer involvement in creatingthe output are often essential factors while in goods production they usually are not. Measuring serviceproductivity also has its own specifics.

4.1 Service Facility Location

The problem of facility location is critical to a company’s eventual success. Service companies’ locationdecisions are guided by variety of criteria. A location close to the customer is especially importantbecause this enables faster delivery goods and services.

Given a set of customer locations N = {1, . . . , n} with bj customers at location j ∈ N , a set ofpotential sitesM = {1, . . . ,m} for locating depots, a fixed cost fi of locating a depot at site i, a capacityui of the depot at site i, and a cost cij of serving customer j from site i during some planning horizon.The facility location problem (FLP) is to decide where to locate depots so that to minimize the total costof locating depots and serving customers.

4.1.1 Integer Programming Formulation

Choosing the following decision variables

yi = 1 if depot is located at site i and yi = 0 otherwise,

xij : number of customers at location j served from depot established at site i,

we formulate the FLP as follows:

m∑i=1

n∑j=1

cijxij +m∑i=1

fiyi → min, (4.1a)

m∑i=1

xij = bj , j = 1, . . . , n, (4.1b)

n∑j=1

xij ≤ uiyi, i = 1, . . . ,m. (4.1c)

51

Page 60: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

52 Chapter 4. Service Management

xij ≤ min{ui, bj}yi, i = 1, . . . ,m, j = 1, . . . , n, (4.1d)

yi ∈ {0, 1}, i = 1, . . . ,m, (4.1e)

xij ∈ Z+, i = 1, . . . ,m, j = 1, . . . , n. (4.1f)

The constraints (4.1b) insure that each customer is served. The capacity constraints (4.1c) inducethat at most ai customers can be served from site i. The redundant constraints (4.1d) are implied by thecapacity constraints. They were introduced to strengthen the formulation.

Let us note, that if all cij = 0 and all fi = 1, then problem (4.1) is to minimize the number of depotsneeded to serve all customers.

4.1.2 MIPCL-PY Implementation

Implementation of IP (3.2) is straightforward and it is given in Listing 4.1.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s F l ( Problem ) :d e f model ( s e l f , q , b , u , f , c ) :

n , m = l e n ( b ) , l e n ( u )s e l f . y = y = VarVec to r ( [m] , ’ y ’ , BIN )s e l f . x = x = VarVec to r ( [m, n ] , ’ x ’ , INT )

min imize (sum ( f [ i ]∗ y [ i ] f o r i i n r a n g e (m) ) + \sum ( c [ i ] [ j ]∗ x [ i ] [ j ] f o r i i n r a n g e (m) f o r j i n r a n g e ( n ) )

)

sum ( y [ i ] f o r i i n r a n g e (m) ) <= q

f o r j i n r a n g e ( n ) :sum ( x [ i ] [ j ] f o r i i n r a n g e (m) ) == b [ j ]

f o r i i n r a n g e (m) :sum ( x [ i ] [ j ] f o r j i n r a n g e ( n ) ) <= u [ i ]∗ y [ i ]

f o r i i n r a n g e (m) :f o r j i n r a n g e ( n ) :

x [ i ] [ j ] <= min ( u [ i ] , b [ j ] ) ∗y [ i ]

Listing 4.1: MIPCL-PY implementation of facility location problem: model

Input parameters:

• q: integer, maximum number of depots;

• b: list, where b[j] is number of customers at location j;

• u: list, where u[i] is depot capacity at site i;

• f: list, where f[i] is fixed cost of locating depot at site i;

Page 61: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.1. Service Facility Location 53

• c: list of lists, where c[i][j] is cost of serving from site i one customer from location j.

When a solution has been found, we can print the result calling the procedure printSolution,which is a member of Fl and is presented in Listing 4.2.

d e f p r i n t S o l u t i o n ( s e l f ) :y , x = s e l f . y , s e l f . xm, n = l e n ( y ) , l e n ( x [ 0 ] )

p r i n t ( ’ O b j e c t i v e v a l u e : { 0 : . 2 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )f o r i i n r a n g e (m) :

i f y [ i ] . v a l > 0 . 5 :p r i n t ( ’\n===== F a c i l i t y a t s i t e { ! r } s e r v e s c u s t o m e r s : ’ . f o r m a t ( i +1) )f o r j i n r a n g e ( n ) :

i f x [ i ] [ j ] . v a l > 0 . 5 :p r i n t ( ’\ t { : . 0 f } from l o c . { ! r } ’ . f o r m a t ( x [ i ] [ j ] . va l , j +1) )

Listing 4.2: MIPCL-PY implementation of facility location problem: printSolution

4.1.3 Examples of Usage: Locating Two Medical Clinics

Two clinics, both of capacity 40, are to be established to provide medical care for people living in fivecommunities, A, B, C, D and E. The population of each community and distances between communitiesare given in Table 4.1. Assume that clinics can be allocated at any of the communities with the sameexpenses (so we may assume that the fixed costs of allocating clinics are zeroes), and the population ofeach community is evenly distributed within the community’s boundaries. The problem is to allocate twoclinics so that to minimize the overall travel distance.

Table 4.1: Population and distances between communities

Com- Distance to (km) Populationmunity A B C D E (thousands)

A 0 11 8 12 15 10B 11 0 10 7 13 8C 8 10 0 9 9 20D 12 7 9 0 6 12E 15 13 9 6 0 14

To solve this example, we prepared the program, presented in Listing 4.3.

# ! / u s r / b i n / py thonfrom f l i m p o r t F l

q = 2b = [ 1 0 , 8 , 20 , 12 , 14]u = [ 4 0 , 40 , 40 , 40 , 40]f = [ 0 , 0 , 0 , 0 , 0 ]c = [

[ 0 , 11 , 8 , 12 , 1 5 ] ,

Page 62: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

54 Chapter 4. Service Management

[ 1 1 , 0 , 10 , 7 , 1 3 ] ,[ 8 , 10 , 0 , 9 , 9 ] ,[ 1 2 , 7 , 9 , 0 , 6 ] ,[ 1 5 , 13 , 9 , 6 , 0 ]

]

prob = Fl ( ” t e s t 1 ” )prob . model ( q , b , u , f , c )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 4.3: Example of usage of class Fl

If we run this program, we get the following result.O b j e c t i v e v a l u e : 220 .00

===== F a c i l i t y a t s i t e 3 s e r v e s c u s t o m e r s :10 from l o c . 120 from l o c . 3

===== F a c i l i t y a t s i t e 4 s e r v e s c u s t o m e r s :8 from l o c . 212 from l o c . 414 from l o c . 5

Listing 4.4: Output of program from Listing 4.3

4.2 Data Envelopment Analysis

Data Envelopment Analysis (DEA) is a technique used to measure the relative performance of branchesof multisite service organizations such as banks, public agencies, fast food services, and many others.DEA provides a more comprehensive and reliable measure of efficiency than any measure composed ofa set of operating ratios or profit measures. A DEA model compares each branch with all other branchesand computes an efficiency rating that is the ratio of weighted product or service outputs to weightedresource inputs. A branch is deemed to be efficient if it is not possible to find a mixture of proportionsof other branches whose combined inputs do not exceed those of the branch being estimated, but whoseoutputs are equal to, or exceed, those of the branch being estimated. Should this not be possible thebranch is deemed to be inefficient and the comparator branches can be identified. The key advantage isthat DEA permits using multiple inputs such as materials and labor hours, and multiple outputs such asproducts sold and repeat customers.

4.2.1 Linear Programming Formulation

Let us assume that there are n service units which are numbered as 1, . . . , n. For one time period, serviceunit i (i = 1, . . . , n) used rij units of resource j (j = 1, . . . ,m), and provided sik services of type k(k = 1, . . . , l). The efficiency of unit i is estimated by the ratio

Ei(u, v)def=

∑lk=1 sikuk∑mj=1 rijvj

,

where uk and vj are weights to be determined by the DEA model.

Page 63: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.2. Data Envelopment Analysis 55

The rating of service unit i0 is computed by solving the following problem of fractional linear pro-gramming:

max{Ei0(u, v) : Ei(u, v) ≤ 1, i = 1, . . . , n; i 6= i0; u ∈ Rl+, v ∈ Rm+}.

This problem can be reformulated as the folloving LP:

l∑k=1

si0kuk → max, (4.2a)

m∑j=1

ri0jvj = 1, (4.2b)

l∑k=1

sikuk ≤m∑j=1

rijvj , i ∈ {1, . . . , n} \ {i0}, (4.2c)

uk ≥ 0, k = 1, . . . , l, (4.2d)

vj ≥ 0, j = 1, . . . ,m. (4.2e)

Let (u∗, v∗) be an optimal solution to problem (4.2). If Ei0(u∗, v∗) < 1, then service unit i0 workedinefficiently, and the unit can improve its efficiency by using some experience of more efficient units ifor which Ei(u∗, v∗) = 1.

To demonstrate, let us consider a small example. A firm established six units each located in stripshopping center parking lot. Only a standard meal consisting of a burger, fries, and a drink is sold in eachunit. Management has decided to use DEA to improve productivity by identifying which units are usingtheir resources most efficiently. Table 4.2 presents data for DEA analysis.

Table 4.2: Data for DEA analysis

Service Labour Material Mealsunit (hours) (dollars) sold

1 32 3200 16002 16 600 4003 24 600 6004 24 400 4005 16 160 2006 8 40 80

To compute the rating of Firm 1, we formulate the following LP:

E1 = 1600u1 → max,

32v1 − 3200v2 = 1,

400u1 − 16v1 − 600v2 ≤ 0,

600u1 − 24v1 − 600v2 ≤ 0,

Page 64: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

56 Chapter 4. Service Management

400u1 − 24v1 − 400v2 ≤ 0,

200u1 − 16v1 − 160v2 ≤ 0,

80u1 − 8v1 − 40v2 ≤ 0,

u1, v1, v2 ≥ 0.

4.2.2 MIPCL-PY Implementation

Our implementation of LP (4.2) is given in Listing 4.5.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s Dea ( Problem ) :d e f model ( s e l f , i0 , r s ) :

d e f r ( i , j ) :r e t u r n r s [ i ] [ 0 ] [ j ]

d e f s ( i , k ) :r e t u r n r s [ i ] [ 1 ] [ k ]

s e l f . r s = r sn , m, l = l e n ( r s ) , l e n ( r s [ 0 ] [ 0 ] ) , l e n ( r s [ 0 ] [ 1 ] )

s e l f . i 0 = i 0 = i0−1s e l f . u = u = VarVec to r ( [ l ] , ” u ” )s e l f . v = v = VarVec to r ( [m] , ” v ” )

maximize ( sum ( s ( i0 , k ) ∗u [ k ] f o r k i n r a n g e ( l ) ) )

sum ( r ( i0 , j ) ∗v [ j ] f o r j i n r a n g e (m) ) == 1

f o r i i n r a n g e ( n ) :i f i != i 0 :

sum ( s ( i , k ) ∗u [ k ] f o r k i n r a n g e ( l ) ) \<= sum ( r ( i , j ) ∗v [ j ] f o r j i n r a n g e (m) )

Listing 4.5: MIPCL-PY implementation of DEA: model

Input parameters:

• i0: integer, service unit to be estimated;

• rs: list, which items are pairs of tuples, where, for one period, service unit i

– uses rs[i][0][j] units of resource j,

– and provides rs[i][1][k] services of type k.

To compute the ratings for all n firms, we need to solve n LPs of type (4.2). Therefore, our MIPCL-PY implementation of the DEA problem somewhat differs from most other applications in this manual.

When a solution has been found, we can print the result using the procedure printSolution,which is a member of Dea and is presented in Listing 4.6.

Page 65: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.2. Data Envelopment Analysis 57

d e f p r i n t S o l u t i o n ( s e l f ) :d e f r ( i , j ) :

r e t u r n r s [ i ] [ 0 ] [ j ]d e f s ( i , k ) :

r e t u r n r s [ i ] [ 1 ] [ k ]

u , v , r s = s e l f . u , s e l f . v , s e l f . r sn , m, l = l e n ( r s ) , l e n ( v ) , l e n ( u )

p r i n t ( ’=> Uni t { ! r } of r a t i n g { : . 4 f } ’ . f o r m a t ( s e l f . i 0 +1 , s e l f . ge tOb jVa l ( ) ) )s t r = ’ v = ( ’f o r j i n r a n g e (m−1) :

s t r += ’ { : . 4 f } , ’ . f o r m a t ( v [ j ] . v a l )p r i n t ( s t r + ’ { : . 4 f } ) ’ . f o r m a t ( v [m−1] . v a l ) )s t r = ’ u = ( ’f o r k i n r a n g e ( l −1) :

s t r += ’ { : . 4 f } , ’ . f o r m a t ( u [ k ] . v a l )p r i n t ( s t r + ’ { : . 4 f } ) ’ . f o r m a t ( u [ l −1] . v a l ) )

p r i n t ( ’ ’ )p r i n t ( ’ | Uni t | R e l a t i v e | Weighted sum of | ’ )p r i n t ( ’ | | r a t i n g | i n p u t s | o u t p u t s | ’ )p r i n t ( ’|−−−−−−+−−−−−−−−−−+−−−−−−−−−+−−−−−−−−−|’ )f o r i i n r a n g e ( n ) :

Ri = 0 . 0f o r j i n r a n g e (m) :

Ri += r ( i , j ) ∗v [ j ] . v a lS i = 0 . 0f o r k i n r a n g e ( l ) :

S i += s ( i , k ) ∗u [ k ] . v a lp r i n t ( ’ | { : 4 d} | { : 6 . 4 f } | { : 7 . 4 f } | { : 7 . 4 f } | ’ . f o r m a t ( i +1 , S i / Ri , Ri , S i

) )p r i n t ( ’ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−’ )

Listing 4.6: MIPCL-PY implementation of DEA: printSolution

4.2.3 Example of Usage

A car manufacturer wants to evaluate the efficiency of different garages who have received a franchiseto sell its cars. The inputs are: staff, showroom space, catchment population in different economiccategories, and inquiries for different brands of car. The outputs are: number sold of different brands ofcar and annual profit. Table 4.3 gives the inputs and outputs for each of the 26 franchised garages.

The program from Listing 4.7 computes the efficiency rating of Garage 1.

# ! / u s r / b i n / py thonfrom dea i m p o r t Dea

r s = (( ( 3 . 0 , 3 . 6 , 3 . 0 , 3 . 0 , 2 . 5 , 1 . 5 ) , ( 0 . 8 , 0 . 2 , 0 . 4 5 ) ) ,( ( 6 . 0 , 7 . 5 , 1 0 . 0 , 1 0 . 0 , 7 . 5 , 4 . 0 ) , ( 1 . 5 , 0 . 4 5 , 0 . 4 5 ) ) ,( ( 7 . 0 , 6 . 0 , 5 . 0 , 7 . 0 , 8 . 5 , 4 . 5 ) , ( 1 . 2 , 0 . 4 8 , 2 . 0 ) ) ,( ( 7 . 0 , 8 . 0 , 7 . 0 , 8 . 0 , 3 . 0 , 2 . 0 ) , ( 1 . 9 , 0 . 7 , 0 . 5 ) ) ,( ( 1 4 . 0 , 9 . 0 , 2 0 . 0 , 2 5 . 0 , 1 0 . 0 , 6 . 0 ) , ( 2 . 6 , 0 . 8 6 , 1 . 9 ) ) ,( ( 1 0 . 0 , 9 . 0 , 1 0 . 0 , 1 0 . 0 , 1 1 . 0 , 5 . 0 ) , ( 2 . 4 , 1 . 0 , 2 . 0 ) ) ,( ( 3 . 0 , 3 . 5 , 3 . 0 , 2 0 . 0 , 2 . 0 , 1 . 5 ) , ( 0 . 9 , 0 . 3 5 , 0 . 5 ) ) ,

Page 66: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

58 Chapter 4. Service Management

Table 4.3: Inputs and outputs of franchised garages

Inputs Outputs

Gar

age

Staf

f

Spac

e(1

00m

2)

Popn

.1(1

000s)

Popn

.2(1

000s)

Mod

el1

inq.

(100

s)

Mod

el2

inq.

(100

s)

Mod

el1

sale

s(1

000s

)

Mod

el2

sale

s(1

000s

)

Profi

t(m

illio

ns)

1 3 3.6 3 3 2.5 1.5 0.8 0.2 0.452 6 7.5 10 10 7.5 4 1.5 0.45 0.453 7 6 5 7 8.5 4.5 1.2 0.48 24 7 8 7 8 3 2 1.9 0.7 0.55 14 9 20 25 10 6 2.6 0.86 1.96 10 9 10 10 11 5 2.4 1 27 3 3.5 3 20 2 1.5 0.9 0.35 0.58 12 8 7 10 12 7 4.5 2 2.39 5 5 10 10 5 2.5 2 0.65 0.9

10 8 10 30 35 9.5 4.5 2.05 0.75 1.711 2 3 40 40 2 1.5 0.8 0.25 0.512 5 6.5 9 12 8 4.5 1.8 0.63 1.413 7 8 10 12 8.5 4 2 0.6 1.514 11 8 8 10 10 6 2.2 0.65 2.215 4 5 10 10 7.5 3.5 1.8 0.62 1.616 24 15 15 13 25 1.9 8 2.6 4.517 30 29 120 80 35 20 7 2.5 818 4 6 1 1 7.5 3.5 1.1 0.45 1.719 6 5.5 2 2 8 5 1.5 0.55 1.5520 8 7.5 5 8 9 4 2.1 0.85 221 5 5.5 8 10 7 3.5 1.2 0.45 1.322 25 16 110 80 27 12 6.5 3.5 5.423 19 10 90 22 25 13 5.5 3.1 4.524 6 6 20 30 9 4.5 2.3 0.7 1.625 6 7 50 40 8.5 3 2.5 0.9 1.626 21 12 6 6 15 8 6 0.25 2.9

Page 67: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.2. Data Envelopment Analysis 59

( ( 1 2 . 0 , 8 . 0 , 7 . 0 , 1 0 . 0 , 1 2 . 0 , 7 . 0 ) , ( 4 . 5 , 2 . 0 , 2 . 3 ) ) ,( ( 5 . 0 , 5 . 0 , 1 0 . 0 , 1 0 . 0 , 5 . 0 , 2 . 5 ) , ( 2 . 0 , 0 . 6 5 , 0 . 9 ) ) ,( ( 8 . 0 , 1 0 . 0 , 3 0 . 0 , 3 5 . 0 , 9 . 5 , 4 . 5 ) , ( 2 . 0 5 , 0 . 7 5 , 1 . 7 ) ) ,( ( 2 . 0 , 3 . 0 , 4 0 . 0 , 4 0 . 0 , 2 . 0 , 1 . 5 ) , ( 0 . 8 , 0 . 2 5 , 0 . 5 ) ) ,( ( 5 . 0 , 6 . 5 , 9 . 0 , 1 2 . 0 , 8 . 0 , 4 . 5 ) , ( 1 . 8 , 0 . 6 3 , 1 . 4 ) ) ,( ( 7 . 0 , 8 . 0 , 1 0 . 0 , 1 2 . 0 , 8 . 5 , 4 . 0 ) , ( 2 . 0 , 0 . 6 , 1 . 5 ) ) ,( ( 1 1 . 0 , 8 . 0 , 8 . 0 , 1 0 . 0 , 1 0 . 0 , 6 . 0 ) , ( 2 . 2 , 0 . 6 5 , 2 . 2 ) ) ,( ( 4 . 0 , 5 . 0 , 1 0 . 0 , 1 0 . 0 , 7 . 5 , 3 . 5 ) , ( 1 . 8 , 0 . 6 2 , 1 . 6 ) ) ,( ( 2 4 . 0 , 1 5 . 0 , 1 5 . 0 , 1 3 . 0 , 2 5 . 0 , 1 . 9 ) , ( 8 . 0 , 2 . 6 , 4 . 5 ) ) ,( ( 3 0 . 0 , 2 9 . 0 , 1 2 0 . 0 , 8 0 . 0 , 3 5 . 0 , 2 0 . 0 ) , ( 7 . 0 , 2 . 5 , 8 . 0 ) ) ,( ( 4 . 0 , 6 . 0 , 1 . 0 , 1 . 0 , 7 . 5 , 3 . 5 ) , ( 1 . 1 , 0 . 4 5 , 1 . 7 ) ) ,( ( 6 . 0 , 5 . 5 , 2 . 0 , 2 . 0 , 8 . 0 , 5 . 0 ) , ( 1 . 5 , 0 . 5 5 , 1 . 5 5 ) ) ,( ( 8 . 0 , 7 . 5 , 5 . 0 , 8 . 0 , 9 . 0 , 4 . 0 ) , ( 2 . 1 , 0 . 8 5 , 2 . 0 ) ) ,( ( 5 . 0 , 5 . 5 , 8 . 0 , 1 0 . 0 , 7 . 0 , 3 . 5 ) , ( 1 . 2 , 0 . 4 5 , 1 . 3 ) ) ,( ( 2 5 . 0 , 1 6 . 0 , 1 1 0 . 0 , 8 0 . 0 , 2 7 . 0 , 1 2 . 0 ) , ( 6 . 5 , 3 . 5 , 5 . 4 ) ) ,( ( 1 9 . 0 , 1 0 . 0 , 9 0 . 0 , 2 2 . 0 , 2 5 . 0 , 1 3 . 0 ) , ( 5 . 5 , 3 . 1 , 4 . 5 ) ) ,( ( 6 . 0 , 6 . 0 , 2 0 . 0 , 3 0 . 0 , 9 . 0 , 4 . 5 ) , ( 2 . 3 , 0 . 7 , 1 . 6 ) ) ,( ( 6 . 0 , 7 . 0 , 5 0 . 0 , 4 0 . 0 , 8 . 5 , 3 . 5 ) , ( 2 . 5 , 0 . 9 , 1 . 6 ) ) ,( ( 2 1 . 0 , 1 2 . 0 , 6 . 0 , 6 . 0 , 1 5 . 0 , 8 . 0 ) , ( 6 . 0 , 0 . 2 5 , 2 . 9 ) )

)

prob = Dea ( ” g a r a g e s ” )prob . model ( 1 , r s )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 4.7: Example of usage of class Dea

Running this program, we get the following result.

=> Uni t 1 o f r a t i n g 0 .8888v = ( 0 . 0 1 8 1 , 0 . 0 0 0 0 , 0 . 0 0 0 0 , 0 . 0 1 0 6 , 0 . 3 6 5 6 , −0.0000)u = ( 0 . 2 9 4 4 , 0 . 0 4 7 4 , 1 . 4 3 0 6 )

| Uni t | R e l a t i v e | Weighted sum of || | r a t i n g | i n p u t s | o u t p u t s ||−−−−−−+−−−−−−−−−−+−−−−−−−−−+−−−−−−−−−|| 1 | 0 .8888 | 1 .0000 | 0 .8888 || 2 | 0 .3744 | 2 .9564 | 1 .1068 || 3 | 0 .9785 | 3 .3084 | 3 .2373 || 4 | 1 .0000 | 1 .3079 | 1 .3079 || 5 | 0 .8445 | 4 .1735 | 3 .5245 || 6 | 0 .8391 | 4 .3084 | 3 .6153 || 7 | 1 .0000 | 0 .9969 | 0 .9969 || 8 | 1 .0000 | 4 .7102 | 4 .7102 || 9 | 0 .9422 | 2 .0242 | 1 .9072 || 10 | 0 .7701 | 3 .9881 | 3 .0712 || 11 | 0 .8088 | 1 .1903 | 0 .9627 || 12 | 0 .8155 | 3 .1423 | 2 .5627 || 13 | 0 .8221 | 3 .3612 | 2 .7632 || 14 | 0 .9660 | 3 .9608 | 3 .8259 || 15 | 0 .9754 | 2 .9203 | 2 .8484 || 16 | 0 .9181 | 9 .7120 | 8 .9165 || 17 | 0 .9605 | 14 .1850 | 13 .6245 || 18 | 0 .9831 | 2 .8252 | 2 .7773 || 19 | 0 .8790 | 3 .0547 | 2 .6852 || 20 | 1 .0000 | 3 .5198 | 3 .5198 |

Page 68: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

60 Chapter 4. Service Management

| 21 | 0 .8109 | 2 .7555 | 2 .2345 || 22 | 0 .8778 | 11 .1696 | 9 .8050 || 23 | 0 .8443 | 9 .7168 | 8 .2041 || 24 | 0 .8071 | 3 .7163 | 2 .9994 || 25 | 0 .8430 | 3 .6392 | 3 .0677 || 26 | 1 .0000 | 5 .9273 | 5 .9273 |−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Listing 4.8: Output of program from Listing 4.7

We see that unit 1 with DEA rating of 0.888808 works inefficiently. Five units, 4,7,8,20, and 26, aremore efficient than unit 1, and management can suggest changes to improve productivity of unit 1 basedon experience of units 4, 7, 8, 20, and 26.

4.3 Yield management

Yield management is an approach to revenue maximization for service firms that exhibit the followingcharacteristics:

1. Relatively fixed capacity. Service firms with substantial investment in facilities (e.g., hotels andairlines) are capacity-constrained (once all the seats on a flight are sold, further demand can be metonly by booking passengers on a later flight).

2. Ability to segment its market into different customer classes. Developing various price-sensitiveclasses of service gives firms more flexibility in different seasons of the year.

3. Perishable inventory. Revenue from an unsold seat in a plane or from unsold room in a hotel islost forever.

4. Reservation systems are adopted by service firms to sell capacity in advance of use. However,managers are faced with uncertainty of whether to accept an early reservation at a discount priceor to wait in hope to sell later seats or rooms at a higher price.

5. Fluctuating demand. To sell more seats or rooms and increase revenue, in periods of slow demandmanagers can lower prices, while in periods of high demand prices are higher.

4.3.1 Yield Management In Airline Industry

Now let us consider a concrete problem. An airline starts selling tickets for a flight to a particulardestination D days before the departure. The time horizon of D days are divided into T periods ofunequal length (for example, a time horizon of D = 60 days can be divided into T = 4 periods of length30, 20, 7 and 3 days). The airline can use one of K available planes, the seats in all planes are dividedinto the same number, I , of classes. Plane k (k = 1, . . . ,K) costs fk to hire, and has qki of seats ofclass i (i = 1, . . . , I). For example, plane k may have qk,1 = 30 first class seats, qk,2 = 40 business classseats, and qk,3 = 60 economy class seats. In plane k, up to rlki and rhki seats of class i can be transformedinto seats of lower, i− 1, and higher, i+ 1, classes, i = 1, . . . , I . It is assumed that tlk,1 = 0 and thkI = 0.

For administrative simplicity, in each period t (t = 1, . . . , T ) only O price options can be used, andlet ctio denote the price of a seat of class i (i = 1, . . . , I) in period t if option o is used.

Demand is uncertain but it is affected by ticket prices. Let us assume that S scenarios are possible ineach period. The probability of scenario s (1 ≤ s ≤ S) in period T is pts,

∑Ss=1 pts = 1. The results of

Page 69: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.3. Yield management 61

demand forecasting are at our disposal: if scenario s occurs in period t, and price option o is used in thisperiod, then the demand for seats of class i will be dtsoi.

We have to choose a plane to hire, and to decide, for each of T periods, which price options to use,how many seats to sell in each class (depending on demand). Our goal is to maximize expected yield.

Let us also note that period t starts at time t− 1 and ends at time t. Therefore, it is assumed that thedecision which option to use in period t is made at time t − 1. The other decision how many seats ofeach class to sell depends on the demand in this period; therefore, this decision is assumed to be made attime t (the end of period t).

4.3.2 Mixed-Integer Programming Formulation

To write a deterministic model for this stochastic problem, we need to describe a scenario tree. In thisapplication the scenario tree has n + 1 =

∑Tt=0 |Vt| nodes, where Vt denotes the set of nodes in level t,

t = 0, 1, . . . , T . Let us also assume that the root of the scenario tree is indexed by 0, then V0 = {0} andV = ∪Tt=0Vt.

Each node j ∈ Vt (t = 1, . . . , T ) corresponds to one of the histories, h(j) = (s1, s2, . . . , st), thatmay happen after t periods, where sτ is an index of a scenario for period τ . By definition, the historyof the root node is empty, h(0) = (). The parent of node j, denoted by parent(j), is that node in Vt−1

which history is (s1, s2, . . . , st−1), i.e, h(j) = (h(parent(j)), st). Note, that the root node 0 is theparent of all nodes in V1 (of level 1). In what follows, if we say that something is doing at node j itmeans that this is doing when the history h(j) is realized.

For j ∈ V \ {0}, the history h(j) is realized with probability p̄jdef=

∏tτ=1 pτ,sτ , p̄0

def= 1. If price

option o is used at node j, the demand for seats of class i is d̄joidef= dt,st,o,i, and their price is ctoi. Let us

define c̄joidef= p̄jctoi.

Now let us define the variables. The first family of binary variables is to decide which plane to use.For each plane k we define

• vk = 1 if plane k is used, and vk = 0 otherwise.

Having hired a plane, we need to decide how to transform the seats in that plane. So, we define twofamilies of integer variables:

• wli: number of seats of class i to be transformed into seats of class i− 1, i = 2, . . . , I;

• whi : number of seats of class i to be transformed into seats of class i+ 1, i = 1, . . . , I − 1.

With each node j ∈ V \ VT of the scenario tree we associate the following decision variables:

• yjo = 1 if price option o is used at node j, and yjo = 0 otherwise.

We also introduce two families of auxiliary variables. For each node j ∈ V \{0}we use the followingvariables:

• xjoi: number of seats of class i to be sold at node j using price option o.

Each node j ∈ V \ {0} is also associated with the variables:

• zji: total number of seats of class i to be sold at node j.

Page 70: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

62 Chapter 4. Service Management

In these variables we write down the following deterministic model:

−K∑k=1

fkvk +∑

j∈V \VT

O∑o=1

I∑i=1

c̄joixjoi → max, (4.3a)

K∑k=1

vk = 1, (4.3b)

ui =K∑k=1

qkivk, i = 1, . . . , I, (4.3c)

wli ≤K∑k=1

tlkivk, i = 1, . . . , I, (4.3d)

whi ≤K∑k=1

thkivk, i = 1, . . . , I, (4.3e)

O∑o=1

yjo = 1, j ∈ V \ VT , (4.3f)

xjoi ≤ d̄jio yparent(j),o, j ∈ V \ {0}, i = 1, . . . , I, o = 1, . . . , O, (4.3g)

zji = zparent(j),i +O∑o=1

xjoi , i = 1, . . . , I, j ∈ V \ {0}, (4.3h)

zj,1 + wh1 ≤ u1 + wl2 , j ∈ VT , (4.3i)

zji + wli + whi ≤ ui + whi−1 + wli+1 , i = 2, . . . , I − 1, j ∈ VT , (4.3j)

zjI + wlI ≤ uI + whI−1 , j ∈ VT , (4.3k)

xjoi ∈ Z+, j ∈ V \ {0}, o = 1, . . . , O, i = 1, . . . , I, (4.3l)

yjo ∈ {0, 1}, j ∈ V \ VT , o = 1, . . . , O, (4.3m)

zji ∈ Z+, j ∈ V, i = 1, . . . , I, (4.3n)

z0i = 0, i = 1, . . . , I, (4.3o)

vk ∈ Z+ , k = 1, . . . ,K, (4.3p)

wli, whi ∈ Z+, i = 1, . . . , I. (4.3q)

The objective (4.3a) is to maximize the profit from selling seats minus the expenses for hiring aplane. Equation (4.3b) prescribes to hire just one plane, and Eqs. (4.3c) determine the capacities of allseat classes in the hired plane. Inequalities (4.3d) and (4.3e) restrict the number of seats in any class thatcan be transformed into seats of the lower and higher classes. Equations (4.3f) prescribe to choose onlyone price option at each not leaf node. The variable upper bounds (4.3g) guarantee that, in any periodand for any price option, the number of seats sold for each class does not exceed the demand. Equations(4.3h) calculate the total number of seats in each class that are sold in any of T periods. Inequalities(4.3i)–(4.3k) imply that, for each class, the number of sold seats plus the number of seats transformedinto seats of adjacent classes does not exceed the total number of seats of this class plus the number ofseats of adjacent classes transformed into seats of this class.

Page 71: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.3. Yield management 63

When (4.3) is solved, we know which option, o1, to use and how many seats of each class to sell inperiod 1. When period 1 is over, we will know the actual number of seats, s1

i , of each class i sold in thisperiod. To determine a price option and the number of seats of each class to be sold in period 2, we willsolve a new planning problem for the time horizon covering periods 2, . . . , T . Writing (4.3) for this newproblem, we need to modify (4.3c) in order to take into account the seats sold in period 1:

ui =K∑k=1

qkivk − s1i , i = 1, . . . , I.

Similarly, we will determine a price option and the number of seats of each class to be sold in anysubsequent period t when period t− 1 is over.

4.3.3 MIPCL-PY Implementation

Our MIPCL-PY implementation of IP (4.3) is given in Listing 4.9.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

c l a s s Revenue ( Problem ) :d e f i n i t ( s e l f , name , p l a n e s , o p t i o n s , nodes ) :

Problem . i n i t ( s e l f , name )s e l f . p l a n e s , s e l f . o p t i o n s , s e l f . nodes = p l a n e s , o p t i o n s , nodess e l f . p r o c e s s D a t a ( )

d e f p r o c e s s D a t a ( s e l f ) :nodes = s e l f . nodesn0 , n , T = −1, l e n ( nodes ) , l e n ( s e l f . o p t i o n s ) ,f o r j i n r a n g e ( 1 , n ) :

nodes [ j ] [ ’ p rob ’ ] ∗= nodes [ nodes [ j ] [ ’ p a r e n t ’ ] ] [ ’ p rob ’ ]i f n0 < 0 :

i f nodes [ j ] [ ’ p e r i o d ’ ] == T :n0 = j

s e l f . n0 = n0 # number o f i n t e r n a l nodes ( n o t l e a v e s )

d e f model ( s e l f , p l a n e s , o p t i o n s , nodes ) :d e f c ( j , o , i ) : r e t u r n nodes [ j ] [ 3 ] ∗ o p t i o n s [ nodes [ j ] [ 1 ] −1 ] [ o ] [ i ]d e f d ( j , i , o ) : r e t u r n nodes [ j ] [ o + 4 ] [ i ]d e f p a r e n t ( j ) : r e t u r n nodes [ j ] [ 2 ]d e f q ( k , i ) : r e t u r n p l a n e s [ k ] [ ’ c l a s s e s ’ ] [ i ] [ 0 ]d e f t l ( k , i ) : r e t u r n p l a n e s [ k ] [ ’ c l a s s e s ’ ] [ i ] [ 1 ]d e f t h ( k , i ) : r e t u r n p l a n e s [ k ] [ ’ c l a s s e s ’ ] [ i ] [ 2 ]d e f f ( k ) : r e t u r n p l a n e s [ k ] [ 1 ]

s e l f . p l a n e s , s e l f . o p t i o n s , s e l f . nodes = p l a n e s , o p t i o n s , nodesK, T , O, I = l e n ( p l a n e s ) , l e n ( o p t i o n s ) , l e n ( o p t i o n s [ 0 ] ) , l e n ( o p t i o n s [ 0 ] [ 0 ] )n , n0 = l e n ( nodes ) , s e l f . n0

s e l f . v = v = VarVec to r ( [K] , ” v ” , BIN )u = VarVec to r ( [ I ] , ” u ” , INT )wl , wh = VarVec to r ( [ I ] , ” wl ” , INT ) , VarVec to r ( [ I ] , ”wh” , INT )x = VarVec to r ( [ n , O, I ] , ” x ” , INT ) # x [ 0 ] i s n o t useds e l f . y = y = VarVec to r ( [ n0 ,O] , ” y ” , BIN )z = VarVec to r ( [ n , I ] , ” z ” , INT )

Page 72: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

64 Chapter 4. Service Management

maximize (sum ( c ( j , o , i ) ∗x [ j ] [ o ] [ i ] f o r j i n r a n g e ( 1 , n ) \

f o r o i n r a n g e (O) f o r i i n r a n g e ( I ) ) \− sum ( f ( k ) ∗v [ k ] f o r k i n r a n g e (K) ) \

)

sum ( v [ k ] f o r k i n r a n g e (K) ) == 1f o r i i n r a n g e ( I ) :

u [ i ] == sum ( q ( k , i ) ∗v [ k ] f o r k i n r a n g e (K) )wl [ i ] <= sum ( t l ( k , i ) ∗v [ k ] f o r k i n r a n g e (K) )wh [ i ] <= sum ( t h ( k , i ) ∗v [ k ] f o r k i n r a n g e (K) )

f o r j i n r a n g e ( n0 ) :sum ( y [ j ] [ o ] f o r o i n r a n g e (O) ) == 1 ;

f o r j i n r a n g e ( 1 , n ) :f o r o i n r a n g e (O) :

f o r i i n r a n g e ( I ) :x [ j ] [ o ] [ i ] <= d ( j , o , i ) ∗y [ p a r e n t ( j ) ] [ o ]

f o r i i n r a n g e ( I ) : z [ 0 ] [ i ] == 0

f o r j i n r a n g e ( 1 , n ) :f o r i i n r a n g e ( I ) :

z [ j ] [ i ] == z [ p a r e n t ( j ) ] [ i ] + sum ( x [ j ] [ o ] [ i ] f o r o i n r a n g e (O) )

f o r j i n r a n g e ( n0 , n ) :z [ j ] [ 0 ] + wh [ 0 ] <= u [ 0 ] + wl [ 1 ]z [ j ] [ I−1] + wl [ I−1] <= u [ I−1] + wh [ I−2]f o r i i n r a n g e ( 1 , I−1) :

z [ j ] [ i ] + wl [ i ] + wh [ i ] <= u [ i ] + wh [ i −1] + wl [ i +1]

Listing 4.9: MIPCL-PY implementation of yield management problem: model

The constructor

The constructor, init (), has four arguments (except self). The first one, name, is the name of aproblem to be solved. The other three arguments describe a problem instance:

• planes: list of plane types, where planes[k] describes planes of type k:

– f(k)=planes[k][’fixedCost’]: cost to hire;

– q(k,i)=planes[k][’classes’][i][0]: numbers of seats in class i;

– tl(k,i)=planes[k][’classes’][0][1]: numbers of seats of class i that can betransformed into seats of class i-1;

– tl(k,i)=planes[k][’classes’][0][2]: numbers of seats of class i that can betransformed into seats of class i+1;

• options: list of options, where options[t] is a list (or tuple) of 3 options for period t, where

– options[t][o]: 3-tuple that represents ticket prices for each of 3 classes if option o isused;

Page 73: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.3. Yield management 65

• nodes: list of nodes of a scenario tree, each node j, except for node 0, is characterized by a list(or tuple) nodes[j] which is structured as follows:

– nodes[j][’name’]: node name;

– nodes[j][’period’]: period;

– nodes[j][’parent’]: index of the parent node;

– nodes[j][’prob’]: probability of reaching this node from its parent;

– nodes[j][’demands’][0]: 3-tuple, demands for tickets for each of three classes ifOption 1 is applied;

– nodes[j][’demands’][1]: 3-tuple, demands for tickets for each of three classes ifOption 2 is applied;

– nodes[j][’demands’][2]: 3-tuple, demands for tickets for each of three classes ifOption 3 is applied.

The constructor invokes the constructor of the base class, stores input arguments in the fields of thecreated Revenue object, and then calls an auxiliary function, processData(), to

• computes probabilities of reaching all non-root scenario-tree nodes (the probability of reachingnode j is the probability of reaching its parent node parent[j] multiplied by the probability ofmoving along the edge (parent[j],j));

• determines the number, n0, of internal nodes (not leaves).

Member Functions

The crucial function in the Problem class is model(), which implements MIP (4.3). To make theimplementation straightforwars, we define a number of local functions that map input parameters ontothe parameters of MIP (4.3).

When a solution has been found, we can print the result using the procedure printSolution —which is a member of Revenue — from Listing 4.10.

d e f p r i n t S o l u t i o n ( s e l f ) :d e f p a r e n t ( j ) : r e t u r n s e l f . nodes [ j ] [ ’ p a r e n t ’ ]d e f name ( k , i ) : r e t u r n s e l f . p l a n e s [ k ] [ ’ c l a s s e s ’ ] [ i ] [ ’ name ’ ]

K, O, I = l e n ( s e l f . p l a n e s ) , l e n ( s e l f . o p t i o n s [ 0 ] ) , l e n ( s e l f . o p t i o n s [ 0 ] [ 0 ] )x , y , v = s e l f . x , s e l f . y , s e l f . v

k0 , o0 = 0 , 0f o r k i n r a n g e (K) :

i f v [ k ] . v a l > 0 . 5 :k0 = kb r e a k

f o r o i n r a n g e (O) :i f y [ 0 ] [ o ] . v a l > 0 . 5 :

o0 = ob r e a k

p r i n t ( ’ Opt imal o b j e c t i v e v a l u e : { : . 4 f } ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )p r i n t ( ’ P l a n e t o h i r e : { ! r } ’ . f o r m a t ( k0 +1) )

Page 74: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

66 Chapter 4. Service Management

p r i n t ( ’\ nIn P e r i o d ˜1 use p r i c e o p t i o n { ! r } , and s e l l :\ n ’ . f o r m a t ( o +1) )f o r j i n r a n g e ( 1 , s e l f . n0 ) :

i f p a r e n t ( j ) != 0 : b r e a kp r i n t ( ’\ t i f s c e n a r i o { ! r } happens :\ n ’ . f o r m a t ( j ) )f o r i i n r a n g e ( I ) :

p r i n t ( ’\ t \ t { ! r } t i c k e t s o f { ! s} c l a s s \n ’ .\f o r m a t ( ( i n t ) ( x [ j ] [ o ] [ i ] . v a l ) , name ( k0 , i ) ) )

Listing 4.10: MIPCL-PY implementation of yield management problem: auxiliary procedures

4.3.4 Example of Usage

An airline is selling tickets for flights to a particular destination. The flight will depart in three weeks’time. Up to three planes can be hired. Each plane costs $75000 to hire, and has

• 35 first class seats, 12 of which can be transformed in seats of business class;

• 40 business class seats, 12 of which can be transformed in seats of first class and other 6 — intoseats of economy class;

• 80 economy class seats, 12 of which can be transformed into seats of business class.

An airline wishes to decide a price for each of these seats. There will be further opportunities toupdate these prices in after one week and two weeks. Once a customer has purchased a ticket there is nocancellation option.

Model (4.3) does not allow us to hire more than one plane. Nevertheless, we can still use it assumingthat we have three virtual planes and plane k has capacities of k original planes, the cost of hire such aplane is k · $75000 (k = 1, 2, 3).

For administrative simplicity three price level options are possible in each class (one of which mustbe chosen). These options are given in Table 4.4 for the current period (perion 1) and two future periods.

Demand is uncertain and is affected by ticket prices. Forecasts have been made, and demand levelshave been divided into three scenarios for each period. The probabilities of these scenarios in each

Table 4.4: Price Options

Class Option 1 Option 2 Option 3

First $1500 $1250 $1000Business $1000 $850 $700

Peri

od1

Economy $500 $400 $300

First $1750 $1500 $1250Business $1250 $1000 $850

Peri

od2

Economy $700 $500 $400

First $1800 $1200 $900Business $800 $850 $600

Peri

od3

Economy $450 $500 $450

Page 75: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.3. Yield management 67

Table 4.5: Forecast Demands

Option 1 Option 2 Option 3

First 25 30 35Business 40 50 70

Scen

ar.1

Economy 100 120 130First 40 50 70Business 90 85 90

Scen

ar.2

Economy 100 105 140First 90 100 120Business 90 95 95

Pe

rio

d1

Scen

ar.3

Economy 110 105 135

First 40 50 65Business 85 90 85

Scen

ar.1

Economy 100 105 125First 20 80 100Business 100 120 160

Scen

ar.2

Economy 120 130 180First 100 110 160Business 40 60 100

Pe

rio

d2

Scen

ar.3

Economy 25 80 120

First 60 70 80Business 80 100 110

Scen

ar.1

Economy 100 120 160First 60 80 120Business 20 80 90

Scen

ar.2

Economy 100 120 140First 100 140 160Business 80 90 120

Pe

rio

d3

Scen

ar.3

Economy 120 130 140

Page 76: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

68 Chapter 4. Service Management

period are: 0.1 for Scenario 1, 0.6 for Scenario 2, 0.3 for Scenario 3. The forecast demands are shown inTable 4.5.

To solve our example, we prepared the program, presented in Listing 4.11.

# ! / u s r / b i n / py thonfrom m i p c l p y . models . r e v e n u e i m p o r t Revenue

p l a n e s = ({

’ f i x e d C o s t ’ : 75000 ,’ c l a s s e s ’ : ({ ’ name ’ : ’ f i r s t ’ , ’ c a p a c i t y ’ : ( 3 0 , 0 , 1 2 ) } ,{ ’ name ’ : ’ b u s i n e s ’ , ’ c a p a c i t y ’ : ( 4 0 , 1 2 , 6 ) } ,{ ’ name ’ : ’ economy ’ , ’ c a p a c i t y ’ : ( 8 0 , 1 2 , 0 ) }

)} ,{

’ f i x e d C o s t ’ : 150000 ,’ c l a s s e s ’ : ({ ’ name ’ : ’ f i r s t ’ , ’ c a p a c i t y ’ : ( 6 0 , 0 , 2 4 ) } ,{ ’ name ’ : ’ b u s i n e s ’ , ’ c a p a c i t y ’ : ( 8 0 , 2 4 , 1 2 ) } ,{ ’ name ’ : ’ economy ’ , ’ c a p a c i t y ’ : ( 1 6 0 , 2 4 , 0 ) }

)} ,{

’ f i x e d C o s t ’ : 225000 ,’ c l a s s e s ’ : ({ ’ name ’ : ’ f i r s t ’ , ’ c a p a c i t y ’ : ( 9 0 , 0 , 3 6 ) } ,{ ’ name ’ : ’ b u s i n e s s ’ , ’ c a p a c i t y ’ : ( 1 2 0 , 3 6 , 1 8 ) } ,{ ’ name ’ : ’ economy ’ , ’ c a p a c i t y ’ : ( 2 4 0 , 3 6 , 0 ) }

)}

)

o p t i o n s = (( ( 1 5 0 0 , 1000 , 500) , ( 1 2 5 0 , 850 , 400) , ( 1 0 0 0 , 700 , 300) ) ,( ( 1 7 5 0 , 1250 , 700) , ( 1 5 0 0 , 1000 , 500) , ( 1 2 5 0 , 850 , 400) ) ,( ( 1 8 0 0 , 800 , 450) , ( 1 2 0 0 , 850 , 500) , ( 900 , 600 , 450) )

)

nodes = ({ ’ name ’ : 0 , ’ p e r i o d ’ : 0 , ’ p a r e n t ’ : −1, ’ prob ’ : 1 . 0} ,{ ’ name ’ : 1 , ’ p e r i o d ’ : 1 , ’ p a r e n t ’ : 0 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 25 , 40 , 100) ,

( 30 , 50 , 120) , ( 35 , 70 , 130) ) } ,{ ’ name ’ : 2 , ’ p e r i o d ’ : 1 , ’ p a r e n t ’ : 0 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 40 , 90 , 100) ,

( 50 , 85 , 100) , ( 70 , 90 , 140) ) } ,{ ’ name ’ : 3 , ’ p e r i o d ’ : 1 , ’ p a r e n t ’ : 0 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 90 , 90 , 110) ,

( 1 0 0 , 95 , 105) , ( 1 2 0 , 95 , 135) ) } ,{ ’ name ’ : 4 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 1 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 40 , 85 , 100) ,

( 50 , 90 , 105) , ( 65 , 85 , 125) ) } ,{ ’ name ’ : 5 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 1 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 20 , 100 , 120) ,

( 80 , 120 , 130) , ( 1 0 0 , 160 , 180) ) } ,{ ’ name ’ : 6 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 1 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 40 , 25) ,

( 1 1 0 , 60 , 80) , ( 1 6 0 , 100 , 120) ) } ,{ ’ name ’ : 7 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 2 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 40 , 85 , 100) ,

( 50 , 90 , 105) , ( 65 , 85 , 125) ) } ,

Page 77: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

4.3. Yield management 69

{ ’ name ’ : 8 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 2 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 20 , 100 , 120) ,( 80 , 120 , 130) , ( 1 0 0 , 160 , 180) ) } ,

{ ’ name ’ : 9 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 2 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 40 , 25) ,( 1 1 0 , 60 , 80) , ( 1 6 0 , 100 , 120) ) } ,

{ ’ name ’ : 10 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 3 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 40 , 85 , 100) ,( 50 , 90 , 105) , ( 65 , 85 , 125) ) } ,

{ ’ name ’ : 11 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 3 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 20 , 100 , 120) ,( 80 , 120 , 130) , ( 1 0 0 , 160 , 180) ) } ,

{ ’ name ’ : 12 , ’ p e r i o d ’ : 2 , ’ p a r e n t ’ : 3 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 40 , 25) ,( 1 1 0 , 60 , 80) , ( 1 6 0 , 100 , 120) ) } ,

{ ’ name ’ : 13 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 4 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 14 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 4 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 15 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 4 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 16 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 5 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 17 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 5 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 18 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 5 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 19 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 6 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 20 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 6 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 21 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 6 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 22 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 7 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 23 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 7 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 24 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 7 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 25 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 8 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 26 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 8 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 27 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 8 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 28 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 9 , ’ p rob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 29 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 9 , ’ p rob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 30 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 9 , ’ p rob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 31 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 10 , ’ prob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 32 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 10 , ’ prob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 33 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 10 , ’ prob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 34 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 11 , ’ prob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 35 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 11 , ’ prob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

Page 78: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

70 Chapter 4. Service Management

{ ’ name ’ : 36 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 11 , ’ prob ’ : 0 . 3 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) } ,

{ ’ name ’ : 37 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 12 , ’ prob ’ : 0 . 1 , ’ demands ’ : ( ( 60 , 80 , 100) ,( 70 , 100 , 120) , ( 80 , 110 , 160) ) } ,

{ ’ name ’ : 38 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 12 , ’ prob ’ : 0 . 6 , ’ demands ’ : ( ( 60 , 20 , 100) ,( 80 , 80 , 120) , ( 1 2 0 , 90 , 140) ) } ,

{ ’ name ’ : 39 , ’ p e r i o d ’ : 3 , ’ p a r e n t ’ : 12 , ’ prob ’ : 0 . 1 , ’ demands ’ : ( ( 1 0 0 , 80 , 120) ,( 1 4 0 , 90 , 130) , ( 1 6 0 , 120 , 140) ) }

)

p rob = Revenue ( ’ t e s t 1 ’ , p l a n e s , o p t i o n s , nodes )prob . model ( )prob . o p t i m i z e ( )prob . p r i n t S o l u t i o n ( )

Listing 4.11: Example of usage of class Revenue

If we run this program, we get the answer shown in Listing 4.12.

P l a n e t o h i r e : 3In P e r i o d 1 use p r i c e o p t i o n 1 , and s e l l :

i f s c e n a r i o 1 happens :25 t i c k e t s o f f i r s t c l a s s30 t i c k e t s o f b u s i n e s s c l a s s35 t i c k e t s o f economy c l a s s

i f s c e n a r i o 2 happens :40 t i c k e t s o f f i r s t c l a s s40 t i c k e t s o f b u s i n e s s c l a s s44 t i c k e t s o f economy c l a s s

i f s c e n a r i o 3 happens :46 t i c k e t s o f f i r s t c l a s s40 t i c k e t s o f b u s i n e s s c l a s s44 t i c k e t s o f economy c l a s s

Listing 4.12: Output of program from Listing 4.11

This solution suggests to hire three planes, and use option 1 in the first week. The latter means thatthe airline assigns prices $1500, $1000, $500 for the, respectively, first, business, and economy classtickets.

One week later, the airline managers will decide which option to apply in the second week when itwill be known how many tickets of all classes have been sold during the first week. To determine anoptimal option for the second week, one can formulate and solve a similar planning problem but onlywith two-period’s horizon (2-nd and 3-rd weeks) and with remaining numbers of seats in three planes.Therefore, IP (4.3), although looking as being dynamic, in fact is not dynamic. They say that such modelsare applied dynamically.

Page 79: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Chapter 5

Logistics management

”Logistics is about getting the right product, to the right customer, in the right quantity, in the rightcondition, at the right place, at the right time, and at the right cost (the seven Rs of Logistics)” - fromSupply Chain Management: A Logistics Perspective By John J. Coyle et al.

Traditionally, logistics focuses on activities such as procurement, inventory management, and distri-bution. It is defined as follows.

Logistics is the . . .“process of planning, implementing, and controlling the efficient, effective flow and storageof goods, services, and related information from point of origin to point of consumption forthe purpose of conforming to customer requirements.“

Council of Logistics Management

Transport logistics deals with air/sea/land transportation and warehousing.

5.1 Fixed Charge Network Flows

A transportation network is given by a directed graph (digraph) G = (V,E). For each node v ∈ V , weknow the demand dv in some product. If dv > 0, then v is a demand node; if dv < 0, then v is a supplynode; dv = 0 for transit nodes. It is assumed that supply and demand are balanced:

∑v∈V dv = 0. The

capacity of an arc e ∈ E is ue > 0, and the cost of shipping xe > 0 units of product along this arc isfe+ cexe. Naturally, if the product is not moved through the arc (xe = 0), then nothing is paid. The fixedcharge network flow problem (FCNF) is to decide on how to transport the product from supply nodes todemand nodes so that the transportation expenses are minimum.

The FCNF problem appears as a subproblem in many practical applications such as design of trans-portation and telecommunication networks, or optimization of supply chains.

An instance of FCNF problem is given in Figure 5.1, where the node indices and demands are de-picted in the upper and lower segments of the node circles. Any (undirected) edge e = (i, j) representstwo (directed) arcs e1 = (i, j) and e2 = (j, i). All horizontal arcs have capacity ue = 3, fixed costfe = 1 and per-unit cost ce = 0, and all vertical arcs have capacity ue = 4, fixed cost fe = 2 and per-unitcost ce = 0.

71

Page 80: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

72 Chapter 5. Logistics management

���� ���� ���� ���� ����−1 −2 −3 −4 −5

���� ���� ���� ���� ����0 0 0 0 0

���� ���� ���� ���� ����0 0 0 0 0

���� ���� ���� ���� ����5 4 3 2 1

0 1 2 3 4

5 6 7 8 9

10 11 12 13 14

15 16 17 18 19

Figure 5.1: An instance of FCNF

5.1.1 Mixed-Integer Programming Formulation

Introducing variables

xe: flow (quantity of shipping product) through arc e ∈ E,

ye = 1, if product is shipped (xe > 0) through arc e, and ye = 0 otherwise,

we formulate the FCNF problem as follows:∑e∈E

(feye + cexe)→ min, (5.1a)∑e∈E(V,v)

xe −∑

e∈E(v,V )

xe = dv, v ∈ V, (5.1b)

0 ≤ xe ≤ ueye, e ∈ E, (5.1c)

ye ∈ {0, 1}, e ∈ E. (5.1d)

Here the objective (5.1a) is to minimize transportation expenses. The balance equations (5.1b) re-quire that the number of flow units entering each particular node equals the number of flow units leavingthe node. The variable upper bounds (5.1c) are capacity restrictions with the following meaning:

• the flow value through any arc cannot exceed the capacity of the arc;

• if some arc is not used for shipping product (ye = 0), then the flow value through this arc is zero(xe = 0).

Page 81: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.1. Fixed Charge Network Flows 73

5.1.2 MIPCL-PY Implementation

A straightforward MIPCL-PY implementation of MIP (5.1)) is given in Listing 5.1.

i m p o r t m i p s h e l lfrom m i p s h e l l i m p o r t ∗

d e f t ( e ) : r e t u r n e [ 0 ]d e f h ( e ) : r e t u r n e [ 1 ]d e f u ( e ) : r e t u r n e [ 2 ]d e f c ( e ) : r e t u r n e [ 3 ]d e f f ( e ) : r e t u r n e [ 4 ]

c l a s s Fcnf ( Problem ) :d e f model ( s e l f ,G) :

s e l f .G = Gd , E = G[ ’ Demands ’ ] , G[ ’ Arcs ’ ]m, n = l e n ( E ) , l e n ( d )

s e l f . x = x = VarVec to r ( [m] , ” x ” )y = VarVec to r ( [m] , ” y ” , BIN )

min imize ( sum ( f ( e ) ∗y [ j ] + c ( e ) ∗x [ j ] f o r j , e i n enumera t e ( E ) ) )

f o r v i n r a n g e ( n ) :sum ( x [ j ] f o r j , e i n enumera t e ( E ) i f h ( e ) ==v ) \

− sum ( x [ j ] f o r j , e i n enumera t e ( E ) i f t ( e ) ==v ) == d [ v ]

f o r j , e i n enumera t e ( E ) :x [ j ] <= u ( e ) ∗y [ j ]

Listing 5.1: MIPCL-PY implementation of FCNF problem: model

Input parameters:

• G: flow network:

– G[’Demands’]: list of demands at nodes;

– G[’Arcs’]: list of arcs, where arc e = G[’Arcs’][j] is represented as a tuple of fiveintegers:

∗ e[0]: tail;∗ e[1]: head;∗ e[2]: capacity;∗ e[3]: fixed cost;∗ e[4]: cost.

When a solution has been found, we can print the result calling printSolution() — a memberof Fcnf —, which is shown in Listing 5.2.

d e f p r i n t S o l u t i o n ( s e l f ) :i f s e l f . i s s o l u t i o n i s n o t None :

i f s e l f . i s s o l u t i o n == True :d , E = s e l f .G[ ’ Demands ’ ] , s e l f .G[ ’ Arcs ’ ]

Page 82: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

74 Chapter 5. Logistics management

x = s e l f . xp r i n t ( ’ Flow c o s t = { : d} ’ . f o r m a t ( i n t ( s e l f . ge tOb jVa l ( ) + 0 . 5 ) ) )f o r j , e i n enumera t e ( E ) :

i f x [ j ] . v a l > 0 . 5 :p r i n t ( ’ f low ( { : d } ,{ : d } ) = { : d} ’ . f o r m a t (\

t ( e ) , h ( e ) , i n t ( x [ j ] . v a l + 0 . 5 ) ) )e l s e :

p r i n t ( ’ Problem has no s o l u t i o n ! ’ )e l s e :

p r i n t ( ’ P l e a s e run o p t i m i z e f i r s t ’ )

Listing 5.2: MIPCL-PY implementation of FCNF problem: printSolution

5.1.3 Example of Usage

To test class Fcnf, we wrote the following program that solves our FCNF-instance from Figure 5.1.

# ! / u s r / b i n / py thonfrom f c n f i m p o r t Fcnf

G = {’ Demands ’ : [−1 , −2, −3, −4, −5, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 5 , 4 , 3 , 2 , 1 ] ,’ Arcs ’ : [

( 0 , 1 , 3 , 1 , 0 ) , ( 1 , 0 , 3 , 1 , 0 ) , ( 1 , 2 , 3 , 1 , 0 ) , ( 2 , 1 , 3 , 1 , 0 ) ,( 2 , 3 , 3 , 1 , 0 ) , ( 3 , 2 , 3 , 1 , 0 ) , ( 3 , 4 , 3 , 1 , 0 ) , ( 4 , 3 , 3 , 1 , 0 ) ,( 5 , 6 , 3 , 1 , 0 ) , ( 6 , 5 , 3 , 1 , 0 ) , ( 6 , 7 , 3 , 1 , 0 ) , ( 7 , 6 , 3 , 1 , 0 ) ,( 7 , 8 , 3 , 1 , 0 ) , ( 8 , 7 , 3 , 1 , 0 ) , ( 8 , 9 , 3 , 1 , 0 ) , ( 9 , 8 , 3 , 1 , 0 ) ,( 1 0 , 11 , 3 , 1 , 0 ) , ( 1 1 , 10 , 3 , 1 , 0 ) , ( 1 1 , 12 , 3 , 1 , 0 ) , ( 1 2 , 11 , 3 , 1 , 0 ) ,( 1 2 , 13 , 3 , 1 , 0 ) , ( 1 3 , 12 , 3 , 1 , 0 ) , ( 1 3 , 14 , 3 , 1 , 0 ) , ( 1 4 , 13 , 3 , 1 , 0 ) ,( 1 5 , 16 , 3 , 1 , 0 ) , ( 1 6 , 15 , 3 , 1 , 0 ) , ( 1 6 , 17 , 3 , 1 , 0 ) , ( 1 7 , 16 , 3 , 1 , 0 ) ,( 1 7 , 18 , 3 , 1 , 0 ) , ( 1 8 , 17 , 3 , 1 , 0 ) , ( 1 8 , 19 , 3 , 1 , 0 ) , ( 1 9 , 18 , 3 , 1 , 0 ) ,( 0 , 5 , 4 , 2 , 0 ) , ( 5 , 0 , 4 , 2 , 0 ) , ( 1 , 6 , 4 , 2 , 0 ) , ( 6 , 1 , 4 , 2 , 0 ) ,( 2 , 7 , 4 , 2 , 0 ) , ( 7 , 2 , 4 , 2 , 0 ) , ( 3 , 8 , 4 , 2 , 0 ) , ( 8 , 3 , 4 , 2 , 0 ) ,( 4 , 9 , 4 , 2 , 0 ) , ( 9 , 4 , 4 , 2 , 0 ) , ( 5 , 10 , 4 , 2 , 0 ) , ( 1 0 , 5 , 4 , 2 , 0 ) ,( 6 , 11 , 4 , 2 , 0 ) , ( 1 1 , 6 , 4 , 2 , 0 ) , ( 7 , 12 , 4 , 2 , 0 ) , ( 1 2 , 7 , 4 , 2 , 0 ) ,( 8 , 13 , 4 , 2 , 0 ) , ( 1 3 , 8 , 4 , 2 , 0 ) , ( 9 , 14 , 4 , 2 , 0 ) , ( 1 4 , 9 , 4 , 2 , 0 ) ,( 1 0 , 15 , 4 , 2 , 0 ) , ( 1 5 , 10 , 4 , 2 , 0 ) , ( 1 1 , 16 , 4 , 2 , 0 ) , ( 1 6 , 11 , 4 , 2 , 0 ) ,( 1 2 , 17 , 4 , 2 , 0 ) , ( 1 7 , 12 , 4 , 2 , 0 ) , ( 1 3 , 18 , 4 , 2 , 0 ) , ( 1 8 , 13 , 4 , 2 , 0 ) ,( 1 4 , 19 , 4 , 2 , 0 ) , ( 1 9 , 14 , 4 , 2 , 0 )

]}

prob = Fcnf ( ” g r i d N e t ” )prob . model (G)prob . o p t i m i z e ( F a l s e )prob . p r i n t S o l u t i o n ( )

Listing 5.3: Example of usage of class Fcnf

Page 83: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.2. Single Depot Vehicle Routing problem 75

If we run the program from Listing 5.3, it prints the following result.

Flow c o s t = 34

f low ( 1 , 0 ) = 3 , f low ( 2 , 1 ) = 1 , f low ( 3 , 2 ) = 2 , f low ( 4 , 3 ) = 1 ,f low ( 1 2 , 1 1 ) = 3 , f low ( 1 3 , 1 2 ) = 3 , f low ( 1 6 , 1 5 ) = 1 , f low ( 1 7 , 1 6 ) = 2 ,f low ( 1 8 , 1 7 ) = 1 , f low ( 1 9 , 1 8 ) = 3 , f low ( 0 , 5 ) = 4 , f low ( 2 , 7 ) = 4 ,f low ( 3 , 8 ) = 3 , f low ( 4 , 9 ) = 4 , f low ( 5 , 1 0 ) = 4 , f low ( 7 , 1 2 ) = 4 ,f low ( 8 , 1 3 ) = 3 , f low ( 9 , 1 4 ) = 4 , f low ( 1 0 , 1 5 ) = 4 , f low ( 1 1 , 1 6 ) = 3 ,f low ( 1 2 , 1 7 ) = 4 , f low ( 1 4 , 1 9 ) = 4

Listing 5.4: Output of program from Listing 2.7

A graphical representation of the result from Listing 5.4 is given in Figure 5.2.

���� ���� ���� ���� ����−1 −2 −3 −4 −5

���� ���� ���� ���� ����0 0 0 0 0

���� ���� ���� ���� ����0 0 0 0 0

���� ���� ���� ���� ����5 4 3 2 1

0 1 2 3 4

5 6 7 8 9

10 11 12 13 14

15 16 17 18 19

����

��

����

6

6

6

6

6

6

6

6

6

6

66

4

4

4

4

4

4

3

3

4

4

4

3 3

3

3

1

1

2

2

1

1

3

Figure 5.2: Solution to FCNF-instance from Figure 5.1

5.2 Single Depot Vehicle Routing problem

There is a depot that supplies customers with some goods. This depot has a fleet of vehicles ofK differenttypes. There are qk vehicles of type k, and each such a vehicle is of capacity uk (maximum weight tocarry). We also know the fixed cost, fk, of using one vehicle of type k during a day.

At a particular day, n customers have ordered some goods to be delivered from the depot to theirplaces: customer i is expecting to get goods of total weight di. To simplify the notations, we will alsoconsider the depot as a customer with zero demand. For vehicle of type k, it costs ckij to travel fromcustomer i to customer j.

Page 84: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

76 Chapter 5. Logistics management

A feasible route for vehicle of type k is given by a list (i0 = 0, i1, . . . , ir, ir+1 = 0) of customers suchthat the total demand of the customers on this route does not exceeds the vehicle capacity,

∑rs=1 ds ≤ uk.

The cost of assigning a vehicle of type k on this route is fk +∑r

s=1 ck(i, j).

The vehicle routing problem (VRP) is to select a subset of vehicles (from the depot fleet) and thenassign any chosen vehicle to a feasible route so that each customer is visited by just one vehicle and thetotal cost of assigning vehicles to the routes is minimal.

5.2.1 Mixed Integer Programming Formulation

To formulate the VRP as an IP, we need the following family of decision binary variables:

• for k = 1, . . . ,K and i, j ∈ {0, 1, . . . , n}, xkij = 1 if some vehicle of type k travels directly fromcustomer i to customer j, and xkij = 0 otherwise.

In addition, we also need one family of auxiliary variables:

• for i, j ∈ {0, 1, . . . , n}, yij is amount of goods that are carried by the vehicle assigned on the routefrom customer i to customer j.

In these variables the model is written as follows:

K∑k=1

n∑j=1

(fk + ck0,j)xk0,j +

K∑k=1

n∑i=1

∑j∈{0,...,n}\{i}

ckijxkij → min, (5.2a)

n∑j=1

xk0,j ≤ qk, k = 1, . . . ,K, (5.2b)

K∑k=1

n∑i=0

xkij = 1, j = 1, . . . , n, (5.2c)

n∑i=0

xkij −n∑i=0

xkji = 0, j = 1, . . . , n, k = 1, . . . ,K, (5.2d)

n∑i=0

yij −n∑i=0

yji = dj , j = 1, . . . , n, (5.2e)

0 ≤ yij ≤K∑k=1

(uk − di)xkij , i, j = 0, . . . , n, (5.2f)

xkii = 0, i = 0, . . . , n, k = 1, . . . ,K, (5.2g)

xkij ∈ {0, 1}, i, j = 0, . . . , n, k = 1, . . . ,K. (5.2h)

The objective (5.2a) is to minimize the total fixed cost of using vehicles plus the traveling cost ofall used vehicles along their routes. The inequalities (5.2b) require that the number of vehicles of anyparticular type that leave the depot does not exceed the number of such vehicles in the depot fleet. Theequations (5.2b) ensure that each customer will be visited by just one vehicle, while the equations (5.2d)guarantee that any vehicle that arrives to a customer will leave that customer. The next family of equa-tions, (5.2e), reflects the fact that any vehicle before leaving a customer must upload the goods ordered

Page 85: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.2. Single Depot Vehicle Routing problem 77

by that customer. Each inequality from (5.2f) imposes the capacity restriction: if a vehicle of type ktravels the route from customer i to customer j, then the total cargo weight on its board cannot exceeduk − di, but, if none of vehicles (of any type) travels along the route (i, j), then yij = 0. One can easilyargued that these capacity restrictions guarantee that each used vehicle will never carry goods of totalweight greater than the vehicle capacity.

A note of precaution is appropriate here. Because of the capacity constraints (5.2f), the entire formu-lation (5.2) may be weak. In our case, the reason for its weakness is in the following. Let us assume thatsome inequality yij ≤

∑kk=1(uk − di)xkij holds as equality. If the capacity, uk, is big, and the demand,

di, is small, then uk − di is big. If we further assume that the sum of demands of all customers thatare on the same route with customer i and that are visited after customer i is small, then yij will alsobe small and, therefore, at least one binary variable xkij will take a small fractional value. Many binaryvariables taking fractional values is usually an indicator of a hard to solve problem. Therefore, one canhardly expect that formulation (5.2) can be used for solving to optimality even VRPs of moderate size.Nevertheless, if implemented properly, an application based on this formulation can produce rather goodapproximate solutions for VRPs of practical importance.

5.2.2 MIPCL-PY Implementation

A Python module designed for solving VRPs is presented in listings 5.5 and 5.6.Listing 5.5 presents the definition of class VRP and an implements of IP (5.2), which is given, as

usually, in the function named model.

from m i p c l p y . m i p s h e l l . m i p s h e l l i m p o r t ∗from math i m p o r t s q r t

c l a s s VRP( Problem ) :d e f i n i t ( s e l f , name , i n s t a n c e ) :

Problem . i n i t ( s e l f , name )s e l f . i n s t a n c e = i n s t a n c e

d e f model ( s e l f ) :d e f d ( j ) : r e t u r n c u s t o m e r [ j ] [ ’Demand ’ ]d e f q ( k ) : r e t u r n v e h i c l e T y p e [ k ] [ ’ Q u a n t i t y ’ ]d e f u ( k ) : r e t u r n v e h i c l e T y p e [ k ] [ ’ C a p a c i t y ’ ]d e f c ( k , i , j ) :

d = c u s t o m e r [ i ] [ ’ Coord ’ ][0]− c u s t o m e r [ j ] [ ’ Coord ’ ] [ 0 ]c o s t = d∗dd = c u s t o m e r [ i ] [ ’ Coord ’ ][1]− c u s t o m e r [ j ] [ ’ Coord ’ ] [ 1 ]c o s t += d∗dc o s t = round ( s q r t ( c o s t ) )c o s t ∗= v e h i c l e T y p e [ k ] [ ’ U n i t D i s t C o s t ’ ]i f i == 0 : c o s t += v e h i c l e T y p e [ k ] [ ’ F i x e d C o s t ’ ]r e t u r n c o s t

v e h i c l e T y p e = s e l f . i n s t a n c e [ ’ V e h i c l e T y p e s ’ ]c u s t o m e r = s e l f . i n s t a n c e [ ’ Cus tomers ’ ]K, n = l e n ( v e h i c l e T y p e ) , l e n ( c u s t o m e r )s e l f . x = x = VarVec to r ( ( K, n , n ) , ” x ” , BIN )y = VarVec to r ( ( n , n ) , ” y ” , INT )

min imize ( sum ( c ( k , i , j ) ∗x [ k ] [ i ] [ j ] f o r k i n r a n g e (K) \f o r i i n r a n g e ( n ) f o r j i n r a n g e ( n ) ) )

Page 86: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

78 Chapter 5. Logistics management

f o r k i n r a n g e (K) :sum ( x [ k ] [ 0 ] [ j ] f o r j i n r a n g e ( 1 , n ) ) <= q ( k )f o r j i n r a n g e ( 1 , n ) :

sum ( x [ k ] [ i ] [ j ] f o r i i n r a n g e ( n ) ) == 1sum ( x [ k ] [ i ] [ j ] f o r i i n r a n g e ( n ) ) − \

sum ( x [ k ] [ j ] [ i ] f o r i i n r a n g e ( n ) ) == 0f o r i i n r a n g e ( n ) :

x [ k ] [ i ] [ i ] == 0

f o r j i n r a n g e ( 1 , n ) :sum ( y [ i ] [ j ] f o r i i n r a n g e ( n ) ) − \

sum ( y [ j ] [ i ] f o r i i n r a n g e ( n ) ) == d ( j )f o r i i n r a n g e ( n ) :

y [ i ] [ j ] <= sum ( ( u ( k )−d ( i ) ) ∗x [ k ] [ i ] [ j ] f o r k i n r a n g e (K) )

Listing 5.5: MIPCL-PY implementation of the VRP: constructor and model

The constructor, init (), stores a reference to a structure, named instance, that describes aVRP-instance. This structure has the following fields:

• instance[’Name’]: instance name;

• instance[’VehicleTypes’]: list of dictionaries that describes the depot fleet of vehi-cles, where vehicleType = instance[’VehicleTypes’][t] describes the vehicles oftype t:

– vehicleType[’Name’]: vehicle identifier (or model name);

– vehicleType[’Quantity’]: number of vehicles of this type in the fleet;

– vehicleType[’Capacity’]: vehicle capacity;

– vehicleType[’FixedCost’]: fixed cost of using one vehicle;

– vehicleType[’UnitDistCost’]: cost of traveling unit distance;

• instance[’Customers’]: list of customers, wherecustomer = instance[’Customers’][i] describes customer i:

– cuscomer[’Name’]: customer name;

– cuscomer[’Coord’]: coordinates of the customer place;

– cuscomer[’Demand’]: demand for goods.

The function model, first, defines a number of local functions that maps some input parameters ontothe coefficients of IP (5.2), then a straightforward implementation of this IP follows. Let us notice that,when implementing the function, c(k,i,j), that computes transportation expenses, the fixed costs ofhiring vehicles are summed together with the transportation costs of traveling along the legs leaving thedepot.

Listing 5.6 presents two auxiliary procedures.

d e f s e t S o l u t i o n ( s e l f ) :x = s e l f . xK, n = l e n ( x ) , l e n ( x [ 0 ] )

Page 87: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.2. Single Depot Vehicle Routing problem 79

s e l f . f i r s t = f i r s t = [ ]s e l f . n e x t = n e x t = [0 f o r i i n r a n g e ( n ) ]

f o r k i n r a n g e (K) :f o r j i n r a n g e ( 1 , n ) :

i f x [ k ] [ 0 ] [ j ] . v a l > 0 . 5 :f i r s t . append ( ( k , j ) )

f o r i i n r a n g e ( 1 , n ) :i f x [ k ] [ i ] [ j ] . v a l > 0 . 5 :

n e x t [ i ] = jb r e a k

d e f p r i n t S o l u t i o n ( s e l f ) :v e h i c l e T y p e = s e l f . i n s t a n c e [ ’ V e h i c l e T y p e s ’ ]c u s t o m e r = s e l f . i n s t a n c e [ ’ Cus tomers ’ ]f i r s t , n e x t = s e l f . f i r s t , s e l f . n e x t

p r i n t ( ’ O b j e c t i v e v a l u e : { 0 : . 2 f }\n ’ . f o r m a t ( s e l f . ge tOb jVa l ( ) ) )

f o r r , ( k , i ) i n enumera t e ( f i r s t ) :s t r = ’\ t 0 ’l o a d = 0w h i l e True :

s t r += ’ −> { : d} ’ . f o r m a t ( i )i f i > 0 :

l o a d += c u s t o m e r [ i ] [ ’Demand ’ ]i = n e x t [ i ]

e l s e : b r e a kp r i n t ( ’ Route { : d } , v e h i c l e o f t y p e { ! s } , c a r g o we ig h t − { : d} ’ .\

f o r m a t ( r +1 , v e h i c l e T y p e [ f i r s t [ r ] [ 0 ] ] [ ’Name ’ ] , l o a d ) )p r i n t ( s t r )

Listing 5.6: MIPCL-PY implementation of VRP: auxiliary procedures

The function setSolution extracts the vehicles routes from the values of x-variables. The routesare stored in two lists:

• first: list of pairs of integers, where first[r][0] is the type of a vehicle that serves route r,and first[r][1] is the first customer on route r;

• next: list of integers, where next[i] is the customer that is on the same route with customer iand is visited just after customer i.

The other auxiliary procedure, printSolution, prints the routes stored in the lists first andnext. In addition, this procedure counts the weights of cargoes on all the routes.

5.2.3 Example of Usage

The program presented below will show you how to use our class VRP.

# ! / u s r / b i n / py thon

from m i p c l p y . models . VRP i m p o r t VRP

vrp1 = {’NAME’ : ” vrp1 ” ,

Page 88: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

80 Chapter 5. Logistics management

’ V e h i c l e T y p e s ’ : ({ ’Name ’ : ” 1 ” , ’ Q u a n t i t y ’ : 3 , ’ C a p a c i t y ’ : 100 , ’ F i x e d C o s t ’ : 0 , ’ U n i t D i s t C o s t ’ :

1} ,) ,’ Cus tomers ’ : ({ ’Name ’ : ” Depot ” , ’ Coord ’ : ( 8 2 , 7 6 ) , ’Demand ’ : 0} ,{ ’Name ’ : ” 1 ” , ’ Coord ’ : ( 9 6 , 4 4 ) , ’Demand ’ : 19} ,{ ’Name ’ : ” 2 ” , ’ Coord ’ : ( 5 0 , 5 ) , ’Demand ’ : 21} ,{ ’Name ’ : ” 3 ” , ’ Coord ’ : ( 4 9 , 8 ) , ’Demand ’ : 6} ,{ ’Name ’ : ” 4 ” , ’ Coord ’ : ( 1 3 , 7 ) , ’Demand ’ : 19} ,{ ’Name ’ : ” 5 ” , ’ Coord ’ : ( 2 9 , 8 9 ) , ’Demand ’ : 7} ,{ ’Name ’ : ” 6 ” , ’ Coord ’ : ( 5 8 , 3 0 ) , ’Demand ’ : 12} ,{ ’Name ’ : ” 7 ” , ’ Coord ’ : ( 8 4 , 3 9 ) , ’Demand ’ : 16} ,{ ’Name ’ : ” 8 ” , ’ Coord ’ : ( 1 4 , 2 4 ) , ’Demand ’ : 6} ,{ ’Name ’ : ” 9 ” , ’ Coord ’ : ( 2 , 3 9 ) , ’Demand ’ : 16} ,{ ’Name ’ : ” 10 ” , ’ Coord ’ : ( 3 , 8 2 ) , ’Demand ’ : 8} ,{ ’Name ’ : ” 11 ” , ’ Coord ’ : ( 5 , 1 0 ) , ’Demand ’ : 14} ,{ ’Name ’ : ” 12 ” , ’ Coord ’ : ( 9 8 , 5 2 ) , ’Demand ’ : 21} ,{ ’Name ’ : ” 13 ” , ’ Coord ’ : ( 8 4 , 2 5 ) , ’Demand ’ : 16} ,{ ’Name ’ : ” 14 ” , ’ Coord ’ : ( 6 1 , 5 9 ) , ’Demand ’ : 3} ,{ ’Name ’ : ” 15 ” , ’ Coord ’ : ( 1 , 6 5 ) , ’Demand ’ : 22} ,{ ’Name ’ : ” 16 ” , ’ Coord ’ : ( 8 8 , 5 1 ) , ’Demand ’ : 18} ,{ ’Name ’ : ” 17 ” , ’ Coord ’ : ( 9 1 , 2 ) , ’Demand ’ : 19} ,{ ’Name ’ : ” 18 ” , ’ Coord ’ : ( 1 9 , 3 2 ) , ’Demand ’ : 1} ,{ ’Name ’ : ” 19 ” , ’ Coord ’ : ( 9 3 , 3 ) , ’Demand ’ : 24} ,{ ’Name ’ : ” 20 ” , ’ Coord ’ : ( 5 0 , 9 3 ) , ’Demand ’ : 8} ,{ ’Name ’ : ” 21 ” , ’ Coord ’ : ( 9 8 , 1 4 ) , ’Demand ’ : 12}

)}

prob = VRP( ”VRP1” , vrp1 )prob . model ( )prob . o p t i m i z e ( F a l s e , 3 6 0 0 )prob . s e t S o l u t i o n ( )prob . p r i n t S o l u t i o n ( )

Listing 5.7: Example of usage of class VRP

If we run the above program, we get the following result.O b j e c t i v e v a l u e : 635 .00

Route 1 , v e h i c l e o f t y p e 1 , c a r g o we ig h t − 1000 −> 8 −> 4 −> 11 −> 9 −> 15 −> 10 −> 5 −> 20 −> 0

Route 2 , v e h i c l e o f t y p e 1 , c a r g o we ig h t − 900 −> 16 −> 7 −> 13 −> 1 −> 12 −> 0

Route 3 , v e h i c l e o f t y p e 1 , c a r g o we ig h t − 980 −> 21 −> 19 −> 17 −> 2 −> 3 −> 18 −> 6 −> 14 −> 0

Listing 5.8: Output of program from Listing 5.7

5.3 Multi-Dimensional Packing

In a m-dimensional (orthogonal) packing problem the main requirement is to pack a number of smallm-dimensional rectangular boxes (items) into a large m-dimensional rectangular box (container) so thatno two items overlap, and item edges are parallel to the container edges.

Page 89: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.3. Multi-Dimensional Packing 81

Two-dimensional (m = 2) packing problems arise in different industries, where steel, wood, glass,or textile materials are cut. In such cases these packing problems are also known as the two-dimensionalcutting stock problems. The problem to optimize the layout of advertisements in a newspaper is alsoformulated as a two-dimensional packing problem. Three-dimensional (m = 3) packing problems —also known as the container loading problems — appear as important subproblems in logistics and supplychain applications.

Many scheduling problems can be formulated as multi-dimensional packing problems: we representa job as a box one of which sizes is its processing time, and the other ones represent amounts of somerenewable resources needed to fulfill this job. Then the container sizes give the limit on the processingtime of all jobs, and the available amounts of all resources.

We are given a large m-dimensional rectangular box (container) which sizes are given by a vectorL = (L1, . . . , Lm)T ∈ Zm and a set of n small m-dimensional rectangular boxes (items), item r sizesare given by a vector lr = (lr1, . . . , l

rm)T ∈ Zm.

In the (orthogonal) m-dimensional knapsack problem (m-KP), for each item r, we also know itscost cr. The goal is to pack into the container — which is also called the knapsack — a subset of itemsof maximum total cost so that no two items overlap, and item edges are parallel to knapsack edges. Ifthe items cannot be rotated (say, when cutting decorated materials, or scheduling machines), then everyedge i of each item is parallel to knapsack edge i — we have an m-KP without rotation.

In the m-dimensional strip packing problem (m-SP), it is assumed that one edge (let us call it theheight) of the container — which is called the strip — is sufficiently big so that all the items can bepacked into the strip, and the objective is to minimize the height to which the strip is used.

In the m-dimensional bin packing problem (m-BP) there are many large boxes of equal sizes —which are called bins — and the objective is to pack all n items into a minimum number of bins. We cantranslate any m-BP instance into an instance of (m + 1)-SP, where the additional (m + 1)-st direction(the height of the strip) is used to count bins: Lm+1 is an upper bound on the number of needed bins, andlrm+1 = 1 for all items r.

In what follows we will develop an integer programming (IP) formulation of m-KP. With minormodifications that formulation is also valid for m-SP (we just have to change the objective).

5.3.1 Integer Programming Formulation of m-KP

The first integer programming (IP) formulation of a two-dimensional packing problem (namely, the cut-ting stock problem) based on the discrete representation of the geometrical space was given by Beasley1.Similar formulation was given by Hadjiconstantinou and Christofides2. Both formulations have a greatdeal of variables, and their constraint matrices are dense (each constraint contains a great deal of non zeroentries) what results in IPs that are difficult to solve. Although both formulations can be easily extendedto model packing problems in higher (than 2) dimensions, the number of variables in each extended for-mulation would increase exponentially as the dimension increases. Here we present a slightly differentformulation of m-KP, that is substantially more compact — it has fewer variables and its matrix is sparse— compared to the above mentioned formulations. Moreover, the number of variables in our formulationgrows only linearly as the dimension grows.

First, let us define two families of decision binary variables:

1 J.E. Beasley. An exact two-dimensional non-guillotine cutting tree search procedure, Operational Research 33 (1985)49–64.

2 E. Hadjiconstantinou, N. Christofides. An exact algorithm for the orthogonal, 2-D cutting problems using guillotine cuts,European Journal of Operational Research 83 (1995) 21–38.

Page 90: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

82 Chapter 5. Logistics management

• for r = 1, . . . , n, zr = 1 if item r is placed into the knapsack, and zr = 0 otherwise;

• for r = 1, . . . , n, i = 1, . . . ,m, and j = 0, . . . , Li − lri , yrij = 1 if j is the value of coordinate iof the corner of item r that is nearest to the origin, and yrij = 0 otherwise.

For modeling purposes, we also need two families of auxiliary variables:

• for r = 1, . . . , n, i = 1, . . . ,m, and j = 1, . . . , Li, xrij = 1 if the open unit strip U ijdef= {w ∈

Rm : j − 1 < wi < j} intersects item r, and xrij = 0 otherwise;

• for r1 = 1, . . . , n − 1, r2 = r1 + 1, . . . , n, and i = 1, . . . ,m, sr1,r2,i = 1 if items r1 and r2 areseparated by a hyperplane that is ortogonal to axis i, and sr1,r2,i = 0 otherwise.

In these variables the model is written as follows:

n∑r=1

crzr → max, (5.3a)

Li−lri∑j=0

yrij = zr, i = 1, . . . ,m, r = 1, . . . , n, (5.3b)

xrij =

min{j−1,Li−lri }∑j1=max{0,j−lri }

yr,i,j1 , j = 1, . . . , Li, i = 1, . . . ,m,

r = 1, . . . , n, (5.3c)Li∑j=1

xrij = lri zr, i = 1, . . . ,m, r = 1, . . . , n, (5.3d)

m∑i=1

sr1,r2,i ≥ zr1 + zr2 − 1, r2 = r1 + 1, . . . , n,

r1 = 1, . . . , n− 1, (5.3e)

xr1,i,j + xr2,i,j + sr1,r2,i ≤ zr1 + zr2 , j = 1, . . . , Li, i = 1, . . . ,m,

r2 = r1 + 1, . . . , n, r1 = 1, . . . , n− 1, (5.3f)

zr ∈ {0, 1}, r = 1, . . . , n, (5.3g)

yrij ∈ {0, 1}, j = 0, . . . , Li − lri , i = 1, . . . ,m,

r = 1, . . . , n, (5.3h)

xrij ∈ {0, 1}, j = 1, . . . , Li, i = 1, . . . ,m,

r = 1, . . . , n, (5.3i)

sr1,r2,i ∈ {0, 1}, i = 1, . . . ,m, r2 = r1 + 1, . . . , n,

r1 = 1, . . . , n− 1. (5.3j)

The objective (5.3a) is to maximize the total cost of items placed into the knapsack. The inequalities(5.3b) set to zero the values of those y-variables that correspond to the items not placed into the knapsack.The equations (5.3c) establish the relationship between x and y-variables. The equalities (5.3d) requirethat each item in the knapsack must be of given sizes. Two families of inequalities, (5.3e) and (5.3f)

Page 91: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.3. Multi-Dimensional Packing 83

imply that each pair of items placed into the knapsack are separated by at least one hyperplane that areortogonal to a coordinate axis.

The other relations (5.3g)–(5.3j) declare that the all variables are binary.

5.3.2 Tightening Basic Model

Computational experiments showed that our basic model (5.3a)–(5.3j) is not tight, and, therefore, thereis no hope to apply it for solving problems of practical importance. Next we will add to (5.3a)–(5.3j)new constrains to make the formulation tighter.

First, we introduce a family of knapsack inequalities that can significantly strengthen our IP (5.3a)–(5.3j). Let us denote by V ol the volume,

∏mi=1 Li, of the knapsack, and by volr the volume,

∏mi=1 l

ri , of

item r. With this notations, we introduce the following knapsack inequalities:

n∑r=1

volrzr ≤ V ol, (5.4a)

n∑r=1

volrlri

xrij ≤V ol

Li, j = 1, . . . , Li, i = 1, . . . ,m. (5.4b)

The inequality (5.4a) imposes the following natural restriction: the sum of item volumes cannot exceedthe knapsack volume. The inequalities (5.4b) express the fact that the sum of volumes of the intersectionsof the items with any unit strip ortogonal to some axis cannon exceed the volume of the intersection ofthe knapsack with that strip.

Computational experiments showed that these knapsack inequalities may greatly tighten the IP for-mulation.

The purpose of the next two families of constraints is to remove symmetry. For two items r1, r2, wewrite r1 � r2 if lr1i ≤ lr2i for all i, cr1 ≥ cr2 , and either at least one of these inequalities are strict orr1 < r2. Two items r1, r2 are identical if they have the same sizes (lr1 = lr2) and costs (cr1 = cr2), insuch a case we write r1 ≡ r2. With these notations we can add to (5.3a)–(5.3j) the following inequalities:

zr1 ≥ zr2 , r1, r2 = 1, . . . , n, r1 � r2, (5.5a)

ori =

Li−lri∑j=0

jyrij , i = 1, . . . ,m, r = 1, . . . , n, (5.5b)

i−1∑k=1

(i−1∏s=k

Ls)(ork − or1,k) + ori − or1,i ≤ 0, i = 1, . . . ,m, ∀ r1 ≡ r2, r1 < r2, (5.5c)

ori ≥ 0, i = 1, . . . ,m, r = 1, . . . , n. (5.5d)

The inequalities (5.5a) imply that out of two related items r1, r2, r1 � r2, item r2 will be in the knapsackonly if item r1 is already there. The equations (5.5b) are to compute, for each item r placed into theknapsack, the item corner nearest to the origin, or = (or1, . . . , orm). For a given pair, (r, r1) withr < r1, of identical items, the inequalities (5.5c) imply that the vector or is lexicographically less thanthe vector or1 .

When we rotate the knapsack with some items inside along the line passing through the knapsackcenter and parallel to some coordinate axis, we get a new symmetric placement of the same items. These

Page 92: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

84 Chapter 5. Logistics management

symmetries may significantly increase the solution time of any modern IP solver. To avoid two centralsymmetries, we can add another system of inequalities. For i = 1, . . . ,m, let us define two integers:ki1 = Li mod 2, ki2 = ki1 if ki1 is even, or ki2 = ki1 + 1 if ki1 is odd. The following inequalities removeall central symmetries:

n∑r=1

ki1∑j=1

(vol(r)/lri )xrij ≥n∑r=1

Li∑j=ki2

(vol(r)/lri )xrij , i = 1, . . . ,m. (5.6)

Rotations and Complex Loading Patterns

In this section we show how to extend our IP formulation of m-KP to cover the cases when rotations ofitems are allowed, as well as when the knapsack and the items are the unions of rectangular boxes.

If rotations of items are allowed, let us assume that all possible rotations of item r result in the boxesof the following sizes: lr1, . . . , lr,Qr ∈ Zm. Then we must substitute (5.3d) for the following system:

Li∑j=1

xrij =

Qr∑q=1

lrqi frq, i = 1, . . . ,m, r = 1, . . . , n,

Qr∑q=1

frq = zr, r = 1, . . . , n,

fr,q ∈ {0, 1}, q = 1, . . . , Qr, r = 1, . . . , n.

(5.7)

Let the knapsack be a rectangular box from which a number of non-overlapping rectangular boxeshave been removed. Alternatively, we can think that a number of dummy items should be placed into theknapsack at predefined positions. It is convenient to think that each item r is either dummy or real. LetD ⊆ {1, . . . , n} denote the set of dummy items and let jr ∈ Rm be the closest to the origin corner ofdummy item r. To guaranty that all dummy items are put into the knapsack at their predefined positions,we just fix the values of some x-variables:

yrijr = 1, i = 1, . . . ,m, r ∈ D. (5.8)

To model the case when some items are unions of two or more rectangular boxes, let us assume thatour input n items are divided into groups of one or more items, and all items from a group are togetherput or together not put into the knapsack. In each group of items we choose one item, r̄, called the base;any non-base item r in this group is assigned a reference, ref(r) = r̄, to the base item, ref(r̄) = −1.Each non-base item r is also assigned a vector vr ∈ Rm: if or̄ is the nearest to the origin corner of thebase item r̄ = ref(r), then or̄ + vr is the nearest to the origin corner of item r. In other words, thevectors vr assigned to all non-base items r in a group uniquely determine the shape of this group.

The following equations model the above defined group restrictions;

zr = zref(r), r = 1, . . . , n, ref(r) ≥ 0,

ori = 0ref(r),i + vri zr, i = 1, . . . ,m, r = 1, . . . , n, ref(r) ≥ 0.(5.9)

5.3.3 MIPCL-PY Implementation

Our implementation of IP (5.3) and some of its extensions (5.5), (5.6), and (5.4), is given in listings 5.9,5.10, and 5.11.

Page 93: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.3. Multi-Dimensional Packing 85

Listing 5.9 presents the definition of class Packing that is a subclass of another class, Problem,which implements an interface to the mipcl-py module.

from m i p c l p y . m i p s h e l l . m i p s h e l l i m p o r t ∗

c l a s s Pack ing ( Problem ) :d e f p r e p a r e ( s e l f , f a c t o r , up ) :

up = s e l f . upLR , Vol = [ ] , 1 . 0f o r s i n s e l f . i n s t a n c e [ ’ Cont . S i z e s ’ ] :

s r = ( s ∗ f a c t o r [ 0 ] ) / / f a c t o r [ 1 ]Vol = Vol ∗ s rLR . append ( s r )

s e l f . i n s t a n c e [ ’ Volume ’ ] = Vols e l f . i n s t a n c e [ ’ Cont . r S i z e s ’ ] = LR

f o r i t em i n s e l f . i n s t a n c e [ ’ I t e m s ’ ] :l r , v = [ ] , 1 . 0f o r s i n i t em [ ’ S i z e s ’ ] :

s r = ( s ∗ f a c t o r [ 0 ] ) / / f a c t o r [ 1 ]i f up :

i f ( s r ∗ f a c t o r [ 1 ] ) < s ∗ f a c t o r [ 0 ] : s r += 1v = v ∗ s rl r . append ( s r )i t em [ ’ Volume ’ ] = vi t em [ ’ r S i z e s ’ ] = l r

d e f i n i t ( s e l f , name , i n s t a n c e , f a c t o r = ( 1 , 1 ) , up=True ) :Problem . i n i t ( s e l f , name )s e l f . i n s t a n c e = i n s t a n c es e l f . f a c t o r = f a c t o rs e l f . up = ups e l f . p r e p a r e ( f a c t o r , up )

Listing 5.9: MIPCL-PY implementation of m-KP: prepare and the constructor

The constructor, init (), stores a reference to a structure, named instance, that describes aninstance of m-KP. This structure has the following fields:

• instance[’Cont. Sizes’]: tuple of container sizes;

• instance[’Items’]: list of dictionaries, where item = instance[’Items’][i] de-scribes item i;

– item[’Type’]: type of item; usually, identical items are of the same type;

– item[’Sizes’]: tuple of item sizes;

– item[’Cost’]: item cost.

The last two arguments passed to init (), factor and up, are useful when packing items intoa big container. If the value of up is True, prepare()

1) divides the container sizes by the value of factor and then rounds down the results;

2) divides the sizes of all items by the value of factor and then rounds up the results.

Page 94: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

86 Chapter 5. Logistics management

As a result, we will get the packing problem which is easier to solve and which solution is feasible forthe original problem.

If the value of up is False, prepare()

1) divides the container sizes by the value of factor and then rounds up the results;

2) divides the sizes of all items by the value of factor and then rounds down the results.

Again we will get the packing problem which is easier to solve, and the optimal objective value for thisproblem is an upper bound for the optimal objective value of the original problem. We can use this upperbound to estimate the quality of any approximate solution.

Our implementation of IP (5.3) is given in the function named modelwhich is shown in Listing 5.10.

d e f model ( s e l f ) :d e f c ( r ) : r e t u r n i t e m s [ r ] [ ’ Cos t ’ ]d e f v o l ( r ) : r e t u r n i t e m s [ r ] [ ’ Volume ’ ]d e f l ( r , i ) : r e t u r n i t e m s [ r ] [ ’ r S i z e s ’ ] [ i ]d e f V( r , i ) :

i f l ( r , i ) > 0 : v = v o l ( r ) / / l ( r , i )e l s e : v = 0r e t u r n v

i n s t a n c e = s e l f . i n s t a n c eL = i n s t a n c e [ ’ Cont . r S i z e s ’ ]i t e m s = i n s t a n c e [ ’ I t e m s ’ ]Vol = i n s t a n c e [ ’ Volume ’ ]m, n = l e n ( L ) , l e n ( i t e m s )

s e l f . z = z = VarVec to r ( [ n ] , ’ z ’ , BIN , p r i o r i t y =10)s e l f . x = x = [ [ VarVec to r ( [ L [ i ] ] , ’ x [ { : d } ] [ { : d } ] ’ . f o r m a t ( r , i ) , BIN ) \

f o r i i n r a n g e (m) ] f o r r i n r a n g e ( n ) ]y = [ [ VarVec to r ( [ L [ i ]− l ( r , i ) +1 ] , ’ y [ { : d } ] [ { : d } ] ’ . f o r m a t ( r , i ) , BIN ) \

f o r i i n r a n g e (m) ] f o r r i n r a n g e ( n ) ]s = [{ r1 : [ Var ( ’ s ( { : d } ,{ : d } ,{ : d } ) ’ . f o r m a t ( r , r1 , i ) , BIN ) f o r i i n r a n g e (m) ] \

f o r r1 i n r a n g e ( r +1 , n ) } f o r r i n r a n g e ( n ) ]o = VarVec to r ( ( n ,m) , ’ o ’ )

maximize ( sum ( c ( r ) ∗z [ r ] f o r r i n r a n g e ( n ) ) )

f o r r i n r a n g e ( n ) :f o r i i n r a n g e (m) :

o [ r ] [ i ] == sum ( j ∗y [ r ] [ i ] [ j ] f o r j i n r a n g e ( L [ i ]− l ( r , i ) +1) )f o r j i n r a n g e ( L [ i ] ) :

x [ r ] [ i ] [ j ] == sum ( y [ r ] [ i ] [ j 1 ] f o r j 1 i n \r a n g e ( max ( 0 , j−l ( r , i ) +1) , min ( j , L [ i ]− l ( r , i ) ) +1) )

sum ( y [ r ] [ i ] [ j ] f o r j i n r a n g e ( L [ i ]− l ( r , i ) +1) ) == z [ r ]# r e s t r i c t i o n s on t h e i t em s i z e s

sum ( x [ r ] [ i ] [ j ] f o r j i n r a n g e ( L [ i ] ) ) == l ( r , i ) ∗z [ r ]

# each p a i r o f i t ems , ( r , r1 ) , must be s e p a r a t e d by a h y p e r p l a n e# which i s o r t h o g o n a l t o one of m axes

f o r r1 i n r a n g e ( r +1 , n ) :sum ( s [ r ] [ r1 ] [ i ] f o r i i n r a n g e (m) ) >= z [ r ] + z [ r1 ] − 1

q = 0f o r i i n r a n g e (m) :

i f l ( r , i ) + l ( r1 , i ) <= L [ i ] :

Page 95: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.3. Multi-Dimensional Packing 87

f o r j i n r a n g e ( L [ i ] ) :x [ r ] [ i ] [ j ] + x [ r1 ] [ i ] [ j ] + s [ r ] [ r1 ] [ i ] <= z [ r ] + z [ r1 ]

e l s e :s [ r ] [ r1 ] [ i ] == 0q += 1

i f q == m:z [ r ] + z [ r1 ] <= 1

# Less s i z e and b i g g e r c o s t => a l l o c a t e f i r s tq , q1 = 0 , 0i f c ( r ) >= c ( r1 ) : q += 1i f c ( r ) <= c ( r1 ) : q1 += 1f o r i i n r a n g e (m) :

i f l ( r , i ) <= l ( r1 , i ) : q += 1i f l ( r , i ) >= l ( r1 , i ) : q1 += 1i f q == m+1:

z [ r ] >= z [ r1 ]i f q1 == m+1: # r and r1 a r e i d e n t i c a l

l s = o [ r ] [ 0 ] − o [ r1 ] [ 0 ]l s <= 0 . 0f o r i i n r a n g e ( 1 ,m) :

l s = L [ i −1]∗ l s + o [ r ] [ i ] − o [ r1 ] [ i ]l s <= 0 . 0

e l i f q1 == m+1:z [ r ] <= z [ r1 ]

# volume knapsacksum ( v o l ( r ) ∗z [ r ] f o r r i n r a n g e ( n ) ) <= Vol

# s t r i p k n a p s a c k sf o r i i n r a n g e (m) :

f o r j i n r a n g e ( 0 , L [ i ] , 1 0 ) :sum (V( r , i ) ∗x [ r ] [ i ] [ j ] f o r r i n r a n g e ( n ) ) <= Vol / / L [ i ]

# b r e a k i n g c e n t r a l symmen t r i e sf o r i i n r a n g e (m) :

L0 = L [ i ]k1 = L0 / / 2i f 2∗k1 < L0 : k2 = k1 + 1e l s e : k2 = k1sum (V( r , i ) ∗x [ r ] [ i ] [ j ] f o r r i n r a n g e ( n ) f o r j i n r a n g e ( k1 ) ) >= \sum (V( r , i ) ∗x [ r ] [ i ] [ j ] f o r r i n r a n g e ( n ) f o r j i n r a n g e ( k2 , L0 ) )

Listing 5.10: MIPCL-PY implementation of m-KP: model

When a solution has been found, one may want to print it in a readable format. Listing 3.6 presentsa procedure — which is a member of Packig — that does this job.

d e f g e t L a y o u t ( s e l f ) :L = s e l f . i n s t a n c e [ ’ Cont . r S i z e s ’ ]f a c t o r = s e l f . f a c t o rm, n = l e n ( L ) , l e n ( s e l f . i n s t a n c e [ ’ I t e m s ’ ] )x , z = s e l f . x , s e l f . zl a y o u t = { ’ Cos t ’ : i n t ( s e l f . ge tOb jVa l ( ) + 0 . 5 ) , ’ P o s i t i o n s ’ : {}}p o s i t i o n s = l a y o u t [ ’ P o s i t i o n s ’ ]

f o r r i n r a n g e ( n ) :i f z [ r ] . v a l > 0 . 5 :

o r i g i n = p o s i t i o n s [ r ] = [ ]

Page 96: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

88 Chapter 5. Logistics management

f o r i i n r a n g e (m) :f o r j i n r a n g e ( L [ i ] ) :

i f x [ r ] [ i ] [ j ] . v a l > 0 . 5 :o r i g i n . append ( ( j ∗ f a c t o r [ 1 ] ) / / f a c t o r [ 0 ] )b r e a k

r e t u r n l a y o u t

d e f p r i n t L a y o u t ( s e l f ) :i f s e l f . i s s o l u t i o n i s n o t None :

i f s e l f . i s s o l u t i o n :i t e m s = s e l f . i n s t a n c e [ ’ I t e m s ’ ]m = l e n ( s e l f . i n s t a n c e [ ’ Cont . S i z e s ’ ] )f a c t o r = s e l f . f a c t o rl a y o u t = s e l f . g e t L a y o u t ( )p o s i t i o n s = l a y o u t [ ’ P o s i t i o n s ’ ]p r i n t ( ’ Layout c o s t = { : d} ’ . f o r m a t ( l a y o u t [ ’ Cos t ’ ] ) )f o r r i n s o r t e d ( p o s i t i o n s . keys ( ) ) :

s t r 0 = r e p r ( i t e m s [ r ] [ ’ Type ’ ] ) . r j u s t ( 3 ) + ’ ( { : d } ) : ’ . f o r m a t (i t e m s [ r ] [ ’ Cos t ’ ] ) . r j u s t ( 8 )

s t r 1 , s t r 2 = ’ ’ , ’ ’f o r i ,X i n enumera t e ( p o s i t i o n s [ r ] ) :

i f i > 0 :s t r 1 += ’ , ’s t r 2 += ’ , ’

s t r 1 += r e p r (X)s t r 2 += r e p r (X + i t e m s [ r ] [ ’ S i z e s ’ ] [ i ] )

p r i n t ( s t r 0 + ’ [ ( ’ + s t r 1 + ’ ) , ( ’ + s t r 2 + ’ ) ] ’ )e l s e :

p r i n t ( ’No f e a s i b l e s o l u t i o n has been found ’ )e l s e :

p r i n t ( ’ P l e a s e c a l l o p t i m i z e ( ) f i r s t ’ )

Listing 5.11: MIPCL-PY implementation of m-KP: auxiliary procedures

First, the procedure printLayout calls getLayout to extract the layouts of items from thevalues of decision variables z[r] and x[r][i][j]. Then this layout is printed.

5.3.4 Example of Usage

The program presented below will show you how to use our class Packing.

# ! / u s r / b i n / py thonfrom m u l t i P a c k i n g i m p o r t Pack ing

i n s t a n c e = {’ Cont . S i z e s ’ : ( 1 0 , 10) ,’ I t e m s ’ : ({ ’ Type ’ : 1 , ’ S i z e s ’ : ( 3 , 7 ) , ’ Cos t ’ : 35} ,{ ’ Type ’ : 1 , ’ S i z e s ’ : ( 3 , 7 ) , ’ Cos t ’ : 35} ,{ ’ Type ’ : 2 , ’ S i z e s ’ : ( 8 , 2 ) , ’ Cos t ’ : 40} ,{ ’ Type ’ : 2 , ’ S i z e s ’ : ( 8 , 2 ) , ’ Cos t ’ : 40} ,{ ’ Type ’ : 3 , ’ S i z e s ’ : ( 1 0 , 2 ) , ’ Cos t ’ : 27} ,{ ’ Type ’ : 4 , ’ S i z e s ’ : ( 5 , 4 ) , ’ Cos t ’ : 23} ,{ ’ Type ’ : 4 , ’ S i z e s ’ : ( 5 , 4 ) , ’ Cos t ’ : 23} ,{ ’ Type ’ : 4 , ’ S i z e s ’ : ( 5 , 4 ) , ’ Cos t ’ : 23} ,{ ’ Type ’ : 5 , ’ S i z e s ’ : ( 2 , 9 ) , ’ Cos t ’ : 43} ,

Page 97: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

5.3. Multi-Dimensional Packing 89

{ ’ Type ’ : 5 , ’ S i z e s ’ : ( 2 , 9 ) , ’ Cos t ’ : 43})

}

prob = Pack ing ( ” t e s t 0 ” , i n s t a n c e )prob . model ( )prob . o p t i m i z e ( F a l s e , 3 6 0 0 )prob . p r i n t L a y o u t ( )

Listing 5.12: Example of usage of class Packing

If we run the above program, we get the following result.

Layout c o s t = 1641 ( 3 5 ) : [ ( 5 , 1 ) , ( 8 , 8 ) ]2 ( 4 0 ) : [ ( 0 , 8 ) , ( 8 , 1 0 ) ]4 ( 2 3 ) : [ ( 0 , 4 ) , ( 5 , 8 ) ]4 ( 2 3 ) : [ ( 0 , 0 ) , ( 5 , 4 ) ]5 ( 4 3 ) : [ ( 8 , 0 ) , ( 1 0 , 9 ) ]

Listing 5.13: Output of program from Listing 5.12

Page 98: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

90 Chapter 5. Logistics management

Page 99: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Bibliography

[1] V. Chvatal. Linear Programming, Freeman, New York (1983).

[2] G.L. Nemhauser, L.A. Wolsey. Integer and Combinatorial Optimization, Wiley (1988).

[3] M. Padber. Linear Optimization and Extensions, Springer-Verlag Berlin Heidelberg (1995).

[4] N.N. Pisaruk. Models and Methods of Mixed Integer Programming (in Russian), Belarus StateUniversity, Minsk (2010).

[5] A. Schriver. Theory of Linear and Integer Programming. Wiley, Chichester (1986).

[6] H.P. Williams. Model building in mathematical programming. Wiley (1999).

[7] L.A.Wolsey. Integer Programming, Wiley (1998).

91

Page 100: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

92 Bibliography

Page 101: Nicolai N. Pisaruk Mixed Integer Programming in Operations ... · Mixed Integer Programming in Operations Management (MIPCL ... Mixed Integer Programming in operations management

Index

backlogging, 2backordering, 2balance equation, 72bound

variable, 2upper, 72

DEA, 54

FCNF, 71finance strategy, iii

inventory, 1

marketing strategy, iiim-KP, 81model applied dynamically, 70m-BP, 81m-SP, 81

operations resources, iiioperations strategy, iii

problem

1|rj , dj |∑wjCj , 17

facility location, 51fixed charge network flow, see FCNFline balancing, 47

simple, 47multi-dimensional bin packing, see m-BPmulti-dimensional knapsack, see m-KPmulti-dimensional packing, 80multi-dimensional strip packing, see m-SPscheduling batch operations, 24single product lot-sizing, 1unit commitment, 20vehicle routing, see VRP

process layout, 41product layout, 41production system, iii

schedulingtime-index formulation, 16

VRP, 76

yield management, 60

93