Changeset 1929 in genesis for nodes/channelga.py
- Timestamp:
- Mar 28, 2004, 2:55:05 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/channelga.py
r1928 r1929 20 20 import re 21 21 import random 22 import os 22 23 23 24 # deze twee zijn nodig voor de evaluatie van een configuratie … … 236 237 # nee. maak een groep en voeg beide 237 238 # endpoints toe 238 group = WIGroup( 'foo')239 group = WIGroup("group%d" % len(groups)) 239 240 group.add_wi(wi) 240 241 groups.append(group) … … 245 246 # END UGLY PARSING CODE 246 247 248 def plot_configuration(conf, out): 249 out.write("digraph plot {\n") 250 for i in range(len(groups)): 251 out.write("group%s [label=\"%d\"]\n" % (i, conf[i])) 252 for nodename in nodes.keys(): 253 for wi in nodes[nodename].wis: 254 if wi.group == None: 255 continue 256 out.write("%s -> %s\n" % (nodename, wi.group.name)) 257 out.write("}") 258 247 259 parse_metafile('l') 248 260 … … 252 264 population.append(conf) 253 265 254 while 1:255 for i in range( 10):266 for iteration in range(1000): 267 for i in range(0, 9): 256 268 p = population[i].copy() 257 population[i].crossover(population[i + 10], 8)269 population[i].crossover(population[i + 10], random.randint(1, 4) * 2) 258 270 population[i + 10] = p 259 population[i + 10].mutate(0.0 1)271 population[i + 10].mutate(0.05) 260 272 population.sort(lambda a, b: cmp(b.score(), a.score())) 261 print population[0].score(), population[0].conf 273 print population[0].score() 274 plot_configuration(population[0].conf, open("foo.dot", 'w')) 275 os.system('neato -Gstart=foo -Goverlap=false/scale -Gsplines=true -Gsep=2 -Gratio=fill -Gnslimit=50.0 -Grotate=90 -Gsize="11,7.5" -Tps -o channelga.ps foo.dot') 276
Note:
See TracChangeset
for help on using the changeset viewer.