X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FBenchmarks%2FPERT%2FMcore%2FEstimator.java;h=2539ae6fdad0deaac67ec2d29e9e6f1876d89320;hb=94ccb1a86a05691c90eaa39d389cd436ba869562;hp=a2232dc914a230bd31fab24ff2043bfb5293b53a;hpb=a3594daa3c49f3005d3274bc8ea52de8c5ee9cb7;p=IRC.git diff --git a/Robust/src/Benchmarks/PERT/Mcore/Estimator.java b/Robust/src/Benchmarks/PERT/Mcore/Estimator.java index a2232dc9..2539ae6f 100644 --- a/Robust/src/Benchmarks/PERT/Mcore/Estimator.java +++ b/Robust/src/Benchmarks/PERT/Mcore/Estimator.java @@ -4,70 +4,70 @@ public class Estimator { int stages; int time; - double variance; - double[] probtable; + float variance; + float[] probtable; public Estimator(int stages) { this.stages = stages; this.time = 0; this.variance = 0; - this.probtable = new double[31]; + this.probtable = new float[31]; int i = 0; - this.probtable[i++] = 0.5000; - this.probtable[i++] = 0.5398; - this.probtable[i++] = 0.5793; - this.probtable[i++] = 0.6179; - this.probtable[i++] = 0.6554; - this.probtable[i++] = 0.6915; - this.probtable[i++] = 0.7257; - this.probtable[i++] = 0.7580; - this.probtable[i++] = 0.7881; - this.probtable[i++] = 0.8159; - this.probtable[i++] = 0.8413; - this.probtable[i++] = 0.8643; - this.probtable[i++] = 0.8849; - this.probtable[i++] = 0.9032; - this.probtable[i++] = 0.9192; - this.probtable[i++] = 0.9332; - this.probtable[i++] = 0.9452; - this.probtable[i++] = 0.9554; - this.probtable[i++] = 0.9641; - this.probtable[i++] = 0.9713; - this.probtable[i++] = 0.9772; - this.probtable[i++] = 0.9821; - this.probtable[i++] = 0.9861; - this.probtable[i++] = 0.9893; - this.probtable[i++] = 0.9918; - this.probtable[i++] = 0.9938; - this.probtable[i++] = 0.9953; - this.probtable[i++] = 0.9965; - this.probtable[i++] = 0.9974; - this.probtable[i++] = 0.9981; - this.probtable[i++] = 0.9987; + this.probtable[i++] = (float)0.5000; + this.probtable[i++] = (float)0.5398; + this.probtable[i++] = (float)0.5793; + this.probtable[i++] = (float)0.6179; + this.probtable[i++] = (float)0.6554; + this.probtable[i++] = (float)0.6915; + this.probtable[i++] = (float)0.7257; + this.probtable[i++] = (float)0.7580; + this.probtable[i++] = (float)0.7881; + this.probtable[i++] = (float)0.8159; + this.probtable[i++] = (float)0.8413; + this.probtable[i++] = (float)0.8643; + this.probtable[i++] = (float)0.8849; + this.probtable[i++] = (float)0.9032; + this.probtable[i++] = (float)0.9192; + this.probtable[i++] = (float)0.9332; + this.probtable[i++] = (float)0.9452; + this.probtable[i++] = (float)0.9554; + this.probtable[i++] = (float)0.9641; + this.probtable[i++] = (float)0.9713; + this.probtable[i++] = (float)0.9772; + this.probtable[i++] = (float)0.9821; + this.probtable[i++] = (float)0.9861; + this.probtable[i++] = (float)0.9893; + this.probtable[i++] = (float)0.9918; + this.probtable[i++] = (float)0.9938; + this.probtable[i++] = (float)0.9953; + this.probtable[i++] = (float)0.9965; + this.probtable[i++] = (float)0.9974; + this.probtable[i++] = (float)0.9981; + this.probtable[i++] = (float)0.9987; } - public boolean estimate(int time, double variance2) { - System.printI(0xff30); + public boolean estimate(int time, float variance2) { + //System.printI(0xff30); this.time += time; this.variance += variance2; --this.stages; - System.printI(0xff31); - System.printI(this.stages); - System.printI(this.time); - System.printI((int)this.variance); + //System.printI(0xff31); + //System.printI(this.stages); + //System.printI(this.time); + //System.printI((int)this.variance); if(this.stages == 0) { - System.printI(0xff32); + //System.printI(0xff32); //System.printString("variance2: " + (int)(this.variance*100) + "(/100); "); - this.variance = Math.sqrt(this.variance); + this.variance = Math.sqrtf(this.variance); //System.printString("variance: " + (int)(this.variance*100) + "(/100)\n"); return true; } - System.printI(0xff33); + //System.printI(0xff33); return false; } - public double getProbability(int x, int y) { + public float getProbability(int x, int y) { int l = x; int r = y; if(x > y) { @@ -75,22 +75,22 @@ public class Estimator { r = x; } - double prob = prob(r) - prob(l); + float prob = prob(r) - prob(l); return prob; } - private double prob(int s) { + private float prob(int s) { int tmp = (int)((s - this.time) * 10 / this.variance); //System.printString(tmp + "\n"); int abs = (int)Math.abs(tmp); - double prob = 0; + float prob = 0; if(abs > this.probtable.length - 1) { prob = 1; } else { prob = this.probtable[abs]; } if(tmp < 0) { - return 1.0 - prob; + return (float)1.0 - prob; } else { return prob; } @@ -100,7 +100,7 @@ public class Estimator { return this.time; } - public double getVariance() { + public float getVariance() { return this.variance; }