use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method addedBinaryNoGoodPropagatesTrueFromTrue.
@Test
public void addedBinaryNoGoodPropagatesTrueFromTrue() {
NoGood noGood = headFirst(fromOldLiterals(-11, 12));
assertNull(assignment.choose(12, TRUE));
assertNull(store.add(5, noGood));
store.propagate();
assertEquals(TRUE, assignment.getTruth(11));
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method conflictingBinary.
@Test
@Disabled("Checks for conflict detection in add.")
public void conflictingBinary() {
final NoGood noGood = new NoGood(fromOldLiterals(1, 2));
assignment.assign(1, TRUE);
assignment.assign(2, 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 propagationAtLowerDecisionLevel.
@Test
@Disabled("Not decision-level aware.")
public void propagationAtLowerDecisionLevel() {
NoGood noGood = headFirst(fromOldLiterals(-1, 2, -3));
assertNull(assignment.choose(3, FALSE));
assertNull(assignment.choose(2, TRUE));
assertNull(assignment.choose(4, TRUE));
assertNull(store.add(10, noGood));
assertNull(store.propagate());
assertEquals(TRUE, assignment.getTruth(1));
Assignment.Entry entry = assignment.get(1);
assertEquals(TRUE, entry.getTruth());
assertEquals(2, entry.getDecisionLevel());
}
use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.
the class NaiveNoGoodStoreTest method binaryNoGoodViolatedDuringAdditionAllTrue.
@Test
@Disabled("Checks for conflict detection in add.")
public void binaryNoGoodViolatedDuringAdditionAllTrue() {
NoGood noGood = new NoGood(fromOldLiterals(1, 2));
assertNull(assignment.assign(1, TRUE));
assertNull(assignment.assign(2, TRUE));
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 DefaultSolver method learnFromConflict.
private void learnFromConflict(ConflictCause conflictCause) {
LOGGER.debug("Violating assignment is: {}", assignment);
Antecedent conflictAntecedent = conflictCause.getAntecedent();
NoGood violatedNoGood = new NoGood(conflictAntecedent.getReasonLiterals().clone());
// TODO: The violatedNoGood should not be necessary here, but this requires major type changes in heuristics.
branchingHeuristic.violatedNoGood(violatedNoGood);
if (searchState.afterAllAtomsAssigned) {
LOGGER.debug("Assignment is violated after all unassigned atoms have been assigned false.");
conflictsAfterClosing++;
if (!treatConflictAfterClosing(conflictAntecedent)) {
searchState.isSearchSpaceCompletelyExplored = true;
}
searchState.afterAllAtomsAssigned = false;
} else {
if (!learnBackjumpAddFromConflict(conflictCause)) {
searchState.isSearchSpaceCompletelyExplored = true;
}
}
}
Aggregations