I'm creating a program which calculates products that can be made from available ingredients based on different recipes. User can add new recipes, ingredients and their quantities. Recipes may contains same ingredients.
I have a List from recipes and a list from ingredients(from which recipes are made). I need to calculate the optimal variation of maximum number of products which can be made among all variations. The constraints are the quantity of ingredients that I have available and the storage space.
When I find the optimal variation and made products I need to decrease quantities in available ingredients with the used quantities for the products.
These are part of my classes for Recipes and Ingredients (all quantities are in grams)
public class Ingredient
{
public Ingredient() { }
public Ingredient(string name, int quantity)
{
Name = name;
Quantity = quantity;
}
public string Name { get; set; }
public int Quantity { get; set; }
}
public class Recipe
{
public Recipe(string recipeName, ObservableCollection<Ingredient> ingredients)
{
RecipeName = recipeName;
Ingredients = new ObservableCollection<Ingredient>();
}
public string RecipeName { get; set; }
public ObservableCollection<Ingredient> Ingredients { get; set; }
}
I'm not sure how to calculate all variations when there are more than 2 recipes.
Update:
This is some sample data:
recipe1 Ingredient - "Peppers", Quantity - 300 Ingredient - "Tomatoes", Quantity - 300 Ingredient - "Carrots", Quantity - 100 Ingredient - "Salt", Quantity - 50 Ingredient - "Sugar", Quantity - 50
recipe2
Ingredient - "Peppers", Quantity - 200
Ingredient - "Tomatoes", Quantity - 200
Ingredient - "Eggplant", Quantity - 300
Ingredient - "Salt", Quantity - 25
Ingredient - "Onion", Quantity - 50
Ingredient - "Garlic", Quantity - 25
recipe3
Ingredient - "Potatoes", Quantity - 200
Ingredient - "Tomatoes", Quantity - 200
Ingredient - "Eggplant", Quantity - 300
Ingredient - "Salt", Quantity - 25
Ingredient - "Onion", Quantity - 50
Ingredient - "Garlic", Quantity - 25
This needs to work with random quantities from available ingredients.