I am working on a solution where we need to route our vehicle to locations of Tasks asked by our Customers. Here is how my domain looks like:
interface TaskOrVehicle{
@InverseShadowVarible Task nextTask;
getLocation();
}
Task:
@PlanningEntity
Class Task implements TaskOrVehicle{
@ChainedPlanningVariable TaskOrVehicle taskOrVehicle;
@PlanningVariable Staff staff;
@AnchorShadowVariable Vehicle vehicle;
}
So, I've got Staff and Vehicle as facts while Task is a planning entity. So with optaplanner, it schedules task in a chain but it assigns different employee to different tasks in same chain.
So, if A, B, C ,D and E are tasks and Staff st1,st2,st3 and Vechcle V1,V2 are there.
Ideal solution looks like: V1->A(st1)->B(st1)->C(st1) V2->D(st2)->E(st2)
But my solution looks like: V1->A(st1)->B(st3)->C(st2) V2->D(st3)->E(st2)
This is because I don't have employees chained and using employee as a planning variable. Now, I can fix it using rules that nextTask should have same employee as current task but that's a overkill.
What are the best practices I can do here so that every task chain has same employee?
Note:I don't want to keep employee in Vehicle as if Vehicle gets free it can be assigned to different employee for new task chain.