Skip to content

Commit 0ceb103

Browse files
author
Release Manager
committed
Trac #34878: MixedIntegerLinearProgram.add_constraint: Option to return row indices, fix handling of empty constraints
(from https://trac.sagemath.org/ticket/21003#comment:136) ... for use with methods that take row indices as input, such as `row`, `row_bounds`, `remove_constraint`. If a backend does not map a constraint to a unique new row (or `check_redundant=True` and the constraint is discarded by the frontend), the method may return `None`. We also fix a longstanding bug in how empty constraints are handled in `add_constraint`. The changed interface (an optional return value) is backward-compatible with user code. We also add a Feature CVXOPT so that the backend gets tested again. URL: https://trac.sagemath.org/34878 Reported by: mkoeppe Ticket author(s): Matthias Koeppe, Martin Rubey Reviewer(s): Martin Rubey, Matthias Koeppe
2 parents df74efb + 3b929f8 commit 0ceb103

File tree

2 files changed

+208
-93
lines changed

2 files changed

+208
-93
lines changed

src/sage/features/mip_backends.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Features for testing the presence of :class:`MixedIntegerLinearProgram` backends
33
"""
44

5-
from . import Feature, FeatureTestResult
5+
from . import Feature, PythonModule, FeatureTestResult
66
from .join_feature import JoinFeature
77

88

@@ -77,7 +77,26 @@ def __init__(self):
7777
spkg='sage_numerical_backends_coin')
7878

7979

80+
class CVXOPT(JoinFeature):
81+
r"""
82+
A :class:`~sage.features.Feature` describing whether the :class:`MixedIntegerLinearProgram` backend ``CVXOPT`` is available.
83+
"""
84+
def __init__(self):
85+
r"""
86+
TESTS::
87+
88+
sage: from sage.features.mip_backends import CVXOPT
89+
sage: CVXOPT()._is_present() # optional - cvxopt
90+
FeatureTestResult('cvxopt', True)
91+
"""
92+
JoinFeature.__init__(self, 'cvxopt',
93+
[MIPBackend('CVXOPT'),
94+
PythonModule('cvxopt')],
95+
spkg='cvxopt')
96+
97+
8098
def all_features():
8199
return [CPLEX(),
82100
Gurobi(),
83-
COIN()]
101+
COIN(),
102+
CVXOPT()]

0 commit comments

Comments
 (0)