Hi again,
Thank you for your answer. Sorry for that problem, I’m writing full code now. Thank you for your interest
set
o “Origin port” /HK,JK,SG,XM,CB/
p “Ports” /HK1,HK2,JK1,SG1,SG2,XM2,CB2/
e “Vessel Classes” /A,B,C/
v “Vessel Speed” /17k, 21k, 25k/
i “Number of ways for go to origin to destination point” /1*10/
;
alias(o,d) ;
alias(p,pp) ;
set
s “Service Routes” / sr1,sr2,T,F /
Tr “Transfer Arc” /HK1.HK2 , SG1.SG2/
parameter
r(p,s) “Ship Routes”
/(HK1.JK1.SG1.HK1).sr1 , (HK2.XM2.SG2.CB2.SG2.HK2).sr2 /
a(o,d,i,p,pp,s) “Container Path”
/ CB.JK.1.CB2.SG2.sr2,
CB.JK.1.SG2.SG1.T,
CB.JK.1.SG1.HK1.sr1,
CB.JK.1.HK1.JK1.sr1,
CB.JK.2.CB2.JK1.F,
CB.JK.3.CB2.SG2.sr2,
CB.JK.3.SG2.HK2.sr2,
CB.JK.3.HK2.HK1.T,
CB.JK.3.HK1.JK1.sr1,
HK.SG.1.HK2.XM2.sr2,
HK.SG.1.XM2.SG2.sr2,
HK.SG.2.HK2.SG2.F,
HK.SG.1.HK1.JK1.sr1,
HK.SG.1.JK1.SG1.sr1,
HK.SG.1.HK1.JK1.sr1,
HK.SG.1.JK1.SG1.sr1,
HK.SG.1.SG1.SG2.T,
HK.SG.2.HK1.SG2.F,
HK.SG.1.HK2.XM2.sr2,
HK.SG.1.XM2.SG2.sr2,
HK.SG.1.SG2.SG1.T,
HK.SG.2.HK2.SG1.F,
HK.XM.1.HK2.XM2.sr2,
HK.JK.1.HK1.JK1.sr1,
SG.CB.1.SG2.CB2.sr2,
SG.HK.1.SG1.HK1.sr1,
SG.HK.1.SG2.HK2.sr2,
HK.JK.1.HK1.JK1.sr1,
HK.JK.1.HK2.HK1.T,
HK.JK.1.HK1.JK1.sr1,
HK.JK.2.HK2.JK1.F,
SG.XM.1.SG1.SG2.T,
SG.XM.1.SG2.HK2.sr2,
SG.XM.1.HK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
CB.JK.1.SG1.HK1.sr1,
CB.JK.1.HK1.JK1.sr1,
CB.JK.2.CB2.SG2.sr2,
CB.JK.2.SG2.HK2.sr2,
CB.JK.2.HK2.HK1.T,
CB.JK.2.HK1.JK1.sr1,
CB.JK.3.CB2.JK1.F,
HK.CB.1.HK2.XM2.sr2,
HK.CB.1.XM2.SG2.sr2,
HK.CB.1.SG2.CB2.sr2,
HK.CB.2.HK2.CB2.F,
HK.CB.1.HK1.JK1.sr1,
HK.CB.1.JK1.SG1.sr1,
HK.CB.1.SG1.SG2.T,
HK.CB.1.SG2.CB2.sr2,
SG.JK.1.SG1.HK1.sr1,
SG.JK.1.HK1.JK1.sr1,
SG.JK.2.SG1.JK1.F, / ;
table t1(o,d) “hours between ports in service 2”
HK SG XM CB
HK 66
SG 158 148
XM 172
CB 148 128
;
table t2(o,d) “hours between ports in service 1”
HK SG JK
HK 178
SG 128
JK 30
;
parameter
teu(e) “Ship size” /A 4000, B 9000, C 19000/
f(e) “Weekly charter rate for vessel e in $” /A 45000 ,B 70000 ,C 110000/
Ne(e) “Available vessel” /A 10, B 7, C 5/
k(p) “Demand for port p” / HK1 100, JK1 100, SG1 100, HK2 100, XM2 100, SG2 100, CB2 100 /
;
table dis(o,d) “Nautical Miles”
HK JK SG CB XM
HK 1789 287
JK 525 ???
SG 1460 1567
CB 1567
XM 1653
;
table g(v,e) “Fuel Consumption per mile Based on Speed and Vessel Class”
A B C
17k 0.098 0.196 0.269
21k 0.158 0.317 0.396
25k 0.258 0.466 0.600
;
parameter U(s) “vessel capacity in service s” /sr1 20000, sr2 40000/
;
table n(e,s) “The number of vessel of class e(s) required to maintain weekly frequency”
A B C
sr1 1 1 1
sr2 2 1 1
;
scalar
cm “Metric Ton Fuel Cost in $” /650/
;
variables
c(s) “Cost of Service”
c(ro) “Cost of a Path ro”
x(ro) “Amount of Commodity k Sent Along the Path”
z “Objective Function”
;
Binary variable y(s)
equations
objective “Total Cost”
cargo_flow(k) “All Cargo is Either Transported or Forfeited”
capacity(a) “Linked the Cargo Paths with the Service Capacity Installed”
fleet_a(e) “The Selected Services can be Operated by the Available Fleet”
cost(s) “Cost of selected service”
;
objective… z =e= sum(s,(c(s)*y(s))+(sum(ro, c(ro)*x(ro)))) ;
cost(s)… c(s) =e= sum(e,n(e,s)f(e)) + sum((e,v),cmg(e,v))*sum((o,d),dis(o,d)) ;
cargo_flow(k)… sum(ro,x(ro)) =e= sum(p,k(p));
capacity(a)… sum(ro,x(ro))- sum(s,U(s)*y(s)) =l= 0;
fleet_a(e)… sum(s,n(e,s)*y(s)) =l= Ne(e);
model TEZZZ /all/ ;
solve TEZZZ using MIP minimizing z;