Skip to main content
added 695 characters in body
Source Link

within CPLEX you could try CPOptimizer and use intervals.

In OPL (One of CPLEX API) you could write

using CP;
int sizeT=10;
range T=1..sizeT;
int d[i in T]=i;

dvar interval t[i in T] size d[i];

{int} T1={i | i in T : i <=(sizeT div 2)};
{int} T2=asSet(T) diff T1;

subject to
{
  forall(i in T1,j in T2) overlapLength(t[i],t[j])==0;
}

and then see

gantt view within CPLEX IDE

This works and is a bit naive.

So a better way as far as solve speed is concerned is to rely on state functions:

using CP;
int sizeT=10;
range T=1..sizeT;
int d[i in T]=i;

dvar interval t[i in T] size d[i];

{int} T1={i | i in T : i <=(sizeT div 2)};
{int} T2=asSet(T) diff T1;

stateFunction s; // 1 or 2 according to T1 or T2

subject to
{
 
  forall(i in T1) alwaysEqual(s,t[i],1);
  forall(i in T2) alwaysEqual(s,t[i],2);
}

which will do the same but faster.

And you can see in the CPLEX IDE for s:

enter image description here

within CPLEX you could try CPOptimizer and use intervals.

In OPL (One of CPLEX API) you could write

using CP;
int sizeT=10;
range T=1..sizeT;
int d[i in T]=i;

dvar interval t[i in T] size d[i];

{int} T1={i | i in T : i <=(sizeT div 2)};
{int} T2=asSet(T) diff T1;

subject to
{
  forall(i in T1,j in T2) overlapLength(t[i],t[j])==0;
}

and then see

gantt view within CPLEX IDE

within CPLEX you could try CPOptimizer and use intervals.

In OPL (One of CPLEX API) you could write

using CP;
int sizeT=10;
range T=1..sizeT;
int d[i in T]=i;

dvar interval t[i in T] size d[i];

{int} T1={i | i in T : i <=(sizeT div 2)};
{int} T2=asSet(T) diff T1;

subject to
{
  forall(i in T1,j in T2) overlapLength(t[i],t[j])==0;
}

and then see

gantt view within CPLEX IDE

This works and is a bit naive.

So a better way as far as solve speed is concerned is to rely on state functions:

using CP;
int sizeT=10;
range T=1..sizeT;
int d[i in T]=i;

dvar interval t[i in T] size d[i];

{int} T1={i | i in T : i <=(sizeT div 2)};
{int} T2=asSet(T) diff T1;

stateFunction s; // 1 or 2 according to T1 or T2

subject to
{
 
  forall(i in T1) alwaysEqual(s,t[i],1);
  forall(i in T2) alwaysEqual(s,t[i],2);
}

which will do the same but faster.

And you can see in the CPLEX IDE for s:

enter image description here

Source Link

within CPLEX you could try CPOptimizer and use intervals.

In OPL (One of CPLEX API) you could write

using CP;
int sizeT=10;
range T=1..sizeT;
int d[i in T]=i;

dvar interval t[i in T] size d[i];

{int} T1={i | i in T : i <=(sizeT div 2)};
{int} T2=asSet(T) diff T1;

subject to
{
  forall(i in T1,j in T2) overlapLength(t[i],t[j])==0;
}

and then see

gantt view within CPLEX IDE