CODE Help

In Python

Dear All

I Want Attached Code To Convert The pseudocode for Sequential constructive crossover operator algorithm ,

to executable code with python Language

I Cant Do It

Can Anyone Please Help Me And Mail It To

[email protected]

Will Be Super Grateful

Thankyou

Attachments

New_Blank_Document.pdf (35.4 KB)

If your node setup is like a tree. You can make use of recursive functions to inspect the parents or childs of each element. Its more natural to find all root elements first and then perform operations on each child but look for parents given a node is also posible.

something like


def search_parents(node):

    parent = node.parent:

    if parent == None: #this is a root element

        #do something
        return any_value

    else:

        #this node has parent
        #recursive traverse all subsequence parents

        any_value = search_parent(parent)

        #do something with any_value
        return any_other_value

nodes = chromosomes.nodes

for each node in nodes:

    search_parent(node)

or

node = chromosomes[34] #any random node inside nodes
search_parent(node)

This code assumes that you have a single parent for each node. If you have many the only difference is that you have to iterate for each one of them before calling search_parents.