-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJunctionTree.ts
46 lines (36 loc) · 1.68 KB
/
JunctionTree.ts
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
import BayesianNetwork from "../BayesianNetwork/BayesianNetwork";
import GraphicalTransformer from "./lib/GraphicalTransformer";
import Initializer from "./lib/Initializer";
import Forest from "../GraphicalStructures/Forest";
import { IClique, ISepSet, IEntity, IPotential } from "../types";
import Propagater from "./lib/Propagater";
export default class JunctionTree {
private entityMap: Map<string, IEntity>;
private consistentJunctionTree: Forest<IClique | ISepSet>;
constructor(bnet: BayesianNetwork) {
this.entityMap = bnet.getEntityMap();
// Graphical Transformation of bayesnet into Optimized Junction Tree
const optimizedJunctionTree = this.transform(bnet);
// Initialization to create an Inconsistent Junction Tree
const inconsistentJunctionTree = this.initialize(optimizedJunctionTree);
// Propagation to create a Consistent Junction Tree
this.consistentJunctionTree = this.propogate(inconsistentJunctionTree);
}
private transform(bnet: BayesianNetwork): Forest<IClique | ISepSet> {
const graphicalTransformer = new GraphicalTransformer(bnet);
return graphicalTransformer.getOptimizedJunctionTree();
}
private initialize(
optimizedJunctionTree: Forest<IClique | ISepSet>
): Forest<IClique | ISepSet> {
const initializer = new Initializer(optimizedJunctionTree, this.entityMap);
return initializer.getInconsistentJunctionTree();
}
private propogate(inconsistentJunctionTree: Forest<IClique | ISepSet>) {
const propagater = new Propagater(inconsistentJunctionTree);
return propagater.getConsistentJunctionTree();
}
public getConsistentJunctionTree(): Forest<IClique | ISepSet> {
return this.consistentJunctionTree;
}
}