[rules-users] How to deal with doubles in Optaplanner drools rules

Geoffrey De Smet ge0ffrey.spam at gmail.com
Thu Nov 21 07:04:00 EST 2013


Use <scoreDefinitionType>HARD_SOFT_DOUBLE</scoreDefinitionType>

Read this section
http://docs.jboss.org/drools/release/latest/optaplanner-docs/html_single/index.html#d0e4068
and especially this section:
http://docs.jboss.org/drools/release/latest/optaplanner-docs/html_single/index.html#avoidFloatingPointNumbersInScoreCalculation

hth

On 21-11-13 11:54, ns wrote:
> Hi,
>
> I am having trouble dealing with doubles in the Optaplanner drools rule drl
> file. See error message below.
>
> Exception in thread "main" java.lang.IllegalStateException: There are errors
> in the scoreDrl's:
> Error Messages:
> Message [id=1, level=ERROR,
> path=optaplanner-kie-namespace//be/ocmwturnhout/permanenties/solver/permanentiesScoreRules.drl,
> line=96, column=0
>     text=Rule Compilation error The method
> addSoftConstraintMatch(RuleContext, int) in the type HardSoftScoreHolder is
> not applicable for the arguments (RuleContext, double)]
>
> I have the following then rule part:
>
> scoreHolder.addSoftConstraintMatch(kcontext, -(10 *
> Math.abs(($employee.getArbeidsbreuk() * $assignmentTotal.intValue()) -
> $assignmentTotalEmployee.intValue())) * (10 *
> Math.abs(($employee.getArbeidsbreuk().intValue() *
> $assignmentTotal.intValue()) - $assignmentTotalEmployee.intValue())) );
>
> $employee.getArbeidsbreuk() is a double.
>
> Aren't doubles allowed or can I convert it? Thanks.
>
> Kind regards,
>
> Ncik
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/How-to-deal-with-doubles-in-Optaplanner-drools-rules-tp4026865.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list