Hi
using CP;
{string} Employee = {"A","B"};
{string} Jobs = {"K","L"};
range EmpIDs = 0..card(Employee)-1;
{int} AvailSlot[EmpIDs] = [{1,2},{2,3}];
range Slots = 1..10;
dvar int Time[Jobs] in Slots;
dvar int Emp[Jobs] in EmpIDs;
subject to{
forall (x in Jobs) {
//Time[x] in AvailSlot[Emp[x]]; //this constraints the assigned time slot for the job x to be one of the available time slots of the employee that is assigned with the same job x.
or (j in EmpIDs) (j==Emp[x] && Time[x] in AvailSlot[j]);
}
}
assert forall (x in Jobs)
Time[x] in AvailSlot[Emp[x]];
works fine
regards
PS:
I answered this at https://stackoverflow.com/questions/62016391/cplex-indexing-an-array-using-the-assigned-value-of-a-dvar/62017203#62017203
Please try to avoid posting the same question in many forums
------------------------------
ALEX FLEISCHER
------------------------------