Skip to content

Add shell-based HiGHS solver interface#3922

Open
KasimVali2207 wants to merge 1 commit intoPyomo:mainfrom
KasimVali2207:highs-shell-interface
Open

Add shell-based HiGHS solver interface#3922
KasimVali2207 wants to merge 1 commit intoPyomo:mainfrom
KasimVali2207:highs-shell-interface

Conversation

@KasimVali2207
Copy link
Copy Markdown

Fixes #3894

Summary

The existing highspy-based HiGHS interface builds the problem in memory by iterating over variables and constraints in Python, which becomes a bottleneck for large models. This PR adds a file-based shell interface that avoids this overhead entirely.

Changes

New: pyomo/solvers/plugins/solvers/HIGHS.py

  • HIGHS: factory entry point registered as SolverFactory('highs'). Dispatches to the shell interface by default, or to the persistent highspy backend when solver_io='direct'.
  • HIGHSSHELL: a SystemCallSolver that writes an LP or MPS file, invokes the highs executable, and parses the solution and log files. Supports LP, MPS, duals, reduced costs, and all standard termination statuses (optimal, infeasible, unbounded, time limit, iteration limit).

Modified: pyomo/contrib/solver/plugins.py

  • The persistent highspy interface is now registered as highs_persistent (legacy name highs_persistent_v2), consistent with how Pyomo handles cplex/cplex_persistent and gurobi/gurobi_persistent.

New: pyomo/solvers/plugins/solvers/tests/test_highs_shell.py

  • 23 tests covering factory dispatch, command-line construction, log-file parsing for all statuses, solution-file parsing, and integration round-trips.

Usage

# Default — shell interface (LP file, highs executable)
opt = SolverFactory('highs')
opt.solve(model)

# MPS format
opt = SolverFactory('highs', solver_io='mps')

# Original persistent highspy interface
opt = SolverFactory('highs', solver_io='direct')
# or
opt = SolverFactory('highs_persistent')

Testing

python -m pytest pyomo/solvers/plugins/solvers/tests/test_highs_shell.py -v
# 23 passed, 5 skipped (skipped tests require highs binary on PATH)

Adds HIGHSSHELL, a SystemCallSolver that writes LP/MPS files and invokes
the HiGHS command-line executable, bypassing the per-variable Python loop
overhead that makes the highspy-based persistent interface slow on large
models (issue Pyomo#3894).

SolverFactory('highs') now defaults to the shell interface.
solver_io='mps' selects MPS file format.
solver_io='direct' routes to the highspy persistent backend.

The persistent highspy interface is re-registered as 'highs_persistent'
to free the 'highs' name for the shell interface, consistent with how
Pyomo names cplex/cplex_persistent and gurobi/gurobi_persistent.

Also adds tests covering factory dispatch, command-line construction,
log-file and solution-file parsing, and full round-trip integration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interface to the Uno solver

1 participant