#12091: bug in add_constraint to MixedIntegerLinearProgram
----------------------------------+-----------------------------------------
   Reporter:  dimpase             |          Owner:  ncohen  
       Type:  defect              |         Status:  new     
   Priority:  critical            |      Milestone:  sage-5.0
  Component:  linear programming  |       Keywords:          
Work_issues:                      |       Upstream:  N/A     
   Reviewer:                      |         Author:          
     Merged:                      |   Dependencies:          
----------------------------------+-----------------------------------------

Comment(by ncohen):

 I spent days already on this problem, so I should at least update the
 ticket. This does not work because of.... that :
 {{{
 sage: p = MixedIntegerLinearProgram()
 sage: b = p.new_variable()
 sage: b[2] + b[4] >= 5
 5 <= x_0 +x_1
 sage: 5 <= b[2] + b[4]
 True
 }}}

 It is as easy as that. And of course, calling ``p.add_constraint(True)``
 can not do anything useful. That comes from the fact that the way it is
 implemented the comparison methods I wrote for the LP variables are
 totally ignored when there is an integer on the left of the equation.

 I went through hell (aka the coercion system) to make it work, and after
 getting back from hell (writing new classes, using categories, parents
 objets, elements objects, ...) Sage finally understood that it has to
 coerce integers to "LinearFunction" objects before applying the ``<=``
 operation.

 I was happy at this point. And then I noticed that when I typed ``3*b[i]``
 in Sage, it first converted the "3" to a ``LinearFunction`` object and
 then tried to multiply linear functions between themselves. And multiply
 linear functions is *never* a good idea.

 So unless there is a magical way to make it work (without destroying all
 the code... I mean, even reaching that former point amounted to something
 like 100 additional lines of code totally exclusively dealing with
 categories and coercion), I'd stand for big "DO NOT PUT AN INTEGER BY
 ITSELF ON THE LEFT SIDE OF A LP INEQUALITY" in the doc.

 But I'd prefer to find a magical way, of course..

 Nathann

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12091#comment:2>
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.

Reply via email to