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);
}
}
}
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");
}
}
}
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;
}