-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1181 lines (1118 loc) · 133 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="libs/jquery.min.js"></script>
<script type='text/javascript' src="libs/xml2json.js"></script>
<style>
svg { border: 1px solid black; }
svg g rect.node-shape { border-radius: 5px !important; fill:#ffecb3 !important; cursor: move; }
svg g text.node-name { font-weight: 800 !important }
svg g rect.node-bar { fill: green !important }
svg g text.node-value { fill:rgb(0,0,0) !important; font-size: 15px; cursor: pointer; }
svg line.edge-line { stroke:rgb(0,0,0) !important }
svg path.edge-head { fill:rgb(0,0,0) !important }
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.js"></script>
<script src="libs/lodash.js"></script>
<script src="libs/graphlib.core.js"></script>
<script src="libs/dagre.js"></script>
<script src="libs/jquery.min.js"></script>
<script src="libs/jsbayes.js"></script>
<script src="libs/jsbayes-viz.js"></script>
<script type="text/javascript" src="libs/xmlToJSON.min.js"></script>
<script type='text/javascript'>
$(window).load(function(){
var x2js = new X2JS();
function convertXml2JSon() {
$("#xmloutput").html($("#xmlArea").val());
}
$("#loadXMLandSD2BBN").click(loadXMLandSD2BBN);
loadXMLandSD2BBN()
});
function loadXMLandSD2BBN() {
$("#xmloutput").html($("#xmlArea").val());
convertJSon2BBN();
}
function convertJSon2BBN() {
if ($("#xmloutput").html() !== '')
{
d3.select("#bbn").remove();
d3.select("body").append("svg").attr("id", "bbn");
//svg.selectAll("*").remove();
var graph = jsbayes.newGraph();
graph.saveSamples = true;
var lifelinenodesBBN = new Array;
var lifelinenodesBBNIDs = new Array;
var interactionnodesBBN = new Array;
var interactionnodesBBNIDs = new Array;
var fragmentnodesBBN = new Array;
var fragmentnodesBBNIDs = new Array;
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
var interactionNodeDetails = new Array;
var DependentSourceLifelineIncoming = new Array;
var DependentSourceLifelineOutgoing = new Array;
//0 = name, 1= type
var combinedFragments= new Array;
var sourceNameList;
var targetNameList;
var lifelineList;
//$("#xmlArea").val(x2js.json2xml_str($.parseJSON($("#jsonArea").val())));
//var lifelineList = doc.getElementsByTagName("lifeline");
//var lifelineList = document.getElementsByTagName("lifeline");
var lifelineList = document.getElementsByTagName("lifeline");
//console.log(lifelineList);
//$("#output").html($("#output").html() + lifelineList + "<br/>")
var connectorList = document.getElementsByTagName("connector");
//console.log(connectorList);
var fragmentList = document.getElementsByTagName("fragment");
//console.log(fragmentList);
//$("#output").html($("#output").html() + connectorList + "<br/>")
for (i = 0; i < lifelineList.length; i++)
{
//LIFELINELIST
var lifelineNode = lifelineList.item(i);
//console.log("" + lifelineNode.attributes.getNamedItem("name").value);
//console.log("" + lifelineNode.attributes.getNamedItem("xmi:id").value);
//$("#output").html($("#output").html() + lifelineNode.attributes.getNamedItem("name").value + "(id: "+ lifelineNode.attributes.getNamedItem("xmi:id").value + ")<br/>")
//lifelinenodesBBN[i] = graph.addNode(lifelineNode.attributes.getNamedItem("name").value.replace(/ /g,''), ['success', 'failure']);
lifelinenodesBBN[i] = graph.addNode(lifelineNode.attributes.getNamedItem("name").value.replace(/\s+/g, '').replace("-", "").replace(/[0-9]/g, ''), ['success', 'failure']);
lifelinenodesBBNIDs[i] = lifelineNode.attributes.getNamedItem("xmi:id").value;
lifelinenodesBBN[i].setCpt([ 0.9, 0.1]);
}
//CONNECTORLIST
for (i = 0; i < connectorList.length; i++) {
var childNode = connectorList.item(i);
var nodeID = childNode.attributes.getNamedItem("xmi:idref").value;
//console.log(nodeID);
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
//interactionNodeDetails[nodeID] = ['', nodeID, '', '', '', '', ''];
//interactionNodeDetails[i] = ['', nodeID, 0, '', '', '', 0, sendEvent];
interactionNodeDetails[i] = ['', nodeID, 0, '', '', '', 0, '', ''];
var connectorNodelist = childNode.childNodes;//alternative is use of .children
for (j = 0; j < connectorNodelist.length; j++)
{
//console.log(nodeID);
var connectoreChilddNodes = connectorNodelist.item(j);
//console.log("" + connectoreChilddNodes.nodeName);
if (connectoreChilddNodes.nodeName.toUpperCase() === "PROPERTIES")
{
//get name of interaction
//console.log(connectoreChilddNodes);
if (connectoreChilddNodes.attributes.getNamedItem("ea_type").value.toUpperCase() === 'SEQUENCE')
{
var name = connectoreChilddNodes.attributes.getNamedItem("name").value;
//console.log(name);
//create connector node
//var latest = Object.keys(interactionnodesBBN).length++;
//interactionnodesBBN[latest] = graph.addNode(name, ['success', 'failure']);
//interactionnodesBBN[nodeID] = graph.addNode(name, ['success', 'failure']);
//interactionnodesBBNIDs[latest] = nodeID;
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent, 8=isOptional?, 8=isOptional?
interactionNodeDetails[i][0] = name;
interactionNodeDetails[i][6] = 'sequence';
//console.log("details " + interactionNodeDetails[latest][3]);
var Interaction = true;
var connectoreChilddNodesProperties = connectoreChilddNodes.childNodes;
//console.log(connectoreChilddNodesProperties);
for (n = 0; n < connectoreChilddNodesProperties.length; n++)
{
//console.log(nodeID);
var connectoreChilddNodesPropertiesNode = connectoreChilddNodesProperties.item(n);
//get sequence of interaction
if (connectoreChilddNodesPropertiesNode.nodeName.toUpperCase() === "APPEARANCE")
{
//console.log(connectoreChilddNodesPropertiesNode.nodeName.toUpperCase());
//console.log(connectoreChilddNodesPropertiesNode);
var seqno = connectoreChilddNodesPropertiesNode.attributes.getNamedItem("seqno").value;
//console.log('sequence ' + seqno);
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
interactionNodeDetails[i][2] = Number(seqno);
}
}
}
else
{
var Interaction = false;
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
interactionNodeDetails[i][6] = 'other';
}
}
//get SOURCE lifeine/component of interaction
if (connectoreChilddNodes.nodeName.toUpperCase() === "SOURCE")
{
//Make NodeList of Source Node ChildNodes
//console.log(connectoreChilddNodes);
//var SourceNodeList = connectoreChilddNodes.childNodes; //alternative is use of .children
var SourceNodeList = connectoreChilddNodes;
//find ID of source lifeline
//console.log(SourceNodeList.attributes.getNamedItem("xmi:idref").value);
var id = SourceNodeList.attributes.getNamedItem("xmi:idref").value;
//find lifeline and make parent node of interaction node.
//for(h = 0; h < Object.keys(lifelinenodesBBNIDs).length; h++){
//console.log(lifelinenodesBBNIDs[h] + ' and ' + id);
// if (lifelinenodesBBNIDs[h] === id)
// {
//var latest = Object.keys(interactionnodesBBN).length;
//interactionnodesBBN[latest] = graph.addNode('temp' + h+latest, ['success', 'failure']);
//interactionnodesBBN[latest].addParent(lifelinenodesBBN[h]);
//interactionnodesBBN[nodeID].addParent(lifelinenodesBBN[h]);
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
//interactionNodeDetails[latest][3] = lifelinenodesBBNIDs[h];
interactionNodeDetails[i][3] = id;
//detect self-calls
if (interactionNodeDetails[i][3] !== interactionNodeDetails[i][4])
{
interactionNodeDetails[i][5]++;
}
// }
//}
}
//get TARGET lifeine/component of interaction
if (connectoreChilddNodes.nodeName.toUpperCase() === "TARGET")
{
//console.log('Target' + connectoreChilddNodes);
//Make NodeList of Target Node ChildNodes
//var targetNodeList = connectoreChilddNodes.childNodes;
var targetNodeList = connectoreChilddNodes;
//find ID of target lifeline
//console.log(targetNodeList.attributes.getNamedItem("xmi:idref").value);
var id = targetNodeList.attributes.getNamedItem("xmi:idref").value
//find lifeline and make parent node of interaction node.
//for(l = 0; l < Object.keys(lifelinenodesBBNIDs).length; l++){
//console.log(lifelinenodesBBNIDs[h] + ' and ' + id);
// if (lifelinenodesBBNIDs[l] === id){
//var latest = Object.keys(interactionnodesBBN).length;
//interactionnodesBBN[latest] = graph.addNode('temp' + h+latest, ['success', 'failure']);
//interactionnodesBBNIDs[latest] = id;
//interactionnodesBBN[latest].addParent(lifelinenodesBBN[h]);
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
interactionNodeDetails[i][4] = id;
//detect self-calls
if (interactionNodeDetails[i][4] !== interactionNodeDetails[i][3])
{
interactionNodeDetails[i][5]++;
}
//console.log("details " + interactionNodeDetails[latest][3]);
// }
//}
}
}
}
//for(h = 0; h < Object.keys(interactionnodesBBN).length; h++)
//for(m = 0; m < interactionNodeDetails.length; m++)
//console.log(Object.keys(interactionNodeDetails).length);
//console.log(interactionNodeDetails);
var fragmentList = document.getElementsByTagName("fragment");
//console.log(fragmentList);
//$("#output").html($("#output").html() + connectorList + "<br/>")
//console.log(JSON.stringify(fragmentList));
for (i = 0; i < fragmentList.length; i++)
{
//LIFELINELIST
var fragmentNode = fragmentList.item(i);
//var fragmentChildNodeID = fragmentChildNode.attributes.getNamedItem("xmi:idref").value;
//var fragmentNodeID = fragmentNode.attributes.getNamedItem("xmi:type").value;
if (fragmentNode.attributes.getNamedItem("interactionOperator"))
{ //only select fragments with an operator
var fragmentNodeOperator = fragmentNode.attributes.getNamedItem("interactionOperator").value;
//console.log(fragmentNodeOperator);
//for each fragment i create
//array with combinedFragment details - TODO match to interactions array
//0 = name, 1= type, 2= (array) fragmentInteractionSendEventIds
combinedFragments[i] = [fragmentNodeOperator, fragmentNodeOperator, []];
var fragmentNodelist = fragmentNode.childNodes;//alternative is use of .children
for (j = 0; j < fragmentNodelist.length; j++)
{
var fragmentChilddNodes = fragmentNodelist.item(j);
if (fragmentChilddNodes.nodeName.toUpperCase() === "OPERAND")
{ //only select operand parts of fragments
//console.log(fragmentChilddNodes);
var fragmentChilddNodesOperandList = fragmentChilddNodes.childNodes;//alternative is use of .children
for (k = 0; k < fragmentChilddNodesOperandList.length; k++)
{
var fragmentChilddNodesOperandNodes = fragmentChilddNodesOperandList.item(k);
//console.log(fragmentChilddNodesOperandNodes);
if (fragmentChilddNodesOperandNodes.nodeName.toUpperCase() === "GUARD")
{ //Get name of combined fragment = is name of certain nodes in reliability BBN
//get child
var fragmentChilddNodesOperandNodesGuardList = fragmentChilddNodesOperandNodes.children;//alternative is use of .children
for (l = 0; l < fragmentChilddNodesOperandNodesGuardList.length; l++)
{
var fragmentChilddNodesOperandNodesGuardListNode = fragmentChilddNodesOperandNodesGuardList.item(l);
//console.log(fragmentChilddNodesOperandNodesGuardListNode);
//console.log(fragmentChilddNodesOperandNodesGuardListNode);
//console.log(fragmentChilddNodesOperandNodesGuardListNode[0]);
//console.log(fragmentChilddNodesOperandNodesGuardListNode.attributes.getNamedItem("xmi:id").value);
if (fragmentChilddNodesOperandNodesGuardListNode.attributes.getNamedItem("body"))
{
fragmentName = fragmentChilddNodesOperandNodesGuardListNode.attributes.getNamedItem("body").value;
//console.log(fragmentChilddNodesOperandNodesGuardListNode.attributes.getNamedItem("body").value);
//0 = name, 1= type, 2= (array) fragmentInteractionSendEventIds
combinedFragments[i][0] += ' ' + fragmentName;
}
//console.log('array: ' + combinedFragments[i]);
}
}
if (fragmentChilddNodesOperandNodes.nodeName.toUpperCase() === "FRAGMENT")
{ //Get IDs of interactions in combined fragment = interactions are nodes in reliability BBN
//which need to be identified and need a special CPT or link to combined fragment node
if (fragmentChilddNodesOperandNodes.attributes.getNamedItem("xmi:id"))
{
let fragmentInteractionIds = fragmentChilddNodesOperandNodes.attributes.getNamedItem("xmi:id").value;
combinedFragments[i][2].push(fragmentInteractionIds);
}
}
}
//console.log('array: ' + combinedFragments[i])
}
}
}
}
//console.log('array: ' + combinedFragments)
//add send events to interactions in order to map these to combined fragments
var messageList = document.getElementsByTagName("message");
for (z = 0; z < messageList.length; z++) {
var messageChildNode = messageList.item(z);
var messageNodeID = messageChildNode.attributes.getNamedItem("xmi:id").value;
var messageSendEvent = messageChildNode.attributes.getNamedItem("sendEvent").value;
//console.log(messageNodeID + ' ' + messageSendEvent);
for(s = 0; s < interactionNodeDetails.length; s++)
{ //go through all interaction IDs
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
//match interaction send-event IDs to send-event IDs in combinedfragement
if (interactionNodeDetails[s][1] === messageNodeID)
{
interactionNodeDetails[s][7] = messageSendEvent;
//console.log(interactionNodeDetails[s][1]);
}
}
}
//add information to interactionNodeDetails when it is in a combined fragment
for(q = 0; q < combinedFragments.length; q++)
{
//add details for interactions in optional or alternative combined fragment
//combinedFragments: 0 = name, 1= type, 2= (array) fragmentInteractionSendEventIds
if (combinedFragments[q])
{
if (combinedFragments[q][1] === 'opt')
{
//create optional nodes with state 'does not occur'
//assume that there are interactions in combined fragment
//var fragmentnodesBBN = new Array;
//combinedFragments: 0 = name, 1= type, 2= (array) fragmentInteractionSendEventIds
//fragmentnodesBBN[q] = graph.addNode(combinedFragments[q][0].replace(/\s+/g, '').replace("-", "").replace(/[0-9]/g, '').replace("-", "").replace(/[0-9]/g, ''); , ['DoesNotOccur', 'Occurs']);
//fragmentnodesBBN[q] = graph.addNode(combinedFragments[q][1].replace(/\s+/g, '').replace("-", "").replace(/[0-9]/g, '').replace("-", "").replace(/[0-9]/g, ''); , ['DoesNotOccur', 'Occurs']);
//fragmentnodesBBN[q].setCpt([ 0.7, 0.3]);
//console.log('array: ' + combinedFragments[q]);
for(r = 0; r < combinedFragments[q][2].length; r++)
{ //go through all send events of interactions affected by combined fragment
//console.log('test - ID in framgent=' + combinedFragments[q][2][r]);
for(s = 0; s < interactionNodeDetails.length; s++)
{ //go through all interaction IDs
//console.log('test interaction ID - ' + interactionNodeDetails[s][7]);
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent, 9=parentOptFragmentnodesBBNID
//match interaction send-event IDs to send-event IDs in combinedfragement
if (interactionNodeDetails[s][7] === combinedFragments[q][2][r])
{
//set interactionNodeDetails[8] to indicate optional combined fragment when calculating CPTs
interactionNodeDetails[s][8] = 'opt';
interactionNodeDetails[s][9] = q; //indicate what ID of fragmentnodesBBN is parent of this interaction node
}
}
}
}
}
}
// remove non-sequence messages
for(o = 0; o < Object.keys(interactionNodeDetails).length; o++)
{
if (interactionNodeDetails[o][6] !== 'sequence')
{
//remove non-interaction element from
//if (i > -1) {
interactionNodeDetails.splice(o, 1);
//}
}
}
//create interaction nodes + assign parents in BBN
for(p = 0; p < Object.keys(interactionNodeDetails).length; p++)
{
//console.log(interactionNodeDetails[p]);
if (interactionNodeDetails[p][6] === 'sequence')
{
//create interaction nodes and linke to parents
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
if(interactionNodeDetails[p][8] == 'opt')
//if(false)
{
interactionnodesBBN[p] = graph.addNode(interactionNodeDetails[p][0].replace(/\s+/g, '').replace("-", "").replace(/[0-9]/g, ''), ['success', 'failure', 'dno']);
//link interaction nodes to optional node == add parent frament node with ID Q to interactionnodeBBN
//interactionnodesBBN[p].addParent(fragmentnodesBBN[interactionNodeDetails[p][9]]);
//console.log('Interaction mapped to Opt combined fragment' + interactionNodeDetails[p][1]);
//interactionNodeDetails[p][5]++; //interaction node has extra dependency on opt fragment node
}
else {
interactionnodesBBN[p] = graph.addNode(interactionNodeDetails[p][0].replace(/\s+/g, '').replace("-", "").replace(/[0-9]/g, ''), ['success', 'failure']);
}
//assign interaction failure dependencies to lifeline/component nodes
for(q = 0; q < Object.keys(lifelinenodesBBNIDs).length; q++){
if (interactionNodeDetails[p][4] === interactionNodeDetails[p][3])
{ //detect self-call - only add source node as parent
if (lifelinenodesBBNIDs[q] === interactionNodeDetails[p][3])
{
interactionnodesBBN[p].addParent(lifelinenodesBBN[q]);
}
}
else {
//add both incoming and outgoing node as parent
if (lifelinenodesBBNIDs[q] === interactionNodeDetails[p][3])
{
interactionnodesBBN[p].addParent(lifelinenodesBBN[q]);
}
if (lifelinenodesBBNIDs[q] === interactionNodeDetails[p][4])
{
interactionnodesBBN[p].addParent(lifelinenodesBBN[q]);
}
}
}
//console.log(interactionNodeDetails[p][5]);
}
}
//determine failure dependencies between interactions
for(m = 0; m < Object.keys(interactionNodeDetails).length; m++)
{ //traverse list of interaction nodes
if (interactionNodeDetails[m][6] === 'sequence')
{
//assign failure dependencies between interaction nodes
//go throught all interactions with a lower sequence number
var currentsequence = interactionNodeDetails[m][2];
var minsequence = -1;
var parentInteractionNodeID = -1;
var previousSequence = -1;
var previousParentInteractionNodeID = -1;
for(n = 0; n < Object.keys(interactionNodeDetails).length; n++)
{ //again traverse list of interaction nodes, checking interactions with a lower sequence number than interaction m (in parent loop)
var sourcelifeline = interactionNodeDetails[m][3];
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
if(sourcelifeline === interactionNodeDetails[n][4])
{
//store sequence of other incoming interactions on source lifeline on which current interaction M is dependent
//DependentSourceLifelineIncoming[sourcelifeline] = new Array(n, interactionNodeDetails[n][2]);
//DependentSourceLifelineIncoming[n] = new Array(interactionNodeDetails[n][2]);
DependentSourceLifelineIncoming[n] = interactionNodeDetails[n][2];
}
if(sourcelifeline === interactionNodeDetails[n][3])
{
//store sequence of other outgoing interactions on source lifeline on which current interaction M is dependent
//DependentSourceLifelineOutgoing[sourcelifeline] = new Array(n, interactionNodeDetails[n][2]);
//DependentSourceLifelineOutgoing[n] = new Array(interactionNodeDetails[n][2]);
DependentSourceLifelineOutgoing[n] = interactionNodeDetails[n][2];
}
//find the interaction with the highest sequence number that has
//the same lifeline-Target as the lifeline-source of this interaction
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
if (interactionNodeDetails[n][2] < currentsequence &&
interactionNodeDetails[n][2] > minsequence &&
interactionNodeDetails[m][3] === interactionNodeDetails[n][4])
{
//store new - highest interaction sequence on which node is dependent
minsequence = interactionNodeDetails[n][2];
parentInteractionNodeID = n;
}
else if (interactionNodeDetails[n][2] < currentsequence &&
interactionNodeDetails[n][2] > previousSequence &&
interactionNodeDetails[m][3] === interactionNodeDetails[n][4])
{
//store next-highest values in case of dependency on optional interaction
previousSequence = interactionNodeDetails[n][2];
previousParentInteractionNodeID = n;
}
}
if (minsequence !== -1 && parentInteractionNodeID !== -1 )
{
//console.log('current: ' + interactionNodeDetails[m][0]);
//console.log(interactionnodesBBN[m]);
//console.log('currentsequence: ' + currentsequence);
//console.log('minseq: ' + minsequence );
//console.log('parent: ' + parentInteractionNodeID + "node: " + interactionNodeDetails[parentInteractionNodeID][0]);
//console.log(interactionnodesBBN);
//console.log(interactionnodesBBN[parentInteractionNodeID]);
//interactionNodeDetails: 0 = name, 1= ID, 2= sequence, 3= lifeLineDependencySource, 4= lifeLineDependencyTarget, 5=noOfDependencies, 6=type, 7=sendEvent, 8=isOptional?, 9=parentOptFragmentnodesBBNID, 10=optparent
//if (minsequence !== 0 && parentInteractionNodeID !== 0 && m === 5)
//console.log('node ' + m);
interactionnodesBBN[m].addParent(interactionnodesBBN[parentInteractionNodeID]);
//increase number of dependencies for this nodes
interactionNodeDetails[m][5]++;
//console.log(interactionnodesBBN[parentInteractionNodeID]);
//console.log('$$$parent: ' + interactionNodeDetails[parentInteractionNodeID][0] + ' ---- dependencee: ' + interactionNodeDetails[m][0])
//if (interactionnodesBBN[m][8] === 'opt')
if (interactionNodeDetails[parentInteractionNodeID][8] === 'opt')
{
console.log('*** parent ' + interactionNodeDetails[m][0] + '####opt dependencee: ' + interactionNodeDetails[parentInteractionNodeID][0]);
//interactionNodeDetails[parentInteractionNodeID][10] = 'optparent';
interactionNodeDetails[m][10] = 'optparent';
console.log(previousSequence + ' ' + previousParentInteractionNodeID)
if (previousSequence !== -1 &&
previousParentInteractionNodeID !== -1 &&
interactionNodeDetails[m][8] !== 'opt')
{ //check if interaction is dependent on a previous interaction that is not optional
//and check that this node is not optional itself
//previousSequence;
//previousParentInteractionNodeID;
//console.log('test' + interactionNodeDetails[previousParentInteractionNodeID][0]);
//add this previous non-optional interaction as a dependency.
interactionnodesBBN[m].addParent(interactionnodesBBN[previousParentInteractionNodeID]);
//increase number of dependencies for this nodes
interactionNodeDetails[m][5]++;
}
}
//check for additional failure dependencies on incoming interactions
var lastOutgoingSequence = 0;
for(s = 0; s < DependentSourceLifelineIncoming.length; s++)
{
//console.log(DependentSourceLifelineOutgoing[s]);
//find maximum sequence number of outgoing node,
//which is smaller (earlier) than minsequence
//(the previous incoming
//interaction on which m has a failure dependency)
if(DependentSourceLifelineOutgoing[s] < minsequence
&& DependentSourceLifelineOutgoing[s] > lastOutgoingSequence
&& typeof DependentSourceLifelineOutgoing[s] !== 'undefined')
{
//console.log(interactionNodeDetails[s][0]);
//console.log(DependentSourceLifelineOutgoing[s]);
lastOutgoingSequence = DependentSourceLifelineIncoming[s];
}
}
//console.log(lastOutgoingSequence);
//console.log(DependentSourceLifelineIncoming);
//console.log(minsequence);
//console.log(lastOutgoingSequence);
for(r = 0; r < DependentSourceLifelineIncoming.length; r++)
{
//Find interactions with sequence numbers that
//are smaller (earlier) than minsequence
//(the previous incoming
//interaction on which m has a failure dependency)
// and larger than the last outgoing sequence.
if(DependentSourceLifelineIncoming[r] < minsequence
&& DependentSourceLifelineIncoming[r] > lastOutgoingSequence
&& DependentSourceLifelineIncoming[r] != null)
{
interactionnodesBBN[m].addParent(interactionnodesBBN[r]);
//increase number of dependencies for this nodes
interactionNodeDetails[m][5]++;
//console.log(interactionnodesBBN[parentInteractionNodeID]);
//console.log('$$$' + interactionNodeDetails[r][0] + '####' + interactionNodeDetails[m][0])
if (interactionNodeDetails[r][8] === 'opt')
{
interactionNodeDetails[m][10] = 'optparent';
console.log('*** ' + interactionNodeDetails[m][0] + '####opt dependent on : ' + interactionNodeDetails[r][0]);
}
}
//if there are no outgoing nodes (lastOutgoingSequence === 0)
//, and there is another incoming node,
//add this node as a parent= interaction m has failure dependency on this node.
if(lastOutgoingSequence === 0 &&
DependentSourceLifelineIncoming[r] < minsequence &&
DependentSourceLifelineIncoming[r] != null)
{
interactionnodesBBN[m].addParent(interactionnodesBBN[r]);
//increase number of dependencies for this nodes
interactionNodeDetails[m][5]++;
//console.log('$$$' + interactionNodeDetails[r][0] + '####' + interactionNodeDetails[m][0])
if (interactionNodeDetails[r][8] === 'opt')
{
interactionNodeDetails[m][10] = 'optparent';
console.log('*** ' + interactionNodeDetails[m][0] + '####opt dependent on: ' + interactionNodeDetails[r][0]);
}
}
//console.log('DependentSourceLifelineIncoming');
//console.log(DependentSourceLifelineIncoming);
//DependentSourceLifelineIncoming.sort(function(a, b){return a-b});
//console.log(DependentSourceLifelineIncoming);
//console.log('DependentSourceLifelineOutgoing');
//console.log(DependentSourceLifelineOutgoing);
//DependentSourceLifelineOutgoing.sort(function(a, b){return a-b});
//console.log(DependentSourceLifelineOutgoing);
}
}
//empty sources DependentSourceLifeline
DependentSourceLifelineIncoming.length = 0;
DependentSourceLifelineOutgoing.length = 0;
//console.log('=====' + interactionNodeDetails[m][0] + 'number or dependencies' + interactionNodeDetails[m][5]);
console.log(interactionnodesBBN[m]);
//CHECK - IS OPTIONAL? (not parent interaction of optional interaction)
//if (interactionNodeDetails[m][8] === 'opt' && interactionNodeDetails[m][10] !== 'optparent')
if (false)
{//does not seem to be supported in jsbayes - only visual representation for now
console.log('optional node: ' + interactionNodeDetails[m][0] + ', number of dependencies: ' + interactionNodeDetails[m][5]);
//CHECK - IS OPTIONAL
//if interaction is dependent on optional interaction node
// nodes that have dep on optional node -> need extra CPT entries
// add CPT state "does not occur"
//set CPT's of interactions - for each failure dependency the number of state combinations is multiplied by 2
switch (interactionNodeDetails[m][5]) {
case 0:
//base values (without parents) - success, failure, does not occur
interactionnodesBBN[m].setCpt([ 0.4, 0.3, 0.4 ]);
break;
case 1:
//first parent is always fragment node
interactionnodesBBN[m].setCpt([
[ 0.4, 0.3, 0.4 ], //parent 1 success
[ 0.3, 0.4, 0.4 ] //parent 1 failure
]);
break;
case 2:
interactionnodesBBN[m].setCpt([
[ 0.4, 0.3, 0.4 ], //parent 1 success, parent 2 success
[ 0.3, 0.4, 0.4 ], //parent 1 failure, parent 2 success
[ 0.3, 0.4, 0.4 ], //parent 1 success, parent 2 failure
[ 0.3, 0.4, 0.4 ] //parent 1 failure, parent 2 failure
]);
break;
case 3:
interactionnodesBBN[m].setCpt([
[ 0.4, 0.3, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ]
]);
break;
case 4:
interactionnodesBBN[m].setCpt([
[ 0.4, 0.3, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ]
]);
break;
case 5:
interactionnodesBBN[m].setCpt([
[ 0.4, 0.3, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ],
[ 0.3, 0.4, 0.4 ]
]);
break;
default:
interactionnodesBBN[m].setCpt([
[ 0.4, 0.3, 0.4 ], //parent 1 success
[ 0.3, 0.4, 0.4 ] //parent 1 failure
]);
}
}
//else if (interactionNodeDetails[m][8] === 'opt' && interactionNodeDetails[m][10] === 'optparent')
else if (false)
{//does not seem to be supported in jsbayes - only visual representation for now
console.log('optional node + parent of optional node: ' + interactionNodeDetails[m][0] + ', number of dependencies: ' + interactionNodeDetails[m][5]);
//node has parent that is optional - 1 extra state next to success and failure
switch (interactionNodeDetails[m][5]) {
case 0:
//success, failure, does not occur
interactionnodesBBN[m].setCpt([ 0.8, 0.1, 0.1 ]);
break;
case 1:
interactionnodesBBN[m].setCpt([
[ 0.8, 0.1, 0.1 ], //parent 1 success
[ 0.1, 0.8, 0.1 ], //parent 1 failure
[ 0.1, 0.1, 0.8 ] //parent 1 does not occur
]);
break;
case 2:
interactionnodesBBN[m].setCpt([
[ 0.8, 0.1, 0.1 ], //parent 1 success, parent 2 success
[ 0.1, 0.8, 0.1 ], //parent 1 failure, parent 2 success
[ 0.1, 0.1, 0.8 ], //parent 1 does not occur, parent 2 success
[ 0.1, 0.8, 0.1 ], //parent 1 success, parent 2 failure
[ 0.1, 0.8, 0.1 ], //parent 1 failure, parent 2 failure
[ 0.1, 0.1, 0.8 ] //parent 1 does not occur, parent 2 failure
]);
case 3:
interactionnodesBBN[m].setCpt([
[ 0.8, 0.1, 0.1 ], //parent 1 success, parent 2 success
[ 0.1, 0.8, 0.1 ], //parent 1 failure, parent 2 success
[ 0.1, 0.1, 0.8 ], //parent 1 does not occur, parent 2 success
[ 0.1, 0.8, 0.1 ], //parent 1 success, parent 2 failure
[ 0.1, 0.8, 0.1 ], //parent 1 failure, parent 2 failure
[ 0.8, 0.1, 0.1 ], //parent 1 success, parent 2 success
[ 0.1, 0.8, 0.1 ], //parent 1 failure, parent 2 success
[ 0.1, 0.1, 0.8 ], //parent 1 does not occur, parent 2 success
[ 0.1, 0.8, 0.1 ], //parent 1 success, parent 2 failure
[ 0.1, 0.8, 0.1 ] //parent 1 failure, parent 2 failure
]);
/*
interactionnodesBBN[m].setCpt([
[ 0.9, 0.1],
[ 0.01, 0.99 ],
[ 0.99, 0.01 ],
[ 0.9, 0.1],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.9, 0.1],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.9, 0.1],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ]
]);
*/
break;
case 4:
interactionnodesBBN[m].setCpt([
[ 0.8, 0.1, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ]
]);
break;
case 5:
interactionnodesBBN[m].setCpt([
[ 0.8, 0.1, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.8, 0.1 ],
[ 0.1, 0.1, 0.8 ]
]);
break;
default:
interactionnodesBBN[m].setCpt([
[ 0.8, 0.1, 0.1 ], //parent 1 success
[ 0.1, 0.8, 0.1 ], //parent 1 failure
[ 0.1, 0.1, 0.8 ] //parent 1 does not occur
]);
}
}
else if (interactionNodeDetails[m][10] === 'optparent')
{
console.log('parent of optional node: ' + interactionNodeDetails[m][0] + ', number of dependencies: ' + interactionNodeDetails[m][5]);
//interactionNodeDetails[m][5];
//node has parent that is optional - 1 extra state next to success and failure
switch (interactionNodeDetails[m][5]) {
case 0:
//success, failure
interactionnodesBBN[m].setCpt([ 0.99, 0.01 ]);
break;
case 1:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ], //parent 1 success
[ 0.01, 0.99 ], //parent 1 failure
[ 0.99, 0.01 ] //parent 1 does not occur
]);
break;
case 2:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ], //parent 1 success, parent 2 succes
[ 0.99, 0.01 ], //parent 1 failure, parent 2 succes
[ 0.99, 0.01 ], //parent 1 does not occur, parent 2 succes
[ 0.01, 0.99 ], //parent 1 success, parent 2 failure
[ 0.01, 0.99 ], //parent 1 failure, parent 2 failure
[ 0.01, 0.99 ] //parent 1 does not occur, parent 2 failure
]);
break;
case 3:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ],
[ 0.99, 0.01 ],
[ 0.99, 0.01 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ]
]);
break;
case 4:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ],
[ 0.01, 0.99 ],
[ 0.99, 0.01 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.1, 0.1 ],
[ 0.01, 0.99 ],
[ 0.1, 0.1 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ]
]);
break;
case 5:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ],
[ 0.01, 0.99 ],
[ 0.99, 0.01 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.1, 0.1 ],
[ 0.01, 0.99 ],
[ 0.1, 0.1 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.1, 0.1 ],
[ 0.01, 0.99 ],
[ 0.1, 0.1 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ],
[ 0.01, 0.99 ]
]);
break;
default:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ], //parent 1 success
[ 0.01, 0.99 ], //parent 1 failure
[ 0.99, 0.01 ] //parent 1 does not occur
]);
}
}
else{
console.log('interaction node: ' + interactionNodeDetails[m][0] + ', number of dependencies: ' + interactionNodeDetails[m][5])
//set CPT's of interactions - for each failure dependency the number of state combinations is multiplied by 2
switch (interactionNodeDetails[m][5]) {
case 0:
//success, failure
interactionnodesBBN[m].setCpt([ 0.99, 0.01 ]);
break;
case 1:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ], //parent 1 success
[ 0.01, 0.99 ] //parent 1 failure
]);
break;
case 2:
interactionnodesBBN[m].setCpt([
[ 0.9, 0.1], //parent 1 success, parent 2 success
[ 0.01, 0.99 ], //parent 1 success, parent 2 failure
[ 0.01, 0.99 ], //parent 1 failure, parent 2 success
[ 0.01, 0.99 ] //parent 1 failure, parent 2 failure
]);
break;
case 3:
interactionnodesBBN[m].setCpt([
[ 0.99, 0.01 ],