Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
1.99k stars 512 forks source link

No executable found for solver 'ipopt' when using Mindtpy on Linux #3081

Closed SalehCheikh closed 9 months ago

SalehCheikh commented 9 months ago

Summary

I am using pyomo to optimize a MINLP using Mindtpy solver

Steps to reproduce the issue

from pyomo.opt import SolverFactory
import sys

instance = model.create_instance() 
## here are problem formulation (declare variables, constraints and objective function)

opt = SolverFactory('mindtpy')
results = opt.solve(instance, mip_solver='glpk', nlp_solver= 'ipopt', tee=False) 

Error Message

$Traceback (most recent call last):
  File "/home/gitlab-runner/esesoft/ESEmanage/Tests/Test_GE.py", line 699, in test_GE_MUT_MDT
    instance, results = Solv.LaunchSolver(instance, SolverType, ParamIn)
  File "/home/gitlab-runner/esesoft/ESEmanage/src/Run_OptimToolbox/LaunchSolver.py", line 48, in LaunchSolver
    results = opt.solve(instance, mip_solver='glpk', nlp_solver= 'ipopt', tee=False)
  File "/home/gitlab-runner/.local/lib/python3.10/site-packages/pyomo/contrib/mindtpy/MindtPy.py", line 227, in solve
    MindtPy_initialize_main(solve_data, config)
  File "/home/gitlab-runner/.local/lib/python3.10/site-packages/pyomo/contrib/mindtpy/initialization.py", line 91, in MindtPy_initialize_main
    init_rNLP(solve_data, config)
  File "/home/gitlab-runner/.local/lib/python3.10/site-packages/pyomo/contrib/mindtpy/initialization.py", line 132, in init_rNLP
    results = nlpopt.solve(m, tee=config.nlp_solver_tee, **nlp_args)
  File "/home/gitlab-runner/.local/lib/python3.10/site-packages/pyomo/opt/base/solvers.py", line 512, in solve
    self.available(exception_flag=True)
  File "/home/gitlab-runner/.local/lib/python3.10/site-packages/pyomo/opt/solver/shellcmd.py", line 128, in available
    raise ApplicationError(msg % self.name)
pyomo.common.errors.ApplicationError: No executable found for solver 'ipopt'

Information on your system

Pyomo version: 6.4.0 Python version: 3.9.18 Operating system: Linux How Pyomo was installed (PyPI, conda, source): pip Solver (if applicable): Mindtpy

Additional information

I am using pyomo to optimize a MINLP model using Mindtpy. Using Mindtpy solver on Windows 64 is executed with no problem. The problem happens on Linux operation system with error message (No executable found for solver 'ipopt'). Even tried to change the path of ipopt in 'nlp_solver' to the corresponding directory, the problem still happens :

results = opt.solve(instance, mip_solver='glpk', nlp_solver= '../esesoft/ipopt_latest/ipopt-linux64/ipopt', tee=False)

jsiirola commented 9 months ago

It sounds like ipopt is not on your PATH. Can you try setting the path to ipopt manually with

from pyomo.common.fileutils import Executable
Executable('ipopt').set_path('../esesoft/ipopt_latest/ipopt-linux64/ipopt')

(before creating / invoking MindtPy)?

SalehCheikh commented 9 months ago

It sounds like ipopt is not on your PATH. Can you try setting the path to ipopt manually with

from pyomo.common.fileutils import Executable
Executable('ipopt').set_path('../esesoft/ipopt_latest/ipopt-linux64/ipopt')

(before creating / invoking MindtPy)?

Thank you, it actually solved my issue