2

When I want to perform an optimisation with pyomo, using one of the solvers I installed via the AMPL license tool, I get an error when just checking the availability of the solver.

This happens for the 'couenne' and 'bonmin' solver. Other solvers seem to work okay.

If anybody knows a solution to the problem, or a suggestion for a different way to use the couenne solver, I would appreciate it

So for example when running the following command,

from pyomo.environ import SolverFactory
SolverFactory('couenne').available()

I get the following error:

Exception in thread Thread-12:
Traceback (most recent call last):
  File "C:\Users\VictorVerbist\anaconda3\envs\energylib\lib\threading.py", line 980, in _bootstrap_inner
    self.run()
  File "C:\Users\VictorVerbist\anaconda3\envs\energylib\lib\threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\VictorVerbist\anaconda3\envs\energylib\lib\subprocess.py", line 1495, in _readerthread
    buffer.append(fh.read())
  File "C:\Users\VictorVerbist\anaconda3\envs\energylib\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 38: character maps to <undefined>

Traceback (most recent call last):

  Cell In[6], line 1
    SolverFactory('Couenne').available()

  File ~\anaconda3\envs\energylib\lib\site-packages\pyomo\solvers\plugins\solvers\ASL.py:123 in available
    return self.version() is not None

  File ~\anaconda3\envs\energylib\lib\site-packages\pyomo\opt\base\solvers.py:443 in version
    self._version = self._get_version()

  File ~\anaconda3\envs\energylib\lib\site-packages\pyomo\solvers\plugins\solvers\ASL.py:109 in _get_version
    ver = _extract_version(results.stdout)

  File ~\anaconda3\envs\energylib\lib\site-packages\pyomo\opt\base\solvers.py:47 in _extract_version
    m = re.search('[t,T]runk', x)

  File ~\anaconda3\envs\energylib\lib\re.py:201 in search
    return _compile(pattern, flags).search(string)

TypeError: expected string or bytes-like object

1 Answer 1

3

You can use AMPL solver modules with Pyomo as follows:

from amplpy import modules
import pyomo.environ as pyo
solver = pyo.SolverFactory(modules.find("couenne"), solve_io="nl") 

For more information, see the documentation at: https://dev.ampl.com/ampl/python/modules.html#using-from-pyomo

In order to use couenne or other COIN-OR solvers you need to install the coin module as follows:

$ python -m amplpy.modules install coin
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.