-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Question/request about indicator and reification #202
Comments
Thanks for the issue. I'm not aware that things like For the
line 66 should work but the error is in line 64 where Have you tried something like the following?
And yes |
Thanks for your comments, Ole. Regarding your comment about
I tried this instead:
But got the error:
So it seems that one cannot use these kind of conditions in the RHS. Well, I'll tested further with your suggestion
However, I changed the line to This is implemented as following. I had to move the all different except 0 constraint in the main function to be able to print the
It don't yield any error (which is nice!), but for n=2 the model show 27 solutions which is not correct (it should be these 7 solutions: [0,0],[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]). Especially, the model yield incorrectly x = [1,1] and [2,2] multiple times. Can you spot some error in the model?
|
Thanks yeah it should be Here:
one bs should be |
Yes, |
Should be solved in #204 If interested you should be able to test this by using: |
Wow, that was quick! I tested the fix and it work as expected. Thanks! (And I'm impressed by the packages feature of Julia. It's really grown on me. :-)) Should we keep this issue still open so you remember the other comments/wishes? An aside: Since I now understand indicators/reification better, I could implemented the Who killed Agatha problem without much problem: http://hakank.org/julia/constraints/who_killed_agatha.jl (It shows 8 occurrences of agatha since the problem is underconstrained). I've started to publish my ConstraintSolver.jl models at http://hakank.org/julia/constraints/ |
Great I'll create a new version soon then. Currently checking out #200 .
and maybe some other parts to tackle them individually. |
BTW just a small comment on: http://hakank.org/julia/constraints/to_num.jl
You try to convert a vector of variables |
Thanks for this. Yes, it works if I rename the variable (as done in the loop some lines below):
|
I'm trying to implement the
all_different_except_0
constraint using indicators, but am a little confused how indicators (and reifications) work. (See last for the main test function I used.)The general idea of the (decomoposition of the) constraint is:
x[i]
andx[j
(where i > j):if both
x[i]
!= 0 andx[j] != 0
thenx[i] != x[j]
The ideal way (for me) is the following, and it would be really great if that worked:
However, it seems that the LHS of the indicator/reification must be a binary variable (defined with
@variable
).Here's a second attempt where two binary variables are defined for the two parts of the
@constraint
:But this don't work either inequality (
!=
) is not supported:Is it correct that '!=
is not supported for indicator/reification constraints? The documentation https://wikunia.github.io/ConstraintSolver.jl/stable/supported/#Supported-constraints-1 seems to indicate that
!=` is supported...I then tried the following - using Boolean algebra - which seems to be somewhat better but - still - get some error.
But this throws the following error in the
optimize!
function (so the parsing seems to be correct):I then tested the following just to try the general idea of using binary variables in a loop:
Which throws:
So it seems that one have to prepare an array of binary variables before the loop and then use it in the loop. Here's a version that does that but it also throws an error.
This throws this rather uninformative error:
I'm not sure if anyone of these versions should work, but - as mentioned earlier - I wonder how one work with indicator/reification in a function such as
all_different_except_0
.Here's the test function I use, where the different
all_different_except_0
functions can be inserted.``'
The text was updated successfully, but these errors were encountered: