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

testing whether a JuMP expression == 0 #789

Closed
chriscoey opened this issue Jun 16, 2016 · 7 comments
Closed

testing whether a JuMP expression == 0 #789

chriscoey opened this issue Jun 16, 2016 · 7 comments
Assignees
Milestone

Comments

@chriscoey
Copy link
Contributor

I am iterating over JuMP AffExprs and do not wish to add empty (0 == 0) constraints to a MIP model.

Can we have simple way to test whether an expression is just 0? i.e. for affine, the constant and all coefficients on variables are 0. It would be nice to be able to write if AffExpr == 0 blah blah.

@mlubin
Copy link
Member

mlubin commented Jan 4, 2017

Whoever needs it is welcome to contribute a smarter definition of equality of AffExpr objects to handle duplicates and promotion.

@chriscoey
Copy link
Contributor Author

@chriscoey chriscoey added this to the 1.0 milestone Jun 9, 2017
@blegat
Copy link
Member

blegat commented Jun 10, 2017

Yes, this what is done in the PolyJuMP tests. Since JuMP is dropping v0.5, we can define this as Base.iszero in JuMP.

@chriscoey
Copy link
Contributor Author

chriscoey commented Jun 10, 2017

Great. Now that 0.5 support is dropped could you move this code to JuMP?

@mlubin
Copy link
Member

mlubin commented Jun 10, 2017

Wrong package, still need a PR to drop 0.5 from JuMP.

@chriscoey
Copy link
Contributor Author

Woops. Karma for using github mobile during a lunch date.

@mlubin can you drop 0.5 for jump too?

@blegat blegat self-assigned this Jun 10, 2017
@mlubin
Copy link
Member

mlubin commented Jun 3, 2018

iszero is implemented and tested: https://github.com/JuliaOpt/JuMP.jl/blob/e392cc873fecea188d6d8d52c891924900eabd13/test/operator.jl#L68
There's could be some debate about the definition and whether it should check for zero coefficients, but that could be a new issue.

@mlubin mlubin closed this as completed Jun 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants