diff --git a/src/Generator/generator.py b/src/Generator/generator.py index bb7ac34..057cf2f 100644 --- a/src/Generator/generator.py +++ b/src/Generator/generator.py @@ -2,6 +2,8 @@ from Parser import JobShopProblem as Problem import random + +def pull_fwd(solution): """ Pull a task from a pseudo-random position to the position of a random task forward. If the task directly in front is part of the same job, pull that instead. The first task can never @@ -9,7 +11,6 @@ import random Returns the modified solution and the tasks index. """ -def pull_fwd(solution): old_idx = random.randint(1, len(solution)-1) while(solution[old_idx][1][0] == solution[old_idx-1][1][0]): old_idx -= 1 @@ -25,18 +26,18 @@ def pull_fwd(solution): return (new_solution, new_idx) +def accept(solution): """ Accept the current generated solution and evaluate it. Maybe skip this during the first step to generate a more random solution. """ -def accept(solution): return 3 +def rectify(solution, idx): """ Transform solution by adapting the begin times and delaying tasks on the same machine if affected. """ -def rectify(solution, idx): global problem #move previous task on the same machine back if clash @@ -54,19 +55,19 @@ def rectify(solution, idx): solution[idx][0] = solution[idx-1][0] +def generate(solution, steps): """Generate a new solution from an existing solution with a specified number of max steps. """ -def generate(solution, steps): options = [pull_fwd, accept] option = random.choice(options) return option(solution) +def mock(): """ Reads a mock problem and creates the corresponding enumerated solution. Should clean up the namespace afterwards. """ -def mock(): global problem global solution from Parser.js2_style import parse_file as mockload