% ---------------% % Input Facts % % The calories that each activity lead us to burn % calories_burnt_per_activity(Activity, Calories burnt per Unit of Time). % % The calories remained to burn % remaining_calories_to_burn(Remaining Calories). % % The possible amounts of the time that can be spent for each activity % how_long(Activity, Duration). % % The maximum duration of the workout % max_time(30). % % The maximum surplus of calories to burn in the suggested workouts % #const surplus = 100. % % The specific optimization operation(s) that the user wants to perform. % optimize(What, Weight, Priority). % % Finally, the maxint value % maxint=1000. % ---------------% % Guessing Part activity_to_do(A, HL) | not_activity_to_do(A, HL) :- how_long(A, HL). % Some useful totals total_calories_activity_to_do(CB) :- #sum{CBA, A : activity_to_do(A, HL), calories_burnt_per_activity(A, TNTB), CBA = TNTB * HL} = CB, #int(CB). total_time_activity_to_do(TS) :- #sum{HL, A : activity_to_do(A, HL)} = TS, #int(TS). % Checking Part % Each activity must be present with a single how_long value :- activity_to_do(A, HL1), activity_to_do(A, HL2), HL1 != HL2. % Ensure that all the remaining calories are burnt :- remaining_calories_to_burn(RC), total_calories_activity_to_do(CB), RC > CB. % and that not more calories than the remaing (added the surplus) are burnt :- remaining_calories_to_burn(RC), total_calories_activity_to_do(CB), CB > RCsurplus, RCsurplus = RC + surplus. % Ensure to not exceed the max_time :- max_time(MTS), total_time_activity_to_do(TS), MTS < TS. % Optimizing Part % Try to minimize the time spent :~ optimize(time, _, P), activity_to_do(_, HL). [HL:P] % Try to minimize the number of different activities to do :~ optimize(activities, _, P), #count{A, HL : activity_to_do(A, HL)} = HM, #int(HM). [HM:P] % Prefere some activities over other :~ optimize(A, W, P), activity_to_do(A, _). [W:P]