def graphReduction(matrix, simAnneal=True, startSolution=None, printFlag=True): matrix = resolveMatrix(matrix) if startSolution == None: startSolution = getRandom(matrix.vertices) if simAnneal: solution, fScore = simulatedannealing.simulateanneal(matrix, startSolution, printFlag) else: solution, fScore, tries = hillclimb.climbhill(matrix, strartSolution) return solution, fScore
def graphReduction(matrix, simAnneal=True, startSolution=None, printFlag=True): matrix = resolveMatrix(matrix) if startSolution == None: startSolution = getRandom(matrix.vertices) if simAnneal: solution, fScore = simulatedannealing.simulateanneal( matrix, startSolution, printFlag) else: solution, fScore, tries = hillclimb.climbhill(matrix, strartSolution) return solution, fScore
# # # DEMO INSTRUCTIONS # # # # STEP ONE - PICK YOUR STARTING MATRIX (uncomment one) # matrix = matrix7 # matrix = matrix26 # matrix = matrix8 # matrix = matrix21 # matrix = matrix4 # matrix = matrix34 # matrix = matrixBin # matrix = matrixStar matrix = matrixWeb # matrix = matrix12 # matrix = matrixNoEdge # Doesn't work. Division by Zero error randSolution = getRandom(matrix.vertices) # STEP TWO - PICK YOUR METHOD (pick one and uncomment it) # METHOD ONE - SIMULATED ANNEALING solution, fScore = simulatedannealing.simulateanneal(matrix, randSolution) # METHOD TWO - HILL CLIMBING # solution, score, tries = hillclimb.climbhill(matrix, randSolution) # METHOD THREE - SIMULATED ANNEALING + HILL CLIMBING (uncomment both lines) # annealSolution, fScore = simulatedannealing.simulateanneal(matrix, randSolution) # solution, score, tries = hillclimb.climbhill(matrix, annealSolution) print "Random Solution" diagnose(matrix, randSolution)