Skip to content

Commit

Permalink
Merge pull request #110 from CharJon/use-list-for-deadlines
Browse files Browse the repository at this point in the history
Scheduling: Use list to define deadlines in parameter generation
  • Loading branch information
CharJon authored Feb 22, 2021
2 parents ef41962 + 2689757 commit 23d2fb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 4 additions & 3 deletions geco/mips/scheduling/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
8 changes: 3 additions & 5 deletions geco/mips/scheduling/heinz.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import itertools

import pyscipopt as scip
from networkx.utils import py_random_state

from geco.mips.scheduling.generic import *


Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions geco/mips/tests/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_hooker_simple_instance():


def test_heinz_simple_instance():
(
params = (
n_resources,
n_tasks,
time_steps,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 23d2fb0

Please sign in to comment.