/* alpenfest_demand.pl */ alpenfest_demand_daily( Year, TlStartDate, TlEndDate, Xs, Ys ) :- alpenfest_demand_key_points( Year, KeyPoints ), % A list of kp(Date,DI,Reason) keypoints. maplist( { TlStartDate } / [ kp(Date,DI,_Reason), Offset-DI ] >> date_interval( Date, TlStartDate, days(Offset) ) , KeyPoints , OffsetsAndDIs ), % A list of Date-DI keypoints. TlStartOffset = 0, date_interval( TlEndDate, TlStartDate, days(TlEndOffset) ), time_series_segments_to_points( TlStartOffset, TlEndOffset, OffsetsAndDIs, Xs, Ys ). % A list of date offsets Xs, and a list of demand increments Ys. alpenfest_demand_key_points( Year, KeyPoints ) :- findall( kp(Date,DI,Reason) , alpenfest_demand_key_point( Year, Date, DI, Reason ) , KeyPoints ). alpenfest_demand_key_point( Year, Date, DI, Reason ) :- alpenfest_demand( DR, DI, Reason ), eval_daterel_alpenfest( DR, Year, Date ). % Alpenfest typically starts on a Saturday in September and ends 16 days later. eval_daterel_alpenfest( 'Alpenfest Start', 2024, date(2024,9,21) ). eval_daterel_alpenfest( 'Alpenfest End', 2024, date(2024,10,6) ). eval_daterel_alpenfest( 'Alpenfest Start', 2025, date(2025,9,20) ). eval_daterel_alpenfest( 'Alpenfest End', 2025, date(2025,10,5) ). eval_daterel_alpenfest( 'Alpenfest Start', 2026, date(2026,9,19) ). eval_daterel_alpenfest( 'Alpenfest End', 2026, date(2026,10,4) ). eval_daterel_alpenfest(DR+Offset, Year, Date) :- eval_daterel_alpenfest(DR, Year, BaseDate), date_add(BaseDate, days(Offset), Date). eval_daterel_alpenfest(DR-Offset, Year, Date) :- eval_daterel_alpenfest(DR, Year, BaseDate), date_add(BaseDate, days(-Offset), Date). alpenfest_demand( 'Alpenfest Start'-9, 0, "Just before early arrivals and pre-festival activities." ). alpenfest_demand( 'Alpenfest Start'-7, 10, "Early arrivals and pre-festival activities." ). alpenfest_demand( 'Alpenfest Start', 30, "Opening day of Alpenfest with peak demand." ). alpenfest_demand( 'Alpenfest Start'+7, 20, "Mid-festival period with sustained high demand." ). alpenfest_demand( 'Alpenfest End', 25, "Final weekend of Alpenfest with high demand." ). alpenfest_demand( 'Alpenfest End'+1, 5, "A few people fly in to meet friends, staff or stars who were at Alpenfest." ). alpenfest_demand( 'Alpenfest End'+3, 0, "End of Alpenfest demand." ).