use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class BerkMinTest method countNegativeLiteralsOnce.
@Test
public void countNegativeLiteralsOnce() {
NoGood violatedNoGood = new NoGood(fromOldLiterals(-1, -2));
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(1, berkmin.getActivity(fromOldLiterals(-1)), DOUBLE_COMPARISON_EPSILON);
assertEquals(1, berkmin.getActivity(fromOldLiterals(-2)), DOUBLE_COMPARISON_EPSILON);
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class BerkMinTest method learnNoGood.
@Test
public void learnNoGood() {
NoGood learnedNoGood = NoGood.learnt(fromOldLiterals(1, 2));
int backjumpLevel = 1;
@SuppressWarnings("unused") boolean clearLastChoiceAfterBackjump = true;
Collection<Integer> resolutionAtoms = Collections.emptySet();
berkmin.analyzedConflict(new ConflictAnalysisResult(learnedNoGood, backjumpLevel, resolutionAtoms));
assertEquals(learnedNoGood, berkmin.getCurrentTopClause());
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class HeapOfActiveAtomsTest method testAllAtomsEqualScore.
@Test
public void testAllAtomsEqualScore() {
int lit1 = Literals.atomToLiteral(1);
int lit2 = Literals.atomToLiteral(2);
int lit3 = Literals.atomToLiteral(3);
HeuristicTestUtils.addNoGoods(atomStore, assignment, noGoodStore, vsids, new NoGood(lit1, lit2), new NoGood(lit2, lit3), new NoGood(lit1, lit3));
double activity1 = vsids.heapOfActiveAtoms.getActivity(lit1);
double activity2 = vsids.heapOfActiveAtoms.getActivity(lit2);
double activity3 = vsids.heapOfActiveAtoms.getActivity(lit3);
assertEquals(activity1, activity2, DOUBLE_COMPARISON_EPSILON);
assertEquals(activity2, activity3, DOUBLE_COMPARISON_EPSILON);
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class HeapOfActiveAtomsTest method testOneAtomHigherScore.
@Test
public void testOneAtomHigherScore() {
int lit1 = Literals.atomToLiteral(1);
int lit2 = Literals.atomToLiteral(2);
int lit3 = Literals.atomToLiteral(3);
int lit1Neg = Literals.atomToLiteral(1, false);
int lit2Neg = Literals.atomToLiteral(2, false);
int lit3Neg = Literals.atomToLiteral(3, false);
HeuristicTestUtils.addNoGoods(atomStore, assignment, noGoodStore, vsids, new NoGood(lit1, lit2Neg), new NoGood(lit1Neg, lit2), new NoGood(lit2, lit3Neg), new NoGood(lit2Neg, lit3));
double activity1 = vsids.heapOfActiveAtoms.getActivity(lit1);
double activity2 = vsids.heapOfActiveAtoms.getActivity(lit2);
double activity3 = vsids.heapOfActiveAtoms.getActivity(lit3);
assertLessThan(activity1, activity2);
assertLessThan(activity3, activity2);
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class VSIDSTest method testConflict.
/**
* Tests the following artificial situation:
* Static nogoods: { {-1, -2}, {-3, -4}}
* Learnt nogood: { 2, 3 }
* Atoms resolved out during conflict analysis: { 1 }
*/
@Test
public void testConflict() {
HeuristicTestUtils.addNoGoods(atomStore, assignment, noGoodStore, vsids, new NoGood(lit1Neg, lit2Neg), new NoGood(lit3Neg, lit4Neg));
// to make VSIDS ingest buffered nogoods
vsids.chooseLiteral();
assertEquals(vsids.getActivity(lit1), vsids.getActivity(lit2), DOUBLE_COMPARISON_EPSILON);
assertEquals(vsids.getActivity(lit2), vsids.getActivity(lit3), DOUBLE_COMPARISON_EPSILON);
assertEquals(vsids.getActivity(lit3), vsids.getActivity(lit4), DOUBLE_COMPARISON_EPSILON);
NoGood learnedNoGood = new NoGood(lit2, lit3);
Collection<Integer> resolutionAtoms = Arrays.asList(1);
ConflictAnalysisResult analysisResult = new ConflictAnalysisResult(learnedNoGood, 1, resolutionAtoms);
vsids.analyzedConflict(analysisResult);
assertEquals(vsids.getActivity(lit1), vsids.getActivity(lit2), DOUBLE_COMPARISON_EPSILON);
assertEquals(vsids.getActivity(lit2), vsids.getActivity(lit3), DOUBLE_COMPARISON_EPSILON);
assertLessThan(vsids.getActivity(lit4), vsids.getActivity(lit3));
assertEquals(0, vsids.getSignBalance(1));
assertEquals(1, vsids.getSignBalance(2));
assertEquals(1, vsids.getSignBalance(3));
assertEquals(0, vsids.getSignBalance(4));
}
Aggregations