% Information about the ingredients array[1..8, 1..4] of int : ingredients = [|50,17,220,25,|330,9,260,15,|310,6,70,10,|1,2,10,9,|260,0,5,3,|3,0,4,4,|160,0,20,2,|3,0,9,4|]; array[1..8] of string : nom_ingredients = ["Beef","Bun","Cheese","Onions","Pickles","Lettuce","Ketchup","Tomato"]; array[1..8] of var 1..5 : recette; var int : total_cost = sum([recette[i] * ingredients[i,4]|i in 1..8]); % Simple constraints constraint recette[6] == recette[7]; % Same quantity for the lettuce and the ketchup constraint recette[5] == recette[8]; % Same quantity for the tomato and the picckles % Contraints apply on a set (concerning the whole burger not only one or two characteristics) constraint sum([recette[i] * ingredients[i,3] | i in 1..8] ) < 3000; % The burger is less than 3000 calories % constraint sum((i in 1..8) (recette[i] * ingredients[i,3])) < 3000; % <= Same constraint but written in the second way to write generetor (see the course) constraint sum([recette[i] * ingredients[i,1] | i in 1..8] ) < 3000; % The burger is less than 3000 salty constraint sum([recette[i] * ingredients[i,2] | i in 1..8] ) < 150; % The burger is less than 150 fat % Solutions identification and listing: %solve satisfy; solve maximize total_cost; % String concatenation for beautifull solution display output["Cost of the burger: ", show(total_cost), "\n"] ++ ["\(nom_ingredients[i]) : \(recette[i]) \n" | i in 1..8];