Exemple #1
0
def new_genome(results_path, **kwargs):
    '''
    *new_genome : takes a set of alleles [function_alleles, leaves_alleles] 
                and options that define initializator, mutator, crossover, evaluator 
                and returns a genome with those options
                
                possible initializator : "grow" : "grow" algorithm of network = recursive and possibly incomplete
                possible mutator : "simple" : change genomic alleles with possible alleles with probability pmut
                possible crossover :
                possible evaluator : "degree_distribution", "2distributions"
                possible network-type : "directed_weighted", "directed_unweighted", "undirected_weighted", "undirected_unweighted"
                possible tree_type : "with_constants"
     '''
    evaluation_method = kwargs.get("evaluation_method")
    network_type = kwargs.get("network_type")
    data_path = kwargs.get("data_path")
    name = kwargs.get("name")
    dynamic = kwargs.get("dynamic")
    extension = kwargs.get("extension")

    choices = emo.get_alleles(evaluation_method, network_type)
    genome = py.GTree.GTree()

    #genome.setParams(nb_nodes=ne.get_number_of_nodes(results_path))
    #genome.setParams(nb_edges=ne.get_number_of_edges(results_path))
    genome.setParams(data_path=data_path)
    genome.setParams(results_path=results_path)
    genome.setParams(name=name)
    genome.setParams(extension=extension)

    #defines alleles : one array containing possible leaves and one containing possible functions
    alleles = gall.GAlleles()
    lst = gall.GAlleleList(choices)
    alleles.add(lst)
    genome.setParams(allele=alleles)

    #defines the way to construct a random tree
    genome.setParams(max_depth=int(kwargs.get("max_depth", "3")))
    genome.setParams(max_siblings=int(kwargs.get("max_siblings", "2")))

    genome.setParams(tree_type=kwargs.get("tree_type", "default"))
    genome.initializator.set(tree_init)

    #defines the how to evaluate a genome
    genome.setParams(evaluation_method=evaluation_method)
    if dynamic:
        genome.evaluator.set(eval_func_dynamic)
    else:
        genome.evaluator.set(eval_func)

    #defines the crossover function - default now

    #defines the function that mutates trees
    genome.mutator.set(mutate_tree)

    #defines the network_type
    genome.setParams(network_type=network_type)

    #tree_init(genome)
    return genome
def new_genome(results_path, **kwargs):
    """
    *new_genome : takes a set of alleles [function_alleles, leaves_alleles]
                and options that define initializator, mutator, crossover, evaluator
                and returns a genome with those options

                possible initializator : "grow" : "grow" algorithm of network = recursive and possibly incomplete
                possible mutator : "simple" : change genomic alleles with possible alleles with probability pmut
                possible crossover :
                possible evaluator : "degree_distribution", "2distributions"
                possible network-type : "directed_weighted", "directed_unweighted", "undirected_weighted", "undirected_unweighted"
                possible tree_type : "with_constants"
     """
    evaluation_method = kwargs.get("evaluation_method")
    network_type = kwargs.get("network_type")
    data_path = kwargs.get("data_path")
    name = kwargs.get("name")
    dynamic = kwargs.get("dynamic")
    extension = kwargs.get("extension")

    choices = emo.get_alleles(evaluation_method, network_type)
    genome = py.GTree.GTree()

    # genome.setParams(nb_nodes=ne.get_number_of_nodes(results_path))
    # genome.setParams(nb_edges=ne.get_number_of_edges(results_path))
    genome.setParams(data_path=data_path)
    genome.setParams(results_path=results_path)
    genome.setParams(name=name)
    genome.setParams(extension=extension)

    # defines alleles : one array containing possible leaves and one containing possible functions
    alleles = gall.GAlleles()
    lst = gall.GAlleleList(choices)
    alleles.add(lst)
    genome.setParams(allele=alleles)

    # defines the way to construct a random tree
    genome.setParams(max_depth=int(kwargs.get("max_depth", "3")))
    genome.setParams(max_siblings=int(kwargs.get("max_siblings", "2")))

    genome.setParams(tree_type=kwargs.get("tree_type", "default"))
    genome.initializator.set(tree_init)

    # defines the how to evaluate a genome
    genome.setParams(evaluation_method=evaluation_method)
    if dynamic:
        genome.evaluator.set(eval_func_dynamic)
    else:
        genome.evaluator.set(eval_func)

    # defines the crossover function - default now

    # defines the function that mutates trees
    genome.mutator.set(mutate_tree)

    # defines the network_type
    genome.setParams(network_type=network_type)

    # tree_init(genome)
    return genome
def createListOfRules():
    choices = emo.get_alleles(evaluation_method,network_type)[1]
    list_of_rules = []
    for allele in choices :
        list_of_rules.append(py.GTree.GTreeNode([5,allele]))
    return list_of_rules
Exemple #4
0
def createListOfRules():
    choices = emo.get_alleles(evaluation_method, network_type)[1]
    list_of_rules = []
    for allele in choices:
        list_of_rules.append(py.GTree.GTreeNode([5, allele]))
    return list_of_rules