conference_scheduler.scheduler¶

Compute a schedule in one of three forms, convert a schedule between forms and compute the difference between .

A schedule can be represented in one of three forms:

• solution: a list of tuples of event index and slot index for each scheduled item
• array: a numpy array with rows for events and columns for slots
• schedule: a generator for a list of ScheduledItem instances
conference_scheduler.scheduler.solution(events, slots, objective_function=None, solver=None, **kwargs)

Compute a schedule in solution form

param events: type events: of resources.Event instances list or tuple of resources.Slot instances list or tuple a pulp solver pulp.solver from lp_problem.objective_functions callable arguments for the objective function keyword arguments A list of tuples giving the event and slot index (for the given events and slots lists) for all scheduled items. list

Example

For a solution where

• event 0 is scheduled in slot 1
• event 1 is scheduled in slot 4
• event 2 is scheduled in slot 5

the resulting list would be:

[(0, 1), (1, 4), (2, 5)]
conference_scheduler.scheduler.array(events, slots, objective_function=None)

Compute a schedule in array form

param events: type events: of resources.Event instances list or tuple of resources.Slot instances list or tuple from lp_problem.objective_functions callable An E by S array (X) where E is the number of events and S the number of slots. Xij is 1 if event i is scheduled in slot j and zero otherwise np.array

Example

For 3 events, 7 slots and a solution where

• event 0 is scheduled in slot 1
• event 1 is scheduled in slot 4
• event 2 is scheduled in slot 5

the resulting array would be:

[[0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 1, 0]]
conference_scheduler.scheduler.schedule(events, slots, objective_function=None, solver=None, **kwargs)

Compute a schedule in schedule form

param events: type events: of resources.Event instances list or tuple of resources.Slot instances list or tuple a pulp solver pulp.solver from lp_problem.objective_functions callable arguments for the objective function keyword arguments A list of instances of resources.ScheduledItem list
conference_scheduler.scheduler.solution_to_array(solution, events, slots)

Convert a schedule from solution to array form

param solution: of tuples of event index and slot index for each scheduled item list or tuple of resources.Event instances list or tuple of resources.Slot instances list or tuple An E by S array (X) where E is the number of events and S the number of slots. Xij is 1 if event i is scheduled in slot j and zero otherwise np.array

Example

For For 3 events, 7 slots and the solution:

[(0, 1), (1, 4), (2, 5)]

The resulting array would be:

[[0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 1, 0]]
conference_scheduler.scheduler.solution_to_schedule(solution, events, slots)

Convert a schedule from solution to schedule form

param solution: of tuples of event index and slot index for each scheduled item list or tuple of resources.Event instances list or tuple of resources.Slot instances list or tuple A list of instances of resources.ScheduledItem list
conference_scheduler.scheduler.schedule_to_array(schedule, events, slots)

Convert a schedule from schedule to array form

param schedule: of instances of resources.ScheduledItem list or tuple of resources.Event instances list or tuple of resources.Slot instances list or tuple An E by S array (X) where E is the number of events and S the number of slots. Xij is 1 if event i is scheduled in slot j and zero otherwise np.array
conference_scheduler.scheduler.array_to_schedule(array, events, slots)

Convert a schedule from array to schedule form

param array: An E by S array (X) where E is the number of events and S the number of slots. Xij is 1 if event i is scheduled in slot j and zero otherwise np.array of resources.Event instances list or tuple of resources.Slot instances list or tuple A list of instances of resources.ScheduledItem list
conference_scheduler.scheduler.event_schedule_difference(old_schedule, new_schedule)

Compute the difference between two schedules from an event perspective

param old_schedule:
of resources.ScheduledItem objects
type old_schedule:
list or tuple
param new_schedule:
of resources.ScheduledItem objects
type new_schedule:
list or tuple
returns:A list of resources.ChangedEventScheduledItem objects
rtype:list

Example

>>> from conference_scheduler.resources import Event, Slot, ScheduledItem
>>> from conference_scheduler.scheduler import event_schedule_difference
>>> events = [Event(f'event_{i}', 30, 0) for i in range(5)]
>>> slots = [Slot(f'venue_{i}', '', 30, 100, None) for i in range(5)]
>>> old_schedule = (
...     ScheduledItem(events[0], slots[0]),
...     ScheduledItem(events[1], slots[1]),
...     ScheduledItem(events[2], slots[2]))
>>> new_schedule = (
...     ScheduledItem(events[0], slots[0]),
...     ScheduledItem(events[1], slots[2]),
...     ScheduledItem(events[2], slots[3]),
...     ScheduledItem(events[3], slots[4]))
>>> diff = (event_schedule_difference(old_schedule, new_schedule))
>>> print([item.event.name for item in diff])
['event_1', 'event_2', 'event_3']
conference_scheduler.scheduler.slot_schedule_difference(old_schedule, new_schedule)

Compute the difference between two schedules from a slot perspective

param old_schedule:
of resources.ScheduledItem objects
type old_schedule:
list or tuple
param new_schedule:
of resources.ScheduledItem objects
type new_schedule:
list or tuple
returns:A list of resources.ChangedSlotScheduledItem objects
rtype:list

Example

>>> from conference_scheduler.resources import Event, Slot, ScheduledItem
>>> from conference_scheduler.scheduler import slot_schedule_difference
>>> events = [Event(f'event_{i}', 30, 0) for i in range(5)]
>>> slots = [Slot(f'venue_{i}', '', 30, 100, None) for i in range(5)]
>>> old_schedule = (
...     ScheduledItem(events[0], slots[0]),
...     ScheduledItem(events[1], slots[1]),
...     ScheduledItem(events[2], slots[2]))
>>> new_schedule = (
...     ScheduledItem(events[0], slots[0]),
...     ScheduledItem(events[1], slots[2]),
...     ScheduledItem(events[2], slots[3]),
...     ScheduledItem(events[3], slots[4]))
>>> diff = slot_schedule_difference(old_schedule, new_schedule)
>>> print([item.slot.venue for item in diff])
['venue_1', 'venue_2', 'venue_3', 'venue_4']