From 35698c650d4ccdd8194af18ce0465c86885e582d Mon Sep 17 00:00:00 2001 From: intrigus-lgtm <60750685+intrigus-lgtm@users.noreply.github.com> Date: Thu, 12 Aug 2021 18:18:18 +0200 Subject: [PATCH] Add AssertSoft String overload for Java Api (#5475) This adds a String overload for AssertSoft. Previously only integer weights could have been used, limiting the user. With Strings the user can now use e.g. Java's BigInteger class converted to a String instead. --- src/api/java/Optimize.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/api/java/Optimize.java b/src/api/java/Optimize.java index c5a26b439..d72a28f08 100644 --- a/src/api/java/Optimize.java +++ b/src/api/java/Optimize.java @@ -173,10 +173,21 @@ public class Optimize extends Z3Object { * **/ public Handle AssertSoft(Expr constraint, int weight, String group) + { + return AssertSoft(constraint, Integer.toString(weight), group); + } + + /** + * Assert soft constraint + * + * Return an objective which associates with the group of constraints. + * + **/ + public Handle AssertSoft(Expr constraint, String weight, String group) { getContext().checkContextMatch(constraint); Symbol s = getContext().mkSymbol(group); - return new Handle<>(this, Native.optimizeAssertSoft(getContext().nCtx(), getNativeObject(), constraint.getNativeObject(), Integer.toString(weight), s.getNativeObject())); + return new Handle<>(this, Native.optimizeAssertSoft(getContext().nCtx(), getNativeObject(), constraint.getNativeObject(), weight, s.getNativeObject())); } /**