/* christmas_demand.pl */ christmas_demand_daily( BaseYear, TlStartDate, TlEndDate, Xs, Ys ) :- christmas_demand_key_points( BaseYear, 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. christmas_demand_key_points( BaseYear, KeyPoints ) :- findall( kp(Date,DI,Reason) , christmas_demand_key_point( BaseYear, Date, DI, Reason ) , KeyPoints ). christmas_demand_key_point( BaseYear, Date, DI, Reason ) :- christmas_demand( DR, DI, Reason ), christmas_demand_eval_daterel( DR, BaseYear, Date ). christmas_demand( 'Christmas Eve'-16 , 0 , "Just before start of school holidays and early vacation departures. Increased demand as families travel for extended holiday stays." ). christmas_demand( 'Christmas Eve'-14 , 10 , "Start of school holidays and early vacation departures. Increased demand as families travel for extended holiday stays." ). christmas_demand( 'Christmas Eve'-2 , 20 , "Significant increase in demand as travellers make final journeys to their holiday destinations." ). christmas_demand( 'Christmas Eve' , 30 , "Peak travel day with highest demand as individuals rush to reach family and holiday destinations." ). christmas_demand( 'Christmas Day' , 20 , "Slightly reduced demand compared to Christmas Eve, as most travellers have already reached their destinations." ). christmas_demand( 'Boxing Day' , 30 , "Renewed surge in travel as individuals take advantage of the holiday for short vacations or return trips." ). christmas_demand( 'New Year\'s Eve'-1 , 40 , "Rising demand for travel to major cities for New Year celebrations and events." ). christmas_demand( 'New Year\'s Eve' , 50 , "Peak demand for New Year's Eve celebrations, particularly in major cities known for public events and parties." ). christmas_demand( 'New Year\'s Day' , 20 , "Decreased demand as many travelers recover from New Year's Eve celebrations and begin their return journeys home." ). christmas_demand( 'Epiphany'-1 , 10 , "Moderate increase in travel, particularly in regions where Epiphany is a significant holiday, marking the end of the extended holiday season." ). christmas_demand( 'Epiphany'+1 , 0 , "End of extended holiday season." ). christmas_demand_eval_daterel( 'Christmas Eve', Y, date(Y,12,24) ). christmas_demand_eval_daterel( 'Christmas Day', Y, date(Y,12,25) ). christmas_demand_eval_daterel( 'Boxing Day', Y, date(Y,12,26) ). christmas_demand_eval_daterel( 'New Year\'s Eve', Y, date(Y,12,31) ). christmas_demand_eval_daterel( 'New Year\'s Day', Y, date(YN,1,1) ) :- YN is Y + 1. christmas_demand_eval_daterel( 'Epiphany', Y, date(YN,1,6) ) :- YN is Y + 1. christmas_demand_eval_daterel( DR+Offset, Y, Date ) :- christmas_demand_eval_daterel( DR, Y, BaseDate ), date_add( BaseDate, days(Offset), Date ). christmas_demand_eval_daterel( DR-Offset, Y, Date ) :- christmas_demand_eval_daterel( DR, Y, BaseDate ), date_add( BaseDate, days(-Offset), Date ).