Skip to content

Commit 4a16a8d

Browse files
committed
Fixed UNSAT core debug logging
1 parent 8881424 commit 4a16a8d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/Memory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class TypeRegistry {
535535

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

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

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

utbot-framework/src/main/kotlin/org/utbot/engine/pc/UtSolver.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,12 @@ data class UtSolver constructor(
270270
UNSATISFIABLE -> {
271271
val unsatCore = z3Solver.unsatCore
272272

273+
val failedSoftConstraints = unsatCore.filter { it in translatedSoft.keys }
274+
val failedAssumptions = unsatCore.filter { it in translatedAssumptions.keys }
275+
273276
// if we don't have any soft constraints and enabled unsat cores
274277
// for hard constraints, then calculate it and print the result using the logger
275-
if (translatedSoft.isEmpty() && translatedAssumptions.isEmpty() && UtSettings.enableUnsatCoreCalculationForHardConstraints) {
278+
if (failedSoftConstraints.isEmpty() && failedAssumptions.isEmpty() && UtSettings.enableUnsatCoreCalculationForHardConstraints) {
276279
with(context.mkSolver()) {
277280
check(*z3Solver.assertions)
278281
val constraintsInUnsatCore = this.unsatCore.toList()
@@ -286,20 +289,16 @@ data class UtSolver constructor(
286289
// an unsat core for hard constraints
287290
if (unsatCore.isEmpty()) return UNSAT
288291

289-
val failedSoftConstraints = unsatCore.filter { it in translatedSoft.keys }
290-
291292
if (failedSoftConstraints.isNotEmpty()) {
292293
failedSoftConstraints.forEach { translatedSoft.remove(it) }
293294
// remove soft constraints first, only then try to remove assumptions
294295
continue
295296
}
296297

297-
unsatCore
298-
.filter { it in translatedAssumptions.keys }
299-
.forEach {
300-
assumptionsInUnsatCore += translatedAssumptions.getValue(it)
301-
translatedAssumptions.remove(it)
302-
}
298+
failedAssumptions.forEach {
299+
assumptionsInUnsatCore += translatedAssumptions.getValue(it)
300+
translatedAssumptions.remove(it)
301+
}
303302
}
304303
else -> {
305304
logger.debug { "Reason of UNKNOWN: ${z3Solver.reasonUnknown}" }

0 commit comments

Comments
 (0)