Originally posted by: AndyHam
tuple t_Job {
int p1; int p2; int qty;
};
{t_Job} Job={
<1 1 2>,
<1 4 1>,
<1 7 3>,
<2 2 1>,
<2 3 2>,
<2 5 4>,
<2 6 2>
};
range p2lst = 1..7;
Now, I am trying to extract p2 and qty from the tuple and give to array as shown below.
int i_Qty[p2 in p2lst] = [<j.qty> | j in Job: j.p2==p2];
The syntax is not right, but I could not make it right.
What I want is to derive the following array from the tuple.
i_Qty[1]=2
i_Qty[2]=1
i_Qty[3]=2
i_Qty[4]=1
i_Qty[5]=4
i_Qty[6]=2
i_Qty[7]=3
Would you please fix my syntax? Any help will be appreciated.
int i_Qty[p2 in p2lst] = [<j.qty> | j in Job: j.p2==p2];
Thanks,
Andy
#DecisionOptimization#OPLusingCPOptimizer