dindizz commited on
Commit
21cbae6
·
verified ·
1 Parent(s): 74412c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -62,8 +62,11 @@ def optimize_dishes_for_budget(city, daily_budget):
62
  calories = [nutritional_data[dish]["Energy (kcal)"] for dish in nutritional_data]
63
  proteins = [nutritional_data[dish]["Protein (g)"] for dish in nutritional_data]
64
 
65
- # Objective function: Maximize nutritional value (calories + protein)
66
- c = [-1 * (cal + prot) for cal, prot in zip(calories, proteins)] # Minimize negative of nutrition for maximization
 
 
 
67
 
68
  # Constraint: Total cost must not exceed the daily budget
69
  A_ub = [costs] # Sum of costs * portions <= daily_budget
 
62
  calories = [nutritional_data[dish]["Energy (kcal)"] for dish in nutritional_data]
63
  proteins = [nutritional_data[dish]["Protein (g)"] for dish in nutritional_data]
64
 
65
+ # Introduce a small penalty for selecting large quantities of any single dish
66
+ diversity_penalty = np.ones(len(costs)) * 0.01
67
+
68
+ # Objective function: Maximize nutritional value (calories + protein) while encouraging diversity
69
+ c = [-1 * (cal + prot) + penalty for cal, prot, penalty in zip(calories, proteins, diversity_penalty)]
70
 
71
  # Constraint: Total cost must not exceed the daily budget
72
  A_ub = [costs] # Sum of costs * portions <= daily_budget