# Obtain the mathematical representation of a schedule¶

When scheduling a conference, it might be desirable to recover the schedule in a different format. Let us schedule a simple conference as described in Tutorial:

>>> from datetime import datetime
>>> from conference_scheduler.resources import Slot, Event
>>> from conference_scheduler import scheduler, converter

>>> slots  = [Slot(venue='Big', starts_at=datetime(2016, 9, 15, 9, 30), duration=30, session="A", capacity=200),
...           Slot(venue='Big', starts_at=datetime(2016, 9, 15, 10, 0), duration=30, session="A", capacity=200)]
>>> events = [Event(name='Talk 1', duration=30, demand=50),
...           Event(name='Talk 2', duration=30, demand=130)]

>>> schedule = scheduler.schedule(events, slots)


We can view this schedule as before:

>>> for item in schedule:
...     print(f"{item.event.name} at {item.slot.starts_at} in {item.slot.venue}")
Talk 1 at 2016-09-15 09:30:00 in Big
Talk 2 at 2016-09-15 10:00:00 in Big


If we want to recover the mathematical array form of our solution (as described in Mathematical model), we use the scheduler.schedule_to_array function:

>>> array = converter.schedule_to_array(schedule, events=events, slots=slots)
>>> array
array([[1, 0],
[0, 1]], dtype=int8)


We can also return from a mathematical array to the schedule using the scheduler.array_to_schedule function:

>>> for item in converter.array_to_schedule(array, events=events, slots=slots):
...     print(f"{item.event.name} at {item.slot.starts_at} in {item.slot.venue}")
Talk 1 at 2016-09-15 09:30:00 in Big
Talk 2 at 2016-09-15 10:00:00 in Big