Search in sources :

Example 6 with NoGood

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

the class HeapOfActiveAtoms method newNoGoods.

/**
 * Stores newly grounded {@link NoGood}s and updates associated activity counters.
 */
public void newNoGoods(Collection<NoGood> newNoGoods) {
    for (NoGood newNoGood : newNoGoods) {
        Type type = newNoGood.getType();
        if (type != Type.LEARNT && type != Type.INTERNAL) {
            analyzeNewNoGood(newNoGood);
            initActivity(newNoGood);
        }
    }
}
Also used : Type(at.ac.tuwien.kr.alpha.core.common.NoGoodInterface.Type) NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood)

Example 7 with NoGood

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

the class BerkMinTest method reachDecayPeriodTwice.

@Test
public void reachDecayPeriodTwice() {
    berkmin.setDecayPeriod(2);
    berkmin.setDecayFactor(0.75);
    NoGood violatedNoGood = new NoGood(fromOldLiterals(1, 2));
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(1, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(1, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(1.5, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(1.5, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(2.5, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(2.5, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(2.625, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(2.625, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 8 with NoGood

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

the class BerkMinTest method countPositiveLiteralsOnce.

@Test
public void countPositiveLiteralsOnce() {
    NoGood violatedNoGood = new NoGood(fromOldLiterals(1, 2));
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(1, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(1, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 9 with NoGood

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

the class BerkMinTest method countPositiveLiteralsTwice.

@Test
public void countPositiveLiteralsTwice() {
    NoGood violatedNoGood = new NoGood(fromOldLiterals(1, 2));
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(2, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(2, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) Test(org.junit.jupiter.api.Test)

Example 10 with NoGood

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

the class BerkMinTest method countPositiveLiteralsThenNegativeLiterals.

@Test
public void countPositiveLiteralsThenNegativeLiterals() {
    NoGood violatedNoGood = new NoGood(fromOldLiterals(1, 2));
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    violatedNoGood = new NoGood(fromOldLiterals(-1, -2));
    berkmin.violatedNoGood(violatedNoGood);
    berkmin.analyzedConflict(pseudo(violatedNoGood));
    assertEquals(2, berkmin.getActivity(fromOldLiterals(1)), DOUBLE_COMPARISON_EPSILON);
    assertEquals(2, berkmin.getActivity(fromOldLiterals(2)), DOUBLE_COMPARISON_EPSILON);
}
Also used : NoGood(at.ac.tuwien.kr.alpha.core.common.NoGood) 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