Opened 3 years ago

Closed 3 years ago

#20337 closed enhancement (fixed)

MIP: Several fixes regarding constant terms in the objective function

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-7.2
Component: numerical Keywords: lp
Cc: dimpase, vdelecroix, jdemeyer Merged in:
Authors: Matthias Koeppe Reviewers: Dima Pasechnik
Report Upstream: N/A Work issues:
Branch: ad40508 (Commits) Commit: ad40508934049090580c678ec4249588273b43cf
Dependencies: Stopgaps:

Description (last modified by mkoeppe)

Contrary to documentation, one cannot set a constantly zero objective function by passing 0 to set_objective.

    sage: p = MixedIntegerLinearProgram(maximization=True)
    sage: x = p.new_variable(nonnegative=True)
    sage: p.set_objective(0)
    AttributeError: 'sage.rings.integer.Integer' object has no attribute 'dict'

This ticket fixes that and actually allows any field number (which ends up in the obj_constant_term).

Moreover, the backend slot obj_constant_term is accessed directly by MixedIntegerLinearProgram.show; it should instead be exposed by a backend method, which this ticket adds as well.

Finally, the show method added an extraneous blank line when a nonzero obj_constant_term was present. Fixed and doctest added.

Change History (8)

comment:1 Changed 3 years ago by mkoeppe

  • Branch set to u/mkoeppe/mip_backends__obj_constant_term_should_be_exposed_by_a_backend_method

comment:2 Changed 3 years ago by mkoeppe

  • Commit set to ad40508934049090580c678ec4249588273b43cf
  • Description modified (diff)
  • Status changed from new to needs_review
  • Summary changed from MIP backends: obj_constant_term should be exposed by a backend method to MIP: Several fixes regarding constant terms in the objective function

New commits:

62a4da0objective_constant_term: New MIP backend method
edb9d7fMixedIntegerLinearProgram.show: Remove extraneous blank line when objective constant term is nonzero; add doctest
ad40508MixedIntegerLinearProgram.set_objective: Accept constants as objective

comment:3 Changed 3 years ago by dimpase

do all backends support this? how do we know?

comment:4 Changed 3 years ago by mkoeppe

Objective constant terms are already part of the backend interface.

#20323 addresses the issue of making the testing of backends more rigorous.

comment:5 Changed 3 years ago by dimpase

  • Reviewers set to Dima Pasechnik
  • Status changed from needs_review to positive_review

ok.

comment:6 Changed 3 years ago by vbraun

  • Status changed from positive_review to needs_work

Author name

comment:7 Changed 3 years ago by dimpase

  • Authors set to Matthias Koeppe
  • Status changed from needs_work to positive_review

comment:8 Changed 3 years ago by vbraun

  • Branch changed from u/mkoeppe/mip_backends__obj_constant_term_should_be_exposed_by_a_backend_method to ad40508934049090580c678ec4249588273b43cf
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.