AI context for solving LP and MIP problems with LP-IP-craft
Last reviewed 2026-10-20 against main at f9ba356 (workspace 0.28.0; released
unchanged in its numerical code as 0.29.0). This
state includes the result contract 0.2 (claims with evidence,
lp-ip.evaluate/1, error codes, JSON Schemas; #15, docs and harness synced in
#16), the shared job crates 0.2.0 of
optimization-jobs at
revision eb1c9de instead of in-repo copies (#17), the optimization-mcp
server (#18), and bounds and gaps published only for the point an outcome
shows (#19); #20 moved the pin to 6a42472 and the release preparation to
423cd87, which add worker-declared artifacts and paged artifact reads
(get_artifact with offset and limit also pages through the results
journal of a running job); the pin is now 9c1427e (tag v0.6.0: optimization-mcp adds skills, output schemas for put_input, get_job and wait_job, the view_result app and an opt-in Files upload; the guide behind get_guide names the releases of 27 November 2026; 0.5.0 let command jobs declare a JSON-lines progress file, read with jobs progress while they run; job and worker protocols are as in 0.4.0); 0.4.0 adds
node capabilities, jobs execution JOB_ID, opt-in trusted local command
jobs with verified binary file transfer, and explicitly placed jobs on SSH
nodes, all through the CLI; 37b30e4 (tag v0.3.0)
added the MCP tools put_input and get_guide (with the corrected Pareto
guidance) and a host report in node doctor. The numerical crates and the Python package did not
change in these pull requests. Since then (CHANGELOG [Unreleased]), the
worker’s describe lists JSON Schemas and runnable examples
(discovery), and scripts/mps_to_model.py
converts MPS files (Import an MPS model). In another
checkout, check Cargo.toml,
python/lp_ip_craft/__init__.py, the worker’s discovery output and the linked
guides before using a command or claiming a capability.
This file is operational context for an AI that must model and solve a user’s linear program (LP) or mixed-integer linear program (MIP) with this repository, or decide that another tool fits better. It is not a performance claim. Every solve status is a numerical finding under declared tolerances, not an exact certificate; report results that way.
If the solver is not chosen yet, start with the entry point in optimization-jobs. It routes between fast-cma-es, fcmaes-rust, LP-IP-craft and SQP-craft and covers installation, the job API and the MCP server.
What the repository is
LP-IP-craft is a native Rust LP/MIP solver. One kernel, a bounded-variable dual
revised simplex on a sparse LU factorization, solves every LP and every node
relaxation. Integer search is best-bound branch and bound with diving and
pseudocost branching, plus presolve, propagation and optional cuts and
heuristics. The engine is owned by the project: no HiGHS, C/C++ solver, BLAS,
CMake or libclang is built or linked. Rayon supplies thread scheduling only.
CI fails if highs, bindgen, cmake, blas or lapack enter the native
dependency tree.
| Package (crate or distribution) | Path | Use as |
|---|---|---|
lp-ip-craft | crates/core | lp_ip_craft: immutable CSR model, options, results, independent checks, conservative bounds, dummy backend; no dependencies |
lp-ip-craft-native | crates/native | lp_ip_craft_native: NativeSolver, NativeOptions, batches |
lp-ip-craft-python / lp-ip-craft | crates/python, python/lp_ip_craft | import lp_ip_craft: optional PyO3 package |
optimization-job-api, optimization-runner | git dependency on optimization-jobs | Shared job protocol, the optimization-run runner and the optimization-mcp server |
lp-ip-job-worker | crates/lp-ip-job-worker | Job worker for profiles lp-ip.solve/1 and lp-ip.evaluate/1 |
Release 0.29.0 is the first on PyPI (python -m pip install lp-ip-craft);
the two library crates lp-ip-craft and lp-ip-craft-native go to
crates.io with the same version. Check the registries for the latest
version before relying on it (RELEASING.md); the worker
stays source-only. For Rust, the
job worker or changes after the latest release, use a checkout
of https://github.com/dietmarwo/LP-IP-craft. The workspace version is 0.34.0;
the shared job crates are 0.6.0. Profile names such as lp-ip.solve/1 are protocol
identifiers, independent of either.
Toolchains:
- The numerical crates need Rust 1.85 or newer; CI checks them with 1.85. The
job worker and the shared job crates need Rust 1.88; CI checks the worker
with 1.88. Plain
cargo buildbuilds onlycrates/coreandcrates/native(the default members). - The Python package needs CPython 3.10 or newer and builds from source with
Rust:
python -m pip install ".[test]". CI tests 3.10 and 3.14 on Linux, macOS and Windows. - The job layer is Linux only.
The application target card is intentionally
incomplete: it awaits a GTOC-based integer application with real data. Do not
claim application-level performance, and do not fill the card with toy
examples. The GTOC12 fixed-route benchmark
measures generated 44-asteroid clusters with a tuned option profile; quote it
with that scope.
The README’s dated version banners describe what each release added; the
option tables in docs/api.md and NativeOptions itself are the
current reference.
Required workflow for the AI
Before modelling, write a problem card with these facts. Inspect the user’s code and data where possible. Ask only for facts that cannot be inferred and would change the solution.
| Question | Why it matters |
|---|---|
| Are the objective and every constraint linear in the decision variables? | This solver accepts only objective_offset + cᵀx and linear row intervals. |
| How many variables, rows and nonzeros? Which variables are integer or binary? | Size and integrality decide LP versus MIP effort and the parallel layout. |
| Does every variable have a finite lower and upper bound? | The default MIP path needs finite bounds of magnitude at most 2^53−1 after root inference. objective_cutoff_bounds can derive sides from a certified incumbent. one_sided_mip permits one infinite side per continuous column with finite discrete domains. |
| Minimize or maximize? Is there a constant term? | Both senses are native; results keep the original sense and include the offset. |
| What are the units and coefficient ranges? | Badly scaled rows weaken numerical acceptance; tolerances are absolute in original units. |
| Which tolerances does the application accept? | Defaults are 1e-7 for feasibility and integrality. Freeze them before tuning. |
| Is a feasible incumbent enough, or is a proven optimum, bound or gap needed? | Finding a good incumbent and proving a gap are different goals with different stopping rules. |
| Are LP duals or reduced costs needed? | They exist only for LPs, never for a MIP. |
| Is a feasible MIP solution known? | Complete primal MIP starts are evaluated as incumbent candidates. LP warm starts are rejected. |
| What time, node, iteration, core and memory budget applies? | Limits are cooperative and retain the incumbent; parallel components split budgets. |
| Is there a reference solver or known optimum? | Validate against it with the independent evaluate check, not the solver’s own report. |
| One model, many independent models, or a durable agent experiment? | This selects the in-process API, a batch, or the job API. |
For every completed solution, state the problem card, the model dimensions, the backend and every non-default option, the thread layout, the budgets, the termination status, the independently evaluated objective and violations, the best bound and gap where they exist, and how the result was validated.
First decide whether LP-IP-craft is appropriate
Use it when the problem is a linear or mixed-integer linear model of small to moderate size, when a dependency-free Rust engine is valuable, or when independent result checks matter more than peak speed. It also suits many independent models solved in one batch.
Prefer another tool when:
- the objective or constraints are nonlinear: for smooth constrained problems with derivatives and at most 256 variables, see SQP-craft; for black-box, nonsmooth, multimodal or multi-objective problems, quality-diversity archives or expensive simulations, see fcmaes-rust. Both run on the same job node (Other solvers on the same node);
- the objective is quadratic: there is no QP or MIQP support;
- peak speed on hard instances decides: in the pinned HiGHS 1.15 comparisons of earlier releases, HiGHS stayed faster on public LPs such as 25fv47 and on some wide LPs, and proved more of the public MIPs (0.21, 0.27); it varies by model, so measure on the user’s models;
- the application needs exact rational optimality or infeasibility certificates: statuses are numerical, and the bounded rational witness covers only incumbent feasibility;
- the model is a large, hard industrial MIP for which a mature solver is expected and permitted: compare with one under the same independent check before choosing;
- a MIP needs free continuous or infinite discrete domains that root inference cannot close. See the one-sided MIP scope;
- a positive MIP gap stop must run in specialized packing or a split parallel tree: these paths reject it. The general search supports both absolute and relative limits.
Choose the integration surface
| Need | Entry point | Scope |
|---|---|---|
| Rust application | lp_ip_craft + lp_ip_craft_native::NativeSolver | Full native option set, starts, cancellation |
| Python application | lp_ip_craft.solve(..., backend="native") | Same engine; the GIL is released during native work |
| Many independent models | solve_batch (Python) or NativeSolver::solve_batch (Rust) | Ordered results; per-model limits; no starts |
| Durable, CPU-budgeted agent experiments | optimization-run + lp-ip-job-worker | One hashed model artifact per job, a smaller option profile; see below |
| Check a point or a bound from any solver | evaluate, lp_residuals, safe_dual_bound | Independent of every solver, including commercial ones |
Python’s solve defaults to backend="dummy", which only evaluates one point
(the start, or else the origin clamped to the bounds) and returns stub.
Always pass backend="native" to optimize.
Build the model
The model is
minimize or maximize objective_offset + cᵀx
subject to row_lower <= A x <= row_upper
lower <= x <= upper
x_j continuous, integer or binary
A is zero-based CSR by rows: indptr has m + 1 entries from 0 to nnz;
each row’s indices are strictly increasing and below n; explicit zeros are
allowed. n is the objective length and m the row-bound length. A zero-row
model uses indptr = [0]. Equal finite row bounds express an equality;
infinite sides express one-sided or free rows and columns. Binary bounds must
lie in [0, 1]. The model is validated once and is immutable; Python models
are picklable. The packages read no model files. For an MPS file,
scripts/mps_to_model.py writes the JSON model artifact of the job API
(Import an MPS model), which also gives the Python
arrays. There is no LP-format reader; otherwise build the CSR arrays from the
user’s data.
Python:
from lp_ip_craft import Model, NativeOptions, solve
inf = float("inf")
m = Model(objective=[3., 2.], sense="maximize",
lower=[0., 0.], upper=[10., 10.],
row_lower=[-inf, -inf], row_upper=[4., 5.],
indptr=[0, 2, 4], indices=[0, 1, 0, 1], values=[1., 1., 2., 1.])
r = solve(m, backend="native", backend_options=NativeOptions())
assert r.status == "optimal" and r.evaluation.feasible_candidate
print(r.evaluation.objective, r.candidate, r.best_bound, r.duals)
kinds=["integer", ...] or "binary" turns the same model into a MIP.
Rust (from crates/native/examples/solve.rs):
use lp_ip_craft::*;
use lp_ip_craft_native::*;
let model = Model::new(ModelData {
sense: Sense::Maximize,
objective: vec![7., 11., 5., 6.],
objective_offset: 0.,
variables: Bounds::new(vec![0.; 4], vec![1.; 4]),
kinds: vec![VariableKind::Binary; 4],
matrix: CsrMatrix::from_dense(1, 4, &[3., 5., 2., 4.])?,
rows: Bounds::new(vec![f64::NEG_INFINITY], vec![8.5]),
})?;
let r = NativeSolver::default().solve(
&model, &Options::default(), None, &CancellationToken::default())?;
assert_eq!(r.status, Status::Optimal);
CsrMatrix::new(rows, cols, indptr, indices, values) takes CSR arrays
directly. A MIP start is Some(&WarmStart::from_primal(x)): a complete point,
used as given, never rounded or repaired.
Modelling rules:
- Give every MIP variable the tightest bounds the application justifies, continuous ones included. The kernel keeps bounds as bounds, not rows, and branching changes them in place.
- Keep coefficients and right-hand sides in sensible units. Native scales internally by powers of two, but acceptance is measured in original units.
- Prefer exact integral data when the objective could be integral: objective lattice tightening needs all-integer variables, integral objective coefficients, zero offset and a finite box.
- Do not encode a nonlinear relation by a fine discretization without telling the user what approximation error it adds.
Options
Options (Rust and Python) holds the original-unit tolerances, both 1e-7 by
default, and threads, the maximum numerical width, 1–8 (default 1). Widths
above 8 are Unsupported (NotImplementedError in Python).
NativeOptions lists only controls the engine honours. Unknown names are
rejected (TypeError in Python), so stale settings fail loudly. The defaults
that matter most:
| Field | Default | Note |
|---|---|---|
time_limit_seconds | None | Cooperative whole-call budget |
node_limit | 100000 | MIP relaxations; None removes it |
iteration_limit | 1000000 | Simplex iterations across all nodes, phase 1, certification LPs and retries |
presolve | true | Master switch: with false, the whole root stage is skipped (reductions, bound inference, cuts and separation, root heuristics) and nodes skip domain propagation; a MIP then needs finite bounds as given |
mip_presolve, coefficient_tightening | true | Default since the change after 0.27; MIP presolve keeps every feasible point, coefficient tightening every integer-feasible point. Set both false for the earlier behaviour |
reduced_cost_fixing, incumbent_heuristic, rational_certification, objective_lattice | true | Each keeps the acceptance checks; disable only for matched ablations |
decompose, component_threads | true, 16 | Independent components may run on up to 16 workers when threads=1 |
strong_branching, reliability_branching, root_cuts, root_separation, gmi_cuts, mir_cuts, root_heuristics, feasibility_jump, dual_presolve | false | Opt-in; effects vary by model |
one_sided_mip, flow_cover_cuts, root_cut_family_quota | false | Serial search with one-sided continuous bounds, exact single-node flow covers and reserved GMI/MIR cut slots. See API. |
packing_root, packing_neighborhoods, packing_cuts, scalable_branching, tree_threads | off (false, 0 or 1) | Experimental packing and parallel-search modes |
Exactly-one and proof-search options (choice_*, mixed_fix_*, mixed_root_rounds, root_refit_*, safe_node_pruning, branch_probe_*, dual_cutoff_interval, root_probe_limit, root_cut_*, proof_conflict_limit, estimated_diving, dive_node_limit) | off | Opt-in; see docs/api.md and the measured profile benchmarks/gtoc12/profiles/suggestions.json |
group_conflict_cuts, group_conflict_rounds, group_conflict_limit | off, 32, 256 | Opt-in root clique cuts from rows that link two exactly-one groups (precedence rows of time-indexed schedules); see docs/api.md |
balance_chain_cuts, balance_chain_heuristic | “off”, false | Opt-in cuts and an objective bound from chains of bounded stock balances whose flows are linked to binaries (MIPLIB vpm1); mode "bound" can close a solve without an LP. See docs/api.md |
block_symmetry_bits | 0 | Opt-in, 0–8: order the first binary columns of blocks that are exactly interchangeable (same columns, local rows and linking-row coefficients) in a cold MIP solve with presolve; a supplied start skips it. See docs/api.md and the unit-commitment profile in benchmarks/gurobi-gap |
integral_slack_reduction, weighted_stock_search | false | Opt-in exact structural paths: common-slack models with local binaries and slacks (MILPBench HEM_mik), and bounded production-stock chains with shared capacities (MIPLIB vpm2). Unrecognized models use the general search. See docs/api.md and benchmarks/milpbench |
clique_cuts, path_cuts, node_selection, plunge_limit, branching_score = "highs", rins_interval, restart_fixing_rate | false / best_bound / 0 | Opt-in methods after HiGHS 1.16: root clique and path-aggregation c-MIR cuts, hybrid node selection and plunging, the HiGHS branching score, RINS in the tree and a root restart. See docs/api.md and benchmarks/generic |
Further HiGHS-derived options: cuts and search (path_cut_strategy, gmi_affine_bounds, probing_affine_bounds, node_separation, node_cut_*, mip_implications, implied_bound_cuts, propagation_conflict_limit, adaptive_branching, root_solution_diving, heuristic_effort, root_heuristic_pivot_limit, tree_restart_*, retained_root_fixing), presolve (parallel_row_presolve, parallel_column_presolve, scaled_parallel_columns, dominated_column_presolve, doubleton_presolve, equality_aggregation, implied_integer_presolve, monotone_dual_fixing, small_binary_enumeration), one_sided_farkas_repair and the LP option seeded_ftran_limit | off | Opt-in, unreleased; see docs/api.md |
large_rational_witness | false | Opt-in: sparse exact incumbent check up to 131,072 rows plus columns and 262,144 nonzeros |
lot_sizing_cut_limit, lot_sizing_zero_dual_limit, one_sided_shrink_first | 96, None, false | Interval cuts per lot-sizing round, retained tight zero-price root cuts, and shrunken-price checks first on open domains; tuned profiles in benchmarks/gurobi-gap/test2.py |
mixed_lattice_pruning, component_progress | false, “off” | Opt-in: lattice-rounded pruning on mixed models with an integral objective; component visiting order ("small_first", "dominant") |
repair_integral_leaves | true | A node LP whose rounded integral point fails the checks is repaired or split instead of ending the solve with numerical_failure |
Change one option at a time and compare on held-out models under the same
independent check. The README’s 0.20–0.28 sections and
docs/api.md describe each mechanism and its measured gains and
regressions. The “Deliberate limits” paragraph of docs/api.md predates several
of these options (cuts, strong branching, MIP presolve, tree workers); its
remaining limits, such as no basis import or export, still hold. Since 0.30.0 the general MIP search has optional gap stops. Since 0.31.0 two opt-in root mechanisms exist: adaptive_root and integer_equality_presolve. Since 0.32.0 root inference follows chains against the row order, and the opt-in objective_cutoff_bounds admits MIPs with missing bounds under a certified incumbent. Since 0.33.0 presolve reads integer data to the feasibility tolerance, so decimal coefficients no longer remove an integer point that the result check accepts; the search still certifies incumbents against the stored rows. Since 0.34.0 opt-in exactly-one and proof-search options exist, measured on generated GTOC12 44-asteroid clusters (benchmark), and a rejected integral leaf no longer stops the solve. Since 0.35.0 the dual simplex no longer drifts on fully degenerate LPs (time-indexed schedules ended in numerical_failure), every numerical_failure names its check in diagnostics.failure_site, gap stops also work when no incumbent can be certified, stopped decompositions keep their component bounds, the opt-in group_conflict_cuts adds clique cuts from rows linking two exactly-one groups (PSPLIB benchmark), and the opt-in balance_chain_cuts="bound" proves MIPLIB vpm1 from a structural objective bound. For single-mode project scheduling (makespan with renewable capacities) use the dedicated scheduler lp_ip_craft.rcpsp.solve instead of a time-indexed MIP: with the benchmark’s two-stage prepass it proves 852 of the 960 PSPLIB J30/J60 instances within 15 s (docs/api.md, benchmark). A default presolve now closes complete binary multiple subset sum models (items assigned to at most one bin, bin rows charging the objective weight; all 10,000 MILPBench HEM_knapsack inputs) at the root, and the opt-in integral_slack_reduction and weighted_stock_search prove MILPBench HEM_mik and MIPLIB vpm2 (docs/api.md, benchmark).
In process or as a job
The lp-ip.solve/1 profile exposes a few of these controls, forces some and
leaves the rest at the native defaults:
| Control | In process (Options, NativeOptions) | lp-ip.solve/1 job |
|---|---|---|
| Tolerances (feasibility, integrality) | Options, 1e-7 each by default | Required payload fields |
threads | Options, 1–8 | resources.inner_threads, 1–8 |
node_limit, iteration_limit | 100000 and 1000000; None removes a limit | Required, positive, per task; no unlimited value |
time_limit_seconds | None | Forced: the job’s remaining wall time |
presolve | Master switch; its sub-switches stay settable | Payload field; false also clears singleton_presolve, root_propagation, mip_presolve and coefficient_tightening |
component_threads, packing_workers, tree_threads | 1–16 (defaults 16, 1, 1) | Forced to 1 |
Every other field: cuts, branching, heuristics, packing modes, decompose, dual_tolerance, factorization | Settable | Native default; unknown payload fields are rejected |
| Starts | One complete point per solve; LP starts rejected | starts, one task each; non-null only for a MIP |
| Many models | solve_batch, 1–16 workers, no starts | One model per job (recipe) |
| Cancellation | Cancellation (Python), CancellationToken (Rust) | jobs cancel sets the native token |
| LP duals and reduced costs | duals of the result | Not exported: details.lp_residuals and the kkt check only |
Only in process: every option outside the profile, unlimited budgets, LP
duals, batches, and evaluate, lp_residuals and safe_dual_bound on
points and duals from any source (lp-ip.evaluate/1 covers evaluate).
Interpret results
status is why the solve ended, independent of candidate quality. Native
reports optimal, infeasible, unbounded, time_limit, node_limit,
iteration_limit, cancelled, numerical_failure and unknown; the dummy
reports stub. The shared Status type also names
infeasible_or_unbounded, solution_limit, objective_limit and
memory_limit, which native does not currently return.
candidateandevaluationappear together.evaluationis the core’s independent check: objective with offset in the original sense, row activities, largest bound and integrality violations, andfeasible_candidate.- LP
optimalrequires independent primal feasibility, stationarity, dual signs and a relative duality gap within tolerance, all in original units. MIP incumbents pass the independent primal and integrality check. best_boundis a proven, outward-rounded bound in the original sense (lower when minimizing, upper when maximizing), never an estimate. It can be absent, and it can differ from an optimal objective by a few ulps.gapis present only with a bound and a feasible candidate; its sign is preserved.dualsexist only for LPs. In the original sense,c = Aᵀ row_duals + reduced_costs. When minimizing, positive multipliers select lower bounds and negative ones upper bounds; maximization reverses the signs.- A limit status keeps the incumbent when one exists. Report it as a feasible solution with its gap, not as optimal.
infeasibleandunboundedare numerical findings. An unbounded MIP relaxation returnsunknown, never integer unboundedness.- A model outside the native domain raises
Unsupported(NotImplementedErrorin Python): a MIP with an infinite or huge bound, a bound out of range after scaling, or a basis factorization abovemax_factor_entries. backend.effective_optionslists the configured value of every control, after native’s own overrides (for examplecomponent_threads=1at width above 1), and thediagnostics.*counters. A listed control did not necessarily run: withpresolve=false, sub-switches such asmip_presolveorroot_cutsare still shown as set.backend.start_statussays what happened to a start (rejectedfor every LP start).
Python errors: ValueError for malformed input, TypeError for wrong types or
unknown options, NotImplementedError for unsupported settings or models,
EvaluationError for floating-point overflow, BackendError for engine
failures.
Independent checks and bounds
evaluate(model, x) checks any point against the model, without rounding or
repair. lp_residuals(model, x, duals) checks an LP primal–dual pair.
safe_dual_bound(model, row_duals) turns any finite row duals into a valid
bound for every feasible LP or MIP point of the stored binary64 model, with
outward-rounded arithmetic; its status says why no finite bound exists
(unbounded_variable, for instance). Use these to validate results from
LP-IP-craft or any other solver. They do not certify a search tree. They need
IEEE binary64 arithmetic with gradual underflow; fast-math is unsupported. See
docs/safe-dual-bounds.md and
examples/safe_bound.py.
Parallelism
- One model:
threads=1is the default. For one large LP or packing root,Options(threads=8)lets the kernels use up to eight workers; small work stays scalar. - Numerical width above 1 serializes component, tree and residual workers.
With width 1,
component_threads(default 16),packing_workersandtree_threadscontrol those outer mechanisms. Count them in the CPU budget of an in-process solve. - Many independent models:
solve_batch(models, workers=8)withOptions(threads=1). Mixed layouts needworkers * threads <= 8(1×8, 2×4, 4×2, 8×1); withthreads=1, up to 16 workers remain allowed. Nested component, residual and tree workers are disabled inside a batch. Results keep input order, and a failed model returns its exception value without discarding the others. - Never multiply eight outer workers by eight numerical workers. Separate callers must manage their combined budget; no global Rayon pool is configured.
- Parallel components reserve fixed shares of the node and iteration limits
(
component_budget_mode = parallel_reserved) and do not redistribute unused shares, so they can stop earlier than a serial solve. Setcomponent_threads=1for one shared budget. - The 0.28 kernels keep scalar operation order and ordered merges; tests require identical factors and packing-root outputs at widths 1, 2, 4 and 8. Outcomes under wall-time limits or cancellation still depend on scheduling. Use node and iteration limits when results must reproduce.
- Python solves from several threads run in parallel because the interpreter is released. A width is a maximum, not a speedup promise; measure on the real models (docs/parallel-028).
Many independent models on many cores
- One process:
solve_batch(models, workers=W)(RustNativeSolver::solve_batch) takes 1–16 workers; withOptions(threads=1)that is W cores, and withthreads > 1,W * threads <= 8. The batch forces component, packing and tree workers to 1, so W is its whole budget. The cap is 16 per batch: for more cores in process, run several batches at once (from threads or processes) and keep the sum of their workers within the cores. - Jobs: a job holds one model, so many models are many jobs on one node. On a
64-slot node (
node init --capacity 64), submit 64 one-slot jobs (1 / 1 / 1) for many small or medium models, or 8 eight-slot jobs (8 / 1 / 8) for large LPs, or mix them. The runner never reserves more than the capacity; a job waits (waiting) until its slots are free. Each job reserves itscpu_slotsfor the whole attempt, so give a job more slots only when its own tasks use them. - A caller that owns the concurrency (its own threads, processes or
scheduler around plain
solvecalls) setscomponent_threads=1:component_threadsdefaults to 16 atthreads=1, so each solve of a model that splits into large independent components (average size at leastcomponent_parallel_min_entries, 2048) may start up to 16 workers. Batches and the job worker set it to 1 themselves. - Repeating identical
nullstarts is not a scaling strategy: those tasks solve the same model the same way and, under node and iteration limits, return the same result. They suit timing and resource checks only. Use distinct complete MIP starts as tasks of one job, and different models as different jobs or batch entries.
Shared agent job API
The envelope, result contract, runner and MCP server live in optimization-jobs. Start with its guide, then docs/job-api.md (this worker) and the LP/MIP tutorial. The job layer gives an agent durable, validated, CPU-admitted solves with journals, cancellation and result manifests. Its profile is deliberately smaller than the in-process API.
cargo build --release --locked -p optimization-runner -p lp-ip-job-worker
python3 tutorials/job-api/run.py --root /tmp/lp-ip-job-tutorial
./target/release/optimization-run --root /tmp/lp-ip-job-tutorial \
problems describe lp-ip
The tutorial creates an eight-slot node, registers the worker as lp-ip,
runs a binary MIP, the same model as an LP (both objective 7 at [1, 0]) and
an infeasible variant, eight tasks each, and evaluates three given points
with lp-ip.evaluate/1. --bin-dir selects the binaries (default
target/release). Commands for a single job, with
validate, run, submit, jobs get|events|wait|cancel|repair and
result, are in the guide.
Agents can drive the same jobs through optimization-mcp, the MCP server
that the runner’s build also makes. Its fifteen tools serve the guide;
describe the node and its workers; validate jobs, stage inputs, submit, wait
for, cancel, kill and repair jobs; and read results, events and artifacts. With the MCP Tasks extension, a submitted
job is a task that completes with its result. Initialize the node and
register the worker with optimization-run first: the server cannot
register workers or change the node. Then connect a client, for example
Claude Code:
claude mcp add lp-ip-jobs -- "$PWD/target/release/optimization-mcp" --root /abs/node
With the default --launch process, jobs outlive the server but not a
reboot. The tool table, launch modes and limits are in
Agents and MCP.
describe_worker also returns the payload and model schemas and runnable
examples (discovery), enough to build a
first job without a checkout.
Other solvers on the same node
One runner and one MCP server can serve the workers of all three repositories against one CPU budget. Send problems that are not LP/MIP to them:
| Problem | Repository, worker | Profile |
|---|---|---|
| Smooth constrained NLP with derivatives, at most 256 variables | SQP-craft, sqp-job-worker | sqp.solve/1 |
| Black-box, nonsmooth or multimodal scalar objective | fcmaes-rust, fcmaes-job-worker | fcmaes.retry/1 |
| Several objectives (Pareto front) | fcmaes-rust | fcmaes.mode/1 |
| Quality-diversity archive | fcmaes-rust | fcmaes.map-elites/1 |
| Expensive deterministic scalar simulation, 1–32 continuous variables, at most 256 evaluations | fcmaes-rust (experimental) | fcmaes.surrogate/1 |
Both workers also check given points (sqp.evaluate/1, fcmaes.evaluate/1).
Unlike lp-ip.solve/1, which takes a model artifact, their profiles solve
models registered in Rust inside a worker (SQP-craft’s registered models and
extension seam, fcmaes application workers); a job never carries code. Build
each worker in its own repository, register it with workers add, and read
that repository’s ai-context.md first. Never add work counters across
profiles.
Shared crates
The shared crates, the shared guide, the JSON Schemas, the integration
harness and the runner regression tests (scripts/job-api/test_review.py
with fake_worker.py) live in
optimization-jobs. This
repository depends on them at the git revision its root Cargo.toml pins;
cargo build -p optimization-runner still builds optimization-run and
optimization-mcp here,
and scripts/job-api/shared_root.py prints the path of Cargo’s checkout, from
which CI runs the harness. Until October 2026 the three repositories carried
byte-identical copies. Version 0.1.1 synchronized them, after they had
drifted following the 0.1.0 delivery, and carries the review fixes of all
three:
jobs repairseals a job whose launcher died while it was queued asinterrupted, with zero work and complete accounting; detached attempts that their unit may still start stay unknown.- Validation stages the worker in a
.staging-*directory under the node root, so anoexecTMPDIRworks; the node root itself must allow execution. - A worker that writes an invalid journal record ends its job
failedwithrunner.journal_errorinstead of leaving itrunning;jobs listreports the error for that job only. - Appends end a torn journal tail first, a signal during validation stops the
validator, finished jobs are not flagged after a reboot,
./model.jsonis a valid input path, and detached jobs run inoptimization-job-ID.service. - The result contract also knows the fcmaes
non_dominated_setandelite_archiveclaims; LP results never use them.
Version 0.2.0 adds the result contract optimization.result/0.2 and worker
protocol optimization.worker/0.2: the claims infeasible, unbounded,
infeasible_or_unbounded, locally_infeasible and certified_optimum;
evidence with checks, refutations and a certificate slot;
objective_bounds; coded runner errors; and JSON Schemas
(docs/job-api/schemas/ in optimization-jobs). The job envelope stays optimization.job/0.1. A 0.2
runner still accepts 0.1 workers, and a 0.1 runner rejects 0.2 workers at
registration. describe reports the shared version as
build.job_api_version. Run a node root through one runner build.
Job specification
schema_version is optimization.job/0.1, worker the registered ID,
payload_schema lp-ip.solve/1. Exactly one entry in inputs holds the
model; its name must equal payload.model_input, its file is relative to
the job file, and its sha256 must match the content. All payload fields are
required, and unknown fields are rejected:
| Payload field | Meaning |
|---|---|
model_input | Name of the model input |
starts | One entry per task, 1 to 1,000,000: null, or for a MIP a complete finite primal vector |
node_limit, iteration_limit | Positive per-task budgets |
feasibility_tolerance, integrality_tolerance | Original-unit tolerances, as in Options |
presolve | Native’s master switch; false skips the whole root stage, including bound inference, so a MIP then needs finite bounds as given. The worker clears the sub-switches, so the job’s effective_options say what ran |
The model artifact is JSON with schema_version: "lp-ip.model/1", sense
(minimize or maximize), objective, objective_offset,
variable_lower, variable_upper, kinds, matrix (indptr, indices,
values) and row_lower, row_upper. In bounds, null means infinite on
that side; JSON has no NaN or Infinity. Its JSON Schema is
input_schemas["lp-ip.model/1"] of describe, whose $comment lists the
rules across fields (lengths, the CSR layout by rows, bounds, the MIP
domain). Convert an MPS file (Import an MPS model),
or copy tutorials/job-api/assignment-mip-model.json, then recompute its
hash:
python3 -c 'import hashlib,pathlib; print(hashlib.sha256(pathlib.Path("my-model.json").read_bytes()).hexdigest())'
An LP with a non-null start, a start of the wrong length, or a non-finite
value is rejected at validation. Starts are inline and validation output is
capped at 4 MiB, so keep all starts together well below that size. Other
native options are not part of the profile. The worker uses the native
defaults, the payload’s limits and tolerances, the remaining wall time as the
time limit, and forces component_threads, packing_workers and
tree_threads to 1, so inner_threads (1–8) maps only to Options::threads
(In process or as a job).
Each job holds one model; its tasks differ only by start. Null starts repeat
the same solve, which is useful for timing or the resource checks of the
tutorial but not as independent evidence. For many different
models, submit one job per model, each with its own slots, or use
solve_batch in process (recipe).
Use 8 / 1 / 8 (cpu_slots / outer_workers / inner_threads) for one large
model and 8 / 8 / 1 for eight MIP starts. The
runner requires outer_workers * inner_threads <= cpu_slots <= 1024 and
reserves cpu_slots for the whole attempt.
Import an MPS model
python3 scripts/mps_to_model.py model.mps -o model.json --names names.json
The script (Python standard library only; .mps.gz works too) reads fixed
and free MPS (--format auto, the default, tries free, then fixed) and
writes lp-ip.model/1 with rows and columns in MPS order. It prints the
file’s sha256 for the job’s inputs. --names writes the row and column
names in model order, to map x and the rows back. Its docstring documents
the conventions:
- The first
Nrow is the objective; furtherNrows are dropped. An RHSbon the objective row is the constant:objective_offset = -b.OBJSENSEwithMAXorMAXIMIZE, on the next line or the header line, setssense; coefficients keep their signs. - RANGES follow the MPS standard (on an
Erow, the sign ofRpicks the side). Default bounds are[0, +inf), for integer marker columns too.BVmakes abinarycolumn,MIkeeps the upper bound, andUPorUIwith a negative value on a column without a given lower bound also sets the lower bound to -infinity, with a warning (the convention documented for CPLEX). - Values of magnitude 1e30 or more (
--infinity) in bounds, RHS and RANGES are infinite. - Errors name the line:
SCbounds, quadratic and other unsupported sections, an infinity on the wrong side, duplicates, unknown names, a second RHS, RANGES or BOUNDS set, a missingENDATA.
The column-wise COLUMNS entries are transposed into the CSR by rows of
lp-ip.model/1. A converted MIP still needs finite bounds after root
inference: an integer marker column without bounds stays [0, +inf) and is
unsupported unless presolve derives a bound from the rows. For an
in-process solve, map null to an infinity:
import json
from lp_ip_craft import Model
d, inf = json.load(open("model.json")), float("inf")
side = lambda v, s: [s if b is None else b for b in v]
m = Model(objective=d["objective"], objective_offset=d["objective_offset"], sense=d["sense"],
lower=side(d["variable_lower"], -inf), upper=side(d["variable_upper"], inf),
kinds=d["kinds"], row_lower=side(d["row_lower"], -inf),
row_upper=side(d["row_upper"], inf), **d["matrix"])
Discovery: schemas and examples
The worker’s describe (problems describe lp-ip, MCP describe_worker)
lists JSON Schemas (draft 2020-12) of each payload (payload_schemas) and of
the model artifact (input_schemas, key lp-ip.model/1), and runnable
examples (examples): a continuous LP, a MIP with a complete start and an
lp-ip.evaluate/1 job, each on 1 / 1 / 1 resources with its model inline.
Rules a schema cannot express (vector lengths, the CSR layout, MIP-only
starts, the inner_threads limits) are in $comment. The same files are in
crates/lp-ip-job-worker/discovery/; tests check that every example and
tutorial payload and model validates against them and that every example
passes the worker’s validation.
To turn an example into a job, add schema_version: "optimization.job/0.1",
a new request_key, worker (the registered ID) and payload_schema (the
example’s profile). Write each input’s content to its file with any JSON
serializer, put the SHA-256 of the written bytes in sha256, and keep only
name, file and sha256 in the inputs entry: the envelope rejects other
fields. An MCP-only client that cannot write files next to the job uses the MCP
tool put_input: it uploads the model JSON and returns its file, sha256
and an input_dir, with which the job is then validated and submitted.
Job results
Inspect the job state first: completed only means every task returned. Then
read each task’s outcome with optimization-run result JOB_DIRECTORY
(schema optimization.result/0.2, ordered by task):
| Outcome field | LP/MIP meaning |
|---|---|
termination | The native status, or unsupported when native refuses the model; details.message says why |
claim | numerical_optimum (native optimal that passed the independent checks), feasible (checked candidate, no optimality), infeasible, unbounded, infeasible_or_unbounded (the native claims), or none |
evidence | rechecked with checks objective, bounds, constraints, plus integrality (MIP) or kkt (LP with duals); claimed for the infeasibility and unboundedness claims, which the native solver does not certify for export, and for none (its checks list what was still recomputed); refuted when a check rejected the native status |
objective_bounds | primal (objective of the checked feasible point the outcome shows) and dual (the proven best bound), in the model’s sense; a bound beyond primal contradicts the point and is left out |
feasible, objective, x | From the independent evaluation of the candidate |
details | sense, is_mip, best_bound (the published dual), gap (of the shown point against it), primal_violation, integrality_violation, lp_residuals (LP), raw_status, warm_start, engine_version, effective_options, message, exact_certificate: false; reported_best_bound and bound_note for a contradictory bound, reported_objective when native’s objective of its candidate differs from the recomputed one |
Non-finite numbers in details are the strings "+infinity" and "-infinity".
An infeasible model is a completed job with termination: "infeasible" and
claim: "infeasible". A native status that fails its independent check is not
reported as such: evidence.refuted names it, with verdict
infeasible_point (optimal, but the candidate violates the model; claim
none), false_optimality (an LP optimum whose duals fail the KKT
acceptance or overflow; claim feasible), objective_mismatch (an optimum
without KKT confirmation, such as a MIP’s, whose candidate does not evaluate to
native’s own objective; claim feasible) or false_infeasibility
(infeasible, but the returned point or the task’s start is feasible; claim
feasible, and x and the details then describe that point). An optimal
status without a candidate has nothing to check: claim none, claimed, and
details.note says so. Bounds and gaps always describe the point the
outcome shows: the gap is recomputed from its objective, and a native bound
that contradicts it (beyond it by more than the shared BOUND_TOLERANCE,
relative 1e-6) is not published. A
refutation indicates a solver defect or a tolerance mismatch; report it. The
KKT acceptance is native’s: primal residual within the feasibility tolerance,
stationarity and dual signs within dual_tolerance * (1 + max|c|), duality gap
within dual_tolerance. Work counters are nodes,
simplex_iterations and validation_evaluations; never add them to another
profile’s counters. If a worker is killed, work is null,
runner.accounting_complete is false and only committed tasks count.
Graceful cancellation sets the native token; jobs cancel --now terminates
the process group after at most one more second. Repair never resumes a
branch-and-bound tree; use a new request key for a fresh solve.
Evaluate given points
lp-ip.evaluate/1 checks points against the model without solving, for
example candidates an agent built or a solution from another solver. Payload:
model_input, points (finite vectors of the model’s dimension, one task
each; they may violate bounds) and the two tolerances; inner_threads must be 1.
Points are inline: the resolved job must stay below the runner’s 4 MiB
validation output. Each outcome has termination: "evaluated", claim
feasible within the tolerances or none, the objective, primal_violation
and integrality_violation in details, objective_bounds.primal for a
feasible point, and rechecked evidence. A point whose objective or row
activity overflows gets claim none, no objective, unknown feasibility,
claimed evidence and the reason in details.message. The work counter is evaluations.
See tutorials/job-api/assignment-evaluate.json.
Extend the job profile
The adapter is crates/lp-ip-job-worker/src/main.rs. Expose another native
option only with a new, strictly typed payload field, validate it in
prepare, record it in effective_options, add it to the payload schema in
crates/lp-ip-job-worker/discovery/, add tests, and bump the profile
version if the mathematical meaning of inputs or results changes. Keep
solver-specific logic out of the shared runner.
Validation and reporting checklist
- Recompute the objective and every violation with
evaluateon the original model, or with the user’s own evaluator, never from the solver’s internal values. - Compare with a reference: a known optimum, SciPy (
examples/validate_native.pyandexamples/validate_random.pyshow the oracle protocol), or the user’s reference solver under the same check. - Report the termination status,
claimorfeasible_candidate, the best bound and gap, nodes and iterations, wall time, thread layout and all non-default options. - Say “numerically optimal under tolerance 1e-7”, not “proven optimal”. Infeasibility is a numerical finding too.
- For tuning, freeze tolerances and held-out models first, change one option at a time, and keep regressions in the report.
- For a MIP stopped by a limit, report the incumbent and the gap; do not round or repair the candidate.
Failure diagnosis
| Symptom | Likely cause and action |
|---|---|
NotImplementedError / Unsupported for a MIP | An infinite or huge variable bound that root inference could not tighten (or presolve is off); add justified finite bounds |
Job task termination: "unsupported" | The same refusal inside a job; the message is in details.message |
| LP start rejected | Basis import is not implemented; pass no start (null in a job) |
time_limit or node_limit with a candidate | Report it as feasible with its gap; raise the budget or try opt-in search options |
numerical_failure or unknown | Rescale the model, check for near-parallel rows or huge coefficients, compare with a reference solver |
Unsupported naming max_factor_entries | The guard (4,000,000 entries) on one factorization; heavy LU fill is a known limit. It is not a whole-process memory cap |
| A parallel component solve stops earlier than serial | Reserved component budgets; set component_threads=1 |
TypeError naming an option | An unknown or removed NativeOptions field |
| A queued job never finishes after its launcher died | jobs repair JOB_ID seals it interrupted with zero work; see Shared crates |
Test commands
The main CI commands, from the repository root:
cargo fmt --all --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked
cargo run -p lp-ip-craft-native --release --example benchmark --locked -- 1
cargo test --release --locked -p lp-ip-job-worker
cargo build --release --locked -p optimization-runner -p lp-ip-job-worker
SHARED=$(python3 scripts/job-api/shared_root.py)
export JOB_API_TARGET="$PWD/target/release" JOB_API_TUTORIALS="$PWD/tutorials/job-api"
python3 "$SHARED/scripts/job-api/test_integration.py"
python3 "$SHARED/scripts/job-api/test_review.py"
python3 "$SHARED/scripts/job-api/test_mcp.py"
LP_IP_JOB_WORKER="$PWD/target/release/lp-ip-job-worker" python3 -m pytest -q tests/test_job_discovery.py
python3 tutorials/job-api/run.py --root /tmp/job-api-tutorial
python -m pip install ".[test]" && python -m pytest -q
python examples/solve_native.py
python examples/safe_bound.py
The test extra includes jsonschema, so pytest also checks the discovery
schemas and examples (against the binary only when LP_IP_JOB_WORKER is set)
and the MPS converter. CI also checks the numerical crates with Rust 1.85
(excluding the job worker) and the job worker with Rust 1.88, and runs family
benchmark smoke runs, the dependency audit and the SciPy oracle validations
(examples/validate_*.py, with scipy installed), the HiGHS oracle for
one_sided_mip (benchmarks/gurobi-gap/validate_one_sided.py, with
highspy), for block_symmetry_bits (validate_block_symmetry.py) and
for the multiple subset sum presolve and integral_slack_reduction
(benchmarks/milpbench/validate_structural.py), for the HiGHS-derived
search options (benchmarks/generic/validate_search.py and
validate_path_cmir.py), a
proof of the Test 4 eight-hour unit commitment
(benchmarks/gurobi-gap/test4.py --require-proof), and rechecks the
committed exact SCIP verdicts on single search decisions
(benchmarks/exact-decisions/verify.py report --check; capturing new
decisions needs the decision-capture feature). Pass --fcmaes, --sqp
(and --lp-ip) executables to test_integration.py to test a mixed node;
optimization-jobs’ CI does that with all three workers.
Repository references
- README.md: release notes, build commands, guarantees and limits
- docs/api.md: native API, options, kernel, search, results
- docs/safe-dual-bounds.md: conservative bounds
- docs/simplex/README.md: kernel and search design and validation
- docs/parallel-028: execution contract for 1–8 workers
- docs/job-api.md (this worker, with links into the shared guide), tutorials/job-api, docs/job-api/VALIDATION.md, docs/job-api/REVIEW.md: shared job API and this worker
- optimization-jobs and its guide: envelope, result contract, schemas, runner and MCP server
- docs/target-card.md: the open application contract
crates/core/src/check.rs,crates/core/src/bound.rs: independent checkscrates/lp-ip-job-worker/src/main.rs: thelp-ip.solve/1andlp-ip.evaluate/1adaptercrates/lp-ip-job-worker/discovery/: the payload and model JSON Schemas and the examples thatdescribeembedsscripts/mps_to_model.py: MPS tolp-ip.model/1, with its conventions in the docstring- AGENTS.md: short orientation and contributor commands
python/lp_ip_craft/__init__.py: Python API and defaults
Structured application tutorials
tutorials/README.md lists nine application chapters (LP1–LP9). Each builds its model with tutorials/_support/linear_model.py, solves it with solve(..., backend="native") and checks every candidate independently of the solver. LP4, LP5 and LP7 also check the solver’s own LP duals: rationalized prices are verified exactly, and safe_dual_bound gives a binary64-safe bound. Run a chapter with python tutorials/<chapter>/run.py --output DIR. The cross-repository driver in optimization-jobs (tutorials/structured/) runs all twenty chapters of the series directly or as trusted command jobs; the chapters add no job profile or worker.
Objective-implied MIP bounds (since 0.32.0)
NativeOptions and lp-ip.solve/1 accept objective_cutoff_bounds, off by default and under the master presolve switch. A MIP whose variables lack finite bounds after root inference is normally Unsupported. With the option, a start that passes the exact feasibility check caps every costly column from the objective value it certifies; the capped model keeps that point and every point at least as good, so optimum and bound are those of the original model. Without such a start, small models with nonnegative oriented costs, nonnegative lower bounds and binary or fixed integer columns get the point from one LP with every binary at its upper bound (at most 512 pivots, counted against the limits). A start that fails the exact check does not block that LP; if it lies outside the capped model it is replaced and start_status is rejected. Read diagnostics.objective_cutoff_sides and diagnostics.objective_cutoff_start_pivots. A model with a zero-cost column that stays unbounded remains Unsupported. Default behavior also changed in 0.32.0: root inference uses a queue, so chains against the row order resolve; on models with missing bounds, reported values can differ from 0.31.0 in the last digits. Details: docs/api.md, the review.
Optional root cuts and integer equalities (since 0.31.0)
NativeOptions and lp-ip.solve/1 accept adaptive_root and integer_equality_presolve, both off by default and both under the master presolve switch. adaptive_root picks bounded GMI or GMI/MIR root separation from the row structure; it helped on lot sizing (binary capacity rows with short continuous balances) and generalized assignment and was neutral or slightly slower elsewhere. integer_equality_presolve propagates residues on short equalities over bounded integers; chains of such equalities that defaults cannot finish in ten seconds solve in well under a second. Try them when the model has that structure; do not expect a general speed-up. Defaults do the same work as 0.30.0. Presolve rounds integer bounds with the feasibility tolerance, so decimal data such as 15x + 0.1y = 29.8 keeps its intended integer point (up to 0.32.0 the default presolve read the stored doubles exactly and reported such a model infeasible). A MIP whose continuous columns all have zero cost now gets the integral-objective bound; a run that stops at a limit can then report a bound equal to its incumbent. See the API and the measurements.
Optional MIP gap stops (since 0.30.0)
NativeOptions and lp-ip.solve/1 accept mip_relative_gap and mip_absolute_gap, both off by default. The general MIP search stops when either positive limit is met against a known global bound. gap_limit retains a checked feasible point and a gap, with no optimality claim. Zero requests complete search; LPs ignore these controls. Relative gaps include the objective offset and use the incumbent’s magnitude; at zero objective use an absolute limit. Gap-limited separable MIPs run whole. Positive limits with specialized packing or split-tree controls are rejected, never ignored. See API and evidence.