A Python-based optimization system that finds the perfect combination of coffee beans to minimize cost while maintaining quality standards. Built with Pyomo, YAML configuration, and Pandas reporting.
You run a coffee shop and need to create a house blend using 3 different coffee beans. Each bean has different costs, quality scores, and availability constraints. The challenge is to find the optimal blend that minimizes cost while meeting quality requirements and business constraints.
Available Beans:
- Bean A (Premium): $12/kg, Quality 9/10, Max 50kg/week
- Bean B (Standard): $8/kg, Quality 6/10, Max 100kg/week
- Bean C (Economy): $5/kg, Quality 4/10, Max 80kg/week
Requirements:
- Total blend: 100kg per week
- Minimum quality score: 6.0/10
- Each bean must be at least 10% of blend
- Premium beans cannot exceed 40% of blend
- ✅ YAML Configuration: Easy-to-modify bean properties and constraints
- ✅ Linear Programming: Optimal solution using Pyomo optimization framework
- ✅ Multiple Objectives: Cost minimization and quality maximization modes
- ✅ Sensitivity Analysis: Test impact of price changes and constraint modifications
- ✅ Clean Reporting: Pandas-based results with CSV export
- Python 3.8+
- Pyomo - Optimization modeling
Clone the repository:
git clone https://github.com/erielC/coffee-blend-optimizer.gitCreate a conda enviorment using the environment.yml file provided:
conda env create -f environment.yml Activate environment:
conda activate cfOnce created the conda environment and it is active then simply:
python run.py==================================================
COFFEE BLEND OPTIMIZATION RESULTS
==================================================
Solver Status: optimal
Optimal Solution Found!
Bean A: 36.0 kg (36.0%) - Cost: $432.00
Bean B: 10.0 kg (10.0%) - Cost: $80.00
Bean C: 54.0 kg (54.0%) - Cost: $270.00
Total Cost: $782.00
Final Quality Score: 6.00Common Issues:
- PyYAML - Configuration management
- Pandas - Data analysis and reporting
- NumPy - Numerical computations
MIT License - see LICENSE file for details.
Built with ☕ and optimization algorithms
*For questions or support, please open an issue or contact [[email protected]]