Search Algorithms

This page includes some more information on the two search methods used.

Fridge.greedyFindComboFunction
greedyFindCombo(fridgeList, recipeDict, numRecipes)

This function uses greedy search to find a good combination of recipes that match your fridge content. It ranks all recipes based on the following formula

$score = (ingredients from fridge used) + 6*(ingredients in fridge remaining) + 2*(extra ingredients needed)$

Input:

  • fridgeList: A list containing the different foods in your fridge as a string.
  • recipeDict: A dictionary in which the keys are the recipe names and the responding values are a list of the needed ingredients.
  • numRecipes: The max amount of recipes that a combo should contain.

Output:

  • bestCombo: A dictionary containing the best found combination of recipes.
source

Simulated Annealing

Fridge.SAFindComboFunction
SAFindCombo(curSolution,  fridgeList, recipeDict, numRecipes, randRecipe; kT=100, r=0.75, Tmax=4, Tmin=1, tabuLength=3)

This function uses simulated annealing to find a better combination of recipes that match your fridge content. It starts with the current solution and tries to improve this.

Input:

  • curSolution: The current best combination of recipes, given as a dictionary in which the keys are the recipe names and the responding values are a list of the needed ingredients.
  • fridgeList: A list containing the different foods in your fridge as a string.
  • recipeDict: A dictionary in which the keys are the recipe names and the responding values are a list of the needed ingredients.
  • numRecipes: The max amount of recipes that a combo should contain.
  • tabuList: A list of recipes that should not be used in the found neighbour.
  • randRecipe: A Boolean true or false value. When true, random recipes are used for the neighbour.

Optional Inputs:

  • kT: repetitions per temperature
  • r: cooling rate
  • Tmax: maximal temperature to start
  • Tmin: minimal temperature to end
  • tabuLength: Number of cycli that recipe needs to be blocked

Output:

  • solution: A dictionary containing the best found combination of recipes.
source

Neighbour Functions

Fridge.randomComboFunction
randomCombo(fridgeList, recipeDict, numRecipes)

This function gives a random combination of recipes from the provided recipe dictionary.

Input:

  • fridgeList: A list containing the different foods in your fridge as a string.
  • recipeDict: A dictionary in which the keys are the recipe names and the responding values are a list of the needed ingredients.
  • numRecipes: The max amount of recipes that a combo should contain.

Output:

  • randCombo: A dictionary containing a random combination of recipes.
source
Fridge.NeighbourFunction
Neighbour(curSolution, fridgeList, recipeDict, numRecipes, tabuList, randRecipe)

This is a function that looks for a neighbour of the current solution. This function is used in the simulated annealing algorithm. It also uses a tabulist to stimulate the use of new solutions.

Input:

  • curSolution: The current best combination of recipes, given as a dictionary in which the keys are the recipe names and the responding values are a list of the needed ingredients.
  • fridgeList: A list containing the different foods in your fridge as a string.
  • recipeDict: A dictionary in which the keys are the recipe names and the responding values are a list of the needed ingredients.
  • numRecipes: The max amount of recipes that a combo should contain.
  • tabuList: A list of recipes that should not be used in the found neighbour.
  • randRecipe: A Boolean true or false value. When true, random recipes are used for the neighbour.

Output:

  • neighbour: A dictionary containing a combination of recipes.
source