{"action":"created","issue":{"url":"https://api.github.com/repos/chocoteam/choco3/issues/272","labels_url":"https://api.github.com/repos/chocoteam/choco3/issues/272/labels{/name}","comments_url":"https://api.github.com/repos/chocoteam/choco3/issues/272/comments","events_url":"https://api.github.com/repos/chocoteam/choco3/issues/272/events","html_url":"https://github.com/chocoteam/choco3/issues/272","id":63130287,"number":272,"title":"ICF.mod returns the wrong number of solutions","user":{"login":"JLiangWaterloo","id":1310718,"avatar_url":"https://avatars.githubusercontent.com/u/1310718?v=3","gravatar_id":"","url":"https://api.github.com/users/JLiangWaterloo","html_url":"https://github.com/JLiangWaterloo","followers_url":"https://api.github.com/users/JLiangWaterloo/followers","following_url":"https://api.github.com/users/JLiangWaterloo/following{/other_user}","gists_url":"https://api.github.com/users/JLiangWaterloo/gists{/gist_id}","starred_url":"https://api.github.com/users/JLiangWaterloo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JLiangWaterloo/subscriptions","organizations_url":"https://api.github.com/users/JLiangWaterloo/orgs","repos_url":"https://api.github.com/users/JLiangWaterloo/repos","events_url":"https://api.github.com/users/JLiangWaterloo/events{/privacy}","received_events_url":"https://api.github.com/users/JLiangWaterloo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-20T01:13:24Z","updated_at":"2015-05-13T06:30:41Z","closed_at":null,"body":"There still seems to be two issues with the current implementation in 3.3.1-SNAPSHOT develop branch. The following code will find many duplicate solutions.\r\n\r\n```java\r\npublic static void main(String[] args) {\r\n    for (int i = 0; i < 1000; i++) {\r\n        Solver s = new Solver();\r\n        IntVar d = VF.enumerated(\"d\", -4, 3, s);\r\n        IntVar e = VF.enumerated(\"e\", -1, 3, s);\r\n        IntVar f = VF.enumerated(\"f\", -1, 4, s);\r\n        s.post(ICF.mod(d, e, f));\r\n        s.set(ISF.random_value(s.retrieveIntVars(), System.currentTimeMillis()));\r\n        Set<String> x = new HashSet<>();\r\n        if (s.findSolution()) {\r\n            do {\r\n                String z = d.getValue() + \" % \" + e.getValue() + \"  = \" + f.getValue();\r\n                if (!x.add(z)) {\r\n                    System.out.println(\"Duplicate solution: \" + z);\r\n                }\r\n            } while (s.nextSolution());\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nIn the next example, the constraint is \"(d % e = f) || (e = 0)\". I expected at least one solution where \"e = 0\" but no solution is returned.\r\n\r\n```java\r\npublic static void main(String[] args) {\r\n    Solver s = new Solver();\r\n    IntVar d = VF.enumerated(\"d\", new int[]{1, 2}, s);\r\n    IntVar e = VF.enumerated(\"e\", new int[]{0, 5}, s);\r\n    IntVar f = VF.enumerated(\"f\", new int[]{3, 4}, s);\r\n    s.post(LCF.or(ICF.mod(d, e, f), ICF.arithm(e, \"=\", 0)));\r\n    System.out.println(s.findSolution());\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/chocoteam/choco3/issues/comments/101530131","html_url":"https://github.com/chocoteam/choco3/issues/272#issuecomment-101530131","issue_url":"https://api.github.com/repos/chocoteam/choco3/issues/272","id":101530131,"user":{"login":"cprudhom","id":1171872,"avatar_url":"https://avatars.githubusercontent.com/u/1171872?v=3","gravatar_id":"","url":"https://api.github.com/users/cprudhom","html_url":"https://github.com/cprudhom","followers_url":"https://api.github.com/users/cprudhom/followers","following_url":"https://api.github.com/users/cprudhom/following{/other_user}","gists_url":"https://api.github.com/users/cprudhom/gists{/gist_id}","starred_url":"https://api.github.com/users/cprudhom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cprudhom/subscriptions","organizations_url":"https://api.github.com/users/cprudhom/orgs","repos_url":"https://api.github.com/users/cprudhom/repos","events_url":"https://api.github.com/users/cprudhom/events{/privacy}","received_events_url":"https://api.github.com/users/cprudhom/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T06:30:41Z","updated_at":"2015-05-13T06:30:41Z","body":"I'm not sure we are trying to solve the right problem.\r\n`eucl_div` and `mod` remove `0` from the divisor and there is nothing we can do about, since otherwise it is mathematically incorrect. \r\nThe main problem happens when those constraints are reified.\r\nActually, the constraints must override the `makeOpposite()` method from `Constraint`."}}