Optimization: principles and algorithms, by Michel Bierlaire
runPert.m
Go to the documentation of this file.
1 %> \file
2 %> Run to illustrate the use of longest path for PERT (Section 23.4 of \cite Bier15-book. Result in Figure 23.5)
3 %>
4 %> @ingroup chap23
5 %> @ingroup Running
6 %> @author Michel Bierlaire
7 %> @date Thu Apr 9 17:57:33 2015
8 
9 
10 cost = [ 0 1 1 1 1 3 3 3 2 5 5 5 6 1 2 2 3 2 1]' ;
11 
12 adj = [ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ;
13  0 0 2 3 0 0 0 0 0 0 0 0 0 0 0 ;
14  0 0 0 4 0 5 0 0 0 0 0 0 0 0 0 ;
15  0 0 0 0 6 0 7 0 0 0 0 0 0 0 0 ;
16  0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 ;
17  0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 ;
18  0 0 0 0 10 0 0 0 11 0 0 0 0 0 0 ;
19  0 0 0 0 0 0 0 0 0 12 0 0 0 0 0 ;
20  0 0 0 0 0 0 0 0 0 0 13 0 0 0 0 ;
21  0 0 0 0 0 0 0 0 0 0 0 14 0 0 0 ;
22  0 0 0 0 0 0 0 0 0 0 0 15 0 16 0 ;
23  0 0 0 0 0 0 0 0 0 0 0 0 17 0 0 ;
24  0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 ;
25  0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 ;
26  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] ;
27 
28 
29 coord = [ 1 3 ;
30  3 3 ;
31  5 5 ;
32  5 3 ;
33  7 3 ;
34  7 5 ;
35  5 1 ;
36  9 5 ;
37  7 1 ;
38  11 5 ;
39  9 1 ;
40  11 3 ;
41  13 3 ;
42  13 1 ;
43  15 3 ] ;
44 
45 
46 orig = 1 ;
47 [lambda,pred] = dijkstra(adj,-cost,orig) ;
48 
49 nnodes = rows(adj) ;
50 for i=1:nnodes
51  if (pred(i) != -1)
52  % The numbering in the figure starts at 0 and not 1.
53  printf("Task %d before task %d\n",pred(i)-1,i-1)
54  endif
55 endfor
Copyright 2015-2016 Michel Bierlaire