#12823: Allow constants for objective function & deletion of rows in
MixedIntegerLinearProgram
--------------------------------------+-------------------------------------
Reporter: john_perry | Owner: ncohen
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.0
Component: linear programming | Resolution:
Keywords: solver objective | Work issues:
Report Upstream: N/A | Reviewers:
Authors: john_perry, ncohen | Merged in:
Dependencies: 12833 | Stopgaps:
--------------------------------------+-------------------------------------
Changes (by ncohen):
* status: needs_info => needs_review
* dependencies: => 12833
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]
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]
--
Comment:
Hellooooooooo !!!
Simple. Your meant Simple. Not Simplex `:-D`
I'm making the same kind of mistake something with crazy words from graph
theory or Sage... Crazy `:-D`
Well... This patch took me... quite some time ! It all began with #12833,
which this patch depends upon. Some problems with Gurobi's interface.
Which I noticed because my gurobi license was not valid anymore. Once I
got this license again (and reinstalled Gurobi), I had a problem when
installing cbc with ``sage -i cbc``, for the first package Sage installed
was the old one. Harald Schilly fixed that.
And... Ok, now this patch !
It does not do much actually, just adds the required methods in cplex and
Gurobi.
Some important things I should mention. Please tell me what you think of
them :
* I renamed self.obj_value to self.obj_constant_term, as I would have
expected self.obj_value to store the optimal value reached by the
objective function.
* Sage should *never* crash, whatever happens in the code. So as usual
((&*@#)*&@%&* indexes in GLPK) I added a +1 to the indices in GLPK, so
that the constraints are numbered from 0 regardless of the solver. I also
added tests in GLPK and Coin to ensure no crash happens. CPLEX and Gurobi
never crash because of that, as they have a smarter management of
exceptions (error codes).
* I also changed some doctests for which solutions were not unique.
Actually I just removed the lines printing the value of variables, which
were not fundamental, and let the others stay as they really tested the
new methods.
* I believe I also added some #optional flags in Coin's file, though
everything is mixed up in my head after editing 4 files in a row `:-D`
Anyway, everything is tested, and....
{{{
~/sage/numerical/backends$ sage -t -optional coin_backend.pyx
glpk_backend.pyx gurobi_backend.pyx cplex_backend.pyx
sage -t -optional "devel/sage-2/sage/numerical/backends/coin_backend.pyx"
[1.3 s]
sage -t -optional "devel/sage-2/sage/numerical/backends/cplex_backend.pyx"
[1.3 s]
sage -t -optional "devel/sage-2/sage/numerical/backends/glpk_backend.pyx"
[1.3 s]
sage -t -optional
"devel/sage-2/sage/numerical/backends/gurobi_backend.pyx"
[1.4 s]
----------------------------------------------------------------------
All tests passed!
Total time for all tests: 5.3 seconds
~/sage/numerical/backends$
}}}
(And I rarely have all solvers installed at the same time)
Soo... Well, if you agree with my patch (I can send you my cplex/gurobi
license if necessary), .... `:-)`
Thank you very much for your work on that one ! It's good to see this
class move a bit `:-)`
Nathann
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12823#comment:8>
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.