Skip to content

Commit

Permalink
Trac #21499: GenericBackend: Add _test_sense method
Browse files Browse the repository at this point in the history
This adds another test method, which all MIP backends pass.

URL: https://trac.sagemath.org/21499
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager authored and vbraun committed Nov 20, 2016
2 parents 8b401c7 + a3a9a0f commit 1469a37
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/sage/numerical/backends/generic_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,28 @@ cdef class GenericBackend:
"""
raise NotImplementedError()

@classmethod
def _test_sense(cls, tester=None, **options):
"""
Run tests on `set_sense` and `is_maximization`.
TEST::
sage: from sage.numerical.backends.generic_backend import GenericBackend
sage: p = GenericBackend()
sage: p._test_sense() # optional - Nonexistent_LP_solver
Exception NotImplementedError ...
"""
p = cls() # fresh instance of the backend
if tester is None:
tester = p._tester(**options)
tester.assertEqual(p.is_maximization(), True)
tester.assertIsNone(p.set_sense(-1))
tester.assertEqual(p.is_maximization(), False)
tester.assertIsNone(p.set_sense(1))
tester.assertEqual(p.is_maximization(), True)

cpdef objective_coefficient(self, int variable, coeff=None):
"""
Set or get the coefficient of a variable in the objective
Expand Down

0 comments on commit 1469a37

Please sign in to comment.