In CPLEX OPL, how do I write summation of i (from 1 to i-1) in constraints?
another question: how do I input 3 dimensional matrix?
Many thanks in advance,
To get 3 dimensional input, you can flatten your 3-d input array to a 1-d array, then assign values to your 3-d array using a simple OPL script code like:
int array[0..I-1][0..J-1][0..K-1];//3-d array
int input[I*J*K]=...;//1-d array to be read as input
execute assignArray{
var index=0;
for(var i=0;i<I;i++){
for(var j=0;j<J;j++){
for(var k=0;k<K;k++){
array[i][j][k]=input[index];
index++;
}
}
}
}
You can create a dvar with 3 dimensions using something like:
and, in order to sum using a range you can do: