Search Algorithms
This page includes some more information on the two search methods used.
Greedy Search
Fridge.greedyFindCombo — FunctiongreedyFindCombo(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.
Simulated Annealing
Fridge.SAFindCombo — FunctionSAFindCombo(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
trueorfalsevalue. Whentrue, 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.
Neighbour Functions
Fridge.randomCombo — FunctionrandomCombo(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.
Fridge.Neighbour — FunctionNeighbour(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
trueorfalsevalue. Whentrue, random recipes are used for the neighbour.
Output:
- neighbour: A dictionary containing a combination of recipes.