Search in sources :

Example 1 with Type

use of at.ac.tuwien.kr.alpha.core.common.NoGoodInterface.Type 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 2 with Type

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

the class LearnedNoGoodDeletionTest method testDeletionReducesNumberOfLearntNoGoods.

@Test
public void testDeletionReducesNumberOfLearntNoGoods() {
    for (int i = 0; i < LearnedNoGoodDeletion.RUN_AFTER_AT_LEAST; i++) {
        learnedNoGoodDeletion.increaseConflictCounter();
    }
    assertFalse(learnedNoGoodDeletion.needToRunNoGoodDeletion());
    learnedNoGoodDeletion.increaseConflictCounter();
    assertTrue(learnedNoGoodDeletion.needToRunNoGoodDeletion());
    assertNull(store.add(4, NoGood.learnt(fromOldLiterals(10, 11, 12)), 3));
    assertNull(store.add(5, NoGood.learnt(fromOldLiterals(10, -13, -14)), 4));
    final Map<Type, Integer> countersBeforeDeletion = countNoGoodsByType(store);
    learnedNoGoodDeletion.runNoGoodDeletion();
    final Map<Type, Integer> countersAfterDeletion = countNoGoodsByType(store);
    for (Type type : Type.values()) {
        if (type == Type.LEARNT) {
            assertTrue(countersBeforeDeletion.get(type) > countersAfterDeletion.get(type), "Count of LEARNT nogoods did not decrease during deletion");
        } else {
            assertEquals(countersBeforeDeletion.get(type), countersAfterDeletion.get(type), "Unexpected count of " + type + " nogoods");
        }
    }
}
Also used : Type(at.ac.tuwien.kr.alpha.core.common.NoGoodInterface.Type) Test(org.junit.jupiter.api.Test)

Example 3 with Type

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

the class LearnedNoGoodDeletionTest method countNoGoodsByType.

private Map<Type, Integer> countNoGoodsByType(NoGoodStore store) {
    final Map<Type, Integer> counters = new HashMap<>();
    final NoGoodCounter noGoodCounter = store.getNoGoodCounter();
    for (Type type : Type.values()) {
        counters.put(type, noGoodCounter.getNumberOfNoGoods(type));
    }
    return counters;
}
Also used : Type(at.ac.tuwien.kr.alpha.core.common.NoGoodInterface.Type) HashMap(java.util.HashMap)

Aggregations

Type (at.ac.tuwien.kr.alpha.core.common.NoGoodInterface.Type)3 NoGood (at.ac.tuwien.kr.alpha.core.common.NoGood)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1