id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,work_issues,upstream,reviewer,author,merged,dependencies,stopgaps
9061,Create an efficient SUM command,ncohen,"jason, jkantor","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",defect,closed,major,sage-4.5,numerical,fixed,,mvngu abmasse,,N/A,Robert Miller,Nathann Cohen,sage-4.5.alpha4,,
