Browse Source

internalFusion() function updated for atLeastOne1 condition

Debashis Chandra Ray 6 years ago
parent
commit
15e44e07fc
1 changed files with 7 additions and 4 deletions
  1. 7 4
      JavaScript/JavaScript_SDK/CertainTrust.js

+ 7 - 4
JavaScript/JavaScript_SDK/CertainTrust.js

@@ -449,6 +449,13 @@ CertainTrust.prototype._internalFusion = function(args, weights, doc) {
 			atLeastOne1 = true;
 			i = arrLength;
 		}
+		
+	if(atLeastOne1 && !allOne){
+		for (i = 0; i < arrLength; ++i)
+		if (args[i].getC() === 1) {
+			args[i].setTC(args[i].getT(),0.99999);
+		}
+	}
 
 	//Calculate T and C
 
@@ -469,9 +476,6 @@ CertainTrust.prototype._internalFusion = function(args, weights, doc) {
 			resT = numeratorT/denominatorT;
 		}
 	} else {
-		if (atLeastOne1)
-			throw "Illegal arguments. Either all C values must equal 1 or none of them. Operation not allowed\n";
-		else {
 			// 2. Any other combination
 			if (allWeightsZero) { // save some calculation time
 				resT = 0;
@@ -498,7 +502,6 @@ CertainTrust.prototype._internalFusion = function(args, weights, doc) {
 			// Special case for T
 			if (allZero)
 				resT = 0.5;
-		}
 	}
 
 	// Calculate F