Changeset 1929 in genesis for nodes/channelga.py


Ignore:
Timestamp:
Mar 28, 2004, 2:55:05 AM (21 years ago)
Author:
lodewijk
Message:
  • .attic weg, ik neem aan dat dat een CVS artefact is
  • prutsen aan channelga.py
File:
1 edited

Legend:

Unmodified
Added
Removed
  • nodes/channelga.py

    r1928 r1929  
    2020import re
    2121import random
     22import os
    2223
    2324# deze twee zijn nodig voor de evaluatie van een configuratie
     
    236237                                        # nee. maak een groep en voeg beide
    237238                                        # endpoints toe
    238                                         group = WIGroup('foo')
     239                                        group = WIGroup("group%d" % len(groups))
    239240                                        group.add_wi(wi)
    240241                                        groups.append(group)
     
    245246# END UGLY PARSING CODE
    246247
     248def 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
    247259parse_metafile('l')
    248260
     
    252264        population.append(conf)
    253265
    254 while 1:
    255         for i in range(10):
     266for iteration in range(1000):
     267        for i in range(0, 9):
    256268                p = population[i].copy()
    257                 population[i].crossover(population[i + 10], 8)
     269                population[i].crossover(population[i + 10], random.randint(1, 4) * 2)
    258270                population[i + 10] = p
    259                 population[i + 10].mutate(0.01)
     271                population[i + 10].mutate(0.05)
    260272        population.sort(lambda a, b: cmp(b.score(), a.score()))
    261         print population[0].score(), population[0].conf
     273print population[0].score()
     274plot_configuration(population[0].conf, open("foo.dot", 'w'))
     275os.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.