# Nested set in OPL/CPLEX

I'm trying to solve a scheduling problem using OPL/CPLEX. In the model, there are nine tasks in which each task has its specific precedence. the precedence relationship is as follows:

[{1}, {1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];​


Where, for example, tasks {1,2,3} are the precedence of task four. I have defined two ways to create this relationship. First, by using a nested tuple set:

tuple link{
};
[{<{1}>}, {<{1}>}, {<{1,2}>}, {<{1,2,3}>}, {<{4,7}>}, {<{6}>}, {<{6}>}, {<{5}>}, {<{8}>}];​


Second, by nested set:

setof(int) operations[tasks] = [{1}, {1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];​


Now, I would like to use this relationship in the following constraint:

$$\begin{equation}\sum_{h \in H} \sum_{i \in I} i . x_{i h j} \leq \sum_{h \in H} \sum_{i \in I} i . x_{i h t} \forall j, t \in N, j​ Where, $${i \in workstation}$$, $${h \in workers}$$ and $${j,t \in tasks}$$.

The OPL code is:

  e4: forall(j,t in tasks: j<t)
sum(h in workers, i in workstation) i*x[i,h,j] <=
sum(h in workers, i in workstation) i*x[i,h,t];


I'm wondering if, which one of these methods can be applied to the constraint and how can I fix this issue?

Why not writing

{int} tasks=asSet(1..9);
{int} workstation={1,2};
{int} workers={1,2};
setof(int) operations[tasks]=[{1},{1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];

subject to
{
e4: forall(j,t in tasks: j in operations[t])
sum(h in workers, i in workstation)i*x[i,h,j] <=
sum(h in workers,i in workstation)i*x[i,h,t];}


and later on you asked for the same with tuple:

{int} tasks=asSet(1..9);
{int} workstation={1,2};
{int} workers={1,2};
//setof(int) operations[tasks]=[{1},{1}, {1,2}, {1,2,3}, {4,7}, {6}, {6}, {5}, {8}];