首页
学习
活动
专区
圈层
工具
发布

OPL运输
EN

Stack Overflow用户
提问于 2017-10-05 12:43:07
回答 1查看 620关注 0票数 0

我正在为中的一个简单传输问题编写代码。这是代码trans.mod (文件)

代码语言:javascript
复制
{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。

代码语言:javascript
复制
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的差。提前谢谢你。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-05 14:59:12

第一个问题是,Tora和cplex都给出了最优结果吗?他们俩没有差距,对吧?

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

检查和比较两个程序的决策变量是否是最优解的最符合逻辑的结果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46585931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档