Skip to content

'StatusNotOk' object has no attribute 'canonical_code' #4606

Closed
@mvds314

Description

@mvds314

What version of OR-Tools and what language are you using?
Version: 9.12.4544
Language: Python

Which solver are you using
GLOP

What operating system and version?
Windows 11

What did you do?
Set up a problem with mathopt, selected a solver that, apparently, was not suitable for the problem.

What did you expect to see
Proper handling of the exception

What did you see instead?
An additional error raised on on handling of the exception:

'StatusNotOk' object has no attribute 'canonical_code'

model = mathopt.Model(name="getting_started_lp")
x = model.add_variable(lb=-1.0, ub=1.5, name="x")
y = model.add_variable(lb=0.0, ub=1.0, name="y")
z = model.add_binary_variable(name="z")
model.add_linear_constraint(x + y + z <= 1.5)
model.maximize(x + 2 * y + z)
params = mathopt.SolveParameters(enable_output=True)

result = mathopt.solve(model, mathopt.SolverType.GLOP, params=params)
if result.termination.reason != mathopt.TerminationReason.OPTIMAL:
    raise RuntimeError(f"model failed to solve: {result.termination}")

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions