37 return Native.optimizeGetHelp(getContext().nCtx(), getNativeObject());
47 Native.optimizeSetParams(getContext().nCtx(), getNativeObject(), value.getNativeObject());
55 return new ParamDescrs(getContext(), Native.optimizeGetParamDescrs(getContext().nCtx(), getNativeObject()));
63 getContext().checkContextMatch(constraints);
66 Native.optimizeAssert(getContext().nCtx(), getNativeObject(), a.getNativeObject());
95 getContext().checkContextMatch(constraint);
96 getContext().checkContextMatch(p);
98 Native.optimizeAssertAndTrack(getContext().nCtx(), getNativeObject(),
99 constraint.getNativeObject(), p.getNativeObject());
105 public static class Handle<R
extends Sort> {
108 private final int handle;
119 public Expr<R> getLower()
121 return opt.GetLower(handle);
127 public Expr<R> getUpper()
129 return opt.GetUpper(handle);
140 public Expr<?>[] getUpperAsVector()
142 return opt.GetUpperAsVector(handle);
150 public Expr<?>[] getLowerAsVector()
152 return opt.GetLowerAsVector(handle);
158 public Expr<R> getValue()
169 return getValue().toString();
181 return AssertSoft(constraint, Integer.
toString(weight), group);
192 getContext().checkContextMatch(constraint);
193 Symbol s = getContext().mkSymbol(group);
194 return new Handle<>(
this, Native.optimizeAssertSoft(getContext().nCtx(), getNativeObject(), constraint.getNativeObject(), weight, s.getNativeObject()));
205 if (assumptions ==
null) {
207 Native.optimizeCheck(
209 getNativeObject(), 0,
null));
213 Native.optimizeCheck(
234 Native.optimizePush(getContext().nCtx(), getNativeObject());
244 Native.optimizePop(getContext().nCtx(), getNativeObject());
256 long x = Native.optimizeGetModel(getContext().nCtx(), getNativeObject());
260 return new Model(getContext(), x);
275 ASTVector core =
new ASTVector(getContext(), Native.optimizeGetUnsatCore(getContext().nCtx(), getNativeObject()));
284 public <R extends Sort> Handle<R> MkMaximize(
Expr<R> e)
286 return new Handle<>(
this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
293 public <R extends Sort> Handle<R> MkMinimize(Expr<R> e)
295 return new Handle<>(
this, Native.optimizeMinimize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
301 private <R extends Sort> Expr<R> GetLower(
int index)
303 return (Expr<R>) Expr.create(getContext(), Native.optimizeGetLower(getContext().nCtx(), getNativeObject(), index));
309 private <R extends Sort> Expr<R> GetUpper(
int index)
311 return (Expr<R>) Expr.create(getContext(), Native.optimizeGetUpper(getContext().nCtx(), getNativeObject(), index));
319 private Expr<?>[] GetUpperAsVector(
int index) {
320 return unpackObjectiveValueVector(
321 Native.optimizeGetUpperAsVector(
322 getContext().nCtx(), getNativeObject(), index
332 private Expr<?>[] GetLowerAsVector(
int index) {
333 return unpackObjectiveValueVector(
334 Native.optimizeGetLowerAsVector(
335 getContext().nCtx(), getNativeObject(), index
340 private Expr<?>[] unpackObjectiveValueVector(
long nativeVec) {
341 ASTVector vec =
new ASTVector(
342 getContext(), nativeVec
345 (Expr<?>) vec.get(0), (Expr<?>) vec.get(1), (Expr<?>) vec.get(2)
355 return Native.optimizeGetReasonUnknown(getContext().nCtx(), getNativeObject());
364 return Native.optimizeToString(getContext().nCtx(), getNativeObject());
373 Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
381 Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
389 ASTVector assertions =
new ASTVector(getContext(), Native.optimizeGetAssertions(getContext().nCtx(), getNativeObject()));
398 ASTVector objectives =
new ASTVector(getContext(), Native.optimizeGetObjectives(getContext().nCtx(), getNativeObject()));
412 getContext().checkContextMatch(var);
413 getContext().checkContextMatch(value);
414 Native.optimizeSetInitialValue(getContext().nCtx(), getNativeObject(),
415 var.getNativeObject(), value.getNativeObject());
423 return new Statistics(getContext(), Native.optimizeGetStatistics(getContext().nCtx(), getNativeObject()));
432 Optimize(Context ctx)
throws Z3Exception
434 super(ctx, Native.mkOptimize(ctx.nCtx()));
439 Native.optimizeIncRef(getContext().nCtx(), getNativeObject());
443 void addToReferenceQueue() {
444 getContext().getReferenceQueue().storeReference(
this, OptimizeRef::new);
447 private static class OptimizeRef
extends Z3ReferenceQueue.Reference<Optimize> {
449 private OptimizeRef(Optimize referent, ReferenceQueue<Z3Object> q) {
454 void decRef(Context ctx,
long z3Obj) {
455 Native.optimizeDecRef(ctx.nCtx(), z3Obj);