Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulp.lpDot update #572

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

pulp.lpDot update #572

wants to merge 6 commits into from

Conversation

nariaki3551
Copy link

@nariaki3551 nariaki3551 commented Aug 22, 2022

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

@CLAassistant
Copy link

CLAassistant commented Aug 22, 2022

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
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.

@pchtsp
Copy link
Collaborator

pchtsp commented Aug 24, 2022

could you add a unit test to show what did not work and how it works now? thanks.

@nariaki3551
Copy link
Author

nariaki3551 commented Aug 25, 2022

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}

@pchtsp
Copy link
Collaborator

pchtsp commented Oct 2, 2023

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.

This reverts commit 63cb5ec.
@nariaki3551
Copy link
Author

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.

@frrad frrad mentioned this pull request Aug 22, 2024
@frrad
Copy link
Contributor

frrad commented Aug 31, 2024

Can probably be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants