pulp
pulp copied to clipboard
pulp.lpDot update
to address issue #483
With this change, the following lpDot operation behaves as expected.
import pandas as pd
import numpy as np
import pulp as pl
x = pd.Series(pl.LpVariable.dicts("x", range(3)), index=range(3)) # Series of LpVariable
y = 2 * x # Series of LpAffineExpression [2*x_0, 2*x_1, 2*x_2]
a = np.arange(3) + 1 # [1, 2, 3]
print(pl.lpDot(y, a))
>>> 2*x_0 + 4*x_1 + 6*x_2 # but, current version is x_0 + 2*x_1 + 3*x_2
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
could you add a unit test to show what did not work and how it works now? thanks.
Thanks for your comment! I added a test for this change. With this change, lpDot outputs the correct LpAffineExpression even when an LpAffineExpression is given to lpDot.
current version
x = LpVariable("x")
y = LpVariable("y")
z = LpVariable("z")
a = [1, 2, 3]
dict(lpDot([2*x, 2*y, 2*z], a))
>>> {x: 1, y: 2, z: 3}
with this change
x = LpVariable("x")
y = LpVariable("y")
z = LpVariable("z")
a = [1, 2, 3]
dict(lpDot([2*x, 2*y, 2*z], a))
>>> {x: 2, y: 4, z: 6}
thanks and sorry for the late reply. Could you take out PSCIP_CMD from this PR? so I can add only the lpDot use? thanks. You can add a new PR with the new solver.
I have completed the requested changes. The PSCIP_CMD addition has been removed from this pull request, focusing solely on the lpDot updating as you suggested.
I apologize for my delayed response. Thanks.