@Test public void test() throws Exception { try { HuginInferenceExample.main(null); }catch (UnsatisfiedLinkError err) { }catch (NoClassDefFoundError ex) { } }
public static void main(String[] args) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new HuginInference(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW, 0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<3.5 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 3.5) ? 1.0 : 0.0)); }
HuginInferenceExample { public static void main(String[] args) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new HuginInference(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW, 0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<3.5 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 3.5) ? 1.0 : 0.0)); } }
HuginInferenceExample { public static void main(String[] args) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new HuginInference(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW, 0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<3.5 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 3.5) ? 1.0 : 0.0)); }  }
HuginInferenceExample { public static void main(String[] args) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new HuginInference(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW, 0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<3.5 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 3.5) ? 1.0 : 0.0)); }  static void main(String[] args); }
HuginInferenceExample { public static void main(String[] args) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new HuginInference(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW, 0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<3.5 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 3.5) ? 1.0 : 0.0)); }  static void main(String[] args);  }