-
Notifications
You must be signed in to change notification settings - Fork 123
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
Element wise addition after multiplication #355
Comments
Thanks for raising the issue; you're right that I'm not quite sure what we should do here. Maybe the first step is to just update the docs to not say that broadcasting is supported; we could also try to give better errors in this situation. The problem is that elementwise manipulations on Convex.jl One can also do something like Do you have a particular use case for broadcasted operations? Or does just switching to eg |
I came across this when trying to minimise multiple competing cost terms. Here is an example: # setup
using Convex
var = Variable(10)
response_mat = rand(100, 10)
competing_target_responses = rand(100, 3)
weights = rand(100, 3)
constraint = var <=10.
constraint += var >= -10.
# cost function to be minimised
response_var = response_mat * var # matrix multiplication
# deviation from several targets (bug here!)
deviation = response_var .- competing_target_responses
cost = sum(deviation .* deviation .* weights)
problem = minimize(cost, constraint) I was able to work around the broadcasting with a for loop. |
I'm also coming across the error:
Here is the full problem:
It doesn't appreciate my attempt to do |
Closing in favor of #479 |
Attempting element wise addition to a variable after multiplication raises an error. If I understand the supported operations page correctly this should be possible?
Examples
does not compile (
ERROR: MethodError: no method matching iterate(::Convex.MultiplyAtom)
)does not compile (
ERROR: MethodError: no method matching iterate(::Convex.DotMultiplyAtom)
)works fine.
The text was updated successfully, but these errors were encountered: