mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
first attempts at getting to the bvsls from opt_context.
This commit is contained in:
parent
97e549d946
commit
c068db16e8
7 changed files with 401 additions and 41 deletions
123
src/opt/bvsls_opt_solver.cpp
Normal file
123
src/opt/bvsls_opt_solver.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
bvsls_opt_solver.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Uses the bvsls engine for optimization
|
||||
|
||||
Author:
|
||||
|
||||
Christoph (cwinter) 2014-3-28
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
#include "bvsls_opt_solver.h"
|
||||
|
||||
namespace opt {
|
||||
|
||||
bvsls_opt_solver::bvsls_opt_solver(ast_manager & m, params_ref const & p) :
|
||||
opt_solver(m, p, symbol("QF_BV")),
|
||||
m_manager(m),
|
||||
m_params(p),
|
||||
m_engine(m, p)
|
||||
{
|
||||
}
|
||||
|
||||
bvsls_opt_solver::~bvsls_opt_solver()
|
||||
{
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::updt_params(params_ref & p)
|
||||
{
|
||||
opt_solver::updt_params(p);
|
||||
m_engine.updt_params(p);
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::collect_param_descrs(param_descrs & r)
|
||||
{
|
||||
opt_solver::collect_param_descrs(r);
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::collect_statistics(statistics & st) const
|
||||
{
|
||||
opt_solver::collect_statistics(st);
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::assert_expr(expr * t) {
|
||||
m_engine.assert_expr(t);
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::push_core()
|
||||
{
|
||||
opt_solver::push_core();
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::pop_core(unsigned n)
|
||||
{
|
||||
opt_solver::pop_core(n);
|
||||
}
|
||||
|
||||
lbool bvsls_opt_solver::check_sat_core(unsigned num_assumptions, expr * const * assumptions)
|
||||
{
|
||||
SASSERT(num_assumptions == 0);
|
||||
SASSERT(assumptions == 0);
|
||||
return m_engine();
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::get_unsat_core(ptr_vector<expr> & r)
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::get_model(model_ref & m)
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
|
||||
proof * bvsls_opt_solver::get_proof()
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
|
||||
std::string bvsls_opt_solver::reason_unknown() const
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::get_labels(svector<symbol> & r)
|
||||
{
|
||||
opt_solver::get_labels(r);
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::set_cancel(bool f)
|
||||
{
|
||||
opt_solver::set_cancel(f);
|
||||
m_engine.set_cancel(f);
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::set_progress_callback(progress_callback * callback)
|
||||
{
|
||||
opt_solver::set_progress_callback(callback);
|
||||
}
|
||||
|
||||
unsigned bvsls_opt_solver::get_num_assertions() const
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
|
||||
expr * bvsls_opt_solver::get_assertion(unsigned idx) const
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
|
||||
void bvsls_opt_solver::display(std::ostream & out) const
|
||||
{
|
||||
NOT_IMPLEMENTED_YET();
|
||||
}
|
||||
}
|
57
src/opt/bvsls_opt_solver.h
Normal file
57
src/opt/bvsls_opt_solver.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
bvsls_opt_solver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Uses the bvsls engine for optimization
|
||||
|
||||
Author:
|
||||
|
||||
Christoph (cwinter) 2014-3-28
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _BVSLS_OPT_SOLVER_H_
|
||||
#define _BVSLS_OPT_SOLVER_H_
|
||||
|
||||
#include "bvsls_opt_engine.h"
|
||||
#include "opt_solver.h"
|
||||
|
||||
namespace opt {
|
||||
|
||||
class bvsls_opt_solver : public opt_solver {
|
||||
ast_manager & m_manager;
|
||||
params_ref const & m_params;
|
||||
bvsls_opt_engine m_engine;
|
||||
|
||||
public:
|
||||
bvsls_opt_solver(ast_manager & m, params_ref const & p);
|
||||
virtual ~bvsls_opt_solver();
|
||||
|
||||
virtual void updt_params(params_ref & p);
|
||||
virtual void collect_param_descrs(param_descrs & r);
|
||||
virtual void collect_statistics(statistics & st) const;
|
||||
virtual void assert_expr(expr * t);
|
||||
virtual void push_core();
|
||||
virtual void pop_core(unsigned n);
|
||||
virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions);
|
||||
virtual void get_unsat_core(ptr_vector<expr> & r);
|
||||
virtual void get_model(model_ref & m);
|
||||
virtual proof * get_proof();
|
||||
virtual std::string reason_unknown() const;
|
||||
virtual void get_labels(svector<symbol> & r);
|
||||
virtual void set_cancel(bool f);
|
||||
virtual void set_progress_callback(progress_callback * callback);
|
||||
virtual unsigned get_num_assertions() const;
|
||||
virtual expr * get_assertion(unsigned idx) const;
|
||||
virtual void display(std::ostream & out) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -33,6 +33,9 @@ Notes:
|
|||
#include "elim_uncnstr_tactic.h"
|
||||
#include "tactical.h"
|
||||
#include "model_smt2_pp.h"
|
||||
#include "card2bv_tactic.h"
|
||||
#include "bvsls_opt_solver.h"
|
||||
#include "nnf_tactic.h"
|
||||
|
||||
namespace opt {
|
||||
|
||||
|
@ -130,12 +133,13 @@ namespace opt {
|
|||
}
|
||||
|
||||
lbool context::optimize() {
|
||||
opt_solver& s = get_solver();
|
||||
m_optsmt.reset();
|
||||
m_optsmt.reset();
|
||||
normalize();
|
||||
internalize();
|
||||
opt_solver& s = get_solver();
|
||||
solver::scoped_push _sp(s);
|
||||
for (unsigned i = 0; i < m_hard_constraints.size(); ++i) {
|
||||
TRACE("opt", tout << "Hard constraint: " << mk_ismt2_pp(m_hard_constraints[i].get(), m) << std::endl;);
|
||||
s.assert_expr(m_hard_constraints[i].get());
|
||||
}
|
||||
|
||||
|
@ -359,7 +363,19 @@ namespace opt {
|
|||
mk_simplify_tactic(m));
|
||||
opt_params optp(m_params);
|
||||
tactic_ref tac2, tac3;
|
||||
if (optp.elim_01()) {
|
||||
if (optp.engine() == "bvsls") {
|
||||
tac2 = mk_elim01_tactic(m);
|
||||
tac3 = mk_lia2card_tactic(m);
|
||||
params_ref lia_p;
|
||||
lia_p.set_bool("compile_equality", optp.pb_compile_equality());
|
||||
tac3->updt_params(lia_p);
|
||||
m_simplify = and_then(tac0.get(), tac2.get(), tac3.get(),
|
||||
mk_card2bv_tactic(m),
|
||||
mk_simplify_tactic(m),
|
||||
mk_nnf_tactic(m));
|
||||
m_solver = alloc(bvsls_opt_solver, m, m_params);
|
||||
}
|
||||
else if (optp.elim_01()) {
|
||||
tac2 = mk_elim01_tactic(m);
|
||||
tac3 = mk_lia2card_tactic(m);
|
||||
params_ref lia_p;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue