[deap] push by felix.antoine.fortin - First fix for bug with OOGP when primitive and terminal insertion is n... on 2014-05-20 22:50 GMT

1 view
Skip to first unread message

de...@googlecode.com

unread,
May 20, 2014, 6:51:04 PM5/20/14
to deap-de...@googlegroups.com
Revision: c97db56930d1
Branch: default
Author: felix.antoine.fortin
Date: Tue May 20 22:50:39 2014 UTC
Log: First fix for bug with OOGP when primitive and terminal insertion
is not ordered.

See gist : https://gist.github.com/cmd-ntrf/7cf0db102eec88041432
and thread : https://groups.google.com/forum/#!topic/deap-users/4ASc8RZzpVc
http://code.google.com/p/deap/source/detail?r=c97db56930d1

Modified:
/deap/gp.py

=======================================
--- /deap/gp.py Wed Mar 26 21:42:45 2014 UTC
+++ /deap/gp.py Tue May 20 22:50:39 2014 UTC
@@ -277,10 +277,13 @@
def _add(self, prim):
def addType(dict_, ret_type):
if not ret_type in dict_:
- dict_[ret_type]
+ new_list = []
for type_, list_ in dict_.items():
if issubclass(type_, ret_type):
- dict_[ret_type].extend(list_)
+ for item in list_:
+ if not item in new_list:
+ new_list.append(item)
+ dict_[ret_type] = new_list

addType(self.primitives, prim.ret)
addType(self.terminals, prim.ret)
Reply all
Reply to author
Forward
0 new messages