# Position of interval variable in sequence

 0 Hi, I'm developing a Constraint Programming (CP) model for a simple scheduling problem. I decided to develop my model in IBM Ilog CPLEX Optimization Studio. I defined my both interval and sequence variables as follows: dvar interval INTERVALS[i in machines][j in jobs] size PROCESS[i][j]; dvar sequence MACHINES[i in machines] in all(j in jobs) INTERVALS[i][j]; Here is my question: Can I access the position of interval variables (INTERVALS) in the sequence variable (MACHINES) during the optimization process? asked 19 Feb '16, 01:41 monash 37●2●4●11 accept rate: 0%

 1 Hello, There is no "direct" way to get this expression in CP Optimizer. One of the reasons why this expression is not provided is that, often (but not always) there are other more efficient ways to model the problem without them. So my first question is, why do you need this positional variable for ? This being said, there are several ways to get these variables in an indirect way. For instance, you could duplicate the sequence and the interval variables on the sequence so as to have a sequence variable with only unit length intervals. If you use "sameSequence" constraint between the two sequences, the position is given by the start value of the intervals on the "position" sequence. It is probably more clear with a pseudocode: dvar interval INTERVALS[j in jobs] size ...; dvar interval UNITDURATION[j in jobs] in 0..n size 1; dvar int POSITION[j in jobs] in -1..n; // POSITION=-1 for absent intervals dvar interval MACHINE in (j in jobs) INTERVALS[j]; // Real sequence dvar interval MACHINE_POS in (j in jobs) UNITDURATION[j]; // Positional sequence // Constraints: noOverlap(MACHINE); noOverlap(MACHINE_POS); sameSequence(MACHINE,MACHINE_POS); forall(j in jobs) { POSITION[j] == startOf(UNITDURATION[j],-1); }  You may want to avoid the interval variables UNITDURATION to mess up with the search (they are not real decision variables) so you can either use search phases (fix INTERVALS first) or translate the intervals UNITDURATION[j] to the left with a big H value: dvar interval UNITDURATION[j in jobs] in H..H+n size 1; ... forall(j in jobs) { POSITION[j] == H - startOf(UNITDURATION[j],-1); }  You can also consider using the "isomorphism" constraint (see delivered example sched_learningeffect). But it would be good to know what you need these positional variables for because there may be more direct models. Philippe answered 19 Feb '16, 07:55 Philippe Lab... 62●3 accept rate: 9% Many thanks @philippe-laborie. Actually, my initial purpose was to sort an array of interval variables based on their "end" property. Have you any solution for this? (19 Feb '16, 12:08) monash @philippe-laborie: I tested your solution but it seems it doesn't work! (24 Feb '16, 00:59) monash
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×191
×37
×29
×2
×2