예제 #1
0
파일: ACO_Sweep.py 프로젝트: mjsyp/Python
    store_data(space,results,pareto_history,run_output_path)
    visualize(space,pareto_history,ant_graphs,run_output_path)
    
#Run through dissipation rates

dissipation_list=[.6,.7,.8,.9]
out_p='output'
num_trials=5
results_list=[]
for c in xrange(len(dissipation_list)):
    print 'Running dissipation =',dissipation_list[c]
    for n in xrange(num_trials):
        #initialize with dissipation rate
        s=Space(size=[4,4],num_ants=10,num_colonies=10,
           source=[[(0,0)],[(3,3)]],source_magnitude=[[20],[10]],
           sink=[[(3,3),(1,3)],[(0,0),(2,0)]],sink_magnitude=[[10,10],[5,5]], sink_threshold=[[.5,1.0],[1.0,1.0]],
           links=[(1,0,(3,3))],capacities=[[5,10],[5]],edge_capacity=20,percent_removals=1.0,
           dissipation=dissipation_list[c],initial_pheromone=1.0,initial_termination=1.0,
           alpha=1.0,beta=1.0)
        
        #iterate until coverged
        converged=0
        i=1
        pareto_history=[]
        criteria=0
        while not converged:
            ant_graphs=s.step()
    
            paretoPoints=[]
            for ant in xrange(len(ant_graphs)):
                paretoPoints.append(ant_graphs[ant][-1])
    
예제 #2
0
파일: SS_ACO Run.py 프로젝트: mjsyp/Python
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 23 17:28:10 2015

@author: colinsh
"""

from System_Structure_ACO import Space


space=Space(size=[4,4],num_ants=10,num_colonies=10,
            source=[[(0,0)],[(3,3)]],source_magnitude=[[20],[10]],
            sink=[[(3,3),(1,3)],[(0,0),(2,0)]],sink_magnitude=[[10,10],[5,5]], sink_threshold=[[.5,1.0],[1.0,1.0]],
            links=[(1,0,(3,3))],capacities=[[5,10],[5]],edge_capacity=20,percent_removals=1.0,
            dissipation=0.7,initial_pheromone=1.0,initial_termination=1.0,
            alpha=1.0,beta=1.0)
converged=0
i=1
pareto_history=[]
criteria=0
while not converged:
    ant_graphs=space.step()
    
    paretoPoints=[]
    for ant in xrange(len(ant_graphs)):
        paretoPoints.append(ant_graphs[ant][-1])
    
    pareto_history.append(paretoPoints)
    if i>5 and pareto_history[-1]==pareto_history[-2]:
        criteria+=1
    else: