2
$\begingroup$

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{
   {int} task;
};
{link} relations[tasks]=
[{<{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<t\end{equation}​ 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?

$\endgroup$
2
$\begingroup$

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}];

dvar boolean x[workers,tasks,tasks];

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}];
tuple link{
   {int} task;
};
link relations[tasks]=
[<{1}>,<{1}>, <{1,2}>, <{1,2,3}>, <{4,7}>, <{6}>, <{6}>, <{5}>, <{8}>];;
dvar boolean x[workers,tasks,tasks];

subject to
{
  e4: forall(j,t in tasks: j in relations[t].task)
sum(h in workers, i in workstation)i*x[i,h,j] <= 
sum(h in workers,i in workstation)i*x[i,h,t];}
| improve this answer | |
$\endgroup$
  • $\begingroup$ Many thanks. Would you please, say how we can use the tuple to do that? $\endgroup$ – A.Omidi May 2 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.