Public Member Functions | |
| __init__ (self, optimize=None, ctx=None) | |
| __copy__ (self) | |
| __deepcopy__ (self, memo={}) | |
| __del__ (self) | |
| __enter__ (self) | |
| __exit__ (self, *exc_info) | |
| set (self, *args, **keys) | |
| help (self) | |
| param_descrs (self) | |
| assert_exprs (self, *args) | |
| add (self, *args) | |
| __iadd__ (self, fml) | |
| assert_and_track (self, a, p) | |
| add_soft (self, arg, weight="1", id=None) | |
| set_initial_value (self, var, value) | |
| maximize (self, arg) | |
| minimize (self, arg) | |
| push (self) | |
| pop (self) | |
| check (self, *assumptions) | |
| reason_unknown (self) | |
| model (self) | |
| unsat_core (self) | |
| lower (self, obj) | |
| upper (self, obj) | |
| lower_values (self, obj) | |
| upper_values (self, obj) | |
| from_file (self, filename) | |
| from_string (self, s) | |
| assertions (self) | |
| objectives (self) | |
| __repr__ (self) | |
| sexpr (self) | |
| statistics (self) | |
| translate (self, target) | |
| set_on_model (self, on_model) | |
| Public Member Functions inherited from Z3PPObject | |
| use_pp (self) | |
Data Fields | |
| ctx = _get_ctx(ctx) | |
| optimize = Z3_mk_optimize(self.ctx.ref()) | |
Protected Attributes | |
| _on_models_id = None | |
Additional Inherited Members | |
| Protected Member Functions inherited from Z3PPObject | |
| _repr_html_ (self) | |
Optimize API provides methods for solving using objective functions and weighted soft constraints
| __init__ | ( | self, | |
| optimize = None, | |||
| ctx = None ) |
Definition at line 8586 of file z3py.py.
| __del__ | ( | self | ) |
Definition at line 8601 of file z3py.py.
| __copy__ | ( | self | ) |
| __deepcopy__ | ( | self, | |
| memo = {} ) |
| __enter__ | ( | self | ) |
| __exit__ | ( | self, | |
| * | exc_info ) |
| __iadd__ | ( | self, | |
| fml ) |
| __repr__ | ( | self | ) |
| add | ( | self, | |
| * | args ) |
| add_soft | ( | self, | |
| arg, | |||
| weight = "1", | |||
| id = None ) |
Add soft constraint with optional weight and optional identifier. If no weight is supplied, then the penalty for violating the soft constraint is 1. Soft constraints are grouped by identifiers. Soft constraints that are added without identifiers are grouped by default.
Definition at line 8678 of file z3py.py.
| assert_and_track | ( | self, | |
| a, | |||
| p ) |
Assert constraint `a` and track it in the unsat core using the Boolean constant `p`.
If `p` is a string, it will be automatically converted into a Boolean constant.
>>> x = Int('x')
>>> p3 = Bool('p3')
>>> s = Optimize()
>>> s.assert_and_track(x > 0, 'p1')
>>> s.assert_and_track(x != 1, 'p2')
>>> s.assert_and_track(x < 0, p3)
>>> print(s.check())
unsat
>>> c = s.unsat_core()
>>> len(c)
2
>>> Bool('p1') in c
True
>>> Bool('p2') in c
False
>>> p3 in c
True
Definition at line 8649 of file z3py.py.
| assert_exprs | ( | self, | |
| * | args ) |
Assert constraints as background axioms for the optimize solver.
Definition at line 8629 of file z3py.py.
| assertions | ( | self | ) |
Return an AST vector containing all added constraints.
Definition at line 8784 of file z3py.py.
| check | ( | self, | |
| * | assumptions ) |
Check consistency and produce optimal values.
Definition at line 8733 of file z3py.py.
| from_file | ( | self, | |
| filename ) |
Parse assertions and objectives from a file
Definition at line 8776 of file z3py.py.
| from_string | ( | self, | |
| s ) |
Parse assertions and objectives from a string
Definition at line 8780 of file z3py.py.
| help | ( | self | ) |
Display a string describing all available options.
Definition at line 8621 of file z3py.py.
| lower | ( | self, | |
| obj ) |
| lower_values | ( | self, | |
| obj ) |
| maximize | ( | self, | |
| arg ) |
Add objective function to maximize.
Definition at line 8709 of file z3py.py.
| minimize | ( | self, | |
| arg ) |
Add objective function to minimize.
Definition at line 8717 of file z3py.py.
| model | ( | self | ) |
Return a model for the last check().
Definition at line 8746 of file z3py.py.
| objectives | ( | self | ) |
returns set of objective functions
Definition at line 8788 of file z3py.py.
| param_descrs | ( | self | ) |
Return the parameter description set.
Definition at line 8625 of file z3py.py.
| pop | ( | self | ) |
restore to previously created backtracking point
Definition at line 8729 of file z3py.py.
| push | ( | self | ) |
create a backtracking point for added rules, facts and assertions
Definition at line 8725 of file z3py.py.
| reason_unknown | ( | self | ) |
Return a string that describes why the last `check()` returned `unknown`.
Definition at line 8742 of file z3py.py.
| set | ( | self, | |
| * | args, | ||
| ** | keys ) |
Set a configuration option. The method `help()` return a string containing all available options.
Definition at line 8614 of file z3py.py.
| set_initial_value | ( | self, | |
| var, | |||
| value ) |
initialize the solver's state by setting the initial value of var to value
Definition at line 8702 of file z3py.py.
| set_on_model | ( | self, | |
| on_model ) |
Register a callback that is invoked with every incremental improvement to objective values. The callback takes a model as argument. The life-time of the model is limited to the callback so the model has to be (deep) copied if it is to be used after the callback
Definition at line 8820 of file z3py.py.
| sexpr | ( | self | ) |
Return a formatted string (in Lisp-like format) with all added constraints. We say the string is in s-expression format.
Definition at line 8796 of file z3py.py.
| statistics | ( | self | ) |
Return statistics for the last check`.
Definition at line 8802 of file z3py.py.
| translate | ( | self, | |
| target ) |
Translate `self` to the context `target`. That is, return a copy of `self` in the context `target`. >>> c1 = Context() >>> c2 = Context() >>> o1 = Optimize(ctx=c1) >>> o2 = o1.translate(c2)
Definition at line 8807 of file z3py.py.
| unsat_core | ( | self | ) |
| upper | ( | self, | |
| obj ) |
| upper_values | ( | self, | |
| obj ) |
| optimize = Z3_mk_optimize(self.ctx.ref()) |