mirror of
https://github.com/Z3Prover/z3
synced 2025-07-18 02:16:40 +00:00
initial integration of opt
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
8205b45839
114 changed files with 3680 additions and 1370 deletions
|
@ -272,7 +272,8 @@ namespace opt {
|
|||
s.assert_expr(m_hard_constraints);
|
||||
IF_VERBOSE(1, verbose_stream() << "(optimize:check-sat)\n";);
|
||||
lbool is_sat = s.check_sat(0,0);
|
||||
TRACE("opt", tout << "initial search result: " << is_sat << "\n";);
|
||||
TRACE("opt", tout << "initial search result: " << is_sat << "\n";
|
||||
s.display(tout););
|
||||
if (is_sat != l_false) {
|
||||
s.get_model(m_model);
|
||||
s.get_labels(m_labels);
|
||||
|
@ -340,6 +341,14 @@ namespace opt {
|
|||
fix_model(mdl);
|
||||
}
|
||||
|
||||
void context::get_box_model(model_ref& mdl, unsigned index) {
|
||||
if (index >= m_box_models.size()) {
|
||||
throw default_exception("index into models is out of bounds");
|
||||
}
|
||||
mdl = m_box_models[index];
|
||||
fix_model(mdl);
|
||||
}
|
||||
|
||||
lbool context::execute_min_max(unsigned index, bool committed, bool scoped, bool is_max) {
|
||||
if (scoped) get_solver().push();
|
||||
lbool result = m_optsmt.lex(index, is_max);
|
||||
|
@ -1036,6 +1045,10 @@ namespace opt {
|
|||
TRACE("opt", tout << "Purifying " << term << "\n";);
|
||||
term = purify(fm, term);
|
||||
}
|
||||
else if (m.is_ite(term)) {
|
||||
TRACE("opt", tout << "Purifying " << term << "\n";);
|
||||
term = purify(fm, term);
|
||||
}
|
||||
if (fm) {
|
||||
m_model_converter = concat(m_model_converter.get(), fm.get());
|
||||
}
|
||||
|
@ -1226,7 +1239,7 @@ namespace opt {
|
|||
out << " (";
|
||||
display_objective(out, obj);
|
||||
if (get_lower_as_num(i) != get_upper_as_num(i)) {
|
||||
out << " (" << get_lower(i) << " " << get_upper(i) << ")";
|
||||
out << " (interval " << get_lower(i) << " " << get_upper(i) << ")";
|
||||
}
|
||||
else {
|
||||
out << " " << get_lower(i);
|
||||
|
|
|
@ -186,6 +186,7 @@ namespace opt {
|
|||
virtual bool print_model() const;
|
||||
virtual void set_model(model_ref& _m) { m_model = _m; }
|
||||
virtual void get_model(model_ref& _m);
|
||||
virtual void get_box_model(model_ref& _m, unsigned index);
|
||||
virtual void fix_model(model_ref& _m);
|
||||
virtual void collect_statistics(statistics& stats) const;
|
||||
virtual proof* get_proof() { return 0; }
|
||||
|
|
|
@ -5,6 +5,8 @@ def_module_params('opt',
|
|||
('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"),
|
||||
('priority', SYMBOL, 'lex', "select how to priortize objectives: 'lex' (lexicographic), 'pareto', or 'box'"),
|
||||
('dump_benchmarks', BOOL, False, 'dump benchmarks for profiling'),
|
||||
('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'),
|
||||
('rlimit', UINT, 0, 'resource limit (0 means no limit)'),
|
||||
('print_model', BOOL, False, 'display model for satisfiable constraints'),
|
||||
('enable_sls', BOOL, False, 'enable SLS tuning during weighted maxsast'),
|
||||
('enable_sat', BOOL, True, 'enable the new SAT core for propositional constraints'),
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace opt {
|
|||
if (m_params.m_case_split_strategy == CS_ACTIVITY_DELAY_NEW) {
|
||||
m_params.m_relevancy_lvl = 0;
|
||||
}
|
||||
// m_params.m_auto_config = false;
|
||||
}
|
||||
|
||||
unsigned opt_solver::m_dump_count = 0;
|
||||
|
@ -357,6 +358,7 @@ namespace opt {
|
|||
}
|
||||
smt::theory_opt& opt = get_optimizer();
|
||||
smt::theory_var v = m_objective_vars[var];
|
||||
TRACE("opt", tout << "v" << var << " " << val << "\n";);
|
||||
|
||||
if (typeid(smt::theory_inf_arith) == typeid(opt)) {
|
||||
smt::theory_inf_arith& th = dynamic_cast<smt::theory_inf_arith&>(opt);
|
||||
|
@ -386,8 +388,32 @@ namespace opt {
|
|||
smt::theory_rdl& th = dynamic_cast<smt::theory_rdl&>(opt);
|
||||
return th.mk_ge(m_fm, v, val);
|
||||
}
|
||||
|
||||
if (typeid(smt::theory_dense_i) == typeid(opt) &&
|
||||
val.get_infinitesimal().is_zero()) {
|
||||
smt::theory_dense_i& th = dynamic_cast<smt::theory_dense_i&>(opt);
|
||||
return th.mk_ge(m_fm, v, val);
|
||||
}
|
||||
|
||||
// difference logic?
|
||||
if (typeid(smt::theory_dense_mi) == typeid(opt) &&
|
||||
val.get_infinitesimal().is_zero()) {
|
||||
smt::theory_dense_mi& th = dynamic_cast<smt::theory_dense_mi&>(opt);
|
||||
return th.mk_ge(m_fm, v, val);
|
||||
}
|
||||
|
||||
if (typeid(smt::theory_dense_si) == typeid(opt) &&
|
||||
val.get_infinitesimal().is_zero()) {
|
||||
smt::theory_dense_si& th = dynamic_cast<smt::theory_dense_si&>(opt);
|
||||
return th.mk_ge(m_fm, v, val);
|
||||
}
|
||||
|
||||
if (typeid(smt::theory_dense_smi) == typeid(opt) &&
|
||||
val.get_infinitesimal().is_zero()) {
|
||||
smt::theory_dense_smi& th = dynamic_cast<smt::theory_dense_smi&>(opt);
|
||||
return th.mk_ge(m_fm, v, val);
|
||||
}
|
||||
|
||||
IF_VERBOSE(0, verbose_stream() << "WARNING: unhandled theory " << typeid(opt).name() << "\n";);
|
||||
return expr_ref(m.mk_true(), m);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue