123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <!DOCTYPE html>
- <html>
- <!--
- CertainTrust Demonstrator in JavaScript
- Demonstrates some capabilities of the CertainTrust SDK
- using a Java applet that interactively calculates
- AND and OR of two CertainTrust data objects and
- visually displays both the input objects and the output.
- @author Florian Volk <florian.volk@cased.de>
- -->
- <head>
- <meta charset="utf-8" />
- <title>CertainTrust Demonstrator in JavaScript</title>
- <style type="text/css">
- h1, p, td:nth-child(2n) { text-align: center; }
- table { margin: 50px 0; }
- </style>
- <!-- include these two scripts and the CSS to enable both CertainTrust and the HTI -->
- <script type="text/javascript" src="CertainTrust.js"></script>
- <script type="text/javascript" src="certainTrustHTI.js"></script>
- <link rel="stylesheet" type="text/css" href="certainTrustHTI.css"/>
- </head>
- <body>
- <h1>Demonstrator for CertainTrust</h1>
- <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>
- <td>AND</td>
- <td id="and-operand2"></td>
- <td>=</td>
- <td id="and-result"></td>
- <td></td>
- </tr>
- <!-- Demonstrator for CertainTrust.OR -->
- <tr>
- <td id="or-operand1"></td>
- <td>OR</td>
- <td id="or-operand2"></td>
- <td>=</td>
- <td id="or-result"></td>
- <td></td>
- </tr>
- <!-- Demonstrator for CertainTrust.cFusion -->
- <tr>
- <td id="cf-operand1"></td>
- <td>cFusion</td>
- <td id="cf-operand2"></td>
- <td>=</td>
- <td id="cf-result"></td>
- <td>DoC <input type="text" id="DoC" size="2"></td>
- </tr>
- <!-- Demonstrator for CertainTrust.wFusion -->
- <tr>
- <td id="wf-operand1"></td>
- <td>wFusion</td>
- <td id="wf-operand2"></td>
- <td>=</td>
- <td id="wf-result"></td>
- <td>Weight1 <select id = "weight1" onChange="selectW1(this.value);">
- <option value="0">0</option>
- <option value="1" selected="selected">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- </select><br><br>
- Weight2 <select id = "weight2" onChange="selectW2(this.value);">
- <option value="0">0</option>
- <option value="1" selected="selected">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- </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">
-
- // create an Array to hold the CertainTrust objects
- var CT_objects = [];
- var N = 10;
- var cweight = [1,1];
- var wweight = [1,1];
- var doc = 0.2;
- 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',
- 'con-operand1','con-operand2','con-result',
- 'dis-operand1','dis-operand2','dis-result'];
- function selectW1(value){
- wweight[0] = parseInt(value);
- WFObserver.update();
- }
-
- function selectW2(value){
- wweight[1] = parseInt(value);
- WFObserver.update();
- }
-
- // ANDObserver is used for the AND calculation
- var ANDObserver = {
- update: function() {
- // calculate the CertainTrust.AND for both values
- var CT_result = CT_objects['and-operand1'].AND(CT_objects['and-operand2']);
- // update the HTI which displays the result
- CT_objects['and-result'].setF(CT_result.getF());
- CT_objects['and-result'].setTC(CT_result.getT(), CT_result.getC());
- }
- };
- // ORObserver is used for the OR calculation
- var ORObserver = {
- update: function() {
- // calculate the CertainTrust.OR for both values
- var CT_result = CT_objects['or-operand1'].OR(CT_objects['or-operand2']);
- // update the HTI which displays the result
- CT_objects['or-result'].setF(CT_result.getF());
- CT_objects['or-result'].setTC(CT_result.getT(), CT_result.getC());
- }
- };
-
- // CFObserver is used for the conflicted fusion (cFusion) calculation
- var CFObserver = {
- update: function() {
- var fusTmp = new CertainTrust(5);
-
- var fusArray = [];
- fusArray.push(CT_objects['cf-operand1']);
- fusArray.push(CT_objects['cf-operand2']);
-
- //cFusion operation
- var CT_result = fusTmp.cFusion(fusArray,cweight);
- doc = CT_result.getDoC();
-
- // update the HTI which displays the result
- CT_objects['cf-result'].setF(CT_result.getF());
- CT_objects['cf-result'].setTC(CT_result.getT(), CT_result.getC());
- document.getElementById("DoC").value = doc;
- }
- };
-
- // WFObserver is used for the weighted fusion (wFusion) calculation
- var WFObserver = {
- update: function() {
- var fusTmp = new CertainTrust(5);
-
- var fusArray = [];
- fusArray.push(CT_objects['wf-operand1']);
- fusArray.push(CT_objects['wf-operand2']);
-
- //cFusion operation
- var CT_result = fusTmp.wFusion(fusArray,wweight);
-
- // update the HTI which displays the result
- CT_objects['wf-result'].setF(CT_result.getF());
- 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) {
- var CT_object = new CertainTrust(N);
- // the result HTIs should be read-only
- var isResultHTI = (-1 !== element.indexOf('-result'));
- var HTI = new CertainTrustHTI(CT_object, {domParent: element, readonly: isResultHTI});
- // register our observers for the calculation
- if (!isResultHTI) {
- var isOR = (0 === element.indexOf('or-'));
- 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);
- }
- 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);
- }
- else{
- CT_object.addObserver(WFObserver);
- }
- }
- // store the created objects for easy access in the Arrays
- CT_objects[element] = CT_object;
- }
- // trigger initial update to the result HTIs
- ANDObserver.update();
- ORObserver.update();
- CFObserver.update();
- WFObserver.update();
- CONObserver.update();
- DISObserver.update();
- </script>
- <p>
- <img src="logo_tudarmstadt.png" alt="Technische Universität Darmstadt" width="176" height="73" />
- <img src="logo_softwarecluster.png" alt="Software-Cluster" width="212" height="73" />
- </p>
- </body>
- </html>
|