demonstrator_updated.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. CertainTrust Demonstrator in JavaScript
  5. Demonstrates some capabilities of the CertainTrust SDK
  6. using a Java applet that interactively calculates
  7. AND and OR of two CertainTrust data objects and
  8. visually displays both the input objects and the output.
  9. @author Florian Volk <florian.volk@cased.de>
  10. -->
  11. <head>
  12. <meta charset="utf-8" />
  13. <title>CertainTrust Demonstrator in JavaScript</title>
  14. <style type="text/css">
  15. h1, p, td:nth-child(2n) { text-align: center; }
  16. table { margin: 50px 0; }
  17. </style>
  18. <!-- include these two scripts and the CSS to enable both CertainTrust and the HTI -->
  19. <script type="text/javascript" src="CertainTrust.js"></script>
  20. <script type="text/javascript" src="certainTrustHTI.js"></script>
  21. <link rel="stylesheet" type="text/css" href="certainTrustHTI.css"/>
  22. </head>
  23. <body>
  24. <h1>Demonstrator for CertainTrust</h1>
  25. <p>CertainTrust provides a means for the evaluation of propositional logic terms under uncertainty.</p>
  26. <table>
  27. <!-- Demonstrator for CertainTrust.AND -->
  28. <tr>
  29. <td id="and-operand1"></td>
  30. <td>AND</td>
  31. <td id="and-operand2"></td>
  32. <td>=</td>
  33. <td id="and-result"></td>
  34. </tr>
  35. <!-- Demonstrator for CertainTrust.OR -->
  36. <tr>
  37. <td id="or-operand1"></td>
  38. <td>OR</td>
  39. <td id="or-operand2"></td>
  40. <td>=</td>
  41. <td id="or-result"></td>
  42. </tr>
  43. <!-- Demonstrator for CertainTrust.cFusion -->
  44. <tr>
  45. <td id="cf-operand1"></td>
  46. <td>cFusion</td>
  47. <td id="cf-operand2"></td>
  48. <td>=</td>
  49. <td id="cf-result"></td>
  50. </tr>
  51. <!-- Demonstrator for CertainTrust.wFusion -->
  52. <tr>
  53. <td id="wf-operand1"></td>
  54. <td>wFusion</td>
  55. <td id="wf-operand2"></td>
  56. <td>=</td>
  57. <td id="wf-result"></td>
  58. </tr>
  59. </table>
  60. <script type="text/javascript">
  61. // create an Array to hold the CertainTrust objects
  62. var CT_objects = [];
  63. var N = 10;
  64. var cweight = [1,1];
  65. var wweight = [1,1];
  66. var doc = 0.2;
  67. var CT_names = ['and-operand1', 'and-operand2', 'and-result',
  68. 'or-operand1', 'or-operand2', 'or-result',
  69. 'cf-operand1','cf-operand2','cf-result',
  70. 'wf-operand1','wf-operand2','wf-result'];
  71. // ANDObserver is used for the AND calculation
  72. var ANDObserver = {
  73. update: function() {
  74. // calculate the CertainTrust.AND for both values
  75. var CT_result = CT_objects['and-operand1'].AND(CT_objects['and-operand2']);
  76. // update the HTI which displays the result
  77. CT_objects['and-result'].setF(CT_result.getF());
  78. CT_objects['and-result'].setTC(CT_result.getT(), CT_result.getC());
  79. }
  80. };
  81. // ORObserver is used for the OR calculation
  82. var ORObserver = {
  83. update: function() {
  84. // calculate the CertainTrust.OR for both values
  85. var CT_result = CT_objects['or-operand1'].OR(CT_objects['or-operand2']);
  86. // update the HTI which displays the result
  87. CT_objects['or-result'].setF(CT_result.getF());
  88. CT_objects['or-result'].setTC(CT_result.getT(), CT_result.getC());
  89. }
  90. };
  91. // CFObserver is used for the conflicted fusion (cFusion) calculation
  92. var CFObserver = {
  93. update: function() {
  94. var fusTmp = new CertainTrust(5);
  95. var fusArray = [];
  96. fusArray.push(CT_objects['cf-operand1']);
  97. fusArray.push(CT_objects['cf-operand2']);
  98. //cFusion operation
  99. var CT_result = fusTmp.cFusion(fusArray,cweight);
  100. doc = CT_result.getDoC();
  101. // update the HTI which displays the result
  102. CT_objects['cf-result'].setF(CT_result.getF());
  103. CT_objects['cf-result'].setTC(CT_result.getT(), CT_result.getC());
  104. }
  105. };
  106. // WFObserver is used for the weighted fusion (wFusion) calculation
  107. var WFObserver = {
  108. update: function() {
  109. var fusTmp = new CertainTrust(5);
  110. var fusArray = [];
  111. fusArray.push(CT_objects['wf-operand1']);
  112. fusArray.push(CT_objects['wf-operand2']);
  113. //cFusion operation
  114. var CT_result = fusTmp.wFusion(fusArray,wweight);
  115. // update the HTI which displays the result
  116. CT_objects['wf-result'].setF(CT_result.getF());
  117. CT_objects['wf-result'].setTC(CT_result.getT(), CT_result.getC());
  118. }
  119. };
  120. // create the CertainTrust objects and the associated HTIs
  121. for (var i = 0, element; element = CT_names[i]; ++i) {
  122. var CT_object = new CertainTrust(N);
  123. // the result HTIs should be read-only
  124. var isResultHTI = (-1 !== element.indexOf('-result'));
  125. var HTI = new CertainTrustHTI(CT_object, {domParent: element, readonly: isResultHTI});
  126. // register our observers for the calculation
  127. if (!isResultHTI) {
  128. var isOR = (0 === element.indexOf('or-'));
  129. var isAND = (0 === element.indexOf('and-'));
  130. var isCF = (0 === element.indexOf('cf-'));
  131. var isWF = (0 === element.indexOf('wf-'));
  132. if(isOR){
  133. CT_object.addObserver(ORObserver);
  134. }
  135. else if(isAND){
  136. CT_object.addObserver(ANDObserver);
  137. }
  138. else if(isCF){
  139. CT_object.addObserver(CFObserver);
  140. }
  141. else{
  142. CT_object.addObserver(WFObserver);
  143. }
  144. }
  145. // store the created objects for easy access in the Arrays
  146. CT_objects[element] = CT_object;
  147. }
  148. // trigger initial update to the result HTIs
  149. ANDObserver.update();
  150. ORObserver.update();
  151. CFObserver.update();
  152. WFObserver.update();
  153. document.write("Degree of Conflict (Doc) for cFusion = " + doc );
  154. </script>
  155. <p>
  156. <img src="logo_tudarmstadt.png" alt="Technische Universität Darmstadt" width="176" height="73" />
  157. <img src="logo_softwarecluster.png" alt="Software-Cluster" width="212" height="73" />
  158. </p>
  159. </body>
  160. </html>