Search in sources :

Example 91 with NoGood

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

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