# OR-Notes

## J E Beasley

OR-Notes are a series of introductory notes on topics that fall under the broad heading of the field of operations research (OR). They were originally used by me in an introductory OR course I give at Imperial College. They are now available for use by any students and teachers interested in OR subject to the following conditions.

A full list of the topics available in OR-Notes can be found here.

#### Network analysis example 1997 UG exam

The table below defines the activities within a small project.

```        Activity        Completion time        Immediate predecessor
(weeks)                 activities
A               2                      -
B               3                      -
C               4                      A
D               3                      B,A
E               8                      D,C
F               3                      C
G               2                      E
H               3                      F,G```
• Draw the network diagram.
• Calculate the minimum overall project completion time and identify which activities are critical.
• What is the slack (float) time associated with each of the non-critical activities.

In the above network there are a number of options for the completion time for activities C, D and E as shown below:

```          Activity     Completion time    Cost (£'000)
C                4               3
3               7
2               10
1               15
D                3               12
2               16
1               25
E                8               5
7               9
6               14```

For example choosing a completion time for activity E of 6 weeks costs £14,000.

Formulate the problem of deciding the completion time for C, D and E so as to ensure that the project is completed within 17 weeks as an integer program.

#### Solution

The network diagram is shown below. Note the introduction of a dummy activity I with a duration of zero to represent the end of the project.

Let Ei represent the earliest start time for activity i such that all its preceding activities have been finished. We calculate the values of the Ei (i=A,B,...,I) by going forward, from left to right, in the network diagram.

To ease the notation let Ti be the activity completion time associated with activity i (e.g. TB = 3). Then the Ei are given by:

EA = 0 (assuming we start at time zero)
EB = 0 (assuming we start at time zero)
EC = EA + TA = 0 + 2 =2
ED = max[EA + TA, EB + TB] = max[0 + 2, 0 + 3] = 3
EE = max[EC + TC, ED + TD] = max[2 + 4, 3 + 3] = 6
EF = EC + TC = 2 + 4 = 6
EG = EE + TE = 6 + 8 = 14
EH = max[EF + TF, EG + TG] =max[6 + 3, 14 + 2] = 16
EI = EH + TH = 16 + 3 = 19

Hence the minimum possible completion time for the entire project is 19 weeks i.e. 19 (weeks) is the minimum time needed to complete all the activities.

We now need to calculate the latest times for each activity.

Let Li represent the latest start time we can start activity i and still complete the project in the minimum overall completion time. We calculate the values of the Li (i=A,B,...,I) by going backward, from right to left, in the network diagram. Hence:

LI = 19
LH= LI - TH = 19 - 3 = 16
LG = LH - TG = 16 - 2 = 14
LF = LH - TF = 16 - 3 = 13
LE = LG - TE = 14 - 8 = 6
LD = LE - TD = 6 - 3 = 3
LC = min[LE - TC, LF - TC] = min[6 - 4, 13 - 4] = 2
LB = LD - TB = 3 - 3 = 0
LA = min[LC - TA, LD - TA] = min[2 - 2, 3 - 2] = 0

Note that as a check all latest times are >=0 at least one activity has a latest start time value of zero.

As we know the earliest start time Ei, and latest start time Li, for each activity i it is clear that the amount of slack or float time Fi available is given by Fi = Li - Ei which is the amount by which we can increase the time taken to complete activity i without changing (increasing) the overall project completion time. Hence we can form the table below:

```Activity   Li          Ei           Float Fi
A          0           0             0
B          0           0             0
C          2           2             0
D          3           3             0
E          6           6             0
F         13           6             7
G         14          14             0
H         16          16             0```

Any activity with a float of zero is critical. Note here that, as a check, all float values should be >= 0.

Hence the critical activities are A,B,C,D, E,G and H and the float for the only non-critical activity F is 7 weeks.

In order to formulate the problem of deciding the completion time for C, D and E so as to ensure that the project is completed within 17 weeks we make use of integer programming.

Let the x variables (suitably subscripted) represent feasible start times for each activity (>=0 and integer). Note here that we deal with feasible start times in formulating this program rather than (as above) with earliest start times.

