use of at.ac.tuwien.kr.alpha.common.NoGood in project Alpha by alpha-asp.
the class AlphaHeuristicTestAssumptions method testIsAtomChoice.
private void testIsAtomChoice(Predicate<? super Integer> isRuleBody) {
Collection<NoGood> noGoods = getNoGoods();
choiceManager.addChoiceInformation(grounder.getChoiceAtoms());
for (NoGood noGood : noGoods) {
for (Integer literal : noGood) {
int atom = atomOf(literal);
String atomToString = grounder.atomToString(atom);
if (atomToString.startsWith("_R_")) {
assertTrue("Atom not choice: " + atomToString, isRuleBody.test(atom));
}
}
}
}
use of at.ac.tuwien.kr.alpha.common.NoGood in project Alpha by alpha-asp.
the class AlphaHeuristicTestAssumptions method testNumbersOfNoGoods.
private void testNumbersOfNoGoods(Predicate<? super Integer> isRuleBody) {
int n = 0;
int bodyNotHead = 0;
int bodyElementsNotBody = 0;
int noHead = 0;
int other = 0;
Collection<NoGood> noGoods = getNoGoods();
choiceManager.addChoiceInformation(grounder.getChoiceAtoms());
for (NoGood noGood : noGoods) {
n++;
boolean knownType = false;
if (noGood.isBodyNotHead(isRuleBody)) {
bodyNotHead++;
knownType = true;
}
if (noGood.isBodyElementsNotBody(isRuleBody)) {
bodyElementsNotBody++;
knownType = true;
}
if (!noGood.hasHead()) {
noHead++;
knownType = true;
}
if (!knownType) {
other++;
}
}
assertEquals("Unexpected number of bodyNotHead nogoods", 1, bodyNotHead);
assertEquals("Unexpected number of bodyElementsNotBody nogoods", 1, bodyElementsNotBody);
assertGreaterThan("Unexpected number of nogoods without head", 4, noHead);
// there may be other nogoods (e.g. for ChoiceOn, ChoiceOff) which we do not care for here
System.out.println("Total number of NoGoods: " + n);
System.out.println("Number of NoGoods of unknown type: " + other);
}
use of at.ac.tuwien.kr.alpha.common.NoGood in project Alpha by alpha-asp.
the class BerkMinTest method reachDecayAgeOnce.
@Test
public void reachDecayAgeOnce() {
berkmin.setDecayAge(3);
berkmin.setDecayFactor(1.0 / 3);
NoGood violatedNoGood = new NoGood(1, 2);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(1, berkmin.getActivity(1), EPSILON);
assertEquals(1, berkmin.getActivity(2), EPSILON);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(2, berkmin.getActivity(1), EPSILON);
assertEquals(2, berkmin.getActivity(2), EPSILON);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(1, berkmin.getActivity(1), EPSILON);
assertEquals(1, berkmin.getActivity(2), EPSILON);
}
use of at.ac.tuwien.kr.alpha.common.NoGood in project Alpha by alpha-asp.
the class BerkMinTest method countNegativeLiteralsTwice.
@Test
public void countNegativeLiteralsTwice() {
NoGood violatedNoGood = new NoGood(-1, -2);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(2, berkmin.getActivity(-1), EPSILON);
assertEquals(2, berkmin.getActivity(-2), EPSILON);
}
use of at.ac.tuwien.kr.alpha.common.NoGood in project Alpha by alpha-asp.
the class BerkMinTest method reachDecayAgeTwice.
@Test
public void reachDecayAgeTwice() {
berkmin.setDecayAge(2);
berkmin.setDecayFactor(0.75);
NoGood violatedNoGood = new NoGood(1, 2);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(1, berkmin.getActivity(1), EPSILON);
assertEquals(1, berkmin.getActivity(2), EPSILON);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(1.5, berkmin.getActivity(1), EPSILON);
assertEquals(1.5, berkmin.getActivity(2), EPSILON);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(2.5, berkmin.getActivity(1), EPSILON);
assertEquals(2.5, berkmin.getActivity(2), EPSILON);
berkmin.violatedNoGood(violatedNoGood);
berkmin.analyzedConflict(pseudo(violatedNoGood));
assertEquals(2.625, berkmin.getActivity(1), EPSILON);
assertEquals(2.625, berkmin.getActivity(2), EPSILON);
}
Aggregations