Skip to content

Commit

Permalink
Use correct sat variables for model counting and model enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
Apfelbeet committed Apr 15, 2024
1 parent 0a87c70 commit dd2d495
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ fun computeRelevantVars(
features: List<String>,
): SortedSet<Variable> =
if (features.isEmpty()) {
(info.knownVariables + info.encodingContext.relevantSatVariables).toSortedSet()
val intSatVariables = info.integerVariables.flatMap { info.encodingContext.variableMap[it.variable]?.values ?: emptySet() }
(info.knownVariables + intSatVariables).toSortedSet()
} else {
val vars = TreeSet<Variable>()
info.integerVariables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ internal object ModelCountComputation :
): ModelCountInternalResult {
// currently no projected model counting
// val variables = computeRelevantVars(f, info, listOf())
val variables = (info.knownVariables + info.intPredicateMapping.values + info.encodingContext.relevantSatVariables).toSortedSet()
val intSatVariables = info.integerVariables.flatMap { info.encodingContext.variableMap[it.variable]?.values ?: emptySet() }
val variables = (info.knownVariables + info.intPredicateMapping.values + intSatVariables).toSortedSet()
val formulas = info.propositions.map { it.formula() }
val additionalDefinitions =
request.additionalConstraints.map { constraint -> processConstraint(f, constraint, model, info, status) }
val additionalConstraints = additionalDefinitions.map { it!!.first.formula() }
val additionalVarDefinitions = additionalDefinitions.flatMap { it!!.second }.toSet().map { info.integerEncodings.getEncoding(it)!! }
val allFormulas = formulas + additionalConstraints + additionalVarDefinitions
val allVariables = (allFormulas.flatMap { it.variables(f) } + variables).toSortedSet()
if (!status.successful()) {
return ModelCountInternalResult(slice, BigInteger.ZERO)
}
return ModelCountInternalResult(
slice,
ModelCounter.count(f, formulas + additionalConstraints + additionalVarDefinitions, variables)
ModelCounter.count(f, formulas + additionalConstraints + additionalVarDefinitions, allVariables)
)
}

Expand Down

0 comments on commit dd2d495

Please sign in to comment.