19package com.microsoft.z3;
21import com.microsoft.z3.enumerations.Z3_lbool;
27@SuppressWarnings(
"unchecked")
35 return Native.optimizeGetHelp(getContext().nCtx(), getNativeObject());
45 Native.optimizeSetParams(getContext().nCtx(), getNativeObject(), value.getNativeObject());
53 return new ParamDescrs(getContext(), Native.optimizeGetParamDescrs(getContext().nCtx(), getNativeObject()));
61 getContext().checkContextMatch(constraints);
64 Native.optimizeAssert(getContext().nCtx(), getNativeObject(), a.getNativeObject());
91 getContext().checkContextMatch(constraint);
92 getContext().checkContextMatch(p);
94 Native.optimizeAssertAndTrack(getContext().nCtx(), getNativeObject(),
95 constraint.getNativeObject(), p.getNativeObject());
101 public static class Handle<R
extends Sort> {
104 private final int handle;
115 public Expr<R> getLower()
117 return opt.GetLower(handle);
123 public Expr<R> getUpper()
125 return opt.GetUpper(handle);
136 public Expr<?>[] getUpperAsVector()
138 return opt.GetUpperAsVector(handle);
146 public Expr<?>[] getLowerAsVector()
148 return opt.GetLowerAsVector(handle);
154 public Expr<R> getValue()
165 return getValue().toString();
177 return AssertSoft(constraint, Integer.
toString(weight), group);
188 getContext().checkContextMatch(constraint);
189 Symbol s = getContext().mkSymbol(group);
190 return new Handle<>(
this, Native.optimizeAssertSoft(getContext().nCtx(), getNativeObject(), constraint.getNativeObject(), weight, s.getNativeObject()));
201 if (assumptions ==
null) {
203 Native.optimizeCheck(
205 getNativeObject(), 0,
null));
209 Native.optimizeCheck(
230 Native.optimizePush(getContext().nCtx(), getNativeObject());
240 Native.optimizePop(getContext().nCtx(), getNativeObject());
252 long x = Native.optimizeGetModel(getContext().nCtx(), getNativeObject());
256 return new Model(getContext(), x);
271 ASTVector core =
new ASTVector(getContext(), Native.optimizeGetUnsatCore(getContext().nCtx(), getNativeObject()));
280 public <R extends Sort> Handle<R> MkMaximize(
Expr<R> e)
282 return new Handle<>(
this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
289 public <R extends Sort> Handle<R> MkMinimize(Expr<R> e)
291 return new Handle<>(
this, Native.optimizeMinimize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
297 private <R extends Sort> Expr<R> GetLower(
int index)
299 return (Expr<R>) Expr.create(getContext(), Native.optimizeGetLower(getContext().nCtx(), getNativeObject(), index));
305 private <R extends Sort> Expr<R> GetUpper(
int index)
307 return (Expr<R>) Expr.create(getContext(), Native.optimizeGetUpper(getContext().nCtx(), getNativeObject(), index));
315 private Expr<?>[] GetUpperAsVector(
int index) {
316 return unpackObjectiveValueVector(
317 Native.optimizeGetUpperAsVector(
318 getContext().nCtx(), getNativeObject(), index
328 private Expr<?>[] GetLowerAsVector(
int index) {
329 return unpackObjectiveValueVector(
330 Native.optimizeGetLowerAsVector(
331 getContext().nCtx(), getNativeObject(), index
336 private Expr<?>[] unpackObjectiveValueVector(
long nativeVec) {
337 ASTVector vec =
new ASTVector(
338 getContext(), nativeVec
341 (Expr<?>) vec.get(0), (Expr<?>) vec.get(1), (Expr<?>) vec.get(2)
351 return Native.optimizeGetReasonUnknown(getContext().nCtx(), getNativeObject());
360 return Native.optimizeToString(getContext().nCtx(), getNativeObject());
369 Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
377 Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
385 ASTVector assertions =
new ASTVector(getContext(), Native.optimizeGetAssertions(getContext().nCtx(), getNativeObject()));
394 ASTVector objectives =
new ASTVector(getContext(), Native.optimizeGetObjectives(getContext().nCtx(), getNativeObject()));
403 return new Statistics(getContext(), Native.optimizeGetStatistics(getContext().nCtx(), getNativeObject()));
412 Optimize(Context ctx)
throws Z3Exception
414 super(ctx, Native.mkOptimize(ctx.nCtx()));
419 Native.optimizeIncRef(getContext().nCtx(), getNativeObject());
423 void addToReferenceQueue() {
424 getContext().getOptimizeDRQ().storeReference(getContext(),
this);
BoolExpr[] ToBoolExprArray()
Status Check(Expr< BoolSort >... assumptions)
Expr<?>[] getObjectives()
void AssertAndTrack(Expr< BoolSort > constraint, Expr< BoolSort > p)
ParamDescrs getParameterDescriptions()
void fromString(String s)
void setParameters(Params value)
BoolExpr[] getUnsatCore()
Handle<?> AssertSoft(Expr< BoolSort > constraint, int weight, String group)
void Assert(Expr< BoolSort > ... constraints)
BoolExpr[] getAssertions()
void Add(Expr< BoolSort > ... constraints)
void fromFile(String file)
String getReasonUnknown()
Handle<?> AssertSoft(Expr< BoolSort > constraint, String weight, String group)
Statistics getStatistics()
static long[] arrayToNative(Z3Object[] a)
Z3_lbool
Lifted Boolean type: false, undefined, true.
def String(name, ctx=None)