OPL运输 [英] OPL Transportation

查看:141
本文介绍了OPL运输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am writing a code for a simple transportation problem in IBM ILOG CPLEX Optimization Studio. Here is the code trans.mod (File)

{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)
}

它的数据文件为 转换数据

The data file of it is as 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的差额. 预先谢谢你.

The problem is that when I run this simple transportation problem on TORA it gives me Optimal Solution as 152535 But when I run this code on cplex it gives me optimal solution as 156366 Please let me know where I am going wrong or why i am getting the difference of 3831. Thank you in advance.

推荐答案

第一个问题是Tora和cplex都给出了最佳结果吗?他们两个之间没有差距吧?

First question is that did both Tora and cplex give the optimal results? There is no gap for both of them right?

如果两个都是最佳结果,请检查是否错误输入了其中一个程序的参数.

If both are optimal results, check parameters if you input into one of the programs wrongly.

检查和比较两个程序的决策变量,结果是否是最佳解决方案中最合逻辑的结果.

Check and compare decision variables for both program whether the result is the most logical result for the optimal solution or not.

这篇关于OPL运输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