3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-16 05:48:44 +00:00

fixes to dotnet interface

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-12-26 17:14:29 -08:00
parent a0e98ca39b
commit 58f8181a74
4 changed files with 16 additions and 11 deletions

View file

@ -129,12 +129,13 @@ extern "C" {
RESET_ERROR_CODE(); RESET_ERROR_CODE();
model_ref _m; model_ref _m;
to_optimize_ref(o).get_model(_m); to_optimize_ref(o).get_model(_m);
if (!_m) {
SET_ERROR_CODE(Z3_INVALID_USAGE);
RETURN_Z3(0);
}
Z3_model_ref * m_ref = alloc(Z3_model_ref); Z3_model_ref * m_ref = alloc(Z3_model_ref);
m_ref->m_model = _m; if (_m) {
m_ref->m_model = _m;
}
else {
m_ref->m_model = alloc(model, mk_c(c)->m());
}
mk_c(c)->save_object(m_ref); mk_c(c)->save_object(m_ref);
RETURN_Z3(of_model(m_ref)); RETURN_Z3(of_model(m_ref));
Z3_CATCH_RETURN(0); Z3_CATCH_RETURN(0);

View file

@ -142,12 +142,12 @@ namespace Microsoft.Z3
public ArithExpr GetLower(uint index) public ArithExpr GetLower(uint index)
{ {
return new ArithExpr(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index)); return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
} }
public ArithExpr GetUpper(uint index) public ArithExpr GetUpper(uint index)
{ {
return new ArithExpr(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index)); return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
} }
public override string ToString() public override string ToString()

View file

@ -114,10 +114,12 @@ namespace opt {
void context::get_model(model_ref& mdl) { void context::get_model(model_ref& mdl) {
mdl = m_model; mdl = m_model;
if (m_model_converter) { if (mdl) {
(*m_model_converter)(mdl, 0); if (m_model_converter) {
(*m_model_converter)(mdl, 0);
}
get_solver().mc()(mdl, 0);
} }
get_solver().mc()(mdl, 0);
} }
lbool context::execute_min_max(unsigned index, bool committed) { lbool context::execute_min_max(unsigned index, bool committed) {

View file

@ -1315,6 +1315,7 @@ namespace smt {
} }
theory_var curr_x_i = pick_var_to_leave(curr_x_j, curr_inc, curr_a_ij, curr_gain, skipped_row); theory_var curr_x_i = pick_var_to_leave(curr_x_j, curr_inc, curr_a_ij, curr_gain, skipped_row);
if (curr_x_i == null_theory_var) { if (curr_x_i == null_theory_var) {
TRACE("opt", tout << "unbounded\n";);
// we can increase/decrease curr_x_j as much as we want. // we can increase/decrease curr_x_j as much as we want.
x_i = null_theory_var; // unbounded x_i = null_theory_var; // unbounded
x_j = curr_x_j; x_j = curr_x_j;
@ -1340,7 +1341,8 @@ namespace smt {
} }
} }
} }
TRACE("opt", tout << "after traversing row:\nx_i: v" << x_i << ", x_j: v" << x_j << ", gain: " << gain << "\n";); TRACE("opt", tout << "after traversing row:\nx_i: v" << x_i << ", x_j: v" << x_j << ", gain: " << gain << "\n";
tout << "skipped row: " << (skipped_row?"yes":"no") << "\n";);
if (x_j == null_theory_var) { if (x_j == null_theory_var) {
TRACE("opt", tout << "row is " << (max ? "maximized" : "minimized") << "\n";); TRACE("opt", tout << "row is " << (max ? "maximized" : "minimized") << "\n";);