use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class GroundConflictNoGoodLearnerTest method smallConflictNonTrivial1UIP.
@Test
public void smallConflictNonTrivial1UIP() {
GroundConflictNoGoodLearner learner = new GroundConflictNoGoodLearner(assignment, atomStore);
NoGood n1 = new NoGood(fromOldLiterals(2, -8, 1));
NoGood n2 = new NoGood(fromOldLiterals(-1, -7));
NoGood n3 = new NoGood(fromOldLiterals(-3, 1));
NoGood n4 = new NoGood(fromOldLiterals(5, 3));
NoGood n5 = new NoGood(fromOldLiterals(6, -5));
NoGood n6 = new NoGood(fromOldLiterals(4, -2));
NoGood n7 = new NoGood(fromOldLiterals(-6, -4));
store.add(10, n1);
store.add(11, n2);
store.add(12, n3);
store.add(13, n4);
store.add(14, n5);
store.add(15, n6);
store.add(16, n7);
assignment.choose(9, ThriceTruth.TRUE);
assignment.choose(8, ThriceTruth.FALSE);
assertNull(store.propagate());
assertFalse(store.didPropagate());
assignment.choose(7, ThriceTruth.FALSE);
ConflictCause conflictCause = store.propagate();
assertTrue(store.didPropagate());
assertNotNull(conflictCause);
Antecedent violatedNoGood = conflictCause.getAntecedent();
assertNotNull(violatedNoGood);
assertTrue(antecedentsEquals(violatedNoGood, n5.asAntecedent()) || antecedentsEquals(violatedNoGood, n7.asAntecedent()));
GroundConflictNoGoodLearner.ConflictAnalysisResult analysisResult = learner.analyzeConflictingNoGood(conflictCause.getAntecedent());
NoGood learnedNoGood = analysisResult.learnedNoGood;
assertEquals(new NoGood(fromOldLiterals(1, -8)), learnedNoGood);
int backjumpingDecisionLevel = analysisResult.backjumpLevel;
assertEquals(backjumpingDecisionLevel, 2);
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method conflictingNary.
@Test
@Disabled("Checks for conflict detection in add.")
public void conflictingNary() {
final NoGood noGood = new NoGood(fromOldLiterals(1, 2, 3));
assignment.assign(1, TRUE);
assignment.assign(2, TRUE);
assignment.assign(3, TRUE);
ConflictCause conflictCause = store.add(1, noGood);
assertTrue(antecedentsEquals(noGood.asAntecedent(), conflictCause.getAntecedent()));
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method naryNoGoodViolatedDuringAdditionAllMbt.
@Test
@Disabled("Checks for conflict detection in add.")
public void naryNoGoodViolatedDuringAdditionAllMbt() {
NoGood noGood = new NoGood(fromOldLiterals(1, 2, 3));
assertNull(assignment.assign(1, MBT));
assertNull(assignment.assign(2, MBT));
assertNull(assignment.assign(3, MBT));
ConflictCause conflictCause = store.add(11, noGood);
assertNotNull(conflictCause);
assertNotNull(conflictCause.getAntecedent());
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method propagateBinaryMBTTwiceOutofSync.
@Test
public void propagateBinaryMBTTwiceOutofSync() {
store.add(1, new NoGood(fromOldLiterals(-1, 2)));
store.add(2, new NoGood(fromOldLiterals(-3, 1)));
assignment.assign(2, MBT);
store.propagate();
assertEquals(MBT, assignment.getTruth(1));
assertEquals(MBT, assignment.getTruth(3));
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method naryNoGoodViolatedAfterAddition.
@Test
public void naryNoGoodViolatedAfterAddition() {
NoGood noGood = new NoGood(fromOldLiterals(1, 2, 3));
assertNull(store.add(11, noGood));
assertNull(assignment.assign(1, MBT));
assertNull(assignment.assign(2, MBT));
assertNull(assignment.assign(3, MBT));
assertNotNull(store.propagate());
}
Aggregations