Skip to content

Commit 7df6d4a

Browse files
committed
Fix bugs with consistency optimisation
1 parent d880ca8 commit 7df6d4a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/scheduler/cli.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from pathlib import Path
33

44
import click
5+
from conference_scheduler.scheduler import event_schedule_difference
6+
from conference_scheduler.converter import solution_to_schedule
57
from conference_scheduler.validator import (
68
is_valid_solution, solution_violations)
79
import daiquiri
@@ -65,10 +67,21 @@ def build(algorithm, objective, input_dir, solution_dir, build_dir):
6567

6668
kwargs = {}
6769
if objective == 'consistency':
68-
kwargs['original_solution'] = io.import_solution()
70+
original_solution = io.import_solution()
71+
defn.add_allocations(events, slots, original_solution, allocations)
72+
original_schedule = solution_to_schedule(
73+
original_solution, events, slots)
74+
kwargs['original_schedule'] = original_schedule
6975

7076
solution = calc.solution(events, slots, algorithm, objective, **kwargs)
7177

78+
if objective == 'consistency':
79+
schedule = solution_to_schedule(solution, events, slots)
80+
event_diff = event_schedule_difference(schedule, original_schedule)
81+
logger.debug(f'\nevent_diff:')
82+
for item in event_diff:
83+
logger.debug(f'{item.event.name} has moved from {item.old_slot.venue} at {item.old_slot.starts_at} to {item.new_slot.venue} at {item.new_slot.starts_at}')
84+
7285
if solution is not None:
7386
defn.add_allocations(events, slots, solution, allocations)
7487
logger.debug(convert.schedule_to_text(solution, events, slots))

src/scheduler/denormalise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def allocations(allocations_definition):
278278
'event': Event(
279279
name=event,
280280
duration=0,
281-
demand=None,
281+
demand=0,
282282
tags=details['tags']),
283283
'slot': Slot(
284284
venue=details['venue'],

0 commit comments

Comments
 (0)