#9061: Create an efficient SUM command
-------------------------+--------------------------------------------------
   Reporter:  ncohen     |       Owner:  jason, jkantor
       Type:  defect     |      Status:  new           
   Priority:  major      |   Milestone:  sage-4.4.3    
  Component:  numerical  |    Keywords:                
     Author:             |    Upstream:  N/A           
   Reviewer:             |      Merged:                
Work_issues:             |  
-------------------------+--------------------------------------------------
Changes (by ncohen):

 * cc: mvngu (added)


Old description:

> Inequalities using <= and >= still do not work properly... :-/
>
> Nathann

New description:

 This *HAS* to be changed :

 {{{
 p = MixedIntegerLinearProgram()
 v = p.new_variable()
 sage: %timeit sum([v[i] for i in xrange(900)])
 5 loops, best of 3: 1.14 s per loop
 }}}

 With this new function :

 {{{
 def mipvariables_sum(L):
     d = {}
     for v in L:
         for (id,coeff) in v._f.iteritems():
             d[id] = coeff + d.get(id,0)
     return LinearFunction(d)
 }}}

 It gives :

 {{{
 sage: from sage.numerical.mip import mipvariables_sum
 sage: %timeit mipvariables_sum([v[i] for i in xrange(900)])
 625 loops, best of 3: 1.5 ms per loop
 }}}

 Even though it requires a new function to add MIPVariables, it is still
 better than nothing for the moment.

 This patch will define the function given, and replace all the occurences
 of "sum" in the graph files to have them use this optimization.

 Nathann

--

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