Skip to content

MPS export silently drops all indicator constraints #1186

Open

Description

@FabianHofmann

Note

The following content was generated by AI.

io_api="mps" (and Model.to_file("*.mps")) writes no indicator constraints. linopy writes MPS through HiGHS, which has no indicator constraints, so they vanish without a warning and the solver returns a wrong "optimal" result.

import linopy

m = linopy.Model()
b = m.add_variables(binary=True, name="b")
x = m.add_variables(lower=0, upper=10, name="x")
m.add_constraints(b >= 1)
m.add_indicator_constraints(b, 1, x, "<=", 5)
m.add_objective(x, sense="max")
m.solve(solver_name="gurobi", io_api="mps")  # or "cplex"
print(x.solution.item())  # 10.0, expected 5.0
solver lp mps direct
gurobi 5 10 5
cplex 5 10 n/a

Proposed fix: raise when indicator constraints would be written to MPS, pointing to io_api="lp" or "direct". Writing an MPS INDICATORS section is a possible follow-up.

Found while checking the empty-body indicator case from #1170 (fixed for lp/direct in #1183); the MPS path ignores all indicators, empty or not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions