I want to retrieve the reduced cost of a decision variable in CPLEX OPL. However, the dvar indices are tuples, and cplex cannot iterate over a tuple to print the reduced costs. Is it impossible with tuples, or is there a way for it? For example there is a decision variable as below:
dvar float+ Production[ProductionLocations][TimePeriods];
tuple timeperiod {
string TimePeriodID;
string TimePeriodName;
float CurrencyRate;
float Rank;
string ActivePeriod;
}
{timeperiod} TimePeriods = ...;
tuple productionlocation {
string ProductID;
string ProductName;
string LocationID;
string LocationName;
}
{productionlocation} ProductionLocations = ...;
Thanks in advance.
Let me expand on Alex's answer: it seems you attempt to query dual values for a MIP. Dual values are however not defined for MIPs. You have two options here:
In order to do the second thing, you can still use scripting:
main {
thisOplModel.generate();
cplex.solve(); // Compute integer optimal solution
cplex.solveFixed(); // Fix integer variables to optimal values, solve LP
// query your dual values:
for (var g in Gasolines) {
writeln("a[",g,"].reducedCost = ",a[g].reducedCost);
}
}