From 32c99ff0759db78f11c03b52eecef9e63e417964 Mon Sep 17 00:00:00 2001 From: Maximilian Schlosser Date: Tue, 11 Jul 2017 13:50:51 +0200 Subject: [PATCH] accept, tighten, generate rewrite (now has magic number describing percentage) --- src/Generator/generator.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Generator/generator.py b/src/Generator/generator.py index ed1a48e..1d115b8 100644 --- a/src/Generator/generator.py +++ b/src/Generator/generator.py @@ -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