Closed hakank closed 3 years ago
Oh good catch. I'll check whether this is a problem in other constraints as well. Should be fairly easy to fix.
I appreciate your test cases 😊
Btw this should work as well:
@constraint(model, x[1] .<= x)
When this is fixed of course 😂 just wanted to show you the broadcasting way in Julia.
Thanks.
I've not used broadcasting especially much in my models but I'll try to use them more. scalar_product
is nice in Julia:
function scalar_product(model,s,x,v)
@constraint(model, s == sum(x.*v))
end
Thanks! This works.
It's used - for example - as a symmetry breaking constraint in my de Bruijn sequence model (http://hakank.org/julia/constraints/debruijn.jl ). The definition of my_min
is in http://hakank.org/julia/constraints/constraints_utils.jl .
The following code yields an BoundsError:
LoadError: BoundsError: attempt to access 0-element Array{ConstraintSolver.Variable,1} at index [1]
Starting
i
from2
instead works without any problems, so it seems that it's not allowed to compare a variable with itself.Here's a simple model showing this:
[I discovered this when I tried a decomposition of
min(model,x,min_val)
for symmetry breaking.]