Faster extend method for LpProblem

50 views
Skip to first unread message

Nicholas Gorman

unread,
Jun 7, 2018, 1:21:05 AM6/7/18
to pulp-or-discuss

Hi Folks,

I'm working on a project I want to distribute open source at some point and pulp is doing a lot of the heavy lifting for me! In my particular problem I need to add many elastic sub problems. I am using the extend method to do this:

constraint = constraint.makeElasticSubProblem(penalty=penalty, proportionFreeBound=0)
prob.extend(constraint)

However I found the line to find the variables to rename was taking up a lot of time:

for v in set(other.variables()).difference(self.variables()):
v.name = other.name + v.name

I changed this to:

for v in other.variables()[-3:]:
v.name = other.name + v.name

Because the new variables were always the last three. This took my problem setup time from 32 s to 7 s.

I'd like to include the faster option in the standard version of pulp so users of my project can also the faster speeds.
However I understand this change might cause problems in other circumstance. After any thoughts on how a change like this might be included,
or maybe its not needed because I am using adding the subproblems in a inefficient way?

Anyway, love to hear some thoughts,

Cheers,
Nick
Reply all
Reply to author
Forward
0 new messages