Project Management
Consider a project of preparing and eating the breakfast, shown in the following table:
aid | description | d[min] | ipred |
1 | Get Eggs | 1 | |
2 | Get Bread | 1 | 1 |
3 | Get Butter | 1 | 2 |
4 | Get Coffee | 2 | 3 |
5 | Boil Eggs | 6 | 1 |
6 | Cut Bread | 2 | 2 |
7 | Butter Bread | 2 | 3,6 |
8 | Make Coffee | 5 | 4 |
9 | Eat Breakfast | 7 | 5,7,8 |
|
The first column states the activity IDs, the second—description, the third—durations (in minutes), the last one—the immediate predecessors.
The first activity (aid = 1) starts this project. Activity 2 follows activity 1. Activity 3 follows activity 2, etc. "Get Butter" (aid = 3) and "Cut Bread" (aid = 6) are needed to be finished in order to start activity "Butter Bread" (aid=7). The last activity, "Eat Breakfast" (aid = 9), must wait until its immediately preceding activities "Boil Eggs", "Butter Bread", and "Make Coffee" (aid = 5, aid = 7, and aid = 8) are completed.
|
R Solution
Step 1: Read Data
eb = read.table(text='aid description duration ipred
1 "Get Eggs" 1 ""
2 "Get Bread" 1 "1"
3 "Get Butter" 1 "2"
4 "Get Coffee" 2 "3"
5 "Boil Eggs" 6 "1"
6 "Cut Bread" 2 "2"
7 "Butter Bread" 2 "3,6"
8 "Make Coffee" 5 "4"
9 "Eat Breakfast" 7 "5,7,8"', header=TRUE)
eb
Step 2. Execute the following code lines (load functions into R):
source("http://biiat.com/pm/cpm/r/predecessor.r")
source("http://biiat.com/pm/cpm/r/successors.r")
source("http://biiat.com/pm/cpm/r/cpm.r")
cpm(eb)
The source statements load the following functions:
- imPred(project_structure)
- imSucc(immediate_predecessors)
- cpm(project_structure)
Object eb from the Breakfast case is a good example for argument project_structure.
Argument immediate_predecessors is a list of integer vectors derieved for column ipred of the project structure.
Using Package ProjectManagement
Installing and opening this package:
# R Code
install.packages("ProjectManagement")
# Upon success, open the package.
library(ProjectManagement)
In order to generate a CMP schedule, using ProjectManagement, the project activities and their relations must be defiened as an adjecency matrix. The following function converts the immediate predecessor list to such matrix:
source("http://biiat.com/pm/cpm/r/ip2matrix.r")
Let's start from scratch.
# Load the project.
eb = read.table(text='aid description duration ipred
1 "Get Eggs" 1 ""
2 "Get Bread" 1 "1"
3 "Get Butter" 1 "2"
4 "Get Coffee" 2 "3"
5 "Boil Eggs" 6 "1"
6 "Cut Bread" 2 "2"
7 "Butter Bread" 2 "3,6"
8 "Make Coffee" 5 "4"
9 "Eat Breakfast" 7 "5,7,8"', ,header=TRUE)
eb
# Get the immediate predecessors. If necessary imort function imPred first.
source("http://biiat.com/pm/cpm/r/predecessor.r")
ip = imPred(eb)
# Get the matrix.
mx = ip2matrix(ip)
# Get the CPM schedule.
cpm = schedule.pert(eb$duration, mx)
# Simplify the header of the data frame.
colnames(cpm[[2]]) = c('aid','d','es','ls','ef','lf','ts','fs','is')
# Show the project completion time and the schedule.
cpm
Developed by Jerzy Letkowski, Ph.D.