Skip to content

Windows fatal exception: access violation message while using HIGHS via math_opt #4226

@vaidzelevich

Description

@vaidzelevich

What version of OR-Tools and what language are you using?
Version: v9.10
Language: Python 3.11.1

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
HIGHS via math_opt

What operating system (Linux, Windows, ...) and version?
Windows

What did you do?
Run the following script

from typing import Sequence
from absl import app
from ortools.math_opt.python import mathopt


def main(argv: Sequence[str]) -> None:
    del argv  # Unused.

    model = mathopt.Model(name="my_model")
    x = model.add_binary_variable(name="x")
    y = model.add_variable(lb=0.0, ub=2.5, name="y")
    model.add_linear_constraint(x + y <= 1.5, name="c")
    objective_expression = 0
    objective_expression += 2 * x
    objective_expression += y
    model.maximize(objective_expression)
    
    result = mathopt.solve(model, mathopt.SolverType.HIGHS)

    if result.termination.reason not in (
        mathopt.TerminationReason.OPTIMAL,
        mathopt.TerminationReason.FEASIBLE,
    ):
        raise RuntimeError(f"model failed to solve: {result.termination}")

    print(f"Objective value: {result.objective_value()}")
    print(f"Value for variable x: {result.variable_values()[x]}")


if __name__ == "__main__":
    app.run(main)

What did you expect to see

Objective value: 2.5
Value for variable x: 1.0

What did you see instead?

The previous message and the following addition

Windows fatal exception: access violation

Thread 0x00001994 (most recent call first):
  <no Python frame>
Windows fatal exception: access violation

Anything else we should know about your project / environment
There is no the error message if I replace app.run(main) with main('').

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions