ApproxLP occasionally produces NaN results for queries that are solvable.
Consider this code:
double eps = 0.000000001; // eps > 0. If set to 0.0, the inference will not work.
DAGModel model = new DAGModel();
int x = model.addVariable(2);
int u = model.addVariable(3);
model.addParent(x,u);
BayesianFactor ifx = new BayesianFactor(model.getDomain(x,u));
ifx.setData(new double[] {
1., 0.,
1., 0.,
0., 1.,
});
model.setFactor(x, ifx);
IntervalFactor ifu = new IntervalFactor(model.getDomain(u), model.getDomain());
ifu.set(new double[] { 0, 0, 0.8-eps}, new double[] { 0.2, 0.2, 0.8 });
model.setFactor(u, ifu);
for(int i=0;i<100;i++) {
ApproxLP2 inference = new ApproxLP2();
double[] upper = inference.query(model, x).getUpper();
System.out.println(Arrays.toString(upper));
}
The out would be:
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[NaN, NaN]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
[0.20000000099999993, 0.8]
...
``
ApproxLP occasionally produces NaN results for queries that are solvable.
Consider this code:
The out would be: