accept, tighten, generate rewrite (now has magic number describing percentage)

This commit is contained in:
Maximilian Schlosser 2017-07-11 13:50:51 +02:00
parent 6783d91c43
commit 32c99ff075

View file

@ -38,7 +38,7 @@ def accept(solution):
Maybe skip this during the first step to generate a more
random solution.
"""
tighten(solution)
return tighten(solution)
def tighten(solution):
@ -79,6 +79,7 @@ def rectify(solution, idx):
#print(solution)
correct_precedence(solution, i)
#print(solution)
return solution
def update_begin(solution, idx):
"""
@ -159,13 +160,16 @@ def generate(old_solution, steps):
specified number of max steps.
"""
solution = old_solution[:]
options = [pull_fwd, accept]
accept_percent = 1
option = pull_fwd #do at least one pull
while(steps > 0):
option = random.choice(options)
solution = option(solution)
if(option == accept):
break
steps -= 1
select = random.randrange(0,100)
option = pull_fwd if (select - accept_percent) > 0 else accept
accept(solution)
return solution
def mock():
@ -174,16 +178,14 @@ def mock():
solution. Should clean up the namespace afterwards.
"""
global problem
global solution
from Parser.js2_style import parse_file as mockload
from SchedulingAlgorithms.enumerate import enumerate as mockenum
problem = mockload('../inputdata/sample')
solution = mockenum(problem)
del mockload
del mockenum
return solution
def init(in_problem, in_solution):
def init(in_problem):
global problem
global solution
problem = in_problem
solution = in_solution