Skip to content

Commit

Permalink
Merge pull request #3470 from jsiirola/gurobi-12-nl
Browse files Browse the repository at this point in the history
Update Gurobi NL interface for Gurobi 12.x
  • Loading branch information
jsiirola authored Feb 12, 2025
2 parents e5d2c78 + 8ba0dfb commit 04bd416
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pyomo/solvers/plugins/solvers/GUROBI.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,28 @@ def __new__(cls, *args, **kwds):
else:
logger.error('Unknown IO type: %s' % mode)
return
opt.set_options('solver=gurobi_ampl')
# The Gurobi ASL solver was 'gurobi_ampl' through Gurobi 11,
# then was renamed to 'gurobi'. Check 'gurobi' first, then
# 'gurobi_ampl'.
for exe_name in ('gurobi', 'gurobi_ampl'):
exe = Executable(exe_name)
if (
exe.available()
and b'[-AMPL]'
in subprocess.run(
exe.executable,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=1,
).stdout
):
opt.set_options(f'solver={exe_name}')
break
else:
# Fall back on 'gurobi' (matching the current Gurobi
# release) if neither appears to be available.
opt.set_options('solver=gurobi')
return opt


Expand Down

0 comments on commit 04bd416

Please sign in to comment.