OPL Transportation

允我心安 提交于 2019-12-13 03:55:47

问题


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
                    ]#
            ]#;

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.


回答1:


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.



来源:https://stackoverflow.com/questions/46585931/opl-transportation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!