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

multiplication of CyLPExpr by constant not commutative #146

Open
sdementen opened this issue Jan 28, 2022 · 1 comment
Open

multiplication of CyLPExpr by constant not commutative #146

sdementen opened this issue Jan 28, 2022 · 1 comment

Comments

@sdementen
Copy link
Contributor

When multiplying by a constant before or after a variable.sum() I get a wrong / good answer

from cylp.cy.CyClpSimplex import CyClpSimplex

s = CyClpSimplex()
x = s.addVariable("x", 2)
y = s.addVariable("y", 2)
s += y >= 0
s += y.sum() - x.sum() * 3 <= -1  # ==> gives wrong solution x=[0,1]
# s += y.sum() - 3 * x.sum() <= -1  # ==> gives correct solution x=[0,0.3333]
s.objective = x.sum()
s.primal()

The two expressions y.sum() - x.sum() * 3 <= -1 and y.sum() - 3 * x.sum() <= -1 should represent the same constraint and give the same results but only the second gives the correct model.

@rsemenoff
Copy link

rsemenoff commented Jan 29, 2022 via email

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

No branches or pull requests

2 participants