Zero-dependency Two-Phase Simplex linear programming optimizer for least-cost smallholder poultry, dairy & swine feed ration formulation with East African local ingredient nutrition tables.
- Mission Domain: Agriculture, Livestock & Food Security
- Stack: Pure Python 3.11+ (zero runtime third-party dependencies,
mypy --strict,ruff,pytest) - Maintainer: Codesphere Innovations (U) Limited (
codesphere-u)
Smallholder poultry and dairy farmers lose 20–35% of profit margins to unbalanced feed mixes while commercial ration-formulation software costs thousands of dollars per license and requires desktop dongles.
- Self-contained pure-Python Two-Phase Simplex LP solver (
solve_lp_min) with Bland's anti-cycling rule — zero SciPy/NumPy/C dependencies. - Built-in East African local ingredient library (
maize_grain,maize_bran,soybean_meal,cottonseed_cake,mukene_fishmeal,sunflower_cake,limestone,premix_salt). - Standard broiler starter, broiler finisher, layers mash, and dairy concentrate nutritional specs enforcing protein, ME kcal/kg, max crude fiber, calcium, lysine, and safe ingredient caps.
flowchart LR
A[Local Ingredient Prices & Nutrients] --> B[simplex.py<br/>Two-Phase Simplex LP]
S[Species Ration Spec] --> B
B --> C[Exact Least-Cost Batch Weights kg & Nutrient Audit]
See docs/architecture.md for module-level design details.
git clone https://github.com/codesphere-u/feedform-opt.git
cd feedform-opt
uv sync --extra devOr install in editable mode with standard pip:
pip install -e ".[dev]"feedform-opt demo --ration broiler_starter --batch-kg 100
feedform-opt demo --ration layer_mash --batch-kg 50from feedform_opt import EAST_AFRICA_INGREDIENTS, STANDARD_RATIONS, formulate_least_cost_ration
sol = formulate_least_cost_ration(EAST_AFRICA_INGREDIENTS, STANDARD_RATIONS["broiler_starter"], batch_kg=100)
assert sol.feasible and abs(sum(sol.batch_weights_kg.values()) - 100.0) <= 0.1uv run ruff check src tests
uv run mypy src
uv run pytest -v- Security: See SECURITY.md for responsible disclosure procedures.
- Contributing: See CONTRIBUTING.md and CODE_OF_CONDUCT.md.
- Changelog & Roadmap: See CHANGELOG.md and ROADMAP.md.
MIT License — see LICENSE.
Open an issue on GitHub Issues or contact codesphereinnovationz@gmail.com.