Browse Source

Update for Certainty value 1 changes to 0.999

Debashis Chandra Ray 4 years ago
parent
commit
efd33cfbf2
23 changed files with 97 additions and 32 deletions
  1. 0 0
      Java/Java_SDK/CertainTrustSDK_Updated_Ver_1.1.jar
  2. BIN
      Java/Java_SDK/CertainTrustSDK_Updated_Ver_1.2.jar
  3. BIN
      Java/Java_SDK/CertainTrustSDK_Updated_Ver_1.3.jar
  4. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrust.class
  5. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas.class
  6. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$1.class
  7. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$2.class
  8. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$3.class
  9. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$CertainTrustActionFocusListener.class
  10. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI.class
  11. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimple.class
  12. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas.class
  13. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$1.class
  14. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$2.class
  15. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$3.class
  16. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$CertainTrustActionFocusListener.class
  17. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI.class
  18. 42 16
      Java/Java_SDK/src/CertainTrust/CertainTrust.java
  19. 6 0
      Java/Java_SDK/src/CertainTrust/CertainTrustCanvas.java
  20. 8 0
      Java/Java_SDK/src/CertainTrust/CertainTrustHTI.java
  21. 29 16
      Java/Java_SDK/src/CertainTrust/CertainTrustSimple.java
  22. 6 0
      Java/Java_SDK/src/CertainTrust/CertainTrustSimpleCanvas.java
  23. 6 0
      Java/Java_SDK/src/CertainTrust/CertainTrustSimpleHTI.java

Java/Java_SDK/CertainTrustSDK_Update.jar → Java/Java_SDK/CertainTrustSDK_Updated_Ver_1.1.jar


BIN
Java/Java_SDK/CertainTrustSDK_Updated_Ver_1.2.jar


BIN
Java/Java_SDK/CertainTrustSDK_Updated_Ver_1.3.jar


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrust.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$1.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$2.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$3.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$CertainTrustActionFocusListener.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimple.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$1.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$2.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$3.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$CertainTrustActionFocusListener.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI.class


+ 42 - 16
Java/Java_SDK/src/CertainTrust/CertainTrust.java

@@ -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;

+ 6 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustCanvas.java

@@ -127,6 +127,12 @@ public class CertainTrustCanvas extends Canvas implements Observer {
 		// ensure that the value is in the interval [0;1]
 		double t = Math.max(Math.min(pointer_x / canvasWidth, 1.0), 0.0);
 		double c = Math.max(Math.min(pointer_y / canvasHeight, 1.0), 0.0);
+		
+		//------------------modified by Debashis------------//
+		if(c == 1){
+			c = 0.999;
+		}
+		
 		cl.setTC(t, c);
 	}
 

+ 8 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustHTI.java

@@ -151,6 +151,12 @@ public class CertainTrustHTI extends JPanel implements Observer {
 			catch (NumberFormatException e) {
 				result = defaultValue;
 			}
+			
+			//------------------modified by Debashis------------//
+			if(result == 1){
+				result = 0.999;
+			}
+			
 			return result;
 		}
 	}
@@ -225,6 +231,8 @@ public class CertainTrustHTI extends JPanel implements Observer {
 				new CertainTrustActionFocusListener() {
 			@Override
 			void update() {
+				
+				
 				cl.setTC(cl.getT(),
 						this.parseInput(c.getText(), cl.getC()));
 			}

+ 29 - 16
Java/Java_SDK/src/CertainTrust/CertainTrustSimple.java

@@ -189,8 +189,12 @@ public class CertainTrustSimple 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;
 		
@@ -251,8 +255,12 @@ public class CertainTrustSimple 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);
 		
@@ -339,6 +347,14 @@ public class CertainTrustSimple 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
@@ -499,18 +515,15 @@ public class CertainTrustSimple 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);
@@ -566,7 +579,7 @@ public class CertainTrustSimple 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;

+ 6 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustSimpleCanvas.java

@@ -127,6 +127,12 @@ public class CertainTrustSimpleCanvas extends Canvas implements Observer {
 		// ensure that the value is in the interval [0;1]
 		double t = Math.max(Math.min(pointer_x / canvasWidth, 1.0), 0.0);
 		double c = Math.max(Math.min(pointer_y / canvasHeight, 1.0), 0.0);
+		
+		//------------------modified by Debashis------------//
+		if(c == 1){
+			c = 0.999;
+		}
+		
 		cl.setTC(t, c);
 	}
 

+ 6 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustSimpleHTI.java

@@ -151,6 +151,12 @@ public class CertainTrustSimpleHTI extends JPanel implements Observer {
 			catch (NumberFormatException e) {
 				result = defaultValue;
 			}
+			
+			//------------------modified by Debashis------------//
+			if(result == 1){
+				result = 0.999;
+			}
+			
 			return result;
 		}
 	}