Urgent!

Problems with syntax of GAMS
Post Reply
onurkusaksiz
User
User
Posts: 1
Joined: 3 months ago

Urgent!

Post by onurkusaksiz » 3 months ago

Hi guys, obviously I have a problem :( I am working on cargo transportation liner shipping networks. I have 2 cyclic routes like HK.JK.SG.HK and HK.XM.SG.CB.SG.HK. Problem has origin to destination demands Dm(o,d) like Dm(HK.CB).My code's problem is if I have a demand for (HK.CB) the ship needs to follow the container path. HK.XM.SG.CB, its ok but as also I have a demand HK.XM. I want that the ship unloads the containers at XM then loads the XM.CB demand go to CB and unloads the whole demand which are HK.CB and XM.CB on the other hand the HK.XM demand must be met. GAMS is not see my container paths. Thanks for help....

set
s "Services" / SR1,SR2,T,F /

p "Ports" / HK,JK,SG,XM,CB /

sr1(p,p,p,p) "SR1" / HK.JK.SG.HK /

sr2(p,p,p,p,p,p) "SR2" / HK.XM.SG.CB.SG.HK /

o(p) "Actual Ports" / HK,JK,SG,XM,CB /

arc(p,p,s) "All of arcs" / HK.JK.SR1,JK.SG.SR1,SG.HK.SR1,HK.XM.SR2
XM.SG.SR2,SG.CB.SR2,CB.SG.SR2,SG.HK.SR2
SG.SG.T,HK.HK.T,CB.HK.F,CB.XM.F,CB.JK.F,SG.XM.F,JK.HK.F
SG.JK.F,HK.SG.F,HK.CB.F,XM.HK.F,XM.CB.F,XM.JK.F,JK.XM.F,JK.CB.F /

ta(p,p,s) "Transfer Arcs" / HK.HK.T,SG.SG.T /

fa(p,p,s) "Forfeiting Arcs" / CB.HK.F,CB.XM.F,CB.JK.F,SG.XM.F
SG.JK.F,HK.SG.F,HK.CB.F,XM.HK.F
XM.CB.F,XM.JK.F,JK.HK.F,JK.XM.F,JK.CB.F /

v "Knots" / 17,21,25 /
e "Vessel Class" / A,B,C /
ve(v,e) "Vessel Knots" / #v:#e /
i "Number of ways for go to origin to destination point" / 1*3 /
j "Number of paths" / 1*3 /


alias(p,pp) ;
alias(o,d) ;

set
sa(p,pp,s) "Sailing Arc" / HK.JK.SR1,JK.SG.SR1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XM.HK.2.(XM.HK.F)
XM.SG.1.(XM.SG.SR2) / ;

set valid(o,d,j);
valid(o,d,j) = no;
valid(o,d,j)$ (sum((p,pp,s)$ q(o,d,j,p,pp,s),1)>0)=yes;
display valid;

set valid2(p,pp,s);
valid2(p,pp,s) = no;
valid2(p,pp,s)$ (sum((o,d,j)$ sa(p,pp,s),1)>0)=yes;
display valid2;


set paths(p,pp,s,o,d,j) ;
paths(p,pp,s,o,d,j) = no;
paths(p,pp,s,o,d,j) $ q(o,d,j,p,pp,s)=yes;
display paths ;

parameter cq(o,d,j) "Paths and costs(it icnludes the revenue obtained by transporting one unit of commodity"

/ CB.JK.1 100
CB.JK.2 2000
CB.JK.3 100
HK.SG.1 100
HK.SG.2 2000
HK.SG.3 100
HK.XM.1 100
HK.JK.1 100
SG.CB.1 100
SG.HK.1 100
SG.XM.1 100
SG.XM.2 100
SG.XM.3 2000
CB.SG.1 100
XM.CB.1 100
XM.CB.2 2000
HK.CB.1 100
HK.CB.2 2000
SG.JK.1 100
SG.JK.2 2000
CB.HK.1 100
CB.HK.2 2000
CB.XM.1 100
CB.XM.2 2000
JK.CB.1 100
JK.CB.2 2000
JK.SG.1 100
JK.HK.1 100
JK.HK.2 2000
JK.XM.1 100
JK.XM.2 2000
XM.JK.1 100
XM.JK.2 2000
XM.HK.1 100
XM.HK.2 2000
XM.SG.1 100 / ;


parameter f(s) "Weekly charter rate for vessel e in $" / SR1 4500 , SR2 7000 , F 10000 / ;

parameter Ne(e) "Available vessel" /A 12, B 12, C 6/

parameter Dm(o,d) "Demand for origin to destination"
/HK.SG 1000
HK.XM 1000
HK.JK 1000
HK.CB 1000
SG.CB 1000
SG.HK 1000
SG.XM 1000
SG.JK 1000
CB.SG 2000
CB.JK 1000
CB.HK 2000
CB.XM 2000
JK.CB 2000
JK.SG 2000
JK.HK 2000
JK.XM 2000
XM.JK 2000
XM.HK 2000
XM.SG 2000
XM.CB 2000 / ;

table va(e,s) "Vessel Assign to Service s"

SR1 SR2 F
A yes
B yes
C yes ;

table dis(p,pp) "Nautical Miles"

HK JK SG CB XM
HK 0 1789 1460 3440 287
JK 1789 0 525 4939 1954
SG 1460 525 0 1567 1653
CB 3440 4939 1567 0 2434
XM 287 1954 1653 2434 0 ;

parameter g(s) "Fuel Consumption per mile Based on Speed and Service" / SR1 0.098 , SR2 0.172 , F 0.252 / ;


parameter U(s) "Vessel Capacity in Service s" / SR1 100000 , SR2 250000 , F 20000 / ;


parameter n(s) "The Number of Vessel Required to Maintain Weekly Frequency in Service s" / SR1 2 , SR2 4 , F 0/ ;

scalar cm "Metric Ton Fuel Cost in $" / 650 / ;

parameter c(s) "Cost of Service" ;

c(s) = n(s)*f(s) + sum((p,pp) $ valid2(p,pp,s), cm*g(s)*dis(p,pp) ) ;

positive variables
x(o,d,j) "Amount of Commodity Sent Along to Path" ;

variable
z "Objective Function" ;


Binary variable
y(s) "0 or 1" ;

equations
objective "Total Cost"
cargo_flow "All Cargo is Either Transported or Forfeited"
capacity "Linked the Cargo Paths with the Service Capacity Installed"
fleet_a "The Selected Services can be Operated by the Available Fleet"
c1 "Validation constraint" ;




cargo_flow(o,d).. sum(j $ valid(o,d,j) , x(o,d,j)) =e= dm(o,d);

c1(o,d,j).. x(o,d,j ) $ (not valid(o,d,j)) =e= 0 ;

capacity(s).. sum( paths(p,pp,s,o,d,j) $ valid2(p,pp,s) , x(o,d,j)) - U(s)*y(s) =l= 0;



fleet_a(e).. sum(s$va(e,s), n(s)*y(s) ) =l= Ne(e);

objective.. z =e= sum(s ,c(s)*y(s))+ sum((o,d), sum( j $ valid(o,d,j), cq(o,d,j)*x(o,d,j)));

option limrow=100;
model TEZ41 /all/ ;
solve TEZ41 using MIP minimizing z;
display x.l , y.l ,z.l, capacity.l , cargo_flow.l , fleet_a.l , c1.l , arc , q ,c , ve, s, ta , fa , sa , va , cq , dis;

Post Reply