mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
parent
46cdefac4d
commit
3bc2213d54
12 changed files with 152 additions and 32 deletions
|
@ -7311,10 +7311,15 @@ class Optimize(Z3PPObject):
|
|||
"""restore to previously created backtracking point"""
|
||||
Z3_optimize_pop(self.ctx.ref(), self.optimize)
|
||||
|
||||
def check(self):
|
||||
def check(self, *assumptions):
|
||||
"""Check satisfiability while optimizing objective functions."""
|
||||
return CheckSatResult(Z3_optimize_check(self.ctx.ref(), self.optimize))
|
||||
|
||||
assumptions = _get_args(assumptions)
|
||||
num = len(assumptions)
|
||||
_assumptions = (Ast * num)()
|
||||
for i in range(num):
|
||||
_assumptions[i] = assumptions[i].as_ast()
|
||||
return CheckSatResult(Z3_optimize_check(self.ctx.ref(), self.optimize, num, _assumptions))
|
||||
|
||||
def reason_unknown(self):
|
||||
"""Return a string that describes why the last `check()` returned `unknown`."""
|
||||
return Z3_optimize_get_reason_unknown(self.ctx.ref(), self.optimize)
|
||||
|
@ -7326,6 +7331,9 @@ class Optimize(Z3PPObject):
|
|||
except Z3Exception:
|
||||
raise Z3Exception("model is not available")
|
||||
|
||||
def unsat_core(self):
|
||||
return AstVector(Z3_optimize_get_unsat_core(self.ctx.ref(), self.optimize), self.ctx)
|
||||
|
||||
def lower(self, obj):
|
||||
if not isinstance(obj, OptimizeObjective):
|
||||
raise Z3Exception("Expecting objective handle returned by maximize/minimize")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue