How can I modify a node in a GP tree?

26 views
Skip to first unread message

Ben

unread,
Dec 20, 2017, 1:01:50 AM12/20/17
to deap-users
Hi there,

I am using STGP. Trees are represented as PrimtiveTrees.
To access a particular node in a tree I can index in as tree[5] for example.

How would I then go about modifying this node? i.e.

tree[5] = updated_value

The type of the node is a Custom class, but when extracting from the tree it is of type deap.gp.Custom.
So how can I convert my variable to this deap.gp form?

I cant use the from string method, as this is broken for custom types and lists, both of which I need

Thanks!

Ben

unread,
Dec 20, 2017, 2:42:26 AM12/20/17
to deap-users
I thought this could be a workaround

new_tree = deepcopy(tree)
new_tree
[5].value = ['a']


But this still changes the original "tree", rather than performing a deep copy for some reason

Reply all
Reply to author
Forward
0 new messages