开发者

How to guard against dividing by zero when doing symbolic regression? ECJ

I'm writing a genetic program to perform symbolic regression on a formula. I'm using ECJ. See tutorial 4 of the samples that开发者_如何学编程 come with ECJ for an example of what this is and the base that I started off of.

The problem comes when implementing division as a function to your genetic program. How do you guard against dividing by zero?


In Java, the Division Operator throws ArithmeticException for an integer divisor equal to zero. For floating-point operands, "Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the [following] rule: ... the sign of the result is positive if both operands have the same sign, negative if the operands have different signs."

So, you either handle the exception or check the results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