Issue 35 in deap: safeDiv should return 1 when the denominator is 0

2 views
Skip to first unread message

de...@googlecode.com

unread,
Mar 26, 2014, 9:33:52 AM3/26/14
to deap-de...@googlegroups.com
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

de...@googlecode.com

unread,
Mar 26, 2014, 9:35:43 AM3/26/14
to deap-de...@googlegroups.com

Comment #1 on issue 35 by felix.antoine.fortin: safeDiv should return 1
Here is the list of example where safeDiv is present:
gp/adf_symbreg.py
gp/spambase.py
gp/symbreg.py
gp/symbreg_numpy.py

de...@googlecode.com

unread,
Apr 2, 2014, 9:05:56 AM4/2/14
to deap-de...@googlegroups.com
Updates:
Labels: Milestone-Release1.1.0

Comment #2 on issue 35 by felix.antoine.fortin: safeDiv should return 1
It has been fixed in revision 891d003bebe7.

I opted for protectedDiv as a name for the new function.

de...@googlecode.com

unread,
Apr 2, 2014, 9:07:49 AM4/2/14
to deap-de...@googlegroups.com
Updates:
Status: Fixed

Comment #3 on issue 35 by felix.antoine.fortin: safeDiv should return 1
Hat tip to Mattias Borwald for pointing out this issue.
Reply all
Reply to author
Forward
0 new messages