Skip to content

MIP: Several fixes regarding constant terms in the objective function #20337

@mkoeppe

Description

@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.

CC: @dimpase @videlec @jdemeyer

Component: numerical

Author: Matthias Koeppe

Branch/Commit: ad40508

Reviewer: Dima Pasechnik

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions