コード例 #1
0
def get_rule(rule_name):
    global evaluation_method
    global tree_type
    global network_type
    global data_path
    global nb_generations
    
    
    multiprocessing = False
    
    results_path ='../../results/temp/working_results.txt'
    
    #do not display numpy warnings     
    np.seterr('ignore') 

    ne.get_datas_from_real_network(data_path,
                               results_path,
                               evaluation_method= evaluation_method,
                               network_type = network_type)

    genome = ga.new_genome(
                       results_path,
                       evaluation_method= evaluation_method,
                       tree_type = tree_type,
                       network_type = network_type
                       )


    return evolve(genome ,rule_name, nb_generations =nb_generations, multiprocessing = multiprocessing)
コード例 #2
0
ファイル: uni_algo.py プロジェクト: FourquetDavid/evo
def main():
    arguments = sys.argv
    network_name = arguments[1]
    is_directed = arguments[2]
    network_number = arguments[3]
    data_path = arguments[4] #data_path = "../work/files/" + network_number + "-" + network['name'] + "/" + network['name']
    results_path = data_path+"_results.xml"
    stats_path = data_path+'_stats.txt'
    dot_path = data_path+'_trees.jpeg'
    nb_generations = arguments[5]
    freq_stats = arguments[6]


    #evaluation_method = "communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    extension = ".gexf"
    multiprocessing = False
    dynamic = False



    print network_name
    if is_directed == "True" :
        network_type = "directed_unweighted"
        evaluation_method = "degrees_distances_clustering_importance"
    else :
        network_type = "undirected_unweighted"
        evaluation_method = "communities_degrees_distances_clustering_importance"

    ne.get_datas_from_real_network(data_path,
                           results_path,
                           name=network_name,
                           evaluation_method=evaluation_method,
                           dynamic=dynamic)



    genome = ga.new_genome(
        results_path,
        name=network_name,
        data_path=data_path,
        evaluation_method=evaluation_method,
        dynamic=dynamic,
        tree_type=tree_type,
        network_type=network_type,
        extension=extension
    )

                # optional arguments for evolve :
                # *nb_generations : number of generations of the evolution
                #                   possible values : int > 0 : default : 100
                # *freq_stats : number of generations between two prints of statistics
                #                   possible values : int > 0 : default : 5
                # *stats_path : path to the file where the stats will be printed
                # *multiprocessing : will use or not multiprocessing
                #                possible values : True False


    ga.evolve(genome, stats_path=stats_path, dot_path=dot_path, nb_generations=nb_generations, freq_stats=freq_stats,
        multiprocessing=multiprocessing)
コード例 #3
0
def get_rule(rule_name):
    global evaluation_method
    global tree_type
    global network_type
    global data_path
    global nb_generations

    multiprocessing = False

    results_path = '../../results/temp/working_results.txt'

    #do not display numpy warnings
    np.seterr('ignore')

    ne.get_datas_from_real_network(data_path,
                                   results_path,
                                   evaluation_method=evaluation_method,
                                   network_type=network_type)

    genome = ga.new_genome(results_path,
                           evaluation_method=evaluation_method,
                           tree_type=tree_type,
                           network_type=network_type)

    return evolve(genome,
                  rule_name,
                  nb_generations=nb_generations,
                  multiprocessing=multiprocessing)
コード例 #4
0
def main():
    arguments = sys.argv
    network_name = "dwt_weighted_network_1977_C"
    is_directed = True
    network_number = "0"
    data_path = "../work/files/" + network_number + "-" + network_name + "/" + network_name
    results_path = data_path + "_results.xml"
    stats_path = data_path + '_stats.txt'
    dot_path = data_path + '_trees.jpeg'
    nb_generations = 40
    freq_stats = 5

    #evaluation_method = "communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    extension = ".gexf"
    multiprocessing = False
    dynamic = False

    print network_name
    if is_directed == "True":
        network_type = "directed_unweighted"
        evaluation_method = "degrees_distances_clustering_importance"
    else:
        network_type = "undirected_unweighted"
        evaluation_method = "communities_degrees_distances_clustering_importance"

    ne.get_datas_from_real_network(data_path,
                                   results_path,
                                   name=network_name,
                                   evaluation_method=evaluation_method,
                                   dynamic=dynamic)

    genome = ga.new_genome(results_path,
                           name=network_name,
                           data_path=data_path,
                           evaluation_method=evaluation_method,
                           dynamic=dynamic,
                           tree_type=tree_type,
                           network_type=network_type,
                           extension=extension,
                           number_of_nodes=10)

    # optional arguments for evolve :
    # *nb_generations : number of generations of the evolution
    #                   possible values : int > 0 : default : 100
    # *freq_stats : number of generations between two prints of statistics
    #                   possible values : int > 0 : default : 5
    # *stats_path : path to the file where the stats will be printed
    # *multiprocessing : will use or not multiprocessing
    #                possible values : True False

    ga.evolve(genome,
              stats_path=stats_path,
              dot_path=dot_path,
              nb_generations=nb_generations,
              freq_stats=freq_stats,
              multiprocessing=multiprocessing)
コード例 #5
0
ファイル: net_d.py プロジェクト: paulrt/evo
def main():

    number_of_nodes = int(sys.argv[1])
    name = sys.argv[2]
    resdir = sys.argv[3]
    #network_name = name.replace(".gexf","")
    network_name = name
    data_path = name
    #data_path = "data/"+network_name
    #res_path = "data/"+network_name+"_"+str(number_of_nodes)+"_u"
    
    #if not os.path.isfile(res_path+'_stats.txt'):
    if not os.path.exists(resdir):
        os.mkdir(resdir)
    results_path = resdir + "/result.xml" #sys.argv[3] #res_path+"_results.xml"
    stats_path = resdir + "/stats.txt" #res_path+'_stats.txt'
    dot_path = resdir + "/trees.jpeg"
    nb_generations = 40
    freq_stats = 5


    evaluation_method = "communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    extension = ".gexf"
    multiprocessing = False
    dynamic = False



    print network_name
    network_type = "directed_unweighted"
    evaluation_method = "degrees_communities_distances_clustering_importance"

    ne.get_datas_from_real_network(data_path,
                              results_path,
                               name=network_name,
                               evaluation_method=evaluation_method,
                               dynamic=dynamic)



    genome = ga.new_genome(
            results_path,
            name=network_name,
            data_path=data_path,
            evaluation_method=evaluation_method,
            dynamic=dynamic,
            tree_type=tree_type,
            network_type=network_type,
            extension=extension,
            number_of_nodes = number_of_nodes
        )

                    # optional arguments for evolve :
                    # *nb_generations : number of generations of the evolution
                    #                   possible values : int > 0 : default : 100
                    # *freq_stats : number of generations between two prints of statistics
                    #                   possible values : int > 0 : default : 5
                    # *stats_path : path to the file where the stats will be printed
                    # *multiprocessing : will use or not multiprocessing
                    #                possible values : True False


    ga.evolve(genome, stats_path=stats_path, dot_path=dot_path, nb_generations=nb_generations, freq_stats=freq_stats,
            multiprocessing=multiprocessing)
コード例 #6
0
def main():

    evaluation_method = "communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    network_type = "undirected_unweighted"
    network = "karate"
    multiprocessing = False
    dynamic = False
    data_path = '../../data/{}/'.format(network)
    results_path = '../../results/{}/{}.xml'.format(network, evaluation_method)
    stats_path = '../../results/{}/{}_stats.txt'.format(
        network, evaluation_method)
    nb_generations = 11
    freq_stats = 5
    #do not display numpy warnings
    np.seterr('ignore')

    #arguments : path to the real network, path to print datas
    #possible arguments :
    #*evaluation_method : the method used to evaluate the proximity between real network and generated network
    #                        possible values : "(nodes)_(vertices)_(clustering)_(importance)_(communities)_(distances)_(degrees)"
    ne.get_datas_from_real_network(data_path,
                                   results_path,
                                   name=network,
                                   evaluation_method=evaluation_method,
                                   network_type=network_type,
                                   dynamic=dynamic,
                                   extension=".gexf")

    #arguments : path to datas about the real network
    #optional arguments for genome :
    #*max_depth : maximal depth of the decision tree that defines a genome
    #             possible values : int > 0
    #evaluation_method : the method used to evaluate the proximity between real network and generated network
    #                        possible values : "(nodes)_(vertices)_(clustering)_(importance)_(communities)_(distances)_(degrees)"
    #tree_type : the type of the trees used to stores genomes : with or without constants in leaves
    #                        possible values : "with_constants" "simple"
    #network_type : the type of the networks studied and generated : directed or not
    #                possible values : "(un)weighted_(un)directed"
    #dynamic : if the network is dynamic or not

    genome = ga.new_genome(results_path,
                           name=network,
                           data_path=data_path,
                           evaluation_method=evaluation_method,
                           dynamic=dynamic,
                           tree_type=tree_type,
                           network_type=network_type,
                           extension=".gexf")

    #optional arguments for evolve :
    #*nb_generations : number of generations of the evolution
    #                   possible values : int > 0 : default : 100
    #*freq_stats : number of generations between two prints of statistics
    #                   possible values : int > 0 : default : 5
    #*stats_path : path to the file where the stats will be printed
    #*multiprocessing : will use or not multiprocessing
    #                possible values : True False

    ga.evolve(genome,
              stats_path=stats_path,
              nb_generations=nb_generations,
              freq_stats=freq_stats,
              multiprocessing=multiprocessing)
コード例 #7
0
def main():
    #evaluation_method = "communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    extension = ".gexf"
    multiprocessing = True
    dynamic = False

    nb_generations = 40
    freq_stats = 10
    while (True):
        try:
            with open("../work/done.csv") as csvfile:
                network_dict = csv.DictReader(csvfile, delimiter=";")
                for network in network_dict:
                    if random.random() < 0.05 and int(
                            network['nb_nodes']) < 1000 and not_done(network):
                        network_name = network['name']
                        print network_name
                        if network['is_directed'] == "True":
                            network_type = "directed_unweighted"
                            evaluation_method = "degrees_distances_clustering_importance"
                        else:
                            network_type = "undirected_unweighted"
                            evaluation_method = "communities_degrees_distances_clustering_importance"

                        data_path = "../work/files/" + network[
                            'number'] + "-" + network['name'] + "/" + network[
                                'name']
                        results_path = data_path + "_results.xml"
                        stats_path = data_path + '_stats.txt'
                        dot_path = data_path + '_trees.jpeg'

                        ne.get_datas_from_real_network(
                            data_path,
                            results_path,
                            name=network_name,
                            evaluation_method=evaluation_method,
                            dynamic=dynamic)

                        genome = ga.new_genome(
                            results_path,
                            name=network_name,
                            data_path=data_path,
                            evaluation_method=evaluation_method,
                            dynamic=dynamic,
                            tree_type=tree_type,
                            network_type=network_type,
                            extension=extension)

                        # optional arguments for evolve :
                        # *nb_generations : number of generations of the evolution
                        #                   possible values : int > 0 : default : 100
                        # *freq_stats : number of generations between two prints of statistics
                        #                   possible values : int > 0 : default : 5
                        # *stats_path : path to the file where the stats will be printed
                        # *multiprocessing : will use or not multiprocessing
                        #                possible values : True False

                        ga.evolve(genome,
                                  stats_path=stats_path,
                                  dot_path=dot_path,
                                  nb_generations=nb_generations,
                                  freq_stats=freq_stats,
                                  multiprocessing=multiprocessing)
        except Exception, e:
            print e
コード例 #8
0
ファイル: seastems2.py プロジェクト: paulrt/seastems
def main():
    # arg1 : le nombre de noeuds voulus, permet de raccourcir l'execution lors de tests
    # arg2: data file ".gexf"
    # arg3 : le res directory
    # arg4 : liste des distances ".csv" ou ".gexf"
    # arg 5 : liste des donnees des noeuds ".txt"
    number_of_nodes = int(sys.argv[1])
    name = sys.argv[2]
    network_name = name
    data_path = name
    resdir = sys.argv[3]
    edge_data = None if sys.argv[4] == 'None' else sys.argv[4]
    node_data = None if sys.argv[5] == 'None' else sys.argv[5]
    if not os.path.exists(resdir):
        os.mkdir(resdir)
    results_path = resdir + "/result.xml"
    stats_path = resdir + "/stats.txt"
    dot_path = resdir + "/trees.jpeg"
    nb_generations = 40
    freq_stats = 5

    tree_type = "with_constants"
    extension = ""
    multiprocessing = False
    dynamic = False

    print network_name
    network_type = "undirected_unweighted"
    evaluation_method = "degrees_communities_distances_clustering_importance"

    ne.get_datas_from_real_network(data_path,
                                   results_path,
                                   name=network_name,
                                   evaluation_method=evaluation_method,
                                   dynamic=dynamic)

    genome = ga.new_genome(results_path,
                           name=network_name,
                           data_path=data_path,
                           evaluation_method=evaluation_method,
                           dynamic=dynamic,
                           tree_type=tree_type,
                           network_type=network_type,
                           extension=extension,
                           number_of_nodes=number_of_nodes,
                           edge_data=edge_data,
                           node_data=node_data)

    # optional arguments for evolve :
    # *nb_generations : number of generations of the evolution
    #                   possible values : int > 0 : default : 100
    # *freq_stats : number of generations between two prints of statistics
    #                   possible values : int > 0 : default : 5
    # *stats_path : path to the file where the stats will be printed
    # *multiprocessing : will use or not multiprocessing
    #                possible values : True False

    ga.evolve(genome,
              stats_path=stats_path,
              dot_path=dot_path,
              nb_generations=nb_generations,
              freq_stats=freq_stats,
              multiprocessing=multiprocessing)
コード例 #9
0
def main() :

    evaluation_method ="communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    network_type = "undirected_unweighted"
    network = "karate"
    multiprocessing = False
    dynamic = False
    data_path = '../../data/{}/'.format(network)
    results_path ='../../results/{}/{}.xml'.format(network,evaluation_method)
    stats_path = '../../results/{}/{}_stats.txt'.format(network,evaluation_method)
    nb_generations =11 
    freq_stats =5
    #do not display numpy warnings     
    np.seterr('ignore') 
 
    
#arguments : path to the real network, path to print datas
    #possible arguments : 
#*evaluation_method : the method used to evaluate the proximity between real network and generated network
#                        possible values : "(nodes)_(vertices)_(clustering)_(importance)_(communities)_(distances)_(degrees)"
    ne.get_datas_from_real_network(data_path,
                               results_path,
                               name= network,
                               evaluation_method= evaluation_method,
                               network_type = network_type,
                               dynamic = dynamic,
                               extension = ".gexf")
    
    
#arguments : path to datas about the real network
#optional arguments for genome : 
#*max_depth : maximal depth of the decision tree that defines a genome 
#             possible values : int > 0
#evaluation_method : the method used to evaluate the proximity between real network and generated network
#                        possible values : "(nodes)_(vertices)_(clustering)_(importance)_(communities)_(distances)_(degrees)"
#tree_type : the type of the trees used to stores genomes : with or without constants in leaves
#                        possible values : "with_constants" "simple"
#network_type : the type of the networks studied and generated : directed or not
#                possible values : "(un)weighted_(un)directed"
#dynamic : if the network is dynamic or not
    
    genome = ga.new_genome(
                       results_path,
                       name= network,
                       data_path = data_path,
                       evaluation_method= evaluation_method,
                       dynamic = dynamic,
                       tree_type = tree_type,
                       network_type = network_type,
                       extension = ".gexf"
                       )
    
#optional arguments for evolve :
#*nb_generations : number of generations of the evolution 
#                   possible values : int > 0 : default : 100
#*freq_stats : number of generations between two prints of statistics 
#                   possible values : int > 0 : default : 5
#*stats_path : path to the file where the stats will be printed 
#*multiprocessing : will use or not multiprocessing 
#                possible values : True False
    

    ga.evolve(genome,stats_path = stats_path , nb_generations =nb_generations,freq_stats = freq_stats, multiprocessing = multiprocessing)
コード例 #10
0
ファイル: many_algo.py プロジェクト: FourquetDavid/evo
def main():
    #evaluation_method = "communities_degrees_distances_clustering_importance"
    tree_type = "with_constants"
    extension = ".gexf"
    multiprocessing = True
    dynamic = False

    nb_generations = 40
    freq_stats = 10
    while(True) :
        try :
            with open("../work/done.csv") as csvfile:
                network_dict = csv.DictReader(csvfile, delimiter=";")
                for network in network_dict:
                    if random.random() < 0.05 and int(network['nb_nodes']) < 1000 and not_done(network)  :
                        network_name = network['name']
                        print network_name
                        if network['is_directed'] == "True" :
                            network_type = "directed_unweighted"
                            evaluation_method = "degrees_distances_clustering_importance"
                        else :
                            network_type = "undirected_unweighted"
                            evaluation_method = "communities_degrees_distances_clustering_importance"

                        data_path = "../work/files/" + network['number'] + "-" + network['name'] + "/" + network['name']
                        results_path = data_path+"_results.xml"
                        stats_path = data_path+'_stats.txt'
                        dot_path = data_path+'_trees.jpeg'





                        ne.get_datas_from_real_network(data_path,
                                               results_path,
                                               name=network_name,
                                               evaluation_method=evaluation_method,
                                               dynamic=dynamic)



                        genome = ga.new_genome(
                            results_path,
                            name=network_name,
                            data_path=data_path,
                            evaluation_method=evaluation_method,
                            dynamic=dynamic,
                            tree_type=tree_type,
                            network_type=network_type,
                            extension=extension
                        )

                # optional arguments for evolve :
                # *nb_generations : number of generations of the evolution
                #                   possible values : int > 0 : default : 100
                # *freq_stats : number of generations between two prints of statistics
                #                   possible values : int > 0 : default : 5
                # *stats_path : path to the file where the stats will be printed
                # *multiprocessing : will use or not multiprocessing
                #                possible values : True False


                        ga.evolve(genome, stats_path=stats_path, dot_path=dot_path, nb_generations=nb_generations, freq_stats=freq_stats,
                            multiprocessing=multiprocessing)
        except Exception, e:
            print e