Hi, I have the following constraint
<pre class="jive-pre">
cumulFunction resUsage[k in 1..q] = sum(j in 1..n) pulse(qcTasks[k][j],l[j]); forall(k in 1..q-1) resUsage[k+1] - resUsage[k] >=2;
</pre>

But this is not what I want. What I actually want is that when
<pre class="jive-pre">
resUsage[k+1] > 0
</pre>
, I restrict
<pre class="jive-pre">
resUsage[k+1] - resUsage[k] >=2;
</pre>

But the following have error
<pre class="jive-pre">
forall(k in 1..q-1) resUsage[k+1] != 0 => resUsage[k+1] - resUsage[k] >=2;
</pre>

Re: How to constrain the distance between cumulFunction?

2012-10-13T09:08:17Z

This is the accepted answer.
This is the accepted answer.

Hello.

Indeed, constraint on cumul function can be used only as top-level constraint, not inside an expression.
However I do not understand what exactly do you want to achieve. Could you please give us more details?

Note that constraining cumul function like this:

resUsage[k+1] - resUsage[k] >=2;

says that the function must be at least two everywhere on interval -maxint/2..maxint/2. It may be better to use alwaysIn constraint that allows to specify different interval than -maxint/2..maxint/2. Note that constraint alwaysIn cannot be used in an expression neither.

I do not understand the condition:

resUsage[k+1] > 0

Does it mean that resUsagek+1 must be bigger than 0 everywhere? Or that there is some point where resUsagek+1 is bigger than 0?

Also note that there is an implicit constraint that says that cumul function can never have a value lower than 0.

Best regards, Petr

Hello.

Indeed, constraint on cumul function can be used only as top-level constraint, not inside an expression.
However I do not understand what exactly do you want to achieve. Could you please give us more details?

Note that constraining cumul function like this:
<pre class="jive-pre">
resUsage[k+1] - resUsage[k] >=2;
</pre>
says that the function must be at least two everywhere on interval -maxint/2..maxint/2. It may be better to use alwaysIn constraint that allows to specify different interval than -maxint/2..maxint/2. Note that constraint alwaysIn cannot be used in an expression neither.

I do not understand the condition:
<pre class="jive-pre">
resUsage[k+1] > 0
</pre>
Does it mean that resUsagek+1 must be bigger than 0 everywhere? Or that there is some point where resUsagek+1 is bigger than 0?

Also note that there is an implicit constraint that says that cumul function can never have a value lower than 0.

Indeed, constraint on cumul function can be used only as top-level constraint, not inside an expression.
However I do not understand what exactly do you want to achieve. Could you please give us more details?

Note that constraining cumul function like this:
<pre class="jive-pre">
resUsage[k+1] - resUsage[k] >=2;
</pre>
says that the function must be at least two everywhere on interval -maxint/2..maxint/2. It may be better to use alwaysIn constraint that allows to specify different interval than -maxint/2..maxint/2. Note that constraint alwaysIn cannot be used in an expression neither.

I do not understand the condition:
<pre class="jive-pre">
resUsage[k+1] > 0
</pre>
Does it mean that resUsagek+1 must be bigger than 0 everywhere? Or that there is some point where resUsagek+1 is bigger than 0?

Also note that there is an implicit constraint that says that cumul function can never have a value lower than 0.

dvar interval qcTasks[k in 1..q][j in 1..n] optional in 10..H ;

Which means that Quay crane k performs task j.

l[i] is always biger than 0.

The cumulative curve of

resUsage[k+1]

falls to 0 between two consecutive intervals. What I want is that when it isn't 0, it should be 2 away from resUsage[k].

Let me try to detail it.
<pre class="jive-pre">
dvar interval qcTasks[k in 1..q][j in 1..n] optional in 10..H ;
</pre>
Which means that Quay crane k performs task j.

l[i] is always biger than 0.

The cumulative curve of
<pre class="jive-pre">
resUsage[k+1]
</pre>
falls to 0 between two consecutive intervals. What I want is that when it isn't 0, it should be 2 away from resUsage[k].

Let me try to detail it.
<pre class="jive-pre">
dvar interval qcTasks[k in 1..q][j in 1..n] optional in 10..H ;
</pre>
Which means that Quay crane k performs task j.

l[i] is always biger than 0.

The cumulative curve of
<pre class="jive-pre">
resUsage[k+1]
</pre>
falls to 0 between two consecutive intervals. What I want is that when it isn't 0, it should be 2 away from resUsage[k].

In fact, what I actually want is that when there is overlap between two tasks by two adjacent quay cranes, I want there are at least 1 bays between the two quay cranes.

In fact, what I actually want is that when there is overlap between two tasks by two adjacent quay cranes, I want there are at least 1 bays between the two quay cranes.

Finally I think I understand. Bay is a position of quay crane for a task. And there is some kind of minimum safety distance for adjacent cranes. Am I right?

I suggest to create a state function for every crane. It's value is the current position of the crane:

stateFunction qCraneState[1..q]; ... subject to
{ ... forall (k in 1..q) forall (j in 1..n) alwaysEqual(qCraneState[k], qcTasks[k][j], l[j]); ...

Note that this state function can also replace noOverlap for qcTasks[k]. I would suggest to try the performance with and without this noOverlap. State function also supports transition times if you need it.

Using alwaysIn constraint, it is possible to restrict position of adjacent crane like this:

// Restrict position of quay crane k+1 to be in interval l[j]+1..1000000 while crane k performs task j: forall(k in 1..q-1) alwaysIn(qCraneState[k+1], qcTasks[k][j], l[j]+1, 1000000);
// Restrict position of quay crane k-1 to be in interval 0..l[j]-1 while crane k performs task j: forall(k in 2..q) alwaysIn(qCraneState[k-1], qcTasks[k][j], 0, l[j]-1);

Note that when qcTasks[k][j] is absent then the alwaysIn constraint is ignored. Also note that alwaysIn constraint does not force the crane to stay in a certain position. The crane can move. Basically, alwaysIn and alwaysEqual can overlap only if they are compatible.

Best regards, Petr

Finally I think I understand. Bay is a position of quay crane for a task. And there is some kind of minimum safety distance for adjacent cranes. Am I right?

I suggest to create a state function for every crane. It's value is the current position of the crane:
<pre class="jive-pre">
stateFunction qCraneState[1..q]; ... subject to
{ ... forall (k in 1..q) forall (j in 1..n) alwaysEqual(qCraneState[k], qcTasks[k][j], l[j]); ...
</pre>
Note that this state function can also replace noOverlap for qcTasks[k]. I would suggest to try the performance with and without this noOverlap. State function also supports transition times if you need it.

Using alwaysIn constraint, it is possible to restrict position of adjacent crane like this:
<pre class="jive-pre">
// Restrict position of quay crane k+1 to be in interval l[j]+1..1000000 while crane k performs task j: forall(k in 1..q-1) alwaysIn(qCraneState[k+1], qcTasks[k][j], l[j]+1, 1000000);
// Restrict position of quay crane k-1 to be in interval 0..l[j]-1 while crane k performs task j: forall(k in 2..q) alwaysIn(qCraneState[k-1], qcTasks[k][j], 0, l[j]-1);
</pre>
Note that when qcTasks[k][j] is absent then the alwaysIn constraint is ignored. Also note that alwaysIn constraint does not force the crane to stay in a certain position. The crane can move. Basically, alwaysIn and alwaysEqual can overlap only if they are compatible.

Finally I think I understand. Bay is a position of quay crane for a task. And there is some kind of minimum safety distance for adjacent cranes. Am I right?

I suggest to create a state function for every crane. It's value is the current position of the crane:
<pre class="jive-pre">
stateFunction qCraneState[1..q]; ... subject to
{ ... forall (k in 1..q) forall (j in 1..n) alwaysEqual(qCraneState[k], qcTasks[k][j], l[j]); ...
</pre>
Note that this state function can also replace noOverlap for qcTasks[k]. I would suggest to try the performance with and without this noOverlap. State function also supports transition times if you need it.

Using alwaysIn constraint, it is possible to restrict position of adjacent crane like this:
<pre class="jive-pre">
// Restrict position of quay crane k+1 to be in interval l[j]+1..1000000 while crane k performs task j: forall(k in 1..q-1) alwaysIn(qCraneState[k+1], qcTasks[k][j], l[j]+1, 1000000);
// Restrict position of quay crane k-1 to be in interval 0..l[j]-1 while crane k performs task j: forall(k in 2..q) alwaysIn(qCraneState[k-1], qcTasks[k][j], 0, l[j]-1);
</pre>
Note that when qcTasks[k][j] is absent then the alwaysIn constraint is ignored. Also note that alwaysIn constraint does not force the crane to stay in a certain position. The crane can move. Basically, alwaysIn and alwaysEqual can overlap only if they are compatible.