/* oce_demand.pl */ oce_demand_daily( Level, OceStartDate, OceEndDate, TlStartDate, TlEndDate, Xs, Ys ) :- oce_demand_key_points( Level, OceStartDate, OceEndDate, KeyPoints), maplist( {TlStartDate} / [kp(Date,DI,_Reason), Offset-DI] >> date_interval(Date, TlStartDate, days(Offset)) , KeyPoints , OffsetsAndDIs ), TlStartOffset = 0, date_interval(TlEndDate, TlStartDate, days(TlEndOffset)), time_series_segments_to_points(TlStartOffset, TlEndOffset, OffsetsAndDIs, Xs, Ys). oce_demand_key_points( Level, OceStartDate, OceEndDate, KeyPoints ) :- findall( kp( Date, DI, Reason ) , oce_demand_key_point( Level, OceStartDate, OceEndDate, Date, DI, Reason ) , KeyPoints ). oce_demand_key_point( l1, OceStartDate, OceEndDate, Date, DI, Reason ) :- world_famous_oce_demand( DR, DI, Reason ), eval_daterel_oce( DR, OceStartDate, OceEndDate, Date ). oce_demand_key_point( l2, OceStartDate, OceEndDate, Date, DI, Reason ) :- regionally_known_oce_demand( DR, DI, Reason ), eval_daterel_oce( DR, OceStartDate, OceEndDate, Date ). oce_demand_key_point( l3, OceStartDate, OceEndDate, Date, DI, Reason ) :- fun_night_oce_demand( DR, DI, Reason ), eval_daterel_oce( DR, OceStartDate, OceEndDate, Date ). world_famous_oce_demand( 'start'-9, 0, "Just before early arrivals for the event." ). world_famous_oce_demand( 'start'-7, 10, "Early arrivals for the event." ). world_famous_oce_demand( 'start'-3, 20, "Increased arrivals, including international fans." ). world_famous_oce_demand( 'start', 50, "Peak demand on event start day." ). world_famous_oce_demand( 'end', 5, "A bit of demand as visitors fly in to meet stars, staff or friends who were there." ). world_famous_oce_demand( 'end'+3, 0, "End of demand." ). . regionally_known_oce_demand( 'start'-7, 0, "Just before early arrivals, mostly local and regional fans" ). regionally_known_oce_demand( 'start'-5, 5, "Early arrivals, mostly local and regional fans" ). regionally_known_oce_demand( 'start'-2, 10, "Increase in arrivals as the oce approaches" ). regionally_known_oce_demand( 'start', 30, "Peak demand on event start day" ). regionally_known_oce_demand( 'end', 1, "A bit of demand as visitors fly in to meet stars, staff or friends who were there." ). regionally_known_oce_demand( 'end'+2, 0, "End of demand" ). fun_night_oce_demand( 'start'-1, 0, "Slight increase in demand due to local attendees." ). fun_night_oce_demand( 'start', 2, "Slight increase in demand due to local attendees." ). fun_night_oce_demand( 'end', 1, "Minimal post-event demand, primarily local." ). fun_night_oce_demand( 'end'+1, 0, "Minimal post-event demand, primarily local." ). eval_daterel_oce( 'start', OceStartDate, _OceEndDate, OceStartDate ). eval_daterel_oce( 'end', _OceStartDate, OceEndDate, OceEndDate ). eval_daterel_oce( DR+Offset, OceStartDate, OceEndDate, Date ) :- eval_daterel_oce( DR, OceStartDate, OceEndDate, DRDate ), date_add( DRDate, days(Offset), Date ). eval_daterel_oce( DR-Offset, OceStartDate, OceEndDate, Date ) :- eval_daterel_oce( DR, OceStartDate, OceEndDate, DRDate ), date_add( DRDate, days(-Offset), Date ).