Skip to content

Raise an error when constraints are added to the wrong MILP #19523

@jdemeyer

Description

@jdemeyer
sage: p = MixedIntegerLinearProgram(solver="glpk")
sage: q = MixedIntegerLinearProgram(solver="glpk")
sage: q.add_constraint(p[0] <= 1)
---------------------------------------------------------------------------
GLPKError                                 Traceback (most recent call last)
...
GLPKError: glp_set_mat_row: i = 1; len = 1; invalid row length 
Error detected in file glpapi01.c at line 760

Before #19525, this would instead crash Sage. A crash still happens with COIN (#20360).

This ticket is to actually fix the error completely or give a better error message.

And low-level error message with the PPL and InteractiveLP (#20296 ) backends.

The CVX backend silently adds a new variable that is accessible only to the backend:.

sage: sage: default_mip_solver("cvxopt")
sage: sage: p = MixedIntegerLinearProgram()
sage: sage: q = MixedIntegerLinearProgram()
sage: sage: q.add_constraint(p[0] <= 1)
sage: q.number_of_variables()
1

CC: @yuan-zhou

Component: linear programming

Issue created by migration from https://trac.sagemath.org/ticket/19523

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions