Originally posted by: Besko
Dear all,
I have difficulties to make everything working right.
Here is the problem introduction:
I have a set of origin/destination paths, i.e S =
(1,2,5,10), (1,2,8), (1,4,6,3,9), (2,8), (3,5,7). It can be noticed that they have different lengths.
Based on that, I have created a set of tuples with the number of elements as of the longest path (5 in this case):
tuple Path {
int a;
int b;
int c;
int d;
int e;
}
{Path} Paths = ...;
And the .dat contains the data:
Paths = {<1,2,5,10,0>, <1,2,8,0,0>, <1,4,6,3,9>, <2,8,0,0,0>, <3,5,7,0,0>};
Furthermore, I have a 0/1 decision variable X.
Now, I have a problem to define a specific constraint.
What I want to do is:
1. to make the subset of nonzero elements for each tuple. i.e for the first tuple: subset = <1,2,5,10>
2. to do some computation with that subset. i.e X[1] + X[2] + X[5] + X
10 I believe that the code could go something like:
forall(i in Paths)
sum(j in Path: "something" ) X[j] >= 1;
It can be noticed that the "something" is the major issue. :) Please correct me if I am wrong even on this point. The question is how to correctly formulate this constraint?
Thank you in advance.
Sincerely,
Nikola Besinovic
#DecisionOptimization#OPLusingCPLEXOptimizer