OPL运输

OPL Transportation

我正在 IBM ILOG CPLEX Optimization Studio 中为一个简单的交通问题编写代码。 这是代码 trans.mod(文件)

{string} Sources = ...;
{string} Destination = ...;
float Demand[Destination]= ...;
float Output[Sources]= ...;
float Shipcost[Sources][Destination]= ...;

assert sum(s in Sources) Output[s] == sum(d in Destination) Demand[d];
dvar int Ship[Sources][Destination] in 1..50;
minimize 
sum(s in Sources, d in Destination)
Shipcost[s][d]*Ship[s][d];
subject to 
{
forall( s in Sources , d in Destination )
sum(d in Destination)
Ship[s][d]<=Output[s];
forall( s in Sources , d in Destination )
sum(s in Sources)
Ship[s][d]>=Demand[d];
forall( s in Sources , d in Destination )
Ship[s][d]>=0;
}     
execute DISPLAY
{
writeln("Ship=",Ship)
}

它的数据文件如下 trans.data

Sources = {Source1 Source2 Source3};
Destination = {mumbai delhi vadodra kolkata};
Demand = #[
        mumbai: 80
        delhi: 65
        vadodra: 70
        kolkata: 85
        ]#;
Output = #[
        Source1: 75
        Source2: 125
        Source3: 100
        ]#;
Shipcost = #[
        Source1: #[
                    mumbai: 464
                    delhi: 513
                    vadodra: 654
                    kolkata: 867
                    ]#
        Source2 : #[
                    mumbai: 352
                    delhi: 416
                    vadodra: 690
                    kolkata: 791
                    ]#
        Source3 : #[
                    mumbai: 995
                    delhi: 682
                    vadodra: 388
                    kolkata: 685
                    ]#
            ]#;

问题是,当我 运行 在 TORA 上遇到这个简单的运输问题时,它给了我最优解 152535 但是当我 运行 cplex 上的这段代码时,它给了我最佳解决方案 156366 请让我知道我哪里出错了或者为什么我得到 3831 的差异。 提前谢谢你。

第一个问题是,Tora 和 cplex 是否都给出了最佳结果?两者没有差距吧?

如果两者都是最优结果,请检查参数是否输入错误。

检查并比较两个程序的决策变量,以确定结果是否是最优解的最合乎逻辑的结果。