Runnable examples for OptAgent live in this repository.
The private optagent repository keeps the core implementation, internal
documents, tests for core behavior, and implementation records. This public
repository keeps example code, example-specific tests, small public data files,
and helper scripts.
examples/linear/: MILP, MathOpt, HiGHS, and linearized routing examples.examples/scheduling/:sequence_var,interval_var,no_overlap, and CP-SAT examples.examples/blackbox/:external_calland heuristic search examples.examples/hybrid/: mixed linear and scheduling examples.examples/presets/: built-in and external preset usage.examples/mps/: MPS import and solve examples.examples/steel/: steel coil sequencing examples and diagnostics.examples/resource_flow/: resource-flow CP-SAT and MILP formulations.examples/mg/: hot-dip galvanizing coil sequencing notebook with inline data.examples/cold_rolling/: generic cold-rolling coil sequencing notebook with inline data.tests/: regression tests for the examples.scripts/: repeatable example experiment helpers.
Install OptAgent from the approved distribution for your environment, then install the example dependencies:
python -m pip install -r requirements-dev.txtFor source-based development, install the OptAgent source checkout or wheel you intend to test before running examples, then install the example dependencies:
python -m pip install -r requirements-dev.txtOptional exact solver examples use ortools and/or highspy. Tests that need
those backends are skipped or narrowed when the dependency is unavailable.
Run commands from the repository root.
PYTHONPATH=. python examples/linear/knapsack_mathopt.py
PYTHONPATH=. python examples/scheduling/job_shop_small.py
PYTHONPATH=. python examples/blackbox/tsp_blackbox_small.py
PYTHONPATH=. python examples/hybrid/hybrid_production_planning_small.py
PYTHONPATH=. python examples/steel/run_blackbox.py --instance bundled_head40 --mode preset
PYTHONPATH=. python examples/resource_flow/solve_case.py --formulation cp --summary-only
PYTHONPATH=. python examples/mg/program/main.py examples/mg/program/data/20260407000000.dbEach example area has its own README with more specific commands and data notes.
Run tests after OptAgent is installed in the active Python environment.
python -m pytest -qTo run a smaller smoke set:
python -m pytest -q tests/test_examples_mps_builder.py tests/test_stage6_steel_examples.pyOnly public, small, and reproducible data belongs here. Small SQLite, JSON, CSV, MPS, and compressed JSON fixtures are acceptable. Do not commit private business data, absolute private paths, credentials, or links to internal-only systems.