Magic number is now a default parameter

simanneal
Maximilian Schlosser 2017-07-11 13:55:02 +02:00
parent 32c99ff075
commit 049e64c675
1 changed files with 3 additions and 3 deletions

View File

@ -154,13 +154,13 @@ def correct_precedence(solution, idx):
task = (new_start,) + task[1:]
solution.insert(idx, task)
def generate(old_solution, steps):
def generate(old_solution, steps, percent=1):
"""
Generate a new solution from an existing solution with a
specified number of max steps.
"""
solution = old_solution[:]
accept_percent = 1
percent = 1
option = pull_fwd #do at least one pull
while(steps > 0):
solution = option(solution)
@ -168,7 +168,7 @@ def generate(old_solution, steps):
break
steps -= 1
select = random.randrange(0,100)
option = pull_fwd if (select - accept_percent) > 0 else accept
option = pull_fwd if (select - percent) > 0 else accept
accept(solution)
return solution