Introduce zero-one variables:
Ci = 1 if a completion time of i (i=4,3,2,1) chosen for activity C, 0 otherwise
Di = 1 if a completion time of i (i=3,2,1) chosen for activity D, 0 otherwise
Ei = 1 if a completion time of i (i=8,7,6) chosen for activity E, 0 otherwise

then the constraints relating to the choice of completion time are:

C4 + C3 + C2 + C1 =1
D3 + D2 + D1 = 1
E8 + E7 + E6 = 1

i.e. exactly one completion time must be chosen for C, D and E respectively.

The constraints relating to the network logic are:

xA= xB = 0

xC >= xA + 2

xD >= xB + 3
xD > = xA + 2

xE >= xC + 4C4 + 3C3 + 2C2 +1C1

where 4C4 + 3C3 + 2C2 +1C1 is the completion time for activity C (remember C4, C3, C2 and C1 are zero-one variables).

xE >= xD + 3D3 + 2D2 +1D1

xF >= xC + 4C4 + 3C3 + 2C2 +1C1

xG >= xE + 8E8 + 7E7 + 6E6

xH >= xF + 3
xH >= xG + 2

xH <= 17 - 3 (to complete in 17 weeks)

and the objective is:

minimise 3C4 + 7C3 + 10C2 +15C1 + 12D3 + 16D2 +25D1 + 5E8 +9E7 +14E6

#### Network analysis example 1996 MBA exam

A project consists of 8 activities. The activity completion times and the precedence relationships are as follows:

```Activity        Completion time   Immediate predecessor
(days)             activities
A           5                  -
B           7                  -
C           6                  -
D           3                  A
E           4                  B,C
F           2                  C
G           6                  A,D
H           5                  E,F```
• Draw the network diagram.
• Calculate the minimum overall project completion time and identify which activities are critical.
• If activity E is delayed by 3 days how is the project completion time affected?
• If activity F is delayed by 3 days how is the project completion time affected?

#### Solution

The network diagram is shown below. Note the introduction of a dummy activity I with a duration of zero to represent the end of the project.

Let Ei represent the earliest start time for activity i such that all its preceding activities have been finished. We calculate the values of the Ei (i=A,B,...,I) by going forward, from left to right, in the network diagram.

To ease the notation let Ti be the activity completion time associated with activity i (e.g. TB = 7). Then the Ei are given by:

EA = 0 (assuming we start at time zero)
EB = 0 (assuming we start at time zero)
EC = 0 (assuming we start at time zero)
ED = EA + TA = 0 + 5 = 5
EG = max[EA + TA, ED + TD] = max[0 + 5, 5 + 3] = 8
EE = max[EB + TB, EC + TC] = max[0 + 7, 0 + 6] = 7
EF = EC + TC = 0 + 6 = 6
EH = max[EE + TE, EF + TF] = max[7 + 4, 6 + 2] = 11
EI = max[EG + TG, EH + TH] = max[8 + 6, 11 + 5] = 16

Hence the minimum possible completion time for the entire project is 16 days, i.e. 16 days is the minimum time needed to complete all the activities.

We now need to calculate the latest times for each activity.

Let Li represent the latest start time we can start activity i and still complete the project in the minimum overall completion time. We calculate the values of the Li (i=A,B,...,I) by going backward, from right to left, in the network diagram. Hence:

LI = 16
LG = LI - TG = 16 - 6 = 10
LH = LI - TH = 16 - 5 = 11
LD = LG - TD = 10 - 3 = 7
LA = min[LD - TA, LG - TA] = min[7 - 5, 10 - 5] = 2
LE = LH - TE = 11 - 4 = 7
LF = LH - TF = 11 - 2 = 9
LC = min[LE - TC, LF - TC] = min[7 - 6, 9 - 6] = 1
LB = LE - TB = 7 - 7 = 0

Note that as a check all latest times are >=0 at least one activity has a latest start time value of zero.

As we know the earliest start time Ei, and latest start time Li, for each activity i it is clear that the amount of slack or float time Fi available is given by Fi = Li - Ei which is the amount by which we can increase the time taken to complete activity i without changing (increasing) the overall project completion time. Hence we can form the table below:

```Activity   Li          Ei           Float Fi
A          2           0             2
B          0           0             0
C          1           0             1
D          7           5             2
E          7           7             0
F          9           6             3
G         10           8             2
H         11          11             0```

Any activity with a float of zero is critical. Note here that, as a check, all float values should be >= 0.

