Status: Accepted
Owner: felix.antoine.fortin
Labels: Type-Defect Priority-Medium
New issue 35 by felix.antoine.fortin: safeDiv should return 1 when the
denominator is 0
http://code.google.com/p/deap/issues/detail?id=35
After looking up the other popular frameworks, it appears that everyone
returns 1 when the denominator of the protected division is 0. I am not
sure where I originally got the idea to return 0... Even in Koza original
book, the list implementation of the protected division returns 1 when the
denominator is zero.
(defun % (numerator denominator)
"The Protected Division Function"
(values (if (= 0 denominator) 1 (/ numerator denominator)))
)
This is also recommended in A Field Guide to Genetic Programming by Poli
and Landgon p.22 footnote 1
"The decision to return the value 1 provides the GP system with a simple
way to
generate the constant 1, via an expression of the form (% x x). This
combined with a
similar mechanism for generating 0 via (- x x) ensures that GP can easily
construct
these two important constants."
To avoid confusion, we should probably rename the function from safeDiv to
protDiv or divProtected.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings