我正在为 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的差异。提前谢谢你。