Magic number is now a default parameter
This commit is contained in:
parent
32c99ff075
commit
049e64c675
|
@ -154,13 +154,13 @@ def correct_precedence(solution, idx):
|
||||||
task = (new_start,) + task[1:]
|
task = (new_start,) + task[1:]
|
||||||
solution.insert(idx, task)
|
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
|
Generate a new solution from an existing solution with a
|
||||||
specified number of max steps.
|
specified number of max steps.
|
||||||
"""
|
"""
|
||||||
solution = old_solution[:]
|
solution = old_solution[:]
|
||||||
accept_percent = 1
|
percent = 1
|
||||||
option = pull_fwd #do at least one pull
|
option = pull_fwd #do at least one pull
|
||||||
while(steps > 0):
|
while(steps > 0):
|
||||||
solution = option(solution)
|
solution = option(solution)
|
||||||
|
@ -168,7 +168,7 @@ def generate(old_solution, steps):
|
||||||
break
|
break
|
||||||
steps -= 1
|
steps -= 1
|
||||||
select = random.randrange(0,100)
|
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)
|
accept(solution)
|
||||||
return solution
|
return solution
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue