Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit b3e7322

Browse files
committed
Use "constant objective" for non-zero constant objectives
1 parent aa5fa1d commit b3e7322

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sage/numerical/mip.pyx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ cdef class MixedIntegerLinearProgram(SageObject):
538538
sage: p.add_constraint(v[1] + v[2], max=1)
539539
sage: p
540540
Boolean Program (no objective, 2 variables, 1 constraint)
541+
sage: p.set_objective(1); p
542+
Boolean Program (constant objective, 2 variables, 1 constraint)
543+
sage: p.set_objective(v[1]); p
544+
Boolean Program (maximization, 2 variables, 1 constraint)
541545
"""
542546
cdef GenericBackend b = self._backend
543547

@@ -566,9 +570,11 @@ cdef class MixedIntegerLinearProgram(SageObject):
566570
# We have no variables...
567571
kind = "Mixed Integer Program"
568572

569-
if (all(b.objective_coefficient(i) == 0 for i in range(nvars))
570-
and b.objective_constant_term() == 0):
571-
minmax = "no objective"
573+
if all(b.objective_coefficient(i) == 0 for i in range(nvars)):
574+
if b.objective_constant_term():
575+
minmax = "constant objective"
576+
else:
577+
minmax = "no objective"
572578
elif b.is_maximization():
573579
minmax = "maximization"
574580
else:

0 commit comments

Comments
 (0)