Date post: | 22-Oct-2014 |
Category: |
Documents |
Upload: | amit15094775 |
View: | 727 times |
Download: | 4 times |
1
A Project Report on
“Heuristic Methods for Solving the Resource-Constrained
Project Scheduling Problems”
Based on
“Edward W. Davis, James H. Patterson. (1975). A Comparison of Heuristic and
Optimum Solutions in Resource Constrained Optimum Scheduling. Management
Science, Vol.21, No. 8”
Submitted By:
Amit Kumar 12
Ayanangshu Das 28
Naveen Tiwari 59
2
NATIONAL INSTITUTE OF INDUSTRIAL ENGINEERING
MUMBAI
CERTIFICATE
This is to certify that Amit Kumar, Ayanangshu Das & Naveen Tiwari, students of PGDIE, Batch No.: 40
have successfully completed the project titled “Heuristic Methods for Solving the Resource-Constrained
Project Scheduling Problems” at NITIE, Vihar Lake, Mumbai under guidance of Dr. L. Ganapathy
(Ph.D) Professor, NITIE, Mumbai from July 2011 to August 2011.
Date:
Faculty Guide:
Dr. L. Ganapathy,
(Ph.D) Professor,
NITIE, Mumbai.
3
Table of Contents 1. Introduction to RCPSP ................................................................................................................... 4
2. Problem Definition .......................................................................................................................... 4
3. Heuristic Methods for solving RCPSP ........................................................................................... 5
4. Modelling usingMATLAB .............................................................................................................. 8
5. Modelling using RESCON ............................................................................................................ 16
6. Heuristic and Meta-Heuristics Currently in use ........................................................................ 26
List of Figures
Figure 1 : Activity On Node Network ........................................................................................................................... 4
Figure 2 : SPAR 1 based Scheduler Flowchart ............................................................................................................ 7
Figure 3 : Result using GRD Heuristic ....................................................................................................................... 14
Figure 4 : Result using LFT Heuristic ........................................................................................................................ 14
Figure 5 : Result using MINSLK Heuristic ................................................................................................................ 15
Figure 6 : Result using RAN Heuristic ........................................................................................................................ 15
Figure 7 : Result using SIO Heuristic ......................................................................................................................... 16
Figure 8 : RESCON Outputs ....................................................................................................................................... 17
Figure 9 : Activity On Node Diagram Generated by RESCON ............................................................................... 19
Figure 10 : Result using SIO Heuristic in RESCON ................................................................................................. 19
Figure 11 : Result using MINSLK Heuristic in RECON .......................................................................................... 20
Figure 12 : Result using LFT Heuristic in RESCON ................................................................................................. 20
Figure 13 : Result using RAN Heuristic in RESCON ................................................................................................ 21
Figure 14 : Result using the Branch & Bound exact Method ................................................................................... 21
Figure 15 : Resource Skyline of R1 using SIO Heuristic ........................................................................................... 22
Figure 16 : Resource Skyline for R2 using SIO Heuristic ......................................................................................... 22
Figure 17 : Resource Skyline for R3 using SIO Heuristic ......................................................................................... 23
Figure 18 : Performance summary using different heuristics .................................................................................. 25
4
1. Introduction to RCPSP
The Resource Constrained Project Scheduling Problem (RCPSP) consists of minimizing the project
duration under fixed resource constraint. When the resources are available in plenty the only determining
factor for the project duration is the duration of each activity and more specifically the duration of activities
in the Critical Path. This non constrained project scheduling problem is the standard Critical Path analysis.
But when the resources are fixed, the scheduling and sequencing of activity becomes more important. The
RCPSP has been shown to be NP hard. Some optimal algorithms exist and the most efficient ones are based
on Branch and Bound approach but for projects with more activities/tasks they become very time
consuming. Heuristic Approaches have become popular over time.
2. Problem Definition
In the selected paper authors have generated fifty seven different computer generated networks having
twenty to twenty seven activities and used eight heuristic methods to solve these and compared the results
with the optimum solution for each of the networks. We have taken only one such network which was
shown in the paper for our simulation purpose.
The objective of this report is to simulate the same results as obtained by the authors in their study.
Figure 1 : Activity On Node Network
5
The Activity on Node (AoN) representation is shown in Figure 1. It is clear that the problem consists of
a twenty seven activity project. The precedence relations are as shown in figure. The duration of each
activity is represented at the top of each activity node. There are three resources r1, r2 and r3 that activities
require in different numbers and these numbers are shown at the bottom of each activity node. The three
resources are limited to six units each.
3. Heuristic Methods for solving RCPSP
For modelling any of the heuristic methods first a scheduler has to be programmed. Scheduler is a
program that schedules the ready activities depending on the priority associated with these activities. The
heuristics are used to determine the priority level of these ready activities. The scheduler that we have
programmed is based on the famous Scheduling Program for Allocation of Resources (SPAR 1). The
detailed flowchart of the scheduler is shown in Figure 2. Please note that in this simulation we have assumed
that we are dealing with static RCPSP and hence activities once started are carried on till they are completed
and no pre-empting is allowed. Therefore the pre-emptive part of the SPAR has not been implemented in the
model.
In order to decide priorities among activities the following heuristic rules have been used. In case of a
tie, the activity with the smallest activity number is selected.
Minimum Job Slack (MINSLK)
Priority in resolving conflict is given to the activity with minimum slack. The slack is determined by
finding the difference of Late Start Time (LST) and Early Start Time (EST). The LST and EST are found
out by the usual Critical Path analysis. Slack is continuously updated. Any delayed activity has its slack
reduced by the amount of the delay.
Resource Scheduling Method (RSM)
Activity Priority is calculated as follows: Give precedence to that activity with the minimum value of dij,
where
dij = increase in project duration resulting when activity j follows activity I,
= max[0; (EFTi – LSTj)],
Where: EFTi = Early Finish Time of activity i
LSTj = Late start time of activity j
And the comparison is made on a pairwise basis among all activities in the conflict set.
Minimum Late Finish Time (LFT)
The priorities are assigned on the basis of the LFT of the activities.
Greatest Resource Demand (GRD)
This rule assigns priorities on the basis of total resource unit requirements of all types, with higher
priorities given for greater resource demands. Activity priority is calculated as:
6
Priority = dj∑
where, dj = duration of activity j
rij = per period requirement of resource type i by activity j
m = number of different types of resources
Greatest Resource Utilization (GRU)
This rule gives priority to that combination of activities which results in maximum resource utilization in
each scheduling interval. This rule can be implemented by solving a zero one integer programming problem.
Shortest Imminent Operation (SIO)
This is the shortest job first rule and assigns priorities on the basis of activity duration.
Most Jobs Possible (MJP)
This rule gives priority to that combination of activities which results in the greatest number of activities
being scheduled in any interval. It is also implemented by solving a zero one integer programming problem.
Select Jobs Randomly (RAN)
This heuristic assigns priority among competing jobs on a purely random basis.
7
Figure 2 : SPAR 1 based Scheduler Flowchart
8
4. Modelling using MATLAB
MATLAB is also known as the language of Technical Computing. It is an IDE that provides
programming capability in which data operations in form of matrices can be performed easily. It is sold by a
company named Mathworks Inc. The opensource competition to this software provided by GNU is Scilab.
Scilab is freely downloadable from the internet.
The scheduler which is based on the SPAR as stated earlier is programmed in a separate file and the
different priority rules are programmed in separate files. The input to the scheduler is given by an excel file
which contains the precedence relationship, the duration of activities and the resource requirement of
activities and all the relevant data. The data corresponding to the problem under consideration is given in the
excel file and is shown for reference in Table 1:
The MATLAB code for the scheduler and the different priority rules is attached below for reference. The
result of solving the stated problem using the different priority rules is attached below in the form of Gantt
Charts. The charts have been generated in MATLAB. The code for this is also present and is indicated in the
scheduler file by comments.
9
Table 1 : Input in form of excel file
Activity Time R1 R2 R3 Pre1 Pre2 Pre3 Pre4
1 0 0 0 0
2 5 3 5 2 1
3 5 5 4 3 1
4 3 5 2 2 1
5 4 4 1 4 2 3 6 1 5 5 4 4
7 6 3 5 2 4
8 2 2 4 4 2 3 9 6 3 2 2 5 8 7
10 3 3 2 4 8 6 7 11 3 3 3 2 6
12 1 4 1 4 5
13 3 1 4 4 9 10 14 6 2 2 2 12
15 3 5 5 4 9
16 4 1 5 4 11
17 4 4 5 4 15 16 18 3 3 2 3 14
19 3 5 3 3 13
20 1 2 4 6 16
21 4 1 6 4 19 18 22 6 3 2 1 17 20 23 4 1 0 4 19
24 1 2 2 1 17
25 3 0 1 3 23 21 24 22
26 3 2 2 2 23
27 0 0 0 0 25 26
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File Name :rcpm.m
% Resource Constraint Project Management Scheduler % Author: Amit Kumar % Date: 3rd August 2011
clearall; clc;
Input = xlsread('rcpm.xls'); sz = size(Input);
for i = 1:sz(1,1) activity(i).duration = Input(i,2); activity(i).resources = Input(i,3:5); activity(i).precedes = Input(i,6:9); activity(i).iscomplete = 0; activity(i).isrunning = 0; activity(i).isready = 0; activity(i).runtime = 0; activity(i).starttime = -1; activity(i).endtime = -1;
10
activity(i).est = -1; activity(i).eft = -1; activity(i).lst = inf; activity(i).lft = inf; end
for i = 1:sz(1,1) for j = 1:4 if (isnan(activity(i).precedes(5-j))) activity(i).precedes(5-j) = []; end end end
running = []; ready = []; completed = []; time = 0;
completed = [1]; activity(1).iscomplete = 1; activity(1).starttime = 0; activity(1).endtime = 0; activity(1).est = 0;
%Critical Path Analysis : Forward Pass to Determine EST and EFT of activities
for i = 1:sz(1,1) for j = 1:length(activity(i).precedes) if activity(i).est< activity(activity(i).precedes(j)).duration +
activity(activity(i).precedes(j)).est activity(i).est = activity(activity(i).precedes(j)).duration +
activity(activity(i).precedes(j)).est; end end end
for i = 1:sz(1,1) activity(i).eft = activity(i).est + activity(i).duration; end
%Critical Path Analysis : Backward Pass to Determine LFT and LST of activities
activity(sz(1,1)).lft = activity(sz(1,1)).eft;
for i = 1:sz(1,1) for j = 1:length(activity(sz(1,1)-i+1).precedes) if activity(activity(sz(1,1)-i+1).precedes(j)).lft> activity(sz(1,1)-i+1).lft -
activity(sz(1,1)-i+1).duration activity(activity(sz(1,1)-i+1).precedes(j)).lft = activity(sz(1,1)-i+1).lft
- activity(sz(1,1)-i+1).duration; end end end
for i = 1:sz(1,1) activity(i).lst = activity(i).lft - activity(i).duration; end
%count = length(completed); r1 = 6; r2 = 6; r3 = 6;
11
while(1) %enumerate ready activities for i = 1:sz(1,1) if activity(i).iscomplete == 0 && activity(i).isrunning == 0 && activity(i).isready ==
0 for j = 1:length(activity(i).precedes) flag = 1; pre = activity(i).precedes(j); if activity(pre).iscomplete == 0 flag = 0; break; end end if flag == 1; ready(length(ready) + 1) = i; activity(i).isready = 1; end end end
%prioritize ready activities %%%%%%GRD%%%%%%%%%%%%%% %ready = grd_priority(activity, ready);
%%%%%%RAN%%%%%%%%%%%%%% %ready = ran_priority(ready);
%%%%%%%SIO%%%%%%%%%%%%% %ready = sio_priority(activity, ready);
%%%%%%%MINSLK%%%%%%%%%% %ready = minslk_priority(activity, ready, time);
%%%%%%%LFT%%%%%%%%%%%%% ready = lft_priority(activity, ready);
%%%%%%%RSM%%%%%%%%%%%%% %ready = rsm_priority(activity, ready);
delfrmready = []; for i = 1:length(ready) if (activity(ready(i)).resources(1) <= r1) && (activity(ready(i)).resources(2) <= r2)
&& (activity(ready(i)).resources(3) <= r3) running(length(running)+1) = ready(i); r1 = r1 - activity(ready(i)).resources(1); r2 = r2 - activity(ready(i)).resources(2); r3 = r3 - activity(ready(i)).resources(3); delfrmready(length(delfrmready)+1) = i; activity(ready(i)).isrunning = 1; activity(ready(i)).isready = 0; activity(ready(i)).starttime = time; end end
for i = 1:length(delfrmready) ready(delfrmready(length(delfrmready) + 1 - i)) = []; end
%run delfrmrunning = []; dur = []; for i = 1:length(running)
12
dur(i) = activity(running(i)).duration - activity(running(i)).runtime; end t = min(dur); for i = 1:length(running) activity(running(i)).runtime = activity(running(i)).runtime + t; if activity(running(i)).runtime == activity(running(i)).duration activity(running(i)).isrunning = 0; activity(running(i)).iscomplete = 1; activity(running(i)).endtime = time + t; completed(length(completed)+1) = running(i); r1 = r1 + activity(running(i)).resources(1); r2 = r2 + activity(running(i)).resources(2); r3 = r3 + activity(running(i)).resources(3); delfrmrunning(length(delfrmrunning)+1) = i; end end
for i = 1:length(delfrmrunning) running(delfrmrunning(length(delfrmrunning) + 1 - i)) = []; end
time = time + t;
count = length(completed); if count == sz(1,1) break; end end
disp('Project MakeSpan = '); disp(time);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%GANNT CHART%%%%%%%%%%%%%%%%
m = 1; for i = 1:sz(1,1) for j = 1:activity(i).duration p(1,m) = activity(i).starttime + j; m = m + 1; end end
m = 1; for i = 1:sz(1,1) for j = 1:activity(i).duration p(2,m) = i; m = m + 1; end end
figure; scatter(p(1,:), p(2,:), 'marker','s','markerfacecolor',[0,0,1]); gridminor; xlabel('Time'); ylabel('Activity Number'); title('Gantt Chart'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File Name :grd_priority.m – Models the GRD Heuristic
function priority = grd_priority(activity, ready) lnth = length(ready); pr = []; for i = 1:lnth pr(i,1) = activity(ready(i)).duration * sum(activity(ready(i)).resources);
13
pr(i,2) = ready(i); end p = sortrows(pr,1); priority = flipud(p(:,2)); %if pr values are equal it will arrange randomly priority = priority'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File Name :lft_priority.m – Models the LFT Heuristic
function priority = lft_priority(activity, ready,time) lnth = length(ready); pr = []; for i = 1:lnth pr(i,1) = activity(ready(i)).lft; pr(i,2) = ready(i); end p = sortrows(pr,1); priority = p(:,2)'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File Name :minslk_priority.m – Models MINSLK Heuristic
function priority = minslk_priority(activity, ready,time)
lnth = length(ready); pr = []; for i = 1:lnth if time > activity(ready(i)).est pr(i,1) = (activity(ready(i)).lst - activity(ready(i)).est) - (time -
activity(ready(i)).est); ifpr(i,1) < 0 pr(i,1) = 0; end else pr(i,1) = activity(ready(i)).lst - activity(ready(i)).est; end pr(i,2) = ready(i); end
p = sortrows(pr,1); priority = p(:,2)'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File Name :ran_priority.m – Models RAN Heuristic
function priority = ran_priority(ready) lnth = length(ready); ran = randperm(lnth); pr = []; for i = 1:lnth pr(i) = ready(ran(i)); end priority = pr'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File Name :sio_priority – Models SIO Heuristic
function priority = sio_priority(activity, ready)
lnth = length(ready); pr = []; for i = 1:lnth pr(i,1) = activity(ready(i)).duration; pr(i,2) = ready(i);
14
end p = sortrows(pr,1); priority = p(:,2)';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------------------------------------------------------RESULTS---------------------------------------------------------
Figure 3 : Result using GRD Heuristic
Figure 4 : Result using LFT Heuristic
0 10 20 30 40 50 60 70 800
5
10
15
20
25
30
Time
Activity N
um
ber
Gantt Chart
0 10 20 30 40 50 60 700
5
10
15
20
25
30
Time
Activity N
um
ber
Gantt Chart
15
Figure 5 : Result using MINSLK Heuristic
Figure 6 : Result using RAN Heuristic
0 10 20 30 40 50 60 70 800
5
10
15
20
25
30
Time
Activity N
um
ber
Gantt Chart
0 10 20 30 40 50 60 70 800
5
10
15
20
25
30
Time
Activity N
um
ber
Gantt Chart
16
Figure 7 : Result using SIO Heuristic
5. Modelling using RESCON
RESCON is educational software for the resource-constrained project scheduling problem. It is
programmed in Visual C++ 6.0. The main features of RESCON are:
Activity-on-the-node representation
Exact and heuristic scheduling procedures
Multiple resource profiles
Gantt chart
Comparative analysis of algorithms
Project metrics "What-if" analysis
DLL support for custom-made scheduling routines
Support for robust scheduling
The outputs are displayed as the following:
0 10 20 30 40 50 60 70 800
5
10
15
20
25
30
Time
Activity N
um
ber
Gantt Chart
17
Figure 8 : RESCON Outputs
The input is given in a .rcp file in the following manner:
Table 2 : Format for Inputting Data in RESCON
N R R1 R2 R3
D1 R11 R12 R13 S11 S12 S13
D2 R21 R22 R23 S21 S22 S23
D3 R31 R32 R33 S31 S32 S33
D4 R41 R42 R43 S41 S42 S43
N : Number of activities in the Network
R : The number of different type of resources required for completing activities
Rj : The available number of resources for each type of resource j, j = 1 to R
Di : The duration of activity I, I =1to number of activities
Rij : The number of units of resource j required by activity i
Sij : Denotes the successors of activity I, j = 1 to number of successors
18
Therefore for the given network problem we can form the .rcp file by inputting data as shown below:
Table 3 : Input data for the Network Problem
27 3
6 6 6 0 0 0 0 3 2 3 4
5 3 5 2 2 5 8
5 5 4 3 2 5 8
3 5 2 2 2 6 7
4 4 1 4 2 9 12
1 5 5 4 2 10 11
6 3 5 2 2 9 10
2 2 4 4 2 9 10
6 3 2 2 2 13 15
3 3 2 4 1 13
3 3 3 2 1 16
1 4 1 4 1 14
3 1 4 4 1 19
6 2 2 2 1 18
3 5 5 4 1 17
4 1 5 4 2 17 20
4 4 5 4 2 22 24
3 3 2 3 1 21
3 5 3 3 2 21 23
1 2 4 6 1 22
4 1 6 2 1 25
6 3 2 1 1 25
4 1 0 4 2 25 26
1 2 2 1 1 25
3 0 1 3 1 27
3 2 2 2 1 27
0 0 0 0 0
19
The above input, when fed in RESCON, will generate the following network diagram:
Figure 9 : Activity On Node Diagram Generated by RESCON
The various heuristic methods used for solving the RCPSP have been discussed earlier. Now we show the
results of using these heuristics to solve the stated problem in RESCON. Results have been shown using
Gantt Charts.
Figure 10 : Result using SIO Heuristic in RESCON
20
Figure 11 : Result using MINSLK Heuristic in RECON
Figure 12 : Result using LFT Heuristic in RESCON
21
Figure 13 : Result using RAN Heuristic in RESCON
RESCON is also able to solve the RCPSP optimally using a Branch and Bound Approach. The Gantt
chart for the optimal scheduling is shown below.
Figure 14 : Result using the Branch & Bound exact Method
22
RESCON also generates the resource skyline for the different types of resources. The resource skyline
for one of the heuristics is shown below. The allocation chart of resource 1(skyline) over the project lifetime
using Shortest Imminent Operation heuristic is as follows:
Figure 15 : Resource Skyline of R1 using SIO Heuristic
Figure 16 : Resource Skyline for R2 using SIO Heuristic
23
Figure 17 : Resource Skyline for R3 using SIO Heuristic
In addition to the available heuristic methods preprogramed in RESCON we can also write our own
heuristic method in C++. As an example the code for simulating Shortest Imminent Operation (SIO)
heuristic is given below:
SIO.cpp
#include "myDLL.h"
extern "C"
{
DLL_EXPORT void getSchedule(int act, int res, int *avail, int *dur, int **req,
int *nrpr, int **pred, int **su, int *nrsu, int **_bestSchedule){
int *bestSchedule = *_bestSchedule;
int i, k, t;
int horizon = 0;
for (i=0; i!=act; i++){
horizon += dur[i];
}
int **profile = new int * [res];
for (k=0; k!=res; k++){
profile[k] = new int[horizon];
for (t=0; t!=horizon; t++){
profile[k][t] = 0;
}
}
bestSchedule[0] = 0;
for (i=1; i!=act; i++){
int minStart = 0;
for (int p=0; p!=nrpr[i]; p++){
int pr = pred[i][p];
if (bestSchedule[pr] + dur[pr] > minStart){
minStart = bestSchedule[pr] + dur[pr];
}
}
bool slotFound = true;
while (true){
24
for (t=minStart; t!=(minStart + dur[i]); t++){
for (k=0; k!=res; k++){
if (profile[k][t] + req[i][k] > avail[k]){
slotFound = false; break;
}
}
if (!slotFound) break;
}
if (!slotFound){
minStart = t+1;
slotFound = true;
}else break;
}
for (t=minStart; t!=(minStart + dur[i]); t++){
for (k=0; k!=res; k++){
profile[k][t] += req[i][k];
}
}
bestSchedule[i] = minStart;
}
for (k=0; k!=res; k++){
delete profile[k];
}
delete profile;
}
}
SIO.h
#ifndef _FLUPPE_MYDLL_INCLUDED
#define _FLUPPE_MYDLL_INCLUDED
#define DLL_EXPORT __declspec(dllexport)
#define DLL_IMPORT __declspec(dllimport)
extern "C"
{
DLL_EXPORT void getSchedule(int act, int res, int *avail, int *dur, int **req, int
*nrpr, int **pred,
int **su, int *nrsu, int **_bestSchedule);
}
#endif
25
Figure 18 : Performance summary using different heuristics
26
6. Heuristic and Meta-Heuristics Currently in use
Apart from the heuristics discussed in this report there are many other heuristic techniques currently in
use. Many of them are being used in software packages both such as RESCON and MS Project and many
others. It has been found that certain heuristic techniques outperform others depending on the class and type
of RCPSP.
Many Meta Heuristic techniques such as Simulated Annealing, Genetic Algorithms, Ant Colony
Optimization and Tabu Search algorithm and their variants have been used to solve the RCPSP.
Researchers solve and publish report on an accepted set of problems for the sake of comparison of
performance of different algorithms. The PSPLIB is an online library of such Project Scheduling Problems.
One can Google “PSPLIB” and download problems for purpose of research.