Thank you, Olivier. It worked. Much appreciated.
Original Message:
Sent: Wed February 21, 2024 01:03 PM
From: Olivier Lhomme
Subject: Exctraction of Dual values C++ - 2D Array
Hello, you can use tuples:
tuple index { typeOfResource resource; typeOfTime time;}{index} Indexes = {<r,t> | r in resources, t in time};for(i in Indexes) AvailabilityCons: sum( s in schedule) s.X_Time[i.time] * lambda[s] <= Available[i.resource][i.time]; or sum( s in schedule) s.X_Time[i.time] * lambda[s] <= Available[i];IloTupleSet indexSet = masterRC.getOplModel().getElement("Indexes").asTupleSet();IloNumMap DualW = subDataElements.getElement("AvailabilityDual").asNumMap();IloConstraintMap AvailabilityConsFill = masterRC.getOplModel().getElement("AvailabilityCons").asConstraintMap();for (IloTupleIterator it(indexSet); it.ok(); ++it) { IloTuple t = *it; IloForAllRange r = AvailabilityConsFill.get(t); DualW.set(t, masterCplex.getDual(r)); }where AvailabilityDual is defined as follows in the .mod files float AvailabilityDual[Indexes] = ...;
------------------------------
Olivier Lhomme
Original Message:
Sent: Thu February 15, 2024 04:27 PM
From: Dheeban Kumar Srinivasan Sampathi
Subject: Exctraction of Dual values C++ - 2D Array
Greetings, Community!
I'm currently working on extracting the dual values of the constraints outlined below:
for(r in resources, t in time)
AvailabilityCons:
sum( s in schedule) s.X_Time[t] * lambda[s] <= Available[r][t];
While I've managed to access and transfer them successfully to the subproblem using CPLEX OPL, I'm facing a challenge in doing so using C++. I've referred to the cutstock example, which worked well for a 1-D array scenario, but in my case, it's a 2D array. Could someone guide me on how to extract and transfer the dual values to the subproblem using C++? Below is the C++ program I've developed:
IloNumMap DualW = subDataElements.getElement("AvailabilityDual").asNumMap();
IloConstraintMap AvailabilityConsFill = masterRC.getOplModel().getElement("AvailabilityCons").asConstraintMap();
for (IloInt i = 1; i <= nbRes; i++) {
IloForAllRange resConstraint = AvailabilityConsFill.get(i);
for (IloInt j = 1; j <= nbTime; j++) {
DualW.set(i, masterCplex.getDual(resConstraint[j]));
}
}
#Decision Optimization
------------------------------
Dheeban Kumar
------------------------------