def initialize_run(): """ initialization procedures. For example: attaching methods to nodes. """ global count_iterations count_iterations = 0 stats.collector = None stats.new_collector() gi.save_weights()
def initialize(): """ initialization procedures. For example: attaching methods to nodes. """ global count_steps count_steps = 0 stats.new_collector() for node in gi.nodes(): if node is not None: setattr(node, "weight", 1.0)
def step(): # what happens in each cycle. Main calls happen here. global count_steps count_steps += 1 print "count_steps "+str(count_steps) nodes = environment.step() wakeup_nodes(nodes) # calls their behaviour, which calls the policy (what to do), and finally applies actions print "killed edges: "+str(stats.collector.num_kills) stats.snapshot() print "total graph weight:"+str(stats.collector.total_weight) stats.new_collector()
def iteration(): # what happens in each cycle. Main calls happen here. print "iteration!" global count_iterations print "count_iterations "+str(count_iterations) nodes = environment.step() wakeup_nodes(nodes) # calls their behaviour, which calls the policy (what to do), and finally applies actions print "killed edges: "+str(stats.collector.num_kills) stats.snapshot() print "total graph weight:"+str(stats.collector.total_weight) print "average path length, see note1:"+ str(stats.collector.path_length) print "mean edge importance:"+str(stats.collector.mean_edges_importance) print "std edge importance:"+str(stats.collector.std_edges_importance) count_iterations +=1 stats.new_collector()