mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
fix memory smash
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
3757f337e5
commit
eb6d39ba46
6 changed files with 27 additions and 9 deletions
|
@ -29,6 +29,7 @@ Notes:
|
|||
#include "pp_params.hpp"
|
||||
#include "opt_params.hpp"
|
||||
#include "model_smt2_pp.h"
|
||||
#include "stopwatch.h"
|
||||
|
||||
namespace opt {
|
||||
|
||||
|
@ -113,14 +114,23 @@ namespace opt {
|
|||
tout << mk_pp(m_context.get_formulas()[i], m_context.m()) << "\n";
|
||||
}
|
||||
});
|
||||
stopwatch w;
|
||||
if (dump_benchmarks()) {
|
||||
w.start();
|
||||
std::stringstream file_name;
|
||||
file_name << "opt_solver" << ++m_dump_count << ".smt2";
|
||||
std::ofstream buffer(file_name.str().c_str());
|
||||
to_smt2_benchmark(buffer, num_assumptions, assumptions, "opt_solver", "");
|
||||
buffer.close();
|
||||
IF_VERBOSE(1, verbose_stream() << "(created benchmark: " << file_name.str() << "...";
|
||||
verbose_stream().flush(););
|
||||
}
|
||||
return m_context.check(num_assumptions, assumptions);
|
||||
lbool r = m_context.check(num_assumptions, assumptions);
|
||||
if (dump_benchmarks()) {
|
||||
w.stop();
|
||||
IF_VERBOSE(1, verbose_stream() << ".. " << r << " " << std::fixed << w.get_seconds() << ")\n";);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void opt_solver::maximize_objectives() {
|
||||
|
|
|
@ -518,6 +518,7 @@ namespace opt {
|
|||
};
|
||||
|
||||
lbool incremental_solve() {
|
||||
IF_VERBOSE(3, verbose_stream() << "(incremental solve)\n";);
|
||||
TRACE("opt", tout << "weighted maxsat\n";);
|
||||
scoped_ensure_theory wth(*this);
|
||||
solver::scoped_push _s(s);
|
||||
|
@ -541,6 +542,7 @@ namespace opt {
|
|||
s.assert_expr(fml);
|
||||
was_sat = true;
|
||||
}
|
||||
IF_VERBOSE(3, verbose_stream() << "(incremental bound)\n";);
|
||||
}
|
||||
if (was_sat) {
|
||||
wth().get_assignment(m_assignment);
|
||||
|
@ -605,6 +607,7 @@ namespace opt {
|
|||
}
|
||||
|
||||
lbool conditional_solve(expr* cond) {
|
||||
IF_VERBOSE(3, verbose_stream() << "(conditional solve)\n";);
|
||||
smt::theory_weighted_maxsat& wth = *get_theory();
|
||||
bool was_sat = false;
|
||||
lbool is_sat = l_true;
|
||||
|
@ -1169,6 +1172,7 @@ namespace opt {
|
|||
// cost becomes 0
|
||||
|
||||
lbool bisection_solve() {
|
||||
IF_VERBOSE(3, verbose_stream() << "(bisection solve)\n";);
|
||||
TRACE("opt", tout << "weighted maxsat\n";);
|
||||
scoped_ensure_theory wth(*this);
|
||||
solver::scoped_push _s(s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue