I am trying to model the following constrain in OPL. Here πG is string set.
$$ r >= \sum_{k=1}^{Np-1} y(k,k+1) \quad \quad \quad \quad ∀p∈ πG $$
Here is how I tried it in CPLEX OPL,
tuple Path {{string} nodes;}
{Path} paths = ...;
subject to{
forall(p in paths)
sum (node in p.nodes) Y[node][next(p.nodes,node)] <= r;
}
since i want to iterate till N-1 th element of set and apply function Y for k+1 th element i used "next" function. But here it iterates till N th element. Is it possible to do it using OPL notation to iterate till N-1 th element and get the k+1 th element in function?