Enabling SCIP as an available solver for testing
Closed this issue · 1 comments
- This would be needed to fully test some functionality, e.g. #1256
- SCIP can be installed using Conda (requires an activated Conda environment):
conda install -c conda-forge scip
- However, this also causes a different (in the sense of non-
idaes-ext
) version of IPOPT to be installed in the Conda environment:$ python -c "from pyomo.environ import SolverFactory as F; s = F('ipopt'); print(s.executable())" /opt/conda/envs/test-idaes-scip/bin/ipopt $ python -c "import idaes; from pyomo.environ import SolverFactory as F; s = F('ipopt'); print(s.executable())" /home/ludo/.idaes/bin/ipopt
My vague concern is that having two versions of IPOPT might lead to hard(er)-to-debug environment issues. However, I don't know enough about the Pyomo solver interface and/or the internals of idaes-ext
to understand whether this can be problematic, so I've opened this issue as a spin-off of an ongoing conversation with @andrewlee94 to discuss it with a wider group.
An alternative is to install it with pip install -i https://pypi.ampl.com ampl_module_scip
. It looks like this is a static build of scip, and therefore won't interfere with the IDAES ipopt build.
To get Pyomo to see the executable, you either need to add a directory to the PATH before importing Pyomo:
import ampl_module_scip
import os
os.environ['PATH'] = os.pathsep.join([ampl_module_scip.bin_dir, os.environ['PATH']])
or else, you can tell Pyomo to re-check the PATH for executables, e.g.:
>>> from pyomo.environ import *
>>> s = SolverFactory('scip')
>>> s.available()
False
>>> import ampl_module_scip
>>> import os
>>> os.environ['PATH'] = os.pathsep.join([ampl_module_scip.bin_dir, os.environ['PATH']])
>>> from pyomo.common import Executable
>>> Executable.rehash()
>>> s.available()
True