在 CPLEX OPL 中检索由 "tuples" 组成的 Dvar 的降低成本
Retrieving Reduced Cost of Dvar composed of "tuples" in CPLEX OPL
我想在 CPLEX OPL 中检索决策变量的降低成本。
但是,dvar 索引是元组,cplex 无法迭代元组来打印降低的成本。元组是不可能的,还是有办法?
例如有一个决策变量如下:
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 = ...;
提前致谢。
您可以迭代元组集。
在 oil.mod 的 OPL CPLEX 示例中,您可能会看到
execute DISPLAY_REDUCED_COSTS{
for( var g in Gasolines ) {
writeln("a[",g,"].reducedCost = ",a[g].reducedCost);
}
}
Gasolines 是一个字符串集,但也可以是一个元组集,这也可以
让我详细说明 Alex 的回答:您似乎试图查询 MIP 的对偶值。然而,没有为 MIP 定义对偶值。您在这里有两个选择:
- 你可以放宽所有的变量,解决放宽的问题。这是一个 LP,因此将提供双重。但是,这可能不太有用。
- 你可以计算出MIP的最优解,固定所有整数变量,然后解决剩下的问题。这又是一个 LP,因此将提供双重价值。这些双重价值可能比你放松一切所获得的价值更有意义。
为了做第二件事,你仍然可以使用脚本:
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);
}
}
我想在 CPLEX OPL 中检索决策变量的降低成本。 但是,dvar 索引是元组,cplex 无法迭代元组来打印降低的成本。元组是不可能的,还是有办法? 例如有一个决策变量如下:
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 = ...;
提前致谢。
您可以迭代元组集。
在 oil.mod 的 OPL CPLEX 示例中,您可能会看到
execute DISPLAY_REDUCED_COSTS{
for( var g in Gasolines ) {
writeln("a[",g,"].reducedCost = ",a[g].reducedCost);
}
}
Gasolines 是一个字符串集,但也可以是一个元组集,这也可以
让我详细说明 Alex 的回答:您似乎试图查询 MIP 的对偶值。然而,没有为 MIP 定义对偶值。您在这里有两个选择:
- 你可以放宽所有的变量,解决放宽的问题。这是一个 LP,因此将提供双重。但是,这可能不太有用。
- 你可以计算出MIP的最优解,固定所有整数变量,然后解决剩下的问题。这又是一个 LP,因此将提供双重价值。这些双重价值可能比你放松一切所获得的价值更有意义。
为了做第二件事,你仍然可以使用脚本:
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);
}
}