Originally posted by: SystemAdmin
[rahul.raghuromeo said:]
How to get elements from a 3d array like this TruckJob2[trucks][Jobs][Jobs] where 2nd & 3rd dimension are same
code snippet is:-
for (int i=1; i<=imAssignments.getSize(); i++) {<br />
// Get allocation this truck
IloIntMap imTruckAssignments = imAssignments.getSub(dataElems.getElement("Trucks").asTupleSet().makeTuple(i-1));
for (int j=1; j<=imTruckAssignments.getSize(); j++) {<br />
IloIntMap imJob1Assignments = imTruckAssignments.getSub(dataElems.getElement("Jobs").asTupleSet().makeTuple(j-1));
for( int k=1; k<=imJob1Assignments.getSize(); k++ ) {<br />
//IloIntMap imJob2Assignments = imJob1Assignments.get(dataElems.getElement("Jobs").asTupleSet().makeTuple(k-1));
if (imJob1Assignments.get(dataElems.getElement("Jobs").asTupleSet().makeTuple(k-1))==1) {
cout << "Truck: " << dataElems.getElement("Trucks").asTupleSet().makeTuple(i-1).getStringValue("rego") << "\t";
cout << "Job1: " << dataElems.getElement("Jobs").asTupleSet().makeTuple(j-1).getIntValue("number") << "\t";
cout << "Job1: " << dataElems.getElement("Jobs").asTupleSet().makeTuple(j-1).getIntValue("size") << "\t" << "followed by" ;
cout << "Job2: " << dataElems.getElement("Jobs").asTupleSet().makeTuple(k-1).getIntValue("number") << "\t";
cout << "Job2: " << dataElems.getElement("Jobs").asTupleSet().makeTuple(k-1).getIntValue("size") << "\t" << endl;<br /> }
cout << imJob1Assignments.get(dataElems.getElement("Jobs").asTupleSet().makeTuple(k-1)) <<"rahul \n" ;<br /> }
}
//getchar();
cout << "end of truck:" << i << "*********************" <<endl;<br />
}
where:-
imAssignments:- total 3d map of all assignments representing TruckJob2
imTruckAssignments:- 2d map of a particular truck assignments
imJob1Assignments:- 1d map of a particular truck and job TruckJob2[trucks][Jobs]
now when I am trying to print the value of elements of the 3d array truckjobs nothing is printed out. Even the line
##cout << imJob1Assignments.get(dataElems.getElement("Jobs").asTupleSet().makeTuple(k-1)) <<"rahul \n" ;## which is out of If statement is not printed. I doubt wheather it goes in the loop iterated by k.<br />
Is it the 2nd and 3rd dimension of the TruckJob2 (which are same), who are causing the problem??? Please tell how to handle this kind of 3d array
Please Help.....really need to work this out for my project
#DecisionOptimization#OPLusingCPLEXOptimizer