Search in sources :

Example 1 with ConflictCause

use of at.ac.tuwien.kr.alpha.core.solver.ConflictCause in project Alpha by alpha-asp.

the class GroundConflictNoGoodLearnerTest method subCurrentDLPropagationWithChoiceCauseOfConflict.

@Test
@Disabled("TrailAssignment no longer propagates at lower decision level.")
public void subCurrentDLPropagationWithChoiceCauseOfConflict() {
    GroundConflictNoGoodLearner learner = new GroundConflictNoGoodLearner(assignment, atomStore);
    NoGood n1 = new NoGood(fromOldLiterals(1, -2));
    NoGood n2 = new NoGood(fromOldLiterals(2, 3));
    store.add(10, n1);
    assignment.choose(1, ThriceTruth.TRUE);
    assignment.choose(3, ThriceTruth.TRUE);
    store.propagate();
    assertEquals(ThriceTruth.MBT, assignment.get(2).getTruth());
    assertEquals(1, assignment.get(2).getDecisionLevel());
    ConflictCause conflictCause = store.add(11, n2);
    assertNotNull(conflictCause);
    assertNotNull(conflictCause.getAntecedent());
    GroundConflictNoGoodLearner.ConflictAnalysisResult conflictAnalysisResult = learner.analyzeConflictingNoGood(conflictCause.getAntecedent());
    assertNull(conflictAnalysisResult.learnedNoGood);
    assertEquals(2, conflictAnalysisResult.backjumpLevel);
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) ConflictCause(at.ac.tuwien.kr.alpha.core.solver.ConflictCause) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 2 with ConflictCause

use of at.ac.tuwien.kr.alpha.core.solver.ConflictCause 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);
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) ConflictCause(at.ac.tuwien.kr.alpha.core.solver.ConflictCause) Antecedent(at.ac.tuwien.kr.alpha.core.solver.Antecedent) Test(org.junit.jupiter.api.Test)

Aggregations

NoGood (at.ac.tuwien.kr.alpha.core.common.NoGood)2 ConflictCause (at.ac.tuwien.kr.alpha.core.solver.ConflictCause)2 Test (org.junit.jupiter.api.Test)2 Antecedent (at.ac.tuwien.kr.alpha.core.solver.Antecedent)1 Disabled (org.junit.jupiter.api.Disabled)1