I saw this question on other threads and I still not understand if this use case is a good fit for OptaPlanner.
Some threads with a similar question:
I'm trying to solve the same exact issue described in SO question i.e. is it possible to use optaplanner to get a list of availabilities?
I can see from other answers that OptaPlanner wouldn't be suited to book a single appointment and I understand why, but in both those questions what is trying to get achieved is a list of possible booking, not to check if a single one can be fulfilled.
I understand that checking if a single booking is available is not a job for OP, but on the contrary if I want to plan all possible bookings under a set of constraints seems to be a good case.
I'm thinking to something like this model but I'm not able to see the whole picture and if I'm on the right way
@PlanningSolution
public class SlotAssignment {
@ValueRangeProvider(id = "timeGrainRange")
@ProblemFactCollectionProperty
private List<TimeGrain> timeGrainList = Collections.emptyList();
@ValueRangeProvider(id = "employeeRange")
@ProblemFactCollectionProperty
private List<Employee> employees = Collections.emptyList();
@ValueRangeProvider(id = "slotRequests")
@PlanningEntityCollectionProperty
private List<Slot> slotAssignments = new ArrayList<>();
@PlanningScore
private HardSoftScore score;
}
@PlanningEntity
public class Slot {
// Assigned by OP
@PlanningVariable(valueRangeProviderRefs = "employeeRange")
Employee employee;
// Starting time of slot chain
@AnchorShadowVariable(sourceVariableName = "previousSlot")
TimeGrain startingTimeGrain;
// This will be moved by engine
@PlanningVariable(valueRangeProviderRefs = "slotRequests", graphType = PlanningVariableGraphType.CHAINED)
private Slot previousSlot;
// This will updated accordingly to previous slot
@InverseRelationShadowVariable(sourceVariableName = "previousSlot")
private Slot nextSlot;
// Service assigned to this slot, problem Fact, never null
Service service;
}
Is this model achievable with OP? Given a set of TimeGrains, a set of Employes, a set of requested services, can optaplanner produce a list of Slots in which every slot has
- a starting TimeGrain (at the beginning of chain)
- an employee (possibly pinned)
- a service to perform (initialized by problem submitter?)
- full chain of other slots each with a service and an employee assigned by OP (possibly pinned)
Or I'm completely wrong? Or maybe chaining is not needed at all.
If this is possibile I think that it will be a good use case to implement in optaplanner-examples since I wasn't able to find anything similar on the web.
Thanks.