Originally posted by: brown_rice
Hi,
I define the following sets outside of main function:
public static final Integer[] _set1= {1};
public static final Integer[] _set2= {1,2};
Then, I convert them into TreeSet in the main function as:
List<Integer> set1_ = Arrays.asList(_set1);
Set<Integer> set1 = new TreeSet<Integer>(set1_);
Additionally, I have "public static final int limit =3;"
Now, I'd like to create my variable and then see how it looks.
IloCplex cplex = new IloCplex();
IloIntVar[][][] T = new IloIntVar[set1.size()][set2.size()][limit];
At this point, I am little confused. If I was in OPL, I'd just do "dvar int+ T[set1][set2][1..time]" and it would work.
In Java, I plan to do something like;
T[i][j][k] = cplex.intVar(0,Integer.MAX_VALUE, "T_"+ i+j+k);
cplex.addEq(T[i][j][k], 0,"Constraint_"+ i+j+k);
However, I am not sure how I should create the for loops. Should I rather create a class (like a tuple in OPL) and pass the class object into IloIntVar[object]? A better question is that if I can create an object based variable in Java? What is the best way to do this? Please note that the example that I am providing is just a toy example. So I have some set containing string values. I am just trying to find a fixed way to go with all the variables. Thanks.
#CPLEXOptimizers#DecisionOptimization