-
Notifications
You must be signed in to change notification settings - Fork 8
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
Negative signs in expressions #323
Labels
Comments
Second case is fixable: julia> @macroexpand @expression(model, sum(-x[i] for i in 1:3))
quote
#= REPL[284]:1 =#
JuMP._valid_model(model, :model)
begin
#= /Users/oscar/.julia/packages/JuMP/CU7H5/src/macros.jl:399 =#
let model = model
#= /Users/oscar/.julia/packages/JuMP/CU7H5/src/macros.jl:400 =#
begin
#= /Users/oscar/.julia/packages/JuMP/CU7H5/src/macros/@expression.jl:86 =#
begin
#= /Users/oscar/.julia/packages/JuMP/CU7H5/src/macros.jl:264 =#
var"#511###405" = begin
#= /Users/oscar/.julia/packages/MutableArithmetics/bmgkg/src/rewrite.jl:374 =#
let
#= /Users/oscar/.julia/packages/MutableArithmetics/bmgkg/src/rewrite.jl:375 =#
begin
#= /Users/oscar/.julia/packages/MutableArithmetics/bmgkg/src/rewrite.jl:371 =#
var"#513###406" = MutableArithmetics.Zero()
for i = 1:3
#= /Users/oscar/.julia/packages/MutableArithmetics/bmgkg/src/rewrite_generic.jl:307 =#
var"#512###407" = (MutableArithmetics.operate!!)(*, -1, x[i])
var"#513###406" = (MutableArithmetics.operate!!)(MutableArithmetics.add_mul, var"#513###406", var"#512###407")
end
end
#= /Users/oscar/.julia/packages/MutableArithmetics/bmgkg/src/rewrite.jl:376 =#
var"#513###406"
end
end
#= /Users/oscar/.julia/packages/JuMP/CU7H5/src/macros.jl:265 =#
var"#514###408" = (JuMP.flatten!)(var"#511###405")
end
#= /Users/oscar/.julia/packages/JuMP/CU7H5/src/macros/@expression.jl:89 =#
JuMP._replace_zero(model, var"#514###408")
end
end
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a test:
Here are results:
I am actually very surprised that the second options is the slowest.
I first write it thinking it was the right way to do the third.
I think the action here is:
Have option 2 as fast as option 1.
Option 3 is seems a bit harder to detect and work with in a first glance.
The text was updated successfully, but these errors were encountered: