This project solves a basic Diet optimization problem using Linear Programming with the help of the PuLP library in Python.
Minimize the cost of food while satisfying a personβs minimum nutritional requirements, such as calories and protein.
- Takes a list of food items with:
- Cost per unit
- Calories per unit
- Protein per unit
- Solves for the minimum cost combination of food items that meets:
- A minimum calorie requirement
- A minimum protein requirement
- Uses PuLP to model and solve the linear programming problem.
Food Items:
- Bread (βΉ2/unit)
- Milk (βΉ3/unit)
- Eggs (βΉ4/unit)
Nutritional requirements:
- At least 500 calories
- At least 30g protein
We define decision variables representing the quantity of each food to consume. Then we:
- Minimize the total cost:
Total Cost = 2*bread + 3*milk + 4*eggs
- Subject to constraints:
Calories >= 500
Protein >= 30
PuLP is used to find the optimal solution that satisfies these constraints at minimum cost.
- Clone the repository or copy the code:
git clone https://github.com/your-username/DietPlan-Optimizer.git cd DietPlan-Optimizer
- Install the dependencies
pip install pulp import pulp