PuLP is an open-source Python library for expressing linear programming models and solving them through optimization solver interfaces. It fits planning problems where a linear objective and linear constraints determine the best feasible allocation. section 2.1.4
A typical PuLP workflow is:
- Create a minimization or maximization model with LpProblem. section 2.1.4
- Define bounded continuous, integer, or binary decision variables with LpVariable. section 2.1.4
- Add the linear objective and named constraints, select a solver, solve, and inspect variable values. section 2.1.4
Animal feed mix
Minimize ingredient cost while setting corn, limestone, and soybean meal proportions. Enforce calcium, protein, fiber, conservation, and non-negativity constraints. The resulting mixture uses 65% corn, 3% limestone, and 32% soybean meal, costing $0.4916 per kilogram. section 2.1.4
Table 2.1 Animal feed mix problem (view table figure)
| Ingredients |
Nutritive content and price of ingredients |
|||
|---|---|---|---|---|
| Calcium (kg/kg) |
Protein (kg/kg) |
Fiber (kg/kg) |
Unit cost (cents/kg) |
|
| Corn |
0.001 |
0.09 |
0.02 |
30.5 |
| Limestone |
0.38 |
0.0 |
0.0 |
10.0 |
| Soybean meal |
0.002 |
0.50 |
0.08 |
90.0 |
Compare each ingredient’s calcium, protein, fiber, and unit-cost coefficients before translating the feed problem into variables and constraints. section 2.1.4
