This is a minimal, self-contained linear program (LP) using Pyomo to decide how many units of two products (A and B) to produce in order to maximize profit subject to machine-hour, labor-hour, and demand constraints.
This model is a plain linear program (LP). When you run it with GLPK or CBC:
- Algorithm: By default they use a (revised) simplex method for LPs
 – GLPK runs simplex; CBC delegates the LP to Clp, which also uses primal/dual simplex.
- Idea in one line: simplex walks along the corners (vertices) of the feasible polygon/polytope, moving to a better adjacent corner until no improving move exists (reduced costs ≥ 0), which certifies optimality.
uv add pyomo matplotlibYou’ll also need a solver (GLPK or CBC):
- macOS:
brew install glpk 
- Ubuntu/Debian:
sudo apt install glpk-utils 
- Windows:
 Download GLPK binaries or install CBC from CoinOR.
uv run python main.pyExample with custom limits:
uv run python main.py --hours 120 --labor 90 --bmax 50To visualize the constraints, feasible region, and optimum:
uv run python main.py --plotExample with custom limits and plot:
uv run python main.py --hours 120 --labor 90 --bmax 50 --plotWhen using --plot, the program will automatically save the diagram as:
docs/fig.png
…while also showing it interactively. You can change the filename/location in plot.py.
Solver: glpk
Status: ok | optimal
Optimal production plan:
  A: 30.00 units
  B: 40.00 units
Total profit: 2200.00
Resource usage at optimum:
  Machine hours: 100.00 / 100
  Labor hours:   70.00 / 80
  B upper bound: 40.00 / 40
