{"action":"created","issue":{"url":"https://api.github.com/repos/chocoteam/choco3/issues/300","labels_url":"https://api.github.com/repos/chocoteam/choco3/issues/300/labels{/name}","comments_url":"https://api.github.com/repos/chocoteam/choco3/issues/300/comments","events_url":"https://api.github.com/repos/chocoteam/choco3/issues/300/events","html_url":"https://github.com/chocoteam/choco3/pull/300","id":77704705,"number":300,"title":"Request for comments: Remove monitors from the solver after optimal solution is found.","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":3,"created_at":"2015-05-18T15:42:40Z","updated_at":"2015-05-21T13:08:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/chocoteam/choco3/pulls/300","html_url":"https://github.com/chocoteam/choco3/pull/300","diff_url":"https://github.com/chocoteam/choco3/pull/300.diff","patch_url":"https://github.com/chocoteam/choco3/pull/300.patch"},"body":"Many meta-algorithms require calling the solver many times, for example, the algorithm in the paper \"Time-versus-capacity compromises in project scheduling\" requires calling many (> 100,000 in some cases) single-objective optimization searches. In the current implementation, every single-objective optimization attaches two permanent monitors. If we need to call single-objective optimization many times, then the monitors accumulate and the performance degrades.\r\n\r\nPerhaps even worse, one of the monitors attached will always restore solution on close which makes it impossible to do a satisfaction search after a single-objective optimization. For example, in the following code, the satisfaction part will only find one solution (i.e., misses 10 solutions). If code was rewritten to do the satisfaction part first, then it will not miss any solutions.\r\n\r\n```java\r\n    public static void main(String[] args) {\r\n        Solver s = new Solver();\r\n        IntVar i = VF.enumerated(\"i\", -5, 5, s);\r\n\r\n        s.findOptimalSolution(ResolutionPolicy.MAXIMIZE, i);\r\n        System.out.println(\"Optimization problem: \" + i);\r\n\r\n        s.getEngine().flush();\r\n        s.getSearchLoop().reset();\r\n\r\n        if (s.findSolution()) {\r\n            do {\r\n                System.out.println(\"Satisfaction problem: \" + i);\r\n            } while (s.nextSolution());\r\n        }\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/chocoteam/choco3/issues/comments/104271180","html_url":"https://github.com/chocoteam/choco3/pull/300#issuecomment-104271180","issue_url":"https://api.github.com/repos/chocoteam/choco3/issues/300","id":104271180,"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},"created_at":"2015-05-21T13:08:45Z","updated_at":"2015-05-21T13:08:45Z","body":"There are search monitors created elsewhere, for example this [line](https://github.com/JLiangWaterloo/choco3/blob/unplug-finished-monitors/choco-solver/src/main/java/org/chocosolver/solver/Solver.java#L182) will plug a monitor on the Solver's constructor. Should `s.getSearchLoop().reset()` remove this monitor too?"}}