コード例 #1
0
ファイル: parser.py プロジェクト: psawaya/CS34-Bus-Routing
    try:
        while True:
            prevScore = tour.score

            if tour.annealKOpt(): #tour.annealSwap():
                print "score = %i, heat = %f, all time best = %i" % (tour.score,tour.heat,lscore)

                iterationsOfNoChange = 0

                if tour.score < lscore:
                    lscore = tour.score

            if tour.score == prevScore:
                iterationsOfNoChange += 1

            if reheat and iterationsOfNoChange > 1 and tour.heat <= 0:
                tour.heat = random.random()

                print "reheating to %s" % tour.heat
                time.sleep(2)

            if tour.heat > 0:
                tour.heat += deltaE
    except KeyboardInterrupt:
        pass
    print
    print " score =", tour.score
    print " tour =", tour.printTour()
    mapinfo.graphvizify(tour.tour, "end.png")