Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed UNSAT core debug logging
  • Loading branch information
Damtev committed Sep 28, 2022
commit 75b2de8b65d3e71a31957e0c3cfc80f2244b99b4
2 changes: 1 addition & 1 deletion utbot-framework/src/main/kotlin/org/utbot/engine/Memory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ class TypeRegistry {

if (sootClass.type.isJavaLangObject()) finalCost += -32

if (sootClass.isAnonymous) finalCost -= 128
if (sootClass.isAnonymous) finalCost += -128

if (sootClass.name.contains("$")) finalCost += -4096

Expand Down
17 changes: 8 additions & 9 deletions utbot-framework/src/main/kotlin/org/utbot/engine/pc/UtSolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ data class UtSolver constructor(
UNSATISFIABLE -> {
val unsatCore = z3Solver.unsatCore

val failedSoftConstraints = unsatCore.filter { it in translatedSoft.keys }
val failedAssumptions = unsatCore.filter { it in translatedAssumptions.keys }

// if we don't have any soft constraints and enabled unsat cores
// for hard constraints, then calculate it and print the result using the logger
if (translatedSoft.isEmpty() && translatedAssumptions.isEmpty() && UtSettings.enableUnsatCoreCalculationForHardConstraints) {
if (failedSoftConstraints.isEmpty() && failedAssumptions.isEmpty() && UtSettings.enableUnsatCoreCalculationForHardConstraints) {
with(context.mkSolver()) {
check(*z3Solver.assertions)
val constraintsInUnsatCore = this.unsatCore.toList()
Expand All @@ -288,20 +291,16 @@ data class UtSolver constructor(
// an unsat core for hard constraints
if (unsatCore.isEmpty()) return UNSAT

val failedSoftConstraints = unsatCore.filter { it in translatedSoft.keys }

if (failedSoftConstraints.isNotEmpty()) {
failedSoftConstraints.forEach { translatedSoft.remove(it) }
// remove soft constraints first, only then try to remove assumptions
continue
}

unsatCore
.filter { it in translatedAssumptions.keys }
.forEach {
assumptionsInUnsatCore += translatedAssumptions.getValue(it)
translatedAssumptions.remove(it)
}
failedAssumptions.forEach {
assumptionsInUnsatCore += translatedAssumptions.getValue(it)
translatedAssumptions.remove(it)
}
}
else -> {
logger.debug { "Reason of UNKNOWN: ${z3Solver.reasonUnknown}" }
Expand Down