Search in sources :

Example 56 with NoGood

use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.

the class NoGoodStoreAlphaRoamingTest method naryNoGoodPropagatesTrueFromFalse.

@Test
public void naryNoGoodPropagatesTrueFromFalse() {
    NoGood noGood = headFirst(fromOldLiterals(-1, 2, -3));
    assertNull(store.add(10, noGood));
    assertNull(assignment.assign(2, TRUE));
    store.propagate();
    assertNull(assignment.assign(3, FALSE));
    store.propagate();
    assertEquals(TRUE, assignment.getTruth(1));
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 57 with NoGood

use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.

the class NoGoodStoreAlphaRoamingTest method binaryNoGoodViolatedAfterAddition.

@Test
public void binaryNoGoodViolatedAfterAddition() {
    NoGood noGood = new NoGood(fromOldLiterals(1, 2));
    assertNull(store.add(11, noGood));
    assertNull(assignment.assign(1, MBT));
    assertNull(assignment.assign(2, MBT));
    assertNotNull(store.propagate());
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 58 with NoGood

use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.

the class NoGoodStoreAlphaRoamingTest method addedViolatedNaryNoGoodPropagatesAfterBacktracking.

@Test
public void addedViolatedNaryNoGoodPropagatesAfterBacktracking() {
    NoGood noGood = new NoGood(fromOldLiterals(70, 195, 36));
    assertNull(assignment.choose(70, MBT));
    assertNull(assignment.choose(195, MBT));
    assertNull(assignment.choose(36, MBT));
    assertNotNull(store.add(3, noGood));
    assignment.backtrack();
    assertNull(store.add(3, noGood));
    store.propagate();
    assertEquals(FALSE, assignment.getTruth(36));
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 59 with NoGood

use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.

the class NoGoodStoreAlphaRoamingTest method binaryNoGoodPropagatesTrueFromTrue.

@Test
public void binaryNoGoodPropagatesTrueFromTrue() {
    NoGood noGood = headFirst(fromOldLiterals(-11, 12));
    assertNull(store.add(5, noGood));
    assertNull(assignment.choose(12, TRUE));
    store.propagate();
    assertEquals(TRUE, assignment.getTruth(11));
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 60 with NoGood

use of at.ac.tuwien.kr.alpha.core.common.NoGood in project Alpha by alpha-asp.

the class NoGoodStoreAlphaRoamingTest method propagationAtLowerDecisionLevel.

@Test
@Disabled("TrailAssignment no longer propagates at lower decision level.")
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));
    store.propagate();
    assertEquals(TRUE, assignment.getTruth(1));
    Assignment.Entry entry = assignment.get(1);
    assertEquals(TRUE, entry.getTruth());
    assertEquals(2, entry.getDecisionLevel());
}
Also used : Assignment(at.ac.tuwien.kr.alpha.core.common.Assignment) NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

NoGood (at.ac.tuwien.kr.alpha.core.common.NoGood)91 Test (org.junit.jupiter.api.Test)73 Disabled (org.junit.jupiter.api.Disabled)10 TrailAssignment (at.ac.tuwien.kr.alpha.core.solver.TrailAssignment)4 LinkedHashMap (java.util.LinkedHashMap)4 Substitution (at.ac.tuwien.kr.alpha.api.grounder.Substitution)3 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)3 NormalProgram (at.ac.tuwien.kr.alpha.api.programs.NormalProgram)3 Atom (at.ac.tuwien.kr.alpha.api.programs.atoms.Atom)3 BasicSubstitution (at.ac.tuwien.kr.alpha.commons.substitutions.BasicSubstitution)3 RuleAtom (at.ac.tuwien.kr.alpha.core.atoms.RuleAtom)3 AtomStore (at.ac.tuwien.kr.alpha.core.common.AtomStore)3 AtomStoreImpl (at.ac.tuwien.kr.alpha.core.common.AtomStoreImpl)3 StratifiedEvaluation (at.ac.tuwien.kr.alpha.core.programs.transformation.StratifiedEvaluation)3 CompiledRule (at.ac.tuwien.kr.alpha.core.rules.CompiledRule)3 ConflictAnalysisResult (at.ac.tuwien.kr.alpha.core.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult)3 Predicate (at.ac.tuwien.kr.alpha.api.programs.Predicate)2 Literal (at.ac.tuwien.kr.alpha.api.programs.literals.Literal)2 Literals.atomToLiteral (at.ac.tuwien.kr.alpha.core.atoms.Literals.atomToLiteral)2 Literals.atomToNegatedLiteral (at.ac.tuwien.kr.alpha.core.atoms.Literals.atomToNegatedLiteral)2