Could not invoke method: java.lang.Math.floor(double) on instance: null in weather
This sort of error is a little bit misleading in a way. The problem isn’t that the calculation is null or any of the three variables involved in the calculation is null. The problem is that Rules DSL couldn’t figure out a way to coerce the type of the result of the calculation to the type required by Math.floor.
As shown in the error, Math.floor requires a double. But calculation in Rules DSL result in a BigDecimal, not a primitive double or int. So this is one of the cases where you need to convert and specify the type explicitly.
Your “fix” worked because you coerced one of the number to be a primitive float which caused Rules DSL to keep the result of the calculation as a float and there is in fact a Math.floor(float).
I would recommend doing the following instead.
var opt = Math.floor(((hpa - hpamin)/hpcont).doubleValue())
Let Rules DSL keep everything as a BigDecimal until the vary last moment where we convert the result of the calculation to a double.