21 using System.Collections.Generic;
22 using System.Diagnostics.Contracts;
24 namespace Microsoft.Z3
29 [ContractVerification(
true)]
39 Contract.Ensures(Contract.Result<
string>() != null);
40 return Native.Z3_optimize_get_help(Context.nCtx, NativeObject);
51 Contract.Requires(value != null);
52 Context.CheckContextMatch(value);
53 Native.Z3_optimize_set_params(Context.nCtx, NativeObject, value.NativeObject);
70 Contract.Requires(constraints != null);
71 Contract.Requires(Contract.ForAll(constraints, c => c != null));
73 Context.CheckContextMatch(constraints);
76 Native.Z3_optimize_assert(Context.nCtx, NativeObject, a.NativeObject);
106 get {
return opt.GetLower(handle); }
114 get {
return opt.GetUpper(handle); }
122 get {
return Lower; }
134 Context.CheckContextMatch(constraint);
135 Symbol s = Context.MkSymbol(group);
151 case Z3_lbool.Z3_L_TRUE:
152 return Status.SATISFIABLE;
153 case Z3_lbool.Z3_L_FALSE:
154 return Status.UNSATISFIABLE;
156 return Status.UNKNOWN;
166 Native.Z3_optimize_push(Context.nCtx, NativeObject);
176 Native.Z3_optimize_pop(Context.nCtx, NativeObject);
191 IntPtr x = Native.Z3_optimize_get_model(Context.nCtx, NativeObject);
192 if (x == IntPtr.Zero)
223 return (
ArithExpr)Expr.Create(
Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
230 private ArithExpr GetUpper(uint index)
232 return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
240 Contract.Ensures(Contract.Result<
string>() != null);
241 return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject);
250 return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
260 Contract.Ensures(Contract.Result<
Statistics>() != null);
271 Contract.Requires(ctx != null);
273 internal Optimize(Context ctx)
276 Contract.Requires(ctx != null);
279 internal class DecRefQueue : IDecRefQueue
281 public DecRefQueue() : base() { }
282 public DecRefQueue(uint move_limit) : base(move_limit) { }
283 internal override void IncRef(Context ctx, IntPtr obj)
285 Native.Z3_optimize_inc_ref(ctx.nCtx, obj);
288 internal override void DecRef(Context ctx, IntPtr obj)
290 Native.Z3_optimize_dec_ref(ctx.nCtx, obj);
294 internal override void IncRef(IntPtr o)
296 Context.Optimize_DRQ.IncAndClear(Context, o);
300 internal override void DecRef(IntPtr o)
302 Context.Optimize_DRQ.Add(o);
override string ToString()
Print the context to a string (SMT-LIB parseable benchmark).
Object for managing optimizization context
Z3_optimize Z3_API Z3_mk_optimize(Z3_context c)
Create a new optimize context.
void Push()
Creates a backtracking point.
Objects of this class track statistical information about solvers.
Handle MkMinimize(ArithExpr e)
Declare an arithmetical minimization objective. Similar to MkMaximize.
Handle MkMaximize(ArithExpr e)
Declare an arithmetical maximization objective. Return a handle to the objective. The handle is used ...
void Pop()
Backtrack one backtracking point.
String getReasonUnknown()
Return a string the describes why the last to check returned unknown
Handle to objectives returned by objective functions.
void Assert(params BoolExpr[] constraints)
Assert a constraint (or multiple) into the optimize solver.
Z3_lbool
Lifted Boolean type: false, undefined, true.
static uint Z3_optimize_assert_soft(Z3_context a0, Z3_optimize a1, Z3_ast a2, string a3, IntPtr a4)
Handle AssertSoft(BoolExpr constraint, uint weight, string group)
Assert soft constraint
A Params objects represents a configuration in the form of Symbol/value pairs.
A ParamDescrs describes a set of parameters.
static Z3_stats Z3_optimize_get_statistics(Z3_context a0, Z3_optimize a1)
A Model contains interpretations (assignments) of constants and functions.
static uint Z3_optimize_maximize(Z3_context a0, Z3_optimize a1, Z3_ast a2)
The main interaction with Z3 happens via the Context.
Status Check()
Check satisfiability of asserted constraints. Produce a model that (when the objectives are bounded a...
Arithmetic expressions (int/real)
static Z3_param_descrs Z3_optimize_get_param_descrs(Z3_context a0, Z3_optimize a1)
void Add(params BoolExpr[] constraints)
Alias for Assert.
Internal base class for interfacing with native Z3 objects. Should not be used externally.
Symbols are used to name several term and type constructors.
static int Z3_optimize_check(Z3_context a0, Z3_optimize a1)
static uint Z3_optimize_minimize(Z3_context a0, Z3_optimize a1, Z3_ast a2)