diff --git a/geco/mips/scheduling/generic.py b/geco/mips/scheduling/generic.py index 75d00b9..b695be6 100644 --- a/geco/mips/scheduling/generic.py +++ b/geco/mips/scheduling/generic.py @@ -58,10 +58,11 @@ def generate_params(number_of_facilities, number_of_tasks, seed=0): release_times = [0] * number_of_tasks - deadlines = {} beta = 20 / 9 - for j in range(number_of_tasks): - deadlines[j] = seed.uniform(beta * number_of_tasks / 4, beta * number_of_tasks) + deadlines = [ + seed.uniform(beta * number_of_tasks / 4, beta * number_of_tasks) + for _ in range(number_of_tasks) + ] resource_requirements = {} for j, k in itertools.product(range(number_of_tasks), range(number_of_facilities)): diff --git a/geco/mips/scheduling/heinz.py b/geco/mips/scheduling/heinz.py index 904f0b4..8e7a8d0 100644 --- a/geco/mips/scheduling/heinz.py +++ b/geco/mips/scheduling/heinz.py @@ -1,7 +1,5 @@ -import itertools - import pyscipopt as scip -from networkx.utils import py_random_state + from geco.mips.scheduling.generic import * @@ -119,7 +117,7 @@ def heinz_formulation( """ model = scip.Model(name) - time_steps = range(min(release_dates), int(max(deadlines.values()))) + time_steps = range(min(release_dates), int(max(deadlines))) # objective function x = {} @@ -170,7 +168,7 @@ def heinz_formulation( # constraint (15) epsilon = filter( - lambda ts: ts[0] < ts[1], itertools.product(release_dates, deadlines.values()) + lambda ts: ts[0] < ts[1], itertools.product(release_dates, deadlines) ) for k, (t1, t2) in itertools.product(range(number_of_facilities), epsilon): model.addCons( diff --git a/geco/mips/tests/test_scheduling.py b/geco/mips/tests/test_scheduling.py index 0c6b5f4..20a37a9 100644 --- a/geco/mips/tests/test_scheduling.py +++ b/geco/mips/tests/test_scheduling.py @@ -22,7 +22,7 @@ def test_hooker_generation(): def test_heinz_formulation(number_of_facilities, number_of_tasks, seed): main_params = number_of_facilities, number_of_tasks p, C, c, R, d, r = heinz_params(*main_params, seed) - time_steps = int(max(d.values()) - min(R)) + time_steps = int(max(d) - min(R)) model = heinz_instance(*main_params) x_vars_count = number_of_facilities * number_of_tasks y_vars_lowerbound = 0 @@ -75,7 +75,7 @@ def test_hooker_simple_instance(): def test_heinz_simple_instance(): - ( + params = ( n_resources, n_tasks, time_steps, @@ -112,7 +112,7 @@ def _simple_instance_params(): release_times = [0] # change the deadline to 0 or 1 to make it infeasible for the heinz formulation # and add 1 late task to the hooker formulation - deadlines = {0: 2} + deadlines = [2] resource_requirements = {(0, 0): 1} return ( n_resources,