1

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.

Sachin Verma
  • 3,712
  • 10
  • 41
  • 74
  • Make Vehicle a planning entity and assign that to an employee instead of assigning each visit to an employee? – Geoffrey De Smet Aug 10 '17 at 15:06
  • Like I already mentioned in question: 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. – Sachin Verma Aug 11 '17 at 07:22
  • Make a custom move ithat does that if you're worried about that (not convinced it's needed). Putting the employee in every visit will blow up your search space and make every move break hard constraints. Putting the employee in the vehicle is most efficient in my opinion. Hope that helps. Good luck. – Geoffrey De Smet Aug 14 '17 at 07:44
  • Reason I keep employee in every visit is because employee has to match skills needed for evey visit. Do you still recommend keeping employee in vehicle? – Sachin Verma Aug 15 '17 at 13:09
  • Yes. Just make a constraint that checks `Visit(getVehicle().getEmployee().getSkills().contains(skill)` – Geoffrey De Smet Aug 17 '17 at 13:40

0 Answers0