Pyomo / pyomo

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

Ignore errors on ASL solver version check #3298

Open alma-walmsley opened 1 week ago

alma-walmsley commented 1 week ago

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, 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:

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:

  1. I agree my contributions are submitted under the BSD license.
  2. 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.