Inconsistency between the lists variablesToEliminate and nodesToEliminate in EliminationHeuristic

Create issue
Issue #227 resolved
Miguel Ángel Artaso Landa created an issue

In the class EliminationHeuristic there is an slight inconsistency between the creation of the lists of lists variablesToEliminate and nodesToEliminate. It may not affect the heuristics, but I think we should create both lists in the same way.

In the 'for' clause that starts in line number 60, the code is as follows:

List<Variable> listOfVariables = new ArrayList<Variable>(list.size());
for(Variable variable : list)

So it may happen that a list is created empty.

Then, in the creation of nodesToEliminate, we find the following code

List<Node> nodes = new ArrayList<>(variables.size());
for(Variable variable : variables)
    if (nodes.size()>0){

So the list of nodes to eliminate is only added to the list of lists if it is not empty.

Similarly, in the undoableEditHappened class, we find this piece of code:

if (listIndex >= 0) {
if(variablesToEliminate.get(listOfListsIndex).isEmpty()) {
if (listIndex >= 0) {
    if (nodesToEliminate.get(listOfListsIndex).isEmpty()) {

Where the items in the lists of lists are not removed exactly in the same conditions.

As stated at the beginning of the issue, it may not affect the heuristics as it is related to the network. But maybe there appears a network which inference might fail.

Comments (2)

  1. Miguel Ángel Artaso Landa reporter

    EliminationHeuristic class has been adapted so now both lists are created consistently one with each other

  2. Log in to comment