optaplannerdrools-planner

Fix a task to an employee in chained planning variable


This is in context of a Task planning problem where task chain(T1,T2,T3 and so on..) is assigned to an employee(anchor), say E1. So, the planned outcome is generally like this:

E1 -> T1 -> T2 -> T3

T1, T2 and T3 could be from any list of tasks. Now, what I want is something like from list of T1,T2,T3,T4,T5,T6.. , T3 has to be assigned to E1. In simple phrase, T3 has to be linked somewhere in between(may not be the first) the chain of anchor E1. Optaplanner only has option to select previous entityOrAnchor in chained planning variable and it'll work if I wanted first task to be assigned to an employee but I want a task that is supposed to happen later in day so somewhere in between task chain.

Solution I can think of:
1. Keep an extra variable 'assignEmployee'.
2. Keep a hard constraint so assignEmployee matches anchor ie employee.

This will work in same cases and I'll have to keep a very strong(weighted) high constraint but the problem is I don't want to keep it as constraint as it's impossible to assign that task to some other employee and I'd like to model it such that specific task is assigned to specific employee. What other options do we have?

What do I want this?
This is because a task in T3 in above is kind of a break specific to that employee and the reason I'm keeping break as a task is because break place is also a location and should be planned according to nearby tasks to avoid totally distinct driving time.


Solution

  • Here's the solution that worked for me:

    If T3 is the task in chain that you want to assign an employee E1, then before submitting to Optaplanner, assign T3 to E1 using:

    This makes T3 already initialised with employee E1 so CH wont change it. Now, filter all of your LS moves(change/swap/chain) such that they do not try to move task with locked employee to other employee.