Browse Source

CONSENSUS and DISCOUNTING Operator updated in demonstrator_updated.html

Debashis Chandra Ray 6 years ago
parent
commit
ecf0c12a5b
1 changed files with 64 additions and 1 deletions
  1. 64 1
      JavaScript/JavaScript_Examples/demonstrator_updated.html

+ 64 - 1
JavaScript/JavaScript_Examples/demonstrator_updated.html

@@ -29,6 +29,14 @@ visually displays both the input objects and the output.
 	<p>CertainTrust provides a means for the evaluation of propositional logic terms under uncertainty.</p>
 
 	<table>
+		<tr>
+			<th>Operand 1</th>
+			<th>Operator</th>
+			<th>Operand 2</th>
+			<th>=</th>
+			<th>Result</th>
+			<th></th>
+		</tr>
 		<!-- Demonstrator for CertainTrust.AND -->
 		<tr>
 			<td id="and-operand1"></td>
@@ -81,6 +89,25 @@ visually displays both the input objects and the output.
 				</select>
 			</td>
 		</tr>
+		<!-- Demonstrator for CertainTrust.CONSENSUS -->
+		<tr>
+			<td id="con-operand1"></td>
+			<td>CONSENSUS</td>
+			<td id="con-operand2"></td>
+			<td>=</td>
+			<td id="con-result"></td>
+			<td></td>
+		</tr>
+		
+		<!-- Demonstrator for CertainTrust.DISCOUNTING -->
+		<tr>
+			<td id="dis-operand1"></td>
+			<td>DIS-<br>-COUNTING</td>
+			<td id="dis-operand2"></td>
+			<td>=</td>
+			<td id="dis-result"></td>
+			<td></td>
+		</tr>
 	</table>
 
 	<script type="text/javascript">
@@ -94,7 +121,9 @@ visually displays both the input objects and the output.
 		var CT_names = ['and-operand1', 'and-operand2', 'and-result',
 										'or-operand1', 'or-operand2', 'or-result',
 										'cf-operand1','cf-operand2','cf-result',
-										'wf-operand1','wf-operand2','wf-result'];
+										'wf-operand1','wf-operand2','wf-result',
+										'con-operand1','con-operand2','con-result',
+										'dis-operand1','dis-operand2','dis-result'];
 
 		function selectW1(value){
 			wweight[0] = parseInt(value);
@@ -167,6 +196,30 @@ visually displays both the input objects and the output.
 				CT_objects['wf-result'].setTC(CT_result.getT(), CT_result.getC());
 			}
 		};
+		
+		// CONObserver is used for the CONSENSUS calculation
+		var CONObserver = {
+			update: function() {
+				// calculate the CertainTrust.AND for both values
+				var CT_result = CT_objects['con-operand1'].CONSENSUS(CT_objects['con-operand2']);
+
+				// update the HTI which displays the result
+				CT_objects['con-result'].setF(CT_result.getF());
+				CT_objects['con-result'].setTC(CT_result.getT(), CT_result.getC());
+			}
+		};
+		
+		// DISObserver is used for the DISCOUNTING calculation
+		var DISObserver = {
+			update: function() {
+				// calculate the CertainTrust.DISCOUNTING for both values
+				var CT_result = CT_objects['dis-operand1'].CONSENSUS(CT_objects['dis-operand2']);
+
+				// update the HTI which displays the result
+				CT_objects['dis-result'].setF(CT_result.getF());
+				CT_objects['dis-result'].setTC(CT_result.getT(), CT_result.getC());
+			}
+		};
 
 		// create the CertainTrust objects and the associated HTIs
 		for (var i = 0, element; element = CT_names[i]; ++i) {
@@ -182,6 +235,8 @@ visually displays both the input objects and the output.
 				var isAND = (0 === element.indexOf('and-'));
 				var isCF = (0 === element.indexOf('cf-'));
 				var isWF = (0 === element.indexOf('wf-'));
+				var isCON = (0 === element.indexOf('con-'));
+				var isDIS = (0 === element.indexOf('dis-'));
 				
 				if(isOR){
 					CT_object.addObserver(ORObserver);
@@ -189,6 +244,12 @@ visually displays both the input objects and the output.
 				else if(isAND){
 					CT_object.addObserver(ANDObserver);
 				}
+				else if(isCON){
+					CT_object.addObserver(CONObserver);
+				}
+				else if(isDIS){
+					CT_object.addObserver(DISObserver);
+				}
 				else if(isCF){
 					CT_object.addObserver(CFObserver);
 				}
@@ -206,6 +267,8 @@ visually displays both the input objects and the output.
 		ORObserver.update();
 		CFObserver.update();
 		WFObserver.update();
+		CONObserver.update();
+		DISObserver.update();
 	</script>
 
 	<p>