Skip to content

Commit

Permalink
Use atom indices from atom store as much as possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
dickensc committed Aug 29, 2023
1 parent 9a5f80e commit 7400761
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,6 @@ protected void fixLabeledRandomVariables() {
continue;
}

observedAtom.setIndex(atomIndex);
randomVariableAtom.setIndex(atomIndex);

atomStore.getAtoms()[atomIndex] = observedAtom;
atomStore.getAtomValues()[atomIndex] = observedAtom.getValue();
latentInferenceAtomValueState[atomIndex] = observedAtom.getValue();
Expand All @@ -730,8 +727,6 @@ protected void unfixLabeledRandomVariables() {
continue;
}

randomVariableAtom.setIndex(atomIndex);

atomStore.getAtoms()[atomIndex] = randomVariableAtom;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ protected synchronized void addAtomInternal(GroundAtom atom) {
atomValues[numAtoms] = atom.getValue();
lookup.put(atom, numAtoms);
connectedComponentsAtomIndexes.put(numAtoms, new ArrayList<Integer>());
connectedComponentsAtomIndexes.get(numAtoms).add(atom.getIndex());
connectedComponentsAtomIndexes.get(numAtoms).add(numAtoms);

if (atom instanceof RandomVariableAtom) {
maxRVAIndex = numAtoms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ public int getIndex() {
return index;
}

public void setIndex(int index) {
this.index = index;
}

public int getParent() {
return parent;
}

public boolean isFixed() { return fixed; }

public void setIndex(int index) {
this.index = index;
}

public void setParent(int parent) {
this.parent = parent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected static void primalVariableComponentUpdate(DualLCQPTermStore termStore,
continue;
}

atomValues[atom.getIndex()] = termStore.getDualLCQPAtom(atom.getIndex()).getPrimal(regularizationParameter);
atomValues[atomIndex] = termStore.getDualLCQPAtom(atomIndex).getPrimal(regularizationParameter);
}
}

Expand Down Expand Up @@ -500,7 +500,7 @@ private static double computePrimalVariableComponentRegularization(TermStore<Dua
continue;
}

atomValueRegularization += regularizationParameter * Math.pow(atomValues[atom.getIndex()], 2.0);
atomValueRegularization += regularizationParameter * Math.pow(atomValues[atomIndex], 2.0);
}

return atomValueRegularization;
Expand Down Expand Up @@ -533,8 +533,8 @@ private static ObjectiveResult computeComponentDualObjective(DualLCQPTermStore t
continue;
}

objectiveValue += dualLCQPAtoms[atom.getIndex()].getLowerBoundObjective(regularizationParameter);
objectiveValue += dualLCQPAtoms[atom.getIndex()].getUpperBoundObjective(regularizationParameter);
objectiveValue += dualLCQPAtoms[atomIndex].getLowerBoundObjective(regularizationParameter);
objectiveValue += dualLCQPAtoms[atomIndex].getUpperBoundObjective(regularizationParameter);
}

return new ObjectiveResult((float)(-0.5 * objectiveValue), 0);
Expand Down

0 comments on commit 7400761

Please sign in to comment.