|
@@ -41,6 +41,7 @@ import java.util.Observable;
|
|
|
public class CertainTrust extends Observable {
|
|
|
|
|
|
private double c, t, f, r, s, doc;
|
|
|
+ private String name;
|
|
|
private int n, weight = 2;
|
|
|
|
|
|
//=========== Constructors =================
|
|
@@ -195,6 +196,14 @@ public class CertainTrust extends Observable {
|
|
|
else throw new IllegalArgumentException("r should be positive. Entered r = " + r + "\n");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sets name value.
|
|
|
+ * @param name - name of object.
|
|
|
+ */
|
|
|
+ public void setName(String s) {
|
|
|
+ this.name = s;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Add some positive evidence to r.
|
|
|
* @param posEvidence - number of new positive evidences
|
|
@@ -295,6 +304,10 @@ public class CertainTrust extends Observable {
|
|
|
return doc;
|
|
|
}
|
|
|
|
|
|
+ public String getName() {
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+
|
|
|
public double getExpectation() {
|
|
|
return t*c + (1-c)*f;
|
|
|
}
|
|
@@ -324,8 +337,12 @@ public class CertainTrust extends Observable {
|
|
|
throw new IllegalStateException("Different N values. Operation not allowed. \n");
|
|
|
|
|
|
resF = f1 + f2 - f1*f2;
|
|
|
- if (almostEqual(resF, 0))
|
|
|
- resC = c1 + c2 - c1*c2;
|
|
|
+ if (almostEqual(resF, 0)) { //--------Modified by Debashis----------------//
|
|
|
+ f1 = 0.99999;
|
|
|
+ f2 = 0.99999;
|
|
|
+ resF = f1 + f2 - f1*f2;
|
|
|
+ resC = c1 + c2 - c1*c2- (c1*f2*(1-c2)*(1-t1)+c2*f1*(1-c1)*(1-t2)) / resF;
|
|
|
+ }
|
|
|
else
|
|
|
resC = c1 + c2 - c1*c2 - (c1*f2*(1-c2)*(1-t1)+c2*f1*(1-c1)*(1-t2)) / resF;
|
|
|
|
|
@@ -386,8 +403,12 @@ public class CertainTrust extends Observable {
|
|
|
|
|
|
resF = f1*f2;
|
|
|
|
|
|
- if (almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resC = c1 + c2 - c1*c2;
|
|
|
+ if (almostEqual(resF, 1)) { //--------Modified by Debashis----------------//
|
|
|
+ f1 = 0.99999;
|
|
|
+ f2 = 0.99999;
|
|
|
+ resF = f1*f2;
|
|
|
+ resC = c1 + c2 - c1*c2- (c2*t2*(1-c1)*(1-f1)+c1*t1*(1-c2)*(1-f2)) / (1 - resF);
|
|
|
+ }
|
|
|
else
|
|
|
resC = c1 + c2 - c1*c2 - (c2*t2*(1-c1)*(1-f1)+c1*t1*(1-c2)*(1-f2)) / (1 - resF);
|
|
|
|
|
@@ -474,6 +495,14 @@ public class CertainTrust extends Observable {
|
|
|
i = arrLength;
|
|
|
}
|
|
|
|
|
|
+ //-------------Modified by Debashis-----------------//
|
|
|
+ if(atLeastOne1 && !allOne){
|
|
|
+ for (int i = 0; i < arrLength; ++i)
|
|
|
+ if (args[i].getC() == 1) {
|
|
|
+ args[i].setTC(args[i].getT(),0.99999);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//Calculate T and C
|
|
|
|
|
|
// 1. all C's = 1
|
|
@@ -634,18 +663,15 @@ public class CertainTrust extends Observable {
|
|
|
if (n != arg.getN())
|
|
|
throw new IllegalStateException("Different N values. Operation not allowed. \n");
|
|
|
|
|
|
- //resF = f1*f2;
|
|
|
-
|
|
|
- if (almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resC = (c1+c2-2*c1*c2)/(1-c1*c2);
|
|
|
- else
|
|
|
- resC = (c1+c2-2*c1*c2)/(1-c1*c2);
|
|
|
+ double tempC = c1*c2;
|
|
|
+ if (this.almostEqual(tempC, 1)){ //avoid division by 0
|
|
|
+ c1 = 0.99999;
|
|
|
+ c2 = 0.99999;
|
|
|
+ }
|
|
|
|
|
|
- if (almostEqual(resC, 0))
|
|
|
- resT = 0.5;
|
|
|
- else if (almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resT = (c1*t1*(1-c2)+c2*t2*(1-c1))/(c1*(1-c2)+c2*(1-c1));
|
|
|
- else resT = (c1*t1*(1-c2)+c2*t2*(1-c1))/(c1*(1-c2)+c2*(1-c1));
|
|
|
+ resF = (f1*c1*(1-c2) + f2*c2*(1-c1))/(c1+c2-2*c1*c2);
|
|
|
+ resC = (c1+c2-2*c1*c2)/(1-c1*c2);
|
|
|
+ resT = (c1*t1*(1-c2)+c2*t2*(1-c1))/(c1+c2-2*c1*c2);
|
|
|
|
|
|
resT = adjustValue(resT);
|
|
|
resC = adjustValue(resC);
|
|
@@ -699,7 +725,7 @@ public class CertainTrust extends Observable {
|
|
|
if (n != arg.getN())
|
|
|
throw new IllegalStateException("Different N values. Operation not allowed. \n");
|
|
|
|
|
|
- //resF = f1*f2;
|
|
|
+ resF = f2;
|
|
|
|
|
|
if (almostEqual(resF, 1))
|
|
|
resC = t1*c1*c2;
|