How to define a three-dimensional parameter?

Problems with modeling
Post Reply
ALSANCAK
User
User
Posts: 6
Joined: 1 year ago

How to define a three-dimensional parameter?

Post by ALSANCAK »

Hello,
I need to define a three-dimensional parameter (D(n,h,t)) in my model. The use of tables is used in two-dimensional parameters. Below I am sharing my model and the parameter I want to define. I'll be happy if you can help me.
Thank you.

Sets;
n> 1*7 (Marmara, Ege, Akdeniz, iç Anadolu, Doğu Anadolu, Güneydoğu Anadolu, Karadeniz)
h> 1*3 (H1, H2, H3)
t>1*12 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 )
OCT25MODEL.gms
(2.14 KiB) Downloaded 61 times
image.png

Code: Select all

Sets

*Dağıtım Yapılacak Bölgeler
n 
/1*7/

*Aşı Öncelik Grubu
h 
/1*3/

*Zaman Periyodu
t 
/1*12/

*Araç Tipi
k 
/1*4/

*Araç Kapasitesi
CapC(k) 
/1 1425
 2 2735
 3 4575
 4 7500/
;

*Ana Depo Kapasitesi
Parameters CapWH; 
CapWH=35000;

*Bölge Deposu Kapasitesi
Parameters CapSH; 
CapSH=1140;
 

Variables
TBH(n,h)
Con3(n,h,t)
DD(n,h,t)
Con1(n,h,t)
Con2(n,h,t)
InvWH(t)
InvSH(n,t)
C(n,k,t)
;

Positive Variables
z
TBH(n,h)
Con3(n,h,t)
DD(n,h,t)
Con1(n,h,t)
Con2(n,h,t)
InvWH(t)
InvSH(n,t)
C(n,k,t)
;

Equations
amac
k1(n)
*k2(n)
*k3(n)
*k4(n)
*k5(n)
k6(n)
k7(n)
k8(n)
k9(n)
k10(t)
k11(n)
k12(k)
k13(n,t)
k14(t)
k15(n,t)
k16(n,t)
k17(n,t)
;

amac..                z=e=sum((n,h), TBH(n,h));
k1(n)..               sum ((h),TBH(n,h))=e=sum ((h,t), Con3(n,h,t));
*k2(n)..               sum((h,t)$(ord(t)=1), DD(n,h,t))=l=sum ((h,t)$(ord(t)=1), D(n,h,t)-Con1(n,h,t));
*k3(n)..               sum((h,t)$(ord(t)=2), DD(n,h,t))=l=sum ((h,t)$(ord(t)=2), DD(n,h,t)+Con(n,h,t-1)-Con1(n,h,t)-Con2(n,h,t));
*k4(n)..               sum((h,t)$(ord(t)>2), DD(n,h,t))=l=sum ((h,t)$(ord(t)>2), DD(n,h,t)+Con(n,h,t-1)+Con2(n,h,t-1)-Con1(n,h,t)-Con2(n,h,t))-Con3(n,h,t));
*k5(n)..               sum ((h,t), Con1(n,h,t))=l=sum ((h,t), D(n,h,t));
k6(n)..               sum ((h,t)$(ord(t)=1), Con2(n,h,t))=l=0;
k7(n)..               sum ((h,t)$(ord(t)>1), Con2(n,h,t))=l=sum ((h,t), Con1(n,h,t-1));
k8(n)..               sum ((h,t)$(ord(t)=2), Con3(n,h,t))=l=0;
k9(n)..               sum ((h,t)$(ord(t)>2), Con3(n,h,t))=l=sum ((h,t), Con2(n,h,t-1));
k10(t)..              InvWH(t)=l=CapWH;
k11(n)..              sum ((t), InvSH(n,t))=l=CapSH;
*k12(k)..              sum ((n,t), C(n,k,t))=l=CapC(k);
k13(n,t)..            InvSH(n,t-1)+sum ((k),C(n,k,t))=l=CapSH;
k14(t)$(ord(t)>1)..   InvWH(t)=l=InvWH(t-1)+CapWH-sum ((n,k),C(n,k,t));
k15(n,t)$(ord(t)>1).. InvSH(n,t)=l=InvSH(n,t-1)+sum ((k), C(n,k,t))-sum ((h), Con1(n,h,t));
k16(n,t)$(ord(t)=2).. InvSH(n,t)=l=InvSH(n,t-1)+sum ((k), C(n,k,t))-sum ((h), (Con1(n,h,t)+Con2(n,h,t)));
k17(n,t)$(ord(t)>2).. InvSH(n,t)=l=InvSH(n,t-1)+sum ((k), C(n,k,t))-sum ((h), (Con1(n,h,t)+Con2(n,h,t)+Con3(n,h,t)));

Model OCT25MODEL /all/;
Solve OCT25MODEL using mip max z;
Thank you.
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: How to define a three-dimensional parameter?

Post by bussieck »

Not clear why you remap from good names (Marmara, Ege, Akdeniz, iç Anadolu, Doğu Anadolu, Güneydoğu Anadolu, Karadeniz) to integers (1*7) but this is independent of your question. Tables can also be used for higher dimensional formats (see https://www.gams.com/latest/docs/UG_Dat ... Dimensions):

Code: Select all

Table D(n,h,t)
       1       2       3       4       5       6       7       8       9      10      11      12
1.1 14323   14323   14323   14323   14323   14323   14323   14323   14323   14323   14323   14323
1.2 178148  178148  178148  178148  178148  178148  178148  178148  178148  178148  178148  178148
...
Seems that you solved this all by yourself (see viewtopic.php?f=2&t=12534).

-Michael
Post Reply