1 task startup(StartupObject s{initialstate}) {
3 // read in configuration parameters
4 //System.printString("Top of task startup\n");
5 String path = new String("/home/jzhou/pert/conf.txt");
6 FileInputStream iStream = new FileInputStream(path);
7 byte[] b = new byte[1024];
8 int length = iStream.read(b);
10 System.printString("Error! Can not read from configure file: " + path + "\n");
14 String content = new String(b, 0, length);
15 int index = content.indexOf('\n');
16 int stages = Integer.parseInt(content.subString(0, index));
17 Estimator estimator = new Estimator(stages){estimate};
18 for(int i = 0; i < stages; ++i) {
19 Stage stage = new Stage(i){sampling};
22 taskexit(s{!initialstate});
25 task sampling(Stage s{sampling}) {
26 //System.printString("Top of task sampling\n");
30 taskexit(s{!sampling, estimate});
33 task estimateStage(Stage s{estimate}) {
34 //System.printString("Top of task estimateStage\n");
38 taskexit(s{!estimate, merge});
41 task estimate(Estimator e{estimate}, optional Stage s{merge}) {
42 //System.printString("Top of task estimate\n");
48 boolean finish = e.estimate(s.getAntTime(), s.getAntVariance2(), fake);
51 taskexit(e{!estimate, prob}, s{!merge});
57 task prob(Estimator e{prob}) {
58 //System.printString("Top of task prob\n");
61 System.printString("There are some sampling data unavailable. The anticipate probability may be greater than it should be!\n");
64 String path = new String("/home/jzhou/pert/prob.txt");
65 FileInputStream iStream = new FileInputStream(path);
66 byte b[] = new byte[1024];
67 int length = iStream.read(b);
69 System.printString("Error! Can not read from input file: " + path + "\n");
73 String content = new String(b, 0, length);
74 int index = content.indexOf('\n');
75 int x = Integer.parseInt(content.subString(0, index));
76 content = content.subString(index + 1);
77 index = content.indexOf('\n');
78 int y = Integer.parseInt(content.subString(0, index));
79 //System.printString("x: " + x + "; y: " + y + "\n");
80 System.printString("The anticipate days need to finish this project is: " + e.getTime() + "\n");
81 System.printString("And the anticipate variance is: " + (int)(e.getVariance()*100) + "(/100)\n");
82 double prob = e.getProbability(x, y);
84 System.printString("The probability of this project to be finished in " + x + " to " + y + " days is: " + (int)(prob*100) + "%\n");