use of at.ac.tuwien.kr.alpha.core.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult 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.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult 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));
}
use of at.ac.tuwien.kr.alpha.core.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult in project Alpha by alpha-asp.
the class VSIDSTest method testTwoConflicts.
/**
* First, calls {@link #testConflict()}.
* Then, simulates a second conflict, learning { -1, 4 } with resolved atoms { 2 }.
* Due to decay, scores of atoms { 1, 4, 2 } must increase by the increased activity delta of {@link VSIDS#DEFAULT_DECAY_FACTOR}.
*/
@Test
public void testTwoConflicts() {
testConflict();
double activity1 = vsids.getActivity(lit1);
double activity2 = vsids.getActivity(lit2);
double activity3 = vsids.getActivity(lit3);
double activity4 = vsids.getActivity(lit4);
NoGood learnedNoGood = new NoGood(lit1Neg, lit4);
Collection<Integer> resolutionAtoms = Arrays.asList(2);
ConflictAnalysisResult analysisResult = new ConflictAnalysisResult(learnedNoGood, 1, resolutionAtoms);
vsids.analyzedConflict(analysisResult);
assertEquals(activity1 + VSIDS.DEFAULT_DECAY_FACTOR, vsids.getActivity(lit1), DOUBLE_COMPARISON_EPSILON);
assertEquals(activity2 + VSIDS.DEFAULT_DECAY_FACTOR, vsids.getActivity(lit2), DOUBLE_COMPARISON_EPSILON);
assertEquals(activity3, vsids.getActivity(lit3), DOUBLE_COMPARISON_EPSILON);
assertEquals(activity4 + VSIDS.DEFAULT_DECAY_FACTOR, vsids.getActivity(lit4), DOUBLE_COMPARISON_EPSILON);
assertEquals(-1, vsids.getSignBalance(1));
assertEquals(1, vsids.getSignBalance(2));
assertEquals(1, vsids.getSignBalance(3));
assertEquals(1, vsids.getSignBalance(4));
}
Aggregations