Subscript reshape (stitching)
Posted: Tue Dec 05, 2017 3:01 pm
Good day,
Using: Vensim 7.1 DSS
After hours of trying to figure this out, including review of the reference material I hope you can help.
Background: I am modelling electricity demand. An input is the sub-hourly daily demand profiles (48 off per day) per Customer Group (for instance residential). Per Customer Group there are 6 daily profiles - Demand Season [Low Demand, High Demand] by Day of Week [Weekday, Saturday, Sunday]. These profiles are repeated over the year (366 days (2016 was a leap year)):
Demand[Customer Group,Year Day,Time of Day]=
IF THEN ELSE( Month DoY[Year Day]<K Season[K1] :OR: Month DoY[Year Day]>K Season[K2],
IF THEN ELSE( Day of Week DoY[Year Day]<=K DoW[K1],
Demand Profile[Customer Group,Low Demand,Weekday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K2],
Demand Profile[Customer Group,Low Demand,Saturday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K3],
Demand Profile[Customer Group,Low Demand,Sunday,Time of Day],0))),
IF THEN ELSE( Day of Week DoY[Year Day]<=K DoW[K1],
Demand Profile[Customer Group,High Demand,Weekday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K2],
Demand Profile[Customer Group,High Demand,Saturday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K3],
Demand Profile[Customer Group,High Demand,Sunday,Time of Day],0)))
)
Problem: For further calculations I need to 'reshape' two subscripts - Year Day (YD 1 to YD366) and Time of Day (h0030, h0100, h0130, etc) - to one subscript Annual HalfHours (AHH1 to AHH17568) which is simply YD1's 48 Time of Days then YD2's 48 Time of Days and so on. The other option is to 'reshape' Annual HalfHours to Year Day and Time of Day subscripts. I believe with Matlab this is achieved with the function "reshape". How is this done in Vensim?
I am busy with IF THEN ELSE per Time of Day but this is tedious with loads of repetition and, at times, around 50 brackets (and still have not got it to run). I am sure there is a more eloquent and simple way to achieve subscript 'stitching' in Vensim. Please assist.
Thank you in advance
Using: Vensim 7.1 DSS
After hours of trying to figure this out, including review of the reference material I hope you can help.
Background: I am modelling electricity demand. An input is the sub-hourly daily demand profiles (48 off per day) per Customer Group (for instance residential). Per Customer Group there are 6 daily profiles - Demand Season [Low Demand, High Demand] by Day of Week [Weekday, Saturday, Sunday]. These profiles are repeated over the year (366 days (2016 was a leap year)):
Demand[Customer Group,Year Day,Time of Day]=
IF THEN ELSE( Month DoY[Year Day]<K Season[K1] :OR: Month DoY[Year Day]>K Season[K2],
IF THEN ELSE( Day of Week DoY[Year Day]<=K DoW[K1],
Demand Profile[Customer Group,Low Demand,Weekday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K2],
Demand Profile[Customer Group,Low Demand,Saturday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K3],
Demand Profile[Customer Group,Low Demand,Sunday,Time of Day],0))),
IF THEN ELSE( Day of Week DoY[Year Day]<=K DoW[K1],
Demand Profile[Customer Group,High Demand,Weekday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K2],
Demand Profile[Customer Group,High Demand,Saturday,Time of Day],
IF THEN ELSE( Day of Week DoY[Year Day]=K DoW[K3],
Demand Profile[Customer Group,High Demand,Sunday,Time of Day],0)))
)
Problem: For further calculations I need to 'reshape' two subscripts - Year Day (YD 1 to YD366) and Time of Day (h0030, h0100, h0130, etc) - to one subscript Annual HalfHours (AHH1 to AHH17568) which is simply YD1's 48 Time of Days then YD2's 48 Time of Days and so on. The other option is to 'reshape' Annual HalfHours to Year Day and Time of Day subscripts. I believe with Matlab this is achieved with the function "reshape". How is this done in Vensim?
I am busy with IF THEN ELSE per Time of Day but this is tedious with loads of repetition and, at times, around 50 brackets (and still have not got it to run). I am sure there is a more eloquent and simple way to achieve subscript 'stitching' in Vensim. Please assist.
Thank you in advance