3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

add to_string and get_help methods to optimize API

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-12-06 11:34:41 -08:00
parent 7884b2ab31
commit 4d6aa1a0f3
6 changed files with 170 additions and 7 deletions

View file

@ -185,6 +185,28 @@ extern "C" {
Z3_CATCH_RETURN(0);
}
Z3_string Z3_API Z3_optimize_to_string(Z3_context c, Z3_optimize o) {
Z3_TRY;
LOG_Z3_optimize_to_string(c, o);
RESET_ERROR_CODE();
return mk_c(c)->mk_external_string(to_optimize_ref(o).to_string());
Z3_CATCH_RETURN("");
}
Z3_string Z3_API Z3_optimize_get_help(Z3_context c, Z3_optimize d) {
Z3_TRY;
LOG_Z3_optimize_get_help(c, d);
RESET_ERROR_CODE();
std::ostringstream buffer;
param_descrs descrs;
to_optimize_ref(d).collect_param_descrs(descrs);
descrs.display(buffer);
return mk_c(c)->mk_external_string(buffer.str());
Z3_CATCH_RETURN("");
}
#if 0
/**

View file

@ -31,7 +31,6 @@ namespace Microsoft.Z3
{
HashSet<uint> indices;
#if false
/// <summary>
/// A string that describes all available optimize solver parameters.
/// </summary>
@ -43,7 +42,6 @@ namespace Microsoft.Z3
return Native.Z3_optimize_get_help(Context.nCtx, NativeObject);
}
}
#endif
/// <summary>
/// Sets the optimize solver parameters.
@ -157,7 +155,7 @@ namespace Microsoft.Z3
}
}
public uint MkMaximize(ArithExpr e)
public uint MkMaximize(ArithExpr e)
{
uint index = Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject);
indices.Add(index);
@ -166,15 +164,15 @@ namespace Microsoft.Z3
public uint MkMinimize(ArithExpr e)
{
uint index = Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject);
uint index = Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject);
indices.Add(index);
return index;
}
}
public ArithExpr GetLower(uint index)
public ArithExpr GetLower(uint index)
{
Contract.Requires(indices.Contains(index));
return new ArithExpr(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
return new ArithExpr(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
}
public ArithExpr GetUpper(uint index)
@ -183,6 +181,11 @@ namespace Microsoft.Z3
return new ArithExpr(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
}
public override string ToString()
{
return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
}
#region Internal
internal Optimize(Context ctx, IntPtr obj)
: base(ctx, obj)

View file

@ -6075,6 +6075,26 @@ END_MLAPI_EXCLUDE
*/
Z3_ast Z3_API Z3_optimize_get_upper(Z3_context c, Z3_optimize o, unsigned idx);
/**
\brief Print the current context as a string.
\param c - context.
\param o - optimization context.
def_API('Z3_optimize_to_string', STRING, (_in(CONTEXT), _in(OPTIMIZE)))
*/
Z3_string Z3_API Z3_optimize_to_string(
__in Z3_context c,
__in Z3_optimize o);
/**
\brief Return a string containing a description of parameters accepted by optimize.
def_API('Z3_optimize_get_help', STRING, (_in(CONTEXT), _in(OPTIMIZE)))
*/
Z3_string Z3_API Z3_optimize_get_help(__in Z3_context c, __in Z3_optimize t);
#endif