Originally posted by: Esin
Hi, I need serious and urgent help about my course timetabling problem.
* I have an array for patterns that each element has a different size. For first element, 1,5 and 10 are slots of this pattern which I can't define.
When I call patterns([1][3]) I can get 10. And since I set array as int patterns[pattern][5] , it fulfills the array as [1,5,10,0,0] and so on.
My problem is; decision varible x has to be assigned to a pattern in this array(from 1 to 7 ) for each course but, all slots for these courses must be different from each other for no conflicts.
I need the slots of patterns that assingned to each courses should be all different.
patterns= [
[1,5,10]
[5]
[2]
[3,4]
[10,11]
];
Therefore I try to use these decision variable in subject to part as
allDifferent( all(c in courses, p in pattern ) patterns [x[c]][p] );
But since it reads my pattern as [1,5,10,0,0] and [5,0,0,0,0]... I got "patterns [x[c]][p]" unlimited warning.
Because 0s can not be different in this condition. But I couldn't say that do it for all variables that not equal to 0.
How can I do it ?
If it is not possible for allDifferent how can I replace that ?
Programme does not allow me to use my decision variable in allDifferent input, is that somehow possible ?
for ex:
allDifferent( all(i in abcd,j in courses : (i>(x[j]-1) * 5) && (i<(x[j]* 5+1)) && (patternler[i] != 0) )
patterns[i]);
which x is decision variable and patterns[i] is an array
Correct assignment of x should be 3,1,4 after this constraint but it is 2,1,4 now.
I'm adding and attaching my files.
Can you please give me an advice ?
Thank you for your time.
DAT
nbcourse = 3;
nbpatterns = 7;
nbmaxslot =5;
hour= [1,3,2] ;
patternsize =[3,1,1,2,2];
patterns = [
[1,5,10]
[3]
[2]
[3,4]
[10,11]
];
MOD
using CP;
int nbcourse = ...;
int nbpatterns = ...;
int nbmaxslot= ...;
range courses = 1..nbcourse;
range pattern = 1..nbpatterns;
range maxslot = 1..nbmaxslot;
int patternsize[pattern]=...;
int hour[courses]= ...;
int patterns[pattern][maxslot]= ...;
dvar int x[courses] in pattern;
execute {
cp.param.FailLimit=100;
cp.param.timeLimit=30;
}
subject to {
allDifferent (x);
forall (i in courses){
hour[i] == patternsize[x[i]];}
allDifferent( all(c in courses, p in maxslot )
patterns [x[c]][p] );
}
#CPOptimizer#DecisionOptimization