mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 10:55:50 +00:00
expose bounds as vector expressions instead of containing ad-hoc expressions. Issue #911
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
e744d0f271
commit
e02160c674
11 changed files with 158 additions and 4 deletions
|
@ -6719,12 +6719,24 @@ class OptimizeObjective:
|
|||
opt = self._opt
|
||||
return _to_expr_ref(Z3_optimize_get_upper(opt.ctx.ref(), opt.optimize, self._value), opt.ctx)
|
||||
|
||||
def lower_values(self):
|
||||
opt = self._opt
|
||||
return AstVector(Z3_optimize_get_lower_as_vector(opt.ctx.ref(), opt.optimize, self._value), opt.ctx)
|
||||
|
||||
def upper_values(self):
|
||||
opt = self._opt
|
||||
return AstVector(Z3_optimize_get_upper_as_vector(opt.ctx.ref(), opt.optimize, self._value), opt.ctx)
|
||||
|
||||
def value(self):
|
||||
if self._is_max:
|
||||
return self.upper()
|
||||
else:
|
||||
return self.lower()
|
||||
|
||||
def __str__(self):
|
||||
return "%s:%s" % (self._value, self._is_max)
|
||||
|
||||
|
||||
class Optimize(Z3PPObject):
|
||||
"""Optimize API provides methods for solving using objective functions and weighted soft constraints"""
|
||||
|
||||
|
@ -6829,6 +6841,16 @@ class Optimize(Z3PPObject):
|
|||
raise Z3Exception("Expecting objective handle returned by maximize/minimize")
|
||||
return obj.upper()
|
||||
|
||||
def lower_values(self, obj):
|
||||
if not isinstance(obj, OptimizeObjective):
|
||||
raise Z3Exception("Expecting objective handle returned by maximize/minimize")
|
||||
return obj.lower_values()
|
||||
|
||||
def upper_values(self, obj):
|
||||
if not isinstance(obj, OptimizeObjective):
|
||||
raise Z3Exception("Expecting objective handle returned by maximize/minimize")
|
||||
return obj.upper_values()
|
||||
|
||||
def from_file(self, filename):
|
||||
"""Parse assertions and objectives from a file"""
|
||||
Z3_optimize_from_file(self.ctx.ref(), self.optimize, filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue