LpSum vs LpAffineExpression

710 views
Skip to first unread message

Tom van der Hoeven

unread,
Mar 14, 2015, 9:30:14 AM3/14/15
to pulp-or...@googlegroups.com
Hi,

in the following example:
---------------
from pulp import *
AA = LpVariable('aa')
BB = LpVariable('bb')
equationlist = [ (AA,1),(BB,2),(AA,5)]
print 'aff ', LpAffineExpression(equationlist)
print 'Lpsum', lpSum(coef*var for var,coef in equationlist)
---------------------------

the output is

__________________
aff 5*aa + 2*bb
Lpsum 6*aa + 2*bb
-------------------------

what happens is that AA is referenced twice.
This happened to me in a larger application.

Is a multiple reference to one variable forbidden for LpAffineExpression
or is it an error.

Tom

Stuart Mitchell

unread,
Mar 15, 2015, 3:05:22 AM3/15/15
to pulp-or...@googlegroups.com
yeah that is a downfall of LpAffineExpression it assumes that you have already collected all the terms together

Stu



Tom

--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.



--
Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru
Reply all
Reply to author
Forward
0 new messages