Hello,
Following up on David Gravot's message, and if your goal is to have a simple structure to define "endBeforeStart", another option is to build the list of precedences from A as follows (providing A is instead a list of sets instead of a 2D array):
using CP;
int MAX_STAGES = 2;
range stages = 0..MAX_STAGES;
{int} machines = {0, 1, 2, 3, 4, 5, 6};
tuple machines_stage_pair {
{int} machines_pred;
{int} machines_post;
}
tuple Precedence { int pre; int post;}
{int} A[stages] = [{0, 1, 2}, {3, 4}, {5, 6}];
{machines_stage_pair} stages_pairs = {<A[i], A[i+1]> | i in stages : i < MAX_STAGES};
{Precedence} precedences with pre, post in machines = {<pr, po> | ms in stages_pairs, pr in ms.machines_pred, po in ms.machines_post};
execute {
writeln("A = ", A);
writeln("stages_pairs = ", stages_pairs);
writeln("precedences = ", precedences);
}
Then, executing the above OPL code produces:
A = [{0 1 2} {3 4} {5 6}]
stages_pairs = {<{0 1 2} {3 4}> <{3 4} {5 6}>}
precedences = {<0 3> <0 4> <1 3> <1 4> <2 3> <2 4> <3 5> <3 6> <4 5> <4 6>}
Regards
------------------------------
Hugues Juille
------------------------------