-
Notifications
You must be signed in to change notification settings - Fork 120
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
Various operations don't support broadcast #218
Comments
With the current release of Convex, I get ERROR: LoadError: MethodError: no method matching iterate(::Convex.MultiplyAtom)
Closest candidates are:
iterate(::Core.SimpleVector) at essentials.jl:568
iterate(::Core.SimpleVector, ::Any) at essentials.jl:568
iterate(::ExponentialBackOff) at error.jl:199 when running your code, which seems much better than silently giving the wrong answer. Removing the broadcast on the constraints (which then matches the examples in https://convexjl.readthedocs.io/en/stable/types.html#constraints, for example) gives julia> p.optval
160.0
julia> x.value
3×1 Array{Float64,2}:
60.0
90.0
10.0 Is this right? |
Yeah that solution is valid. I was a user of Convex.jl but since migrated to JuMP. That day I was quickly solving an LP checking for some exam solutions and found it didn't work right and reported. |
Ok, great! On the one hand, I think using broadcasted notation could make sense for Convex, but on the other, I don’t think there’s really another way to interpret the non-broadcasted constraints besides elementwise. I think it isn’t good if broadcasted notation doesn’t error and gives a different result though. So I’ll submit a pull request to add some tests to make sure that the broadcasted notation errors, and update the docs to explicitly point out that one should not use broadcasted constraints. Then if that goes through maybe we can close this issue. |
Hmm, well I realized x = Variable(5)
y = rand(5)
C = x .== y yields that [ x[i] == y[i] for i = 1:5 ] It could be someone is using this for some purpose, although I'm not sure. So I'm not sure we want to disallow broadcasting entirely. Maybe the simplest fix is to add a test to check the formulation from your first post yields an error (with a reference to this issue), and if the broadcasting in |
Closing in favor of #479 |
I'm using Julia v0.6.1 with Mosek.jl v0.8.2 and the latest Convex.jl master installed via Pkg.checkout.
I'm trying to solve a simple resource allocation problem, which is an LP of the form:
And I obtain as output:
Which is clearly non-optimal (x=[60;0;100] works better).
Using SCS the problem is the same:
I suspected an issue with broadcasting in
p.constraints+=R*x.<=C
. In fact inserting the constraints separately yields the correct answer.The text was updated successfully, but these errors were encountered: