123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <!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>
- <!-- 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>
- </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>
- </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>
- </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>
- </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'];
- // 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());
- }
- };
-
- // 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());
- }
- };
- // 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-'));
-
- if(isOR){
- CT_object.addObserver(ORObserver);
- }
- else if(isAND){
- CT_object.addObserver(ANDObserver);
- }
- 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();
- document.write("Degree of Conflict (Doc) for cFusion = " + doc );
- </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>
|