Skip to content

Draft: Merge fork for interoperability of KoMa solver

Felix Blanke requested to merge felix_bonn/akplanning:main into main

This MR is WIP. Before merging, we plan to first a) refactor the new code and b) add more features.

The KoMa developed a tool to approximate an optimal conference schedule based on constraints and participant preferences. The aim of this MR is to enable interoperability with that solver. To do this, two functionalities are added:

  • A workflow to export data from this tool (rooms, AKs, timeslots, ...) in a JSON format that can be fed to the solver
  • A workflow to import the schedule of the solver back into this

Note that the solver also needs preferences of all participants. As this tool does not collect such data (for now at least), one needs to employ a third tool, e.g. this very basic one.

Export data to the solver

The key functionality is the AKJSONExportView which generates a JSON string that can be imported into the solver.

Notably, the KoMa solver models timeslots differently to this tool. Where this tool basically allows for arbitrary time slot design, the KoMa solver has a more constricted notion: The timeslots are modeled as blocks (i.e. simple lists) of consecutive timeslots of a fixed length. The AKs simply store an integer duration, i.e. the number of consecutive timeslots covered by the AK.

To convert the data of this tool into the solver's model, the following strategy is implemented (see Event::default_time_slots, Event::merge_blocks):

  • all DefaultSlot instances are discretized into timeslots of a uniform length (beginning at the start and dropping partial timeslots at the end) → each DefaultSlot forms a "block"
  • Consecutive blocks are merged. Overlapping timeslots are identified with each other, but partial overlap errors out

Import a schedule from the solver

This is realized in the form JSONImportForm and the corresponding view AKJSONImportView. The JSON string is simply read from the form and passed to Event::schedule_from_json.

Minor changes

  • Bump python version to 3.10
  • Availability::{merge_with,intersect_with}: If both objects are from the same Event, set the event also for the returned Availability object
  • Add utility class-method Availibility::is_event_covered to check if Event is covered by a list of Availability objects
    • (Possible bug in Availability::with_event_length: To my understanding the returned availability does in fact not have the exact duration of event)
  • ak_requirements_changed_handler: Skip slots with no set room

Changes to model objects (AKModel/models.py)

Event

  • Event::_generate_slots_from_block: Given a start and time as well as a slot duration, discretizes it into blocks of consecutive discrete time slots.
    • Slots are dropped if no room is available for the slot.
    • If end - start is not a multiple of duration, the last slot is dropped as well.
  • Event::uniform_time_slots to uniformly discretize the full event into blocks of time slots:
    • For the block creation, see Event::_generate_slots_from_block
    • Adds constraints to allow all AKCategories in each timeslot
  • Event::default_time_slots to derive blocks by uniformly discretizing DefaultSlots
    • Splits each DefaultSlotof the event into one block.
    • Adds constraints such that only AKs from the DefaultSlot's primary categories are allowed to be scheduled in the block
  • Event::merge_blocks: Merge blocks in iterable
    • Flatten blocks into list of all timeslots
    • If two slots overlap:
      • If start and end match: merge slots
      • If overlap only partial: error out
    • group consecutive slots into block
  • Event::schedule_from_json: Load scheduling from json file, i.e. assign each slot a room, start time and duration

AKCategory

  • AKOwner::create_category_constraints: static method to create constraint strings for all AKCategories in iterable

Room

  • Room::as_json: Export JSON representation for the room object

AKSlot

  • AKSlot::as_json: Export JSON representation for the AKobject of this slot

Merge request reports

Loading