Originally posted by: CaWa
Hi,
I am writing an optimization program with CPLEX Studio IDE 12.6 and I had a question concerning the right handling of tuple arrays.
I am reading one-dimensional arrays from Excel as input parameters whose type is a tuple: tupleType array[X] = ..;
As decision variables I need to determine a 4-dimensional array: dvar int T[A][B][C][D];
Now I need to define several constraints concerning T which I formulated as follows:
//tuple definition
range X = ...;
tuple
tupleType {
int a;
int b;
int
Value;
}
tupleType array[X] = ...;
//decision variable
dvar int T[A][B][C][D] in 0..1;
//constraint
forall (a
in A, b
in B,
i
in X) {
if (array[
i].a == a && array[
i].b ==
b) {
sum (c
in C, d
in D)
T[a][b][c][d] == array[
i].
Value;
} else {
sum (c
in C, d
in D)
T[a][b][c][d] == 0;
}
}
Does anyone know if I can adress a specific tuple as in the if-clause? Or how do I usually adress a tuple pair?
Because I need to make sure that the array is zero when the indices aren't the same and contain the value of the tuplepair when the indices are the same.
Right now it assigns to the whole matrix T[a][b][c][d] 0.
Thanks in advance for your help!
P.S.: And I was also wondering how I could formulate the decision variable T[a][b][c][d] also as a 1-dim. tuple array but I don't know if that's possible since I don't know the length of the array in advance. Am I right?
#DecisionOptimization#MathematicalProgramming-General