|
@@ -277,8 +277,12 @@ CertainTrust.prototype._singleOR = function(arg) {
|
|
|
|
|
|
resF = f1 + f2 - f1*f2;
|
|
|
|
|
|
- if (this._almostEqual(resF, 0))
|
|
|
- resC = c1 + c2 - c1*c2;
|
|
|
+ if (this._almostEqual(resF, 0)){
|
|
|
+ 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;
|
|
|
|
|
@@ -339,15 +343,17 @@ CertainTrust.prototype._singleAND = function(arg){
|
|
|
return undefined;
|
|
|
|
|
|
resF = f1*f2;
|
|
|
- if (this._almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resC = c1 + c2 - c1*c2;
|
|
|
+ if (this._almostEqual(resF, 1)){ //avoid division by 0
|
|
|
+ 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);
|
|
|
|
|
|
if (this._almostEqual(resC, 0))
|
|
|
resT = 0.5;
|
|
|
- else if (this._almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resT = (1/resC) * (c1*t1*c2*t2);
|
|
|
else resT = (1/resC) * ((c1*t1*c2*t2) + (c1*f2*t1*(1-c2)*(1-f1)+c2*f1*t2*(1-c1)*(1-f2)) / (1 - resF));
|
|
|
|
|
|
resT = this._adjustValue(resT);
|
|
@@ -781,56 +787,7 @@ CertainTrustSimple.prototype.clone = function() {
|
|
|
return copy;
|
|
|
};
|
|
|
|
|
|
-/* From this point codes were added or modified by Debashis Chandra Ray */
|
|
|
-
|
|
|
-/* OR function for CertainTrustSimple objects*/
|
|
|
-CertainTrustSimple.prototype._singleOR = function(arg) {
|
|
|
- var c1 = this.getC();
|
|
|
- var t1 = this.getT();
|
|
|
- var f1 = this.getF();
|
|
|
-
|
|
|
- var c2 = arg.getC();
|
|
|
- var t2 = arg.getT();
|
|
|
- var f2 = arg.getF();
|
|
|
-
|
|
|
- var resT = 0.5, resF = 0.5, resC = 0;
|
|
|
-
|
|
|
- if (!this._operationAllowed(this, arg))
|
|
|
- return undefined;
|
|
|
-
|
|
|
- resF = f1 + f2 - f1*f2;
|
|
|
-
|
|
|
- if (this._almostEqual(resF, 0))
|
|
|
- resC = c1 + c2 - c1*c2;
|
|
|
- else
|
|
|
- resC = c1 + c2 - c1*c2 - (c1*f2*(1-c2)*(1-t1)+c2*f1*(1-c1)*(1-t2)) / resF;
|
|
|
-
|
|
|
- if (this._almostEqual(resC, 0))
|
|
|
- resT = 0.5;
|
|
|
- else resT = (1/resC) * (c1*t1 + c2*t2 - c1*c2*t1*t2);
|
|
|
-
|
|
|
- resT = this._adjustValue(resT);
|
|
|
- resC = this._adjustValue(resC);
|
|
|
- resF = this._adjustValue(resF);
|
|
|
-
|
|
|
- var result = new CertainTrustSimple(resT, resC, resF, this.n, 0);
|
|
|
-
|
|
|
- return result;
|
|
|
-};
|
|
|
-
|
|
|
-CertainTrustSimple.prototype.OR = function() {
|
|
|
- var result = this.clone();
|
|
|
- for (var i = 0; i < arguments.length; ++i) {
|
|
|
- var m = arguments[i];
|
|
|
- if (!this._operationAllowed(this, m))
|
|
|
- continue;
|
|
|
- result = result._singleOR(m);
|
|
|
- }
|
|
|
- return result;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-/* AND function for CertainTrustSimple objects*/
|
|
|
+/*Added by Debashis*/
|
|
|
CertainTrustSimple.prototype._singlesimpleAND = function(arg){
|
|
|
var c1 = this.getC();
|
|
|
var f1 = this.getF();
|
|
@@ -846,15 +803,17 @@ CertainTrustSimple.prototype._singlesimpleAND = function(arg){
|
|
|
return undefined;
|
|
|
|
|
|
resF = f1*f2;
|
|
|
- if (this._almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resC = c1 + c2 - c1*c2;
|
|
|
+ if (this._almostEqual(resF, 1)){ //avoid division by 0
|
|
|
+ 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);
|
|
|
|
|
|
if (this._almostEqual(resC, 0))
|
|
|
resT = 0.5;
|
|
|
- else if (this._almostEqual(resF, 1)) //avoid division by 0
|
|
|
- resT = (1/resC) * (c1*t1*c2*t2);
|
|
|
else resT = (1/resC) * ((c1*t1*c2*t2) + (c1*f2*t1*(1-c2)*(1-f1)+c2*f1*t2*(1-c1)*(1-f2)) / (1 - resF));
|
|
|
|
|
|
resT = this._adjustValue(resT);
|
|
@@ -901,17 +860,15 @@ CertainTrust.prototype._singleCONSENSUS = function(arg){
|
|
|
if (!this._operationAllowed(this, arg))
|
|
|
return undefined;
|
|
|
|
|
|
- //resF = f1*f2;
|
|
|
- if (this._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);
|
|
|
+ var tempC = c1*c2;
|
|
|
+ if (this._almostEqual(tempC, 1)){ //avoid division by 0
|
|
|
+ c1 = 0.99999;
|
|
|
+ c2 = 0.99999;
|
|
|
+ }
|
|
|
|
|
|
- if (this._almostEqual(resC, 0))
|
|
|
- resT = 0.5;
|
|
|
- else if (this._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 = this._adjustValue(resT);
|
|
|
resC = this._adjustValue(resC);
|
|
@@ -981,4 +938,54 @@ CertainTrust.prototype.DISCOUNTING = function() {
|
|
|
result = result._singleDISCOUNTING(m);
|
|
|
}
|
|
|
return result;
|
|
|
-};
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Computes CONSENSUS function for this CertainTrustSimple object and the specified argument. Result is returned as a new object,
|
|
|
+ * argument and this CertainTrust object remain unchanged.
|
|
|
+ * N values of both objects should be equal.
|
|
|
+ * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
|
|
|
+ * @param arg - CertainTrustSimple object
|
|
|
+ * @return - result of CONSENSUS computation for this object and an argument.
|
|
|
+ */
|
|
|
+CertainTrustSimple.prototype._singlesimpleCONSENSUS = function(arg){
|
|
|
+ var c1 = this.getC();
|
|
|
+ var f1 = this.getF();
|
|
|
+ var t1 = this.getT();
|
|
|
+
|
|
|
+ var c2 = arg.getC();
|
|
|
+ var f2 = arg.getF();
|
|
|
+ var t2 = arg.getT();
|
|
|
+
|
|
|
+ var resC = 0, resT = 0.5, resF = 0.5;
|
|
|
+
|
|
|
+ if (!this._operationAllowed(this, arg))
|
|
|
+ return undefined;
|
|
|
+
|
|
|
+ var tempC = c1*c2;
|
|
|
+ if (this._almostEqual(tempC, 1)){ //avoid division by 0
|
|
|
+ c1 = 0.99999;
|
|
|
+ c2 = 0.99999;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 = this._adjustValue(resT);
|
|
|
+ resC = this._adjustValue(resC);
|
|
|
+ resF = this._adjustValue(resF);
|
|
|
+
|
|
|
+ return new CertainTrustSimple(resT, resC, resF);
|
|
|
+};
|
|
|
+
|
|
|
+CertainTrustSimple.prototype.simpleCONSENSUS = function() {
|
|
|
+ var result = this.clone();
|
|
|
+ for (var i = 0; i < arguments.length; i++) {
|
|
|
+ var m = arguments[i];
|
|
|
+ if (!this._operationAllowed(this, m))
|
|
|
+ continue;
|
|
|
+ result = result._singlesimpleCONSENSUS(m);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+};
|