Skip to content

Commit

Permalink
Fix schedule logic #101
Browse files Browse the repository at this point in the history
  • Loading branch information
torressa committed Apr 15, 2022
1 parent 92d5024 commit 7dd4d00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
26 changes: 6 additions & 20 deletions tests/test_toy.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,10 @@ def test_cspy_schedule(self):
time_windows=True,
)
prob.solve()
# Check departure times
for k1, v1 in prob.departure_time.items():
for k2, v2 in v1.items():
assert self.G.nodes[k2]["lower"] <= v2
assert v2 <= self.G.nodes[k2]["upper"]
# Check arrival times
for k1, v1 in prob.arrival_time.items():
for k2, v2 in v1.items():
assert self.G.nodes[k2]["lower"] <= v2
assert v2 <= self.G.nodes[k2]["upper"]
assert prob.departure_time[1]["Source"] == 0
assert prob.arrival_time[1]["Sink"] in [41, 62]
prob.check_arrival_time()
prob.check_departure_time()

###############
# subsolve lp #
Expand Down Expand Up @@ -143,16 +137,8 @@ def test_LP_schedule(self):
time_windows=True,
)
prob.solve(cspy=False)
# Check departure times
for k1, v1 in prob.departure_time.items():
for k2, v2 in v1.items():
assert self.G.nodes[k2]["lower"] <= v2
assert v2 <= self.G.nodes[k2]["upper"]
# Check arrival times
for k1, v1 in prob.arrival_time.items():
for k2, v2 in v1.items():
assert self.G.nodes[k2]["lower"] <= v2
assert v2 <= self.G.nodes[k2]["upper"]
prob.check_arrival_time()
prob.check_departure_time()

def test_LP_stops_elementarity(self):
"""Tests column generation procedure on toy graph"""
Expand Down
9 changes: 5 additions & 4 deletions vrpy/vrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ def departure_time(self):
for j in range(1, len(route)):
tail = route[j - 1]
head = route[j]
departure[i][head] = min(
arrival[i][head] + self._H.nodes[head]["service_time"],
self._H.nodes[head]["upper"],
departure[i][head] = (
arrival[i][head] + self._H.nodes[head]["service_time"]
)
return departure

Expand All @@ -414,7 +413,9 @@ def check_departure_time(self):
for k1, v1 in self.departure_time.items():
for k2, v2 in v1.items():
assert self.G.nodes[k2]["lower"] <= v2
assert v2 <= self.G.nodes[k2]["upper"]
# Upper TW should not be checked as lower + service_time > upper
# in many cases. Also not enforced at the subproblem level.
# assert v2 <= self.G.nodes[k2]["upper"]

@property
def schedule(self):
Expand Down

0 comments on commit 7dd4d00

Please sign in to comment.