Sched Midterm Note
Sched Midterm Note
Phúc
I. PERT Model
1. Components
❖ Job – Node, Start time: ES/LS Slack: LC – EC or LS – ES
❖ Precedence diagram, Completion time: EC/LC Makespan
❖ Processing time: 𝑝𝑗
2. Precedence diagram
Job Processing Precedence
time
1 5 -
2 4 1
3 6 1
4 10 1, 2
5 8 2
6 5 3, 4
7 11 4, 5, 6
8 7 5, 7
4. Critical path
The path(s) has longest total processing time, and all jobs having Slack = 0
1–2–4–6–7–8
1
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
II. Time-Cost tradeoff
1. Components and concepts
❖ Overhead cost = 𝑐0 × 𝑚𝑎𝑘𝑒𝑠𝑝𝑎𝑛
Renting machine, Renting land cost, Labor cost
❖ Processing time: Vary in the range of [𝒑𝒎𝒊𝒏 ; 𝒑𝒎𝒂𝒙 ]
At 𝒑𝒎𝒊𝒏
𝒋 the cost is 𝒄𝒂𝒋 , at 𝒑𝒎𝒂𝒙
𝒋 the cost is 𝒄𝒃𝒋 𝒄𝒂𝒋 ≥ 𝒄𝒃𝒋
Cost to reduce processing time of a job by 1 unit of time: 𝛼𝑗
𝑐𝑗𝑎 − 𝑐𝑗𝑏
𝛼𝑗 = 𝑚𝑎𝑥
𝑝𝑗 − 𝑝𝑗𝑚𝑖𝑛
=> To reduce overhead cost, reducing makespan = reducing PT of CP
Rule: cost of reducing PT ≤ overhead cost unit
2. Procedure (𝒄𝟎 = 𝟔)
2
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
Iteration 1: 𝒑𝒋 = 𝒑𝒎𝒂𝒙
𝒋 for all jobs
Job 1 2 3 4 5 6 7 8 9 10 11
ES 0 8 0 0 6 3 3 8 8 13 15
EC 8 13 6 3 8 8 5 12 15 17 24
LS 0 15 0 0 6 3 13 11 8 20 15
LC 8 20 6 3 8 8 15 15 15 24 24
Slack 0 7 0 0 0 0 10 3 0 7 0
- Cmax = 24
- Total overhead cost = 6 x 24 = 144
- Critical paths:
(1 – 9 – 11)
(3 – 5 – 9 – 11)
(4 – 6 – 9 – 11)
- Minimum cut set: {1, 3, 4} , {1, 5, 6} , {1, 3, 6} , {1, 5, 4}, {9}, {11} with
𝛼134 = 𝟏𝟎, 𝛼156 = 𝟏𝟐, 𝛼136 = 𝟏𝟐, 𝛼154 = 𝟏𝟎, 𝛼9 = 𝟒, 𝛼11 = 𝟒
- Best candidate: {9} and {11}
- Saving cost of candidate: 6 – 4 = 2
- Cmax = 23
- Total overhead cost = 6 x 23 = 138
- Critical paths:
(1 – 9 – 11),
(3 – 5 – 9 – 11),
(4 – 6 – 9 – 11)
- Minimum cut set: {1, 3, 4} , {1, 5, 6} , {1, 3, 6} , {1, 5, 4}, {9}, {11} with
𝛼134 = 𝟗, 𝛼156 = 𝟏𝟐, 𝛼136 = 𝟏𝟐, 𝛼154 = 𝟏𝟎, 𝛼9 = 𝟒, 𝛼11 = 𝟒
- Best candidate: {9} and {11}
- Saving cost of candidate: 6 – 4 = 2
3
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
Iteration 3: Reducing processing time of job 9 by 1 unit
Job 1 2 3 4 5 6 7 8 9 10 11
ES 0 8 0 0 6 3 3 8 8 13 13
EC 8 13 6 3 8 8 5 12 13 17 22
LS 0 13 0 0 6 3 11 9 8 18 13
LC 8 18 6 3 8 8 13 13 13 22 22
Slack 0 5 0 0 0 0 8 1 0 5 0
- Cmax = 22
- Total overhead cost = 6 x 22 = 138
- Critical paths: (1 – 9 – 11), (3 – 5 – 9 – 11), (4 – 6 – 9 – 11)
- Minimum cut set: {1, 3, 4} , {1, 5, 6} , {1, 3, 6} , {1, 5, 4}, {9}, {11} with
𝛼134 = 𝟗, 𝛼156 = 𝟏𝟐, 𝛼136 = 𝟏𝟐, 𝛼154 = 𝟏𝟎, 𝛼11 = 𝟒
(𝑝9 = 𝑝9𝑚𝑖𝑛 → no consideration)
- Best candidate: {11}
- Saving cost of candidate: 6 – 4 = 2
4
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
III. JOB SHOP PROBLEM
Answer
5
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
IV. MATHEMATICAL MODEL
∑( ) ≤ 𝐶𝑗 × 𝑋𝑗 ∑( ) ≤ 𝐵𝑖𝑔𝑀 × 𝑋𝑗
𝑖 𝑖
3. Inference Condition
If (X = 1) then 𝐴 ≤ 𝐵 𝐵𝑖𝑔𝑀 × (𝑋 − 1) + 𝐴 ≤ 𝐵
If (X = 0) then 𝐴 ≥ 𝐵 𝐵𝑖𝑔𝑀 × 𝑋 + 𝐴 ≥ 𝐵
𝐵𝑖𝑔𝑀 × (𝑋 − 1) + 𝐴 ≤ 𝐵
If (X = 1) then 𝐴 = 𝐵 {
𝐵𝑖𝑔𝑀 × (1 − 𝑋) + 𝐴 ≥ 𝐵
4. Max Constraint
𝑋 = max(𝐴, 𝐵)
Let 𝑌 be the binary variable
1 , 𝑖𝑓 𝐴 − 𝐵 ≥ 0
𝑌={
0 , 𝑖𝑓 𝐴 − 𝐵 ≤ 0
The constraint 𝑋 = max (𝐴, 𝐵) can be transformed to linear form:
𝐵 ≤ 𝑋 ≤ 𝐵 + 𝐵𝑖𝑔𝑀 × 𝑌
{
𝐴 ≤ 𝑋 ≤ 𝐴 + 𝐵𝑖𝑔𝑀 × (1 − 𝑌)
5. Min Constraint
𝑋 = min(𝐴, 𝐵)
Let 𝑌 be the binary variable
1 , 𝑖𝑓 𝐴 − 𝐵 ≥ 0
𝑌={
0 , 𝑖𝑓 𝐴 − 𝐵 ≤ 0
The constraint 𝑋 = min (𝐴, 𝐵) can be transformed to linear form:
6
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
𝐵 ≥ 𝑋 ≥ 𝐵 − 𝐵𝑖𝑔𝑀 × (1 − 𝑌)
{
𝐴 ≥ 𝑋 ≥ 𝐴 − 𝐵𝑖𝑔𝑀 × 𝑌
6. ‘And’ Condition
Given 𝑋𝑖 , 𝑌 are binary variables. 𝑌 relates to 𝑋𝑖 through ‘And’ operator
𝑌 = 𝑋1 ∩ 𝑋2 ∩ 𝑋3 … ∩ 𝑋𝑛
This constraint can be transformed to linear form as
𝑌 ≤ 𝑋𝑖 , ∀𝑖, 𝑖 = 1 … 𝑛
{
𝑌 ≥ Σ𝑖 𝑋𝑖 − 𝑛 + 1
7. ‘Or’ Condition
Given 𝑋𝑖 , 𝑌 are binary variables. 𝑌 relates to 𝑋𝑖 through ‘Or’ operator
𝑌 = 𝑋1 ∪ 𝑋2 ∪ 𝑋3 … ∪ 𝑋𝑛
This constraint can be transformed to linear form as
𝑌 ≥ 𝑋𝑖 , ∀𝑖, 𝑖 = 1 … 𝑛
{
𝑌 ≤ Σ𝑖 𝑋𝑖
Example:
The company wants to maximize the benefit of a project:
- If they manufacture type A, they have to buy at least 𝑛1 type 1 PL.
- If they manufacture type B, they have to buy at least 𝑛2 type 2 PL
- If item A is not manufactured, then the # of type 1 production lines is .
- If item B is not manufactured, then the # of type 2 production lines is 0.
- If they decide to manufacture both A and B, they have to open the DC D .
- If either A or B is manufactured, then they have to hire a 3rd party G.
Parameters
𝑐1 : cost for buy one type 1 production line
𝑐2 : cost for buy one type 2 production line
𝑛1 : minimum number of type 1 PL for manufacturing type A
𝑛2 : minimum number of type 2 PL for manufacturing type B
𝑐𝐷 : cost for open and operation of distribution center D
𝑐𝐺 : cost for hire the logistics service G during the planning horizon
𝑏𝐴 : benefit if item A is produced during the planning horizon
𝑏𝐵 : benefit if item B is produced during the planning horizon
Decision variables
𝑥𝐴 , 𝑥𝐵 , 𝑥𝐷 , 𝑥𝐺 : binary variablehired, otherwise 0
𝑌1 : number of production line type 1
𝑌2 : number of production line type 2
7
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
ANSWER
Objective: Maximize Z = 𝑏𝐴 𝑋𝐴 + 𝑏𝐵 𝑋𝐵 − 𝑐1 𝑌1 − 𝑐2 𝑌2 − 𝑐𝐷 𝑋𝐷 − 𝑐𝐺 𝑋𝐺
Subject to
8
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
a) Assume that all day are normal days, make the model for this problem
Introduce new variable
𝑍𝑑 : binary, 𝑍𝑑 = 1 if ∑𝑗 𝑝𝑗 𝑋𝑗𝑑 ≥ 𝐻𝑑𝑒𝑓𝑎𝑢𝑙𝑡 , otherwise 𝑍𝑑 = 0
Minimize ∑𝑑 𝑎 × 𝑂𝑑
Subject to
∑ 𝑋𝑗𝑑 = 1 ∀𝑗
𝑑
∑ 𝑝𝑗 𝑋𝑗𝑑 ≤ 𝐻𝑚𝑎𝑥 ∀𝑑
𝑗
b) Assume that on weekend, ie days 6, 7, 13, 14, 20, 21, 27, 28, the total overtime in day 𝑑 is
equal to the total working time in that day. Modify model in part a) to fix with this adjustment
Explanation:
Overtime on normal day = 𝑂𝑑 = max (𝑝𝑗 × 𝑋𝑗𝑑 – 𝐻𝑑𝑒𝑓𝑎𝑢𝑙𝑡 , 0)
Overtime on weekend = 𝑝𝑗 × 𝑋𝑗𝑑
𝑀𝑖𝑛𝑖𝑚𝑖𝑧𝑒 𝑎 (∑ 𝑂𝑑 + ∑ 𝑝𝑗 × 𝑋𝑗𝑑 )
𝑑∈𝑁 𝑑∈𝑊
Subject to
∑ 𝑋𝑗𝑑 = 1 ∀𝑗
𝑑∈𝐷
∑ 𝑝𝑗 𝑋𝑗𝑑 ≤ 𝐻𝑚𝑎𝑥 ∀𝑑 ∈ 𝐷
𝑗
9
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
𝑂𝑑 ≤ 𝐵𝑖𝑔𝑀 × 𝑍𝑑 ∀ 𝑑 ∈ 𝑁
10
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
V. CODE CPLEX
• Declare the size of set (int)
• Declare the range of each index (range)
• Declare the parameters (float, int)
• Declare the decision variable (dvar type: float, float+, int, int+, boolean)
• Objective function (maximize, minimize)
• Constraint (forall, sum, …)
How to use Tuple?
- Define the tuple
tuple tupleName{
dataType attribute1;
dataType attribute2;
}
- Create the sets corresponding to tuple
setof (tupleName) tupleSet = …;
- Read parameters which use tuple as index
float ParameterA [tupleSet] = …;
- Declare the decision variables which use tuple as index
dvar boolean X[tupleSet];
Example 1
1. Size and range
𝑖: index of the item type
2. Parameters
𝐵𝑖 : the benefit of an item type 𝑖
𝑊𝑖 : the weight of an item type 𝑖
𝑛𝑖 : the maximum quantity of item type 𝑖
𝐶𝑎𝑝: maximum capacity of the system
3. Decision variable
𝑋𝑖 : the number of item type 𝑖 is adopted
4. Objective function
max 𝑍 = ∑ 𝐵𝑖 𝑋𝑖
𝑖
11
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
5. Constraint
0 ≤ 𝑋𝑖 < 𝑛𝑖 ∀ 𝑖 ∈ 𝑇𝑦𝑝𝑒
∑ 𝑊𝑖 𝑋𝑖 ≤ 𝐶𝑎𝑝
𝑖
ANSWER
int numbType = ...;
range Type = 1..numbType;
float B[Type] = …;
float W[Type] = …;
float n[Type] = …;
float Cap = …;
12
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
Example 2:
Index
t= 1..T: index of tanks
l = 1..L: index of lots of harvested grapes
Parameters
𝐶𝑡 : capacity (tons) of tank 𝑡
𝑃𝑡 = 1 if tank 𝑡 is proscibed from use in certain fermentations, 0 otherwise;
𝑆𝑡 : setup cost incurred each time tank 𝑡 is used;
𝐴𝑙 : expected amount (tons) of lot 𝑙;
𝐻𝑙 : expected harvest date, measured in days from the start of the season of lot 𝑙;
𝐹𝑙 : expeccted fermentation length (days) of lot 𝑙;
𝑅𝑙 : =1 if lot 1 is intedended to become a red wine,
𝑊: user-specified objective weight, where 0 ≤ 𝑊 ≤ 1
𝑀𝑙1,𝑙2 : conflict matrix 𝑀𝑙1,𝑙2 =1 if (𝐻𝑙1 + 𝐹𝑙1 ≥ 𝐻𝑙2 or 𝐻𝑙1 ≤ 𝐻𝑙2 and 𝑙1 ≠ 𝑙2 ),
0 otherwise. In short, it is given and is calculated from other parameters.
Variables
𝑣𝑙,𝑡 : volume of lot 𝑙 assigned to tank 𝑡;
𝑤𝑙,𝑡 : wasted space in tank 𝑡 leftover from being used for lot 𝑙;
𝑚𝑙,𝑡 = 1 if lot 𝑙 is matched to tank t, 0 otherwise;
Objective function
Subject to
∑ 𝐶𝑡 𝑚𝑙,𝑡 ≥ 𝐴𝑙 ∀ 𝑙 ∈ 𝐿
𝑡
∑ 𝑣𝑙,𝑡 = 𝐴𝑙 ∀𝑙 ∈ 𝐿
𝑡
∑ 𝑅𝑙 𝑚𝑙,𝑡 = 0 ∀ 𝑡 ∈ 𝑇, 𝑃𝑡 = 1
𝑙
ANSWER
int T =...;
int L =...;
13
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
14
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
Practice
Index
𝑗: index of job
𝑤: index of worker
𝑏: index of batch
<𝑤, 𝑏> tuple indicating which batch 𝑏 can be handled by worker 𝑤 <𝑤, 𝑏> ∈ 𝐴
<𝑗, 𝑏> tuple indicating which job 𝑗 can be handled by batch 𝑏 < 𝑗, 𝑏 > ∈ 𝐵
Parameter
𝑝𝑗 : processing time of job 𝑗
𝐵𝑖𝑔𝑀: very large number
𝐶𝑎𝑝: working time per shift
Decision variables
𝐻𝑚𝑎𝑥 : The largest completion time of all workers
𝐻𝑚𝑖𝑛 : The smallest completion time of all workers
𝑋<𝑗,𝑏> : binary variable, 𝑋<𝑗,𝑏> = 1 if job 𝑗 is assigned to batch 𝑏 otherwise 𝑋<𝑗,𝑏> = 0
𝑈𝑏 : binary variable, 𝑈𝑏 = 1 if at least one job is assigned to batch 𝑏, otherwise 𝑈𝑏 = 0
𝑇𝑏 : processing time of batch 𝑏
𝑊<𝑤,𝑏> : binary variable, 𝑊<𝑤,𝑏> =1 if worker 𝑤 handles batch 𝑏, otherwise 𝑊<𝑤,𝑏> = 0
𝑍<𝑤,𝑏> : processing time of worker 𝑤 for batch 𝑏
𝐻𝑤 : total processing time worker 𝑤 per shift
𝑅𝑤 : binary variable, 𝑅𝑤 = 1 if worker 𝑤 on board, otherwise 𝑅𝑤 = 0
Objective function
Minimize 𝐻𝑚𝑎𝑥 − 𝐻𝑚𝑖𝑛
Constraints
𝐵𝑖𝑔𝑀(1 − 𝑅𝑤 ) + 𝐻𝑚𝑎𝑥 ≥ 𝐻𝑤 ∀𝑤 ∈ 𝑊
𝐵𝑖𝑔𝑀(𝑅𝑤 − 1) + 𝐻𝑚𝑖𝑛 ≤ 𝐻𝑤 ∀𝑤 ∈ 𝑊
𝑅𝑤 ≥ 𝑊<𝑤,𝑏> ∀ < 𝑤, 𝑏 > ∈ 𝐴
𝑅𝑤 ≤ ∑ 𝑊<𝑤,𝑏> ∀𝑤 ∈ 𝑊
<𝑤,𝑏> ∈ 𝐴
∑ 𝑋<𝑗,𝑏> = 1 ∀𝑏
<𝑗,𝑏> ∈ 𝐵
15
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
𝐻𝑤 ≤ 𝐶𝑎𝑝 ∀𝑤
∑ 𝑊<𝑤,𝑏> = 1 ∀𝑏
<𝑤,𝑏> ∈ 𝐴
𝑇𝑏 = ∑ 𝑋<𝑗,𝑏> × 𝑝𝑗 ∀𝑏
<𝑗,𝑏> ∈ 𝐵
𝐻𝑤 = ∑ 𝑍<𝑤,𝑏> ∀𝑤
<𝑤,𝑏>∈𝐴
𝑈𝑏 ≤ ∑ 𝑋<𝑗,𝑏> ∀𝑏
<𝑗,𝑏> ∈ 𝐵
ANSWER
int J = …;
int W = …;
int B = …;
tuple WorkerBatch {
int Worker;
int Batch;
}
tuple JobBatch {
int Job;
int Batch;
}
float p[Job]=…;
16
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
float BigM =…;
float Cap =…;
17
Scheduling and Sequencing – Mỹ Dung. Reference: Dr. P.N.K.Phúc
forall (<w,b> in WorkerBatchSet) {
Z[<w,b>] <= BigM * W[<w,b>];
Z[<w,b>] <= T[b] + BigM * (1 – W[<w,b>]);
Z[<w,b>] >= T[b] - BigM * (1 – W[<w,b>]);
}
forall (w in Worker) {
H[w] == sum(<w,b> in WorkerBatchSet) Z[<w,b>];
}
forall (<j,b> in JobBatchSet) {
U[b] >= X[<j,b>];
}
forall (b in Batch) {
U[b] <= sum(<j,b> in JobBatchSet) X[<j,b>];
}
}
18