1

I have a condition where I need to sum over the next 5 elements of a set.

My condition is: sum(neighbor(x)) = 1 w.r.t x, from x+1 to x+5

    Equation has_1_neighbor(x);
    has_1_neighbor(x).. Sum(x,x + 1,x+5,neighbor(x)) =e= 1; 

Unfortunately since I need to have x in the domain of the equation I'm not really allowed to sum with regards to x.

Does anyone know how to implement a constraint like this?

Bomaz
  • 1,871
  • 1
  • 17
  • 22

1 Answers1

2

You can use an alias of x, to use the set in both the sum and the equation.

The syntax to create an alias is simply:

Alias(x,xx);
Martin Bonde
  • 536
  • 3
  • 11