#12823: Allow constants for objective function & deletion of rows in
MixedIntegerLinearProgram
--------------------------------------+-------------------------------------
Reporter: john_perry | Owner: ncohen
Type: defect | Status: needs_info
Priority: major | Milestone: sage-5.0
Component: linear programming | Resolution:
Keywords: solver objective | Work issues: failing doctests
Report Upstream: N/A | Reviewers:
Authors: john_perry, ncohen | Merged in:
Dependencies: 12833 | Stopgaps:
--------------------------------------+-------------------------------------
Changes (by john_perry):
* status: needs_review => needs_info
Old description:
> Currently, MixedIntegerLinearProgram does not allow deleting rows. We
> would like to enable this for all backends that allow it.
>
> Also, this is a bug.
> {{{
> sage: lp = MixedIntegerLinearProgram()
> sage: x, y = lp[0], lp[1]
> sage: lp.add_constraint(2*x + 3*y <= 6)
> sage: lp.add_constraint(3*x + 2*y <= 6)
> sage: lp.set_objective(x + y + 7)
> sage: lp.set_integer(x); lp.set_integer(y)
> sage: lp.solve()
> 2.0
> }}}
> The correct value ought to be '''9''', not '''2'''. The problem is this
> line in the `set_objective()` method of `mip.pyx`:
> {{{
> f.pop(-1,0)
> }}}
>
> John Perry will create a patch for GLPK and CBC; Nathann Cohen will
> create a patch for Gurobi and CPLEX.
>
> '''Apply''':
> * [attachment:trac_12823_const_for_obj_funs.patch]
> * [attachment:trac_12823-cplex_gurobi.patch]
New description:
Currently, MixedIntegerLinearProgram does not allow deleting rows. We
would like to enable this for all backends that allow it.
Also, this is a bug.
{{{
sage: lp = MixedIntegerLinearProgram()
sage: x, y = lp[0], lp[1]
sage: lp.add_constraint(2*x + 3*y <= 6)
sage: lp.add_constraint(3*x + 2*y <= 6)
sage: lp.set_objective(x + y + 7)
sage: lp.set_integer(x); lp.set_integer(y)
sage: lp.solve()
2.0
}}}
The correct value ought to be '''9''', not '''2'''. The problem is this
line in the `set_objective()` method of `mip.pyx`:
{{{
f.pop(-1,0)
}}}
John Perry will create a patch for GLPK and CBC; Nathann Cohen will create
a patch for Gurobi and CPLEX.
'''Apply''':
* [attachment:trac_12823_const_for_obj_funs.patch]
* [attachment:trac_12823-cplex_gurobi.patch]
'''or'''
* [attachment:trac_12823_alternate_removal.patch]
--
Comment:
I've attached another patch that
* removes `remove_constraints()` from `mip.pyx`,
* incorporates a generic `remove_constraints()` into
`generic_backend.pyx`, more or less along the lines of what you were doing
with CPLEX and gurobi, but
* retains the definitions of `remove_constraints()` used previously in
`coin_backend.pyx` and `glpk_backend.pyx`, taking advantage of their
respective optimizations.
The CPLEX & Gurobi patch can be changed so that '''only'''
`remove_constraint()` need be defined. If you prefer, we could rename that
to `remove_single_constraint()`. This eliminates some code duplication,
though not much. I think the tradeoff is worth the trouble, myself.
Oh -- notice that I still have the old WARN:: and so on in there. I'll
change it to the way you had it, if you're okay with this approach. I have
a meeting now, but I wanted to get this out so you could look at it &
consider it.
Or, we can stick with the older patches.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12823#comment:29>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.