Trying to run the couenne solver executable through Pyomo throws an error. Pyomo tries to check the version of the executable specified to verify that the solver can be run. In couenne's case, running couenne -v returns couenne (Microsoft cl 15.00.21022.08 für 80x86), ASL(20100130), except the ü runs into a problem with default encoding / utf-8 and cannot be decoded. This throws an error in the subprocess call which is not caught and so the solver cannot be run. Note that this problem is not necessarily couenne specific, but rather due to subprocess expecting the data in a text format where special characters like ü could not be recognised.
To reproduce, for example:
from pyomo.environ import *
model = ConcreteModel()
model.x = Var(initialize=0, bounds=(0, 10))
model.obj = Objective(expr=model.x, sense=maximize) # maximize x -> x=10
# solve the model
solver = SolverFactory("couenne")
solver.solve(model) # throws an error: 'utf-8' codec can't decode byte 0x81 in position 38: invalid start byte
Changes proposed in this PR:
Add errors='ignore' to the ASL solver version check subprocess call. This will ignore any errors while trying to decode the data received from the -v command (ie. errors arising from special characters, unexpected bytes, etc). After all, Pyomo does not care about the value of the solver version; the version check appears to only verify the solver exists before attempting to solve - See opt/base/solvers.py and solvers/plugins/solvers/ASL.py for more details. You can also read about the errors argument to subprocess here: https://docs.python.org/3.10/library/io.html#io.TextIOWrapper
Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:
I agree my contributions are submitted under the BSD license.
I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.
Fixes # .
Summary/Motivation:
Trying to run the
couenne
solver executable through Pyomo throws an error. Pyomo tries to check the version of the executable specified to verify that the solver can be run. In couenne's case, runningcouenne -v
returnscouenne (Microsoft cl 15.00.21022.08 für 80x86), ASL(20100130)
, except theü
runs into a problem with default encoding / utf-8 and cannot be decoded. This throws an error in the subprocess call which is not caught and so the solver cannot be run. Note that this problem is not necessarily couenne specific, but rather due tosubprocess
expecting the data in a text format where special characters likeü
could not be recognised.To reproduce, for example:
Changes proposed in this PR:
errors='ignore'
to the ASL solver version check subprocess call. This will ignore any errors while trying to decode the data received from the-v
command (ie. errors arising from special characters, unexpected bytes, etc). After all, Pyomo does not care about the value of the solver version; the version check appears to only verify the solver exists before attempting to solve - Seeopt/base/solvers.py
andsolvers/plugins/solvers/ASL.py
for more details. You can also read about theerrors
argument tosubprocess
here: https://docs.python.org/3.10/library/io.html#io.TextIOWrapperLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: