I have the following dataset:
food_a(bagel, 245).
food_a(sandwich, 200).
food_a(salad,300).
food(bagel).
food(sandwich).
food(salad).
I want to satisfy the following constraint: Given a total calorie count, I want to return the food items that satisfy that. For eg. total calorie count = 500, the program should return 'bagel+sandwich' as the solution. I coded he following clingo code:
food_a(bagel, 245).
food_a(sandwich, 200).
food_a(salad,300).
food(bagel).
food(sandwich).
food(salad).
has(bagel, wheat).
has(sandwich, bread).
has(sandwich, tomatoes).
has(sandwich, onion).
has(sandwich, cheese).
%calories(food,amount):-food_a(food,amount).
%food(F):-food_a(F,C).
%limits(calories,200).
%sol(F) :- food_a(F,C1),food_a(F,C2), C1+C2<500.
%:- {food(F,C) : food_a(F,C1),food_a(F,C2)} , C1+C2 >500.
%food_diet(F) :- food(F,C), C<250.
%:- food(F1) ,food_a(F2,C2), C1+C2=445.
totals(P, S) :- S = #sum{ I : food_a(P,I)}, food(P), S<500.
The output I'm getting is in the screenshot:
Apparently, the program is returning jsut single food items, and not considering the combinations of 2 or 3 of them at a time. Can anyone suggest the changes or steps I must follow to achieve the same.