Hence the critical activities are B, E and H and the floats for the non-critical activities are given in the table above.

If activity E is delayed by 3 days then as E is critical the project completion time increases by exactly 3 days.

If activity F is delayed by 3 days then as F has a float of 3 days the project completion time is unaffected.

#### Network analysis example 1994 MBA exam

A project consists of 8 activities named A to H.

Construct a network so as to satisfy the scheduling requirements shown in the table below.

```Activity        Completion time   Immediate predecessor
(days)             activities
A           3                  -
B           6                  A

C           7                  A
D           5                  A
E           13                 B,C
F           8                  C,D
G           11                 D,F
H           6                  G,E```

Find the least time required to complete the whole project and identify the critical activities.

How is the project completion time affected if:

• activity F is delayed by 3 days
• activity E is delayed by 7 days
• activity G is finished 7 days early

#### Solution

The network diagram is shown below. Note the introduction of a dummy activity I with a duration of zero to represent the end of the project.

Let Ei represent the earliest start time for activity i such that all its preceding activities have been finished. We calculate the values of the Ei (i=A,B,...,I) by going forward, from left to right, in the network diagram.

To ease the notation let Ti be the activity completion time associated with activity i (e.g. TB = 7). Then the Ei are given by:

EA = 0 (assuming we start at time zero)
EB = EA + TA = 0 + 3 = 3
EC = EA + TA = 0 + 3 = 3
ED = EA + TA = 0 + 3 = 3
EE = max[EB + TB, EC + TC] = max[3 + 6, 3 + 7] = 10
EF = max[EC + TC, ED + TD] = max[3 + 7, 3 + 5] = 10
EG = max[EF + TF, ED + TD] = max[10 + 8, 3 + 5] = 18
EH = max[EE + TE, EG + TG] = max[10 + 13, 18 + 11] = 29
EI = EH + TH = 29 + 6 = 35

Hence the minimum possible completion time for the entire project is 35 days, i.e. 35 days is the minimum time needed to complete all the activities.

We now need to calculate the latest times for each activity.

Let Li represent the latest start time we can start activity i and still complete the project in the minimum overall completion time. We calculate the values of the Li (i=A,B,...,I) by going backward, from right to left, in the network diagram. Hence:

LI = 35
LH = LI - TH = 35 - 6 = 29
LG = LH - TG = 29 - 11 = 18
LE = LH - TE = 29 - 13 = 16
LF = LG - TF = 18 - 8 = 10
LB = LE - TB = 16 - 6 = 10
LC = min[LE - TC, LF - TC] = min[16 - 7, 10 - 7] = 3
LD = min[LF - TD, LG - TD] = min[10 - 5, 18 - 5] = 5
LA = min[LB - TA, LC - TA, LD - TA] = min[10 - 3, 3 - 3, 5 - 3] = 0

Note that as a check all latest times are >=0 at least one activity has a latest start time value of zero.

As we know the earliest start time Ei, and latest start time Li, for each activity i it is clear that the amount of slack or float time Fi available is given by Fi = Li - Ei which is the amount by which we can increase the time taken to complete activity i without changing (increasing) the overall project completion time. Hence we can form the table below:

```Activity   Li          Ei           Float Fi
A          0           0             0
B         10           3             7
C          3           3             0
D          5           3             2
E         16          10             6
F         10          10             0
G         18          18             0
H         29          29             0```

Any activity with a float of zero is critical. Note here that, as a check, all float values should be >= 0.

Hence the critical activities are A, C, F, G and H and the floats for the non-critical activities are given in the table above.

If activity F is delayed by 3 days then as F is critical the project completion time increases by exactly 3 days.

If activity E is delayed by 7 days then as E has a float of 6 days the project completion time is affected. The project completion time will increase by exactly (7-6) = 1 day to 36 days.

If activity G is finished 7 days early then as G is a critical activity the overall project completion time will (potentially) be reduced. To see the effect of this change we need to redo the calculation for the earliest times given above but with a completion time for G of 4 days. The only change is in the calculation of EH and EI and these now are:
EH = max[EE + TE, EG + TG] = max[10 + 13, 18 + 4] = 23
EI = EH + TH = 23 + 6 = 29
Hence the overall project completion time falls to 29 days (a decrease of 6 days).