Skip to content

Commit

Permalink
Add AssertSoft String overload for Java Api (#5475)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
intrigus-lgtm authored Aug 12, 2021
1 parent b016465 commit 35698c6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/api/java/Optimize.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,21 @@ public String toString()
*
**/
public Handle<?> AssertSoft(Expr<BoolSort> 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<BoolSort> 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()));
}

/**
Expand Down

0 comments on commit 35698c6

Please sign in to comment.