0

Now I am facing a problem that making a variation does not exceed a specific value. I will describe in details below.

using CP;

int a = 4;
int b = 3;
int c = 5;

range arange = 1..a;
range brange = 1..b;
range crange = 1..c;

dvar boolean x[a][b][c];
dvar int y[b][c] in 1..4;

In this case, I'm trying to calculate

y[b][c+1] = x[a][b][c] - 1 + y[b][c]; 

However, all y[e][t] are in 1 to 4.

I mean

if y[b][c] >= 4, then y[b][c] == 4, and if y[b][c] <= 1, then y[b][c] == 1

like that.


So, Now I trying to do this

y[b][c+1] == max(min(x[a][b][c] -1 + y[b][c], 4), 1);

but it doesn't work.

1 Answers1

2

Use minl and maxl instead:

y[b][c+1] == maxl(minl(2 * x[a][b][c] -1 + y[b][c], 4), 1);
Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22