Skip to content

Commit

Permalink
Extract clause minimization to method.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoniusW committed Mar 25, 2020
1 parent f94f528 commit 7e8da06
Showing 1 changed file with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,26 @@ private ConflictAnalysisResult analyzeTrailBased(Antecedent conflictReason) {
// Add the 1UIP literal.
resolutionLiterals.add(atomToLiteral(nextAtom, assignment.getTruth(nextAtom).toBoolean()));

int[] learnedLiterals = minimizeLearnedLiterals(resolutionLiterals, seenAtoms);

NoGood learnedNoGood = NoGood.learnt(learnedLiterals);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Learned NoGood is: {}", atomStore.noGoodToString(learnedNoGood));
}

int backjumpingDecisionLevel = computeBackjumpingDecisionLevel(learnedNoGood);
if (backjumpingDecisionLevel < 0) {
// Due to out-of-order assigned literals, the learned nogood may be not assigning.
backjumpingDecisionLevel = computeConflictFreeBackjumpingLevel(learnedNoGood);
if (backjumpingDecisionLevel < 0) {
return ConflictAnalysisResult.UNSAT;
}
}
LOGGER.trace("Backjumping decision level: {}", backjumpingDecisionLevel);
return new ConflictAnalysisResult(learnedNoGood, backjumpingDecisionLevel, resolutionAtoms, computeLBD(learnedLiterals));
}

private int[] minimizeLearnedLiterals(List<Integer> resolutionLiterals, Set<Integer> seenAtoms) {
int[] learnedLiterals = new int[resolutionLiterals.size()];
int i = 0;
// Do local clause minimization: if an implied literal has all its antecedents seen (i.e., in the clause already), it can be removed.
Expand Down Expand Up @@ -255,22 +275,7 @@ private ConflictAnalysisResult analyzeTrailBased(Antecedent conflictReason) {
if (i < resolutionLiterals.size()) {
learnedLiterals = Arrays.copyOf(learnedLiterals, i);
}

NoGood learnedNoGood = NoGood.learnt(learnedLiterals);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Learned NoGood is: {}", atomStore.noGoodToString(learnedNoGood));
}

int backjumpingDecisionLevel = computeBackjumpingDecisionLevel(learnedNoGood);
if (backjumpingDecisionLevel < 0) {
// Due to out-of-order assigned literals, the learned nogood may be not assigning.
backjumpingDecisionLevel = computeConflictFreeBackjumpingLevel(learnedNoGood);
if (backjumpingDecisionLevel < 0) {
return ConflictAnalysisResult.UNSAT;
}
}
LOGGER.trace("Backjumping decision level: {}", backjumpingDecisionLevel);
return new ConflictAnalysisResult(learnedNoGood, backjumpingDecisionLevel, resolutionAtoms, computeLBD(learnedLiterals));
return learnedLiterals;
}

private int computeLBD(int[] literals) {
Expand Down

0 comments on commit 7e8da06

Please sign in to comment.