Closed hakank closed 3 years ago
A magic bug for magic squares :smile:
Agree that this shouldn't happen. Will have a look tmr. Done for today. Thanks again for spotting this weirdness
The bugfix will be part of v0.6 which will be registered in the next hour.
I can confirm that both versions of sum
works now. Thanks!
This is a magic square model where the position of
s
in thesum
constraints give anINFEASIBLE solution
if the first constraint (the rows constraint) in thefor
loop is stated as@constraint(model, sum(x[i,:]) == s) # INFEASIBLE
but it works if it stated as@constraint(model, s == sum(x[i,:])) # This works
What I have understood there shouldn't be any restriction on the position of the
sum
in a constraints (i.e. LHS or RHS).For the second (column) constraint both ways work. It's the same problem with the first diagonal constraint where position of
s
matters, while the second diagonal constraint works either way.Note that
s
is a constant (Int64). Ifs
has been defined as a variable then there is no problem.Also, I tested with a simple model with a single
sum
constraint, but then there's no problem where thesum
is placed (LHS or RHS).