As of now, get_random_initial_state
is too much random, which is making it harder to implement local search. Not only it needs to find the sweet spot in the timetable for a given event, but also has to attempt to switch rooms, i.e., there's no guarantee that the picked room for an event has the required capacity and features.
It makes it very hard for the hill climbing work unless some greedy heuristic is applied, and we don't have hill climbing anymore.
So, here's a new approach:
- Go through all existing events, available in the
Instance
object
- Pick the room that has just enough capacity. It would be nice to have rooms sorted by capacity. We pick a room such that
min(room.size - event.attendees.size)
.
- Starting at the picked room, check if the room has all the required features. If not, go to the next room which probably has a higher capacity but mets the required features.
- Pick a random timeslot and insert the room there, unless there's an event already using the same room.
This is a more greedy approach to generate the initial state, instead of being as random as possible but makes it easier to implement the hill climbing searches. It should reduce a lot of overhead too when generating neighbor states.
However, step 3 is not perfect. What if a given event A
picks the room 1
because has just enough capacity and all features and extra features it doesn't need, and then the event B
picks the room 2
, which it's also suitable for event A
, but lacks a feature for event B? It would be great for these events to switch rooms. If this is tackled on the generation of the initial state, the hill climbing just needs to exchange pairs (room, event)
to different spots.