1 import java.io.FileInputStream;
13 //this.estimator = null;
16 public Estimator getEstimator() {
20 public void setEstimator(Estimator estimator) {
21 this.estimator = estimator;
24 public void setStageNum(int stageNum) {
25 this.stageNum = stageNum;
28 public void createStages() {
29 this.stages = new Stage[this.stageNum];
30 for(int i = 0; i < stageNum; ++i) {
31 this.stages[i] = new Stage(i);
35 public void sampling() {
36 for(int i = 0; i < this.stageNum; ++i) {
37 this.stages[i].sampling();
41 public void estimate() {
42 for(int i = 0; i < this.stageNum; ++i) {
43 this.stages[i].estimate();
48 for(int i = 0; i < this.stageNum; ++i) {
49 Stage tmp = this.stages[i];
50 this.estimator.estimate(tmp.getAntTime(), tmp.getAntVariance2(), false);
54 public static void main(String args[]) {
56 PERT pert = new PERT();
58 String path = new String("/home/jzhou/pert/conf.txt");
59 FileInputStream iStream = new FileInputStream(path);
60 byte[] b = new byte[1024];
61 int length = iStream.read(b);
63 System./*out.println*/printString("Error! Can not read from configure file: " + path + "\n");
67 String content = new String(b, 0, length);
68 int index = content.indexOf('\n');
69 int stage = Integer.parseInt(content.substring(0, index));
70 Estimator estimator = new Estimator(stage);
71 pert.setStageNum(stage);
72 pert.setEstimator(estimator);
77 path = new String("/home/jzhou/pert/prob.txt");
78 iStream = new FileInputStream(path);
79 byte c[] = new byte[1024];
80 length = iStream.read(c);
82 System./*out.println*/printString("Error! Can not read from input file: " + path + "\n");
86 content = new String(c, 0, length);
87 index = content.indexOf('\n');
88 int x = Integer.parseInt(content.substring(0, index));
89 content = content.substring(index + 1);
90 index = content.indexOf('\n');
91 int y = Integer.parseInt(content.substring(0, index));
92 //System.out.println("x: " + x + "; y: " + y);
93 System./*out.println*/printString("The anticipate days need to finish this project is: " + pert.getEstimator().getTime() + "\n");
94 System./*out.println*/printString("And the anticipate variance is: " + (int)(pert.getEstimator().getVariance()*100) + "(/100)\n");
95 double prob = pert.getEstimator().getProbability(x, y);
97 System./*out.println*/printString("The probability of this project to be finished in " + x + " to " + y + " days is: " + (int)(prob*100) + "(/100)\n");
98 /* } catch(Exception e) {