Skip to content

About

Zero-dependency Two-Phase Simplex linear programming optimizer for least-cost smallholder poultry, dairy & swine livestock feed ration formulation with East African ingredient tables.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

feedform-opt

CI License: MIT Python 3.11+ Zero Dependencies

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)

Problem Solved

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.

Key Features

  • 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.

Architecture Overview

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]
Loading

See docs/architecture.md for module-level design details.

Installation

git clone https://github.com/codesphere-u/feedform-opt.git
cd feedform-opt
uv sync --extra dev

Or install in editable mode with standard pip:

pip install -e ".[dev]"

Quick Start (CLI)

feedform-opt demo --ration broiler_starter --batch-kg 100
feedform-opt demo --ration layer_mash --batch-kg 50

Quick Start (Python API)

from 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.1

Testing & Quality Gates

uv run ruff check src tests
uv run mypy src
uv run pytest -v

Security, Contributing & Roadmap

License

MIT License — see LICENSE.

Support & Contact

Open an issue on GitHub Issues or contact codesphereinnovationz@gmail.com.

About

Zero-dependency Two-Phase Simplex linear programming optimizer for least-cost smallholder poultry, dairy & swine livestock feed ration formulation with East African ingredient tables.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages