{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/opam/issues/2109","labels_url":"https://api.github.com/repos/ocaml/opam/issues/2109/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/opam/issues/2109/comments","events_url":"https://api.github.com/repos/ocaml/opam/issues/2109/events","html_url":"https://github.com/ocaml/opam/issues/2109","id":68358848,"number":2109,"title":"Adding support for \"as fresh as possible\" installations","user":{"login":"rdicosmo","id":687807,"avatar_url":"https://avatars.githubusercontent.com/u/687807?v=3","gravatar_id":"","url":"https://api.github.com/users/rdicosmo","html_url":"https://github.com/rdicosmo","followers_url":"https://api.github.com/users/rdicosmo/followers","following_url":"https://api.github.com/users/rdicosmo/following{/other_user}","gists_url":"https://api.github.com/users/rdicosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/rdicosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdicosmo/subscriptions","organizations_url":"https://api.github.com/users/rdicosmo/orgs","repos_url":"https://api.github.com/users/rdicosmo/repos","events_url":"https://api.github.com/users/rdicosmo/events{/privacy}","received_events_url":"https://api.github.com/users/rdicosmo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-14T12:37:03Z","updated_at":"2015-04-14T14:03:19Z","closed_at":null,"body":"The current implementation of opam, when calling the external solver, is unable to obtain solutions that give preference to fresher packages (it only supports, using the -notuptodate measure, giving preference to the latest version). This issue is raised again and again all over the place, see #2108 and #1897.\r\n\r\nIt is pretty easy to give priority to fresher versions when the latest is impossible to install, with no changes to the solver, as follows:\r\n\r\n   - for each package, add in the generated CUDF an integer field\r\n         penalty: \r\n     with value equal to the number of versions it lags behind the latest one available\r\n  \r\n    For example, if package foo has version 3.1 4.2 5.6 and 5.7, then 3.1 has penalty 3,\r\n    4.2 has penalty 2, 5.6 has penalty 1 and 5.7 has penalty 0\r\n\r\n  - add the user preference \"-sum(solution, penalty)\" when calling the solver\r\n\r\nand that will do it ... of course, on the academic side, we know this will not be \"perfect\" in all cases, but in practice it will make a hell of a difference.\r\n\r\nA side note, as always: there are no \"quirks\" in the external solvers.... aspcud/packup and the like *really* return a solution that is optimal according to the criteria passed to them. The issue is to find the right criteria/preferences to obtain what we have in mind :-)\r\n"},"comment":{"url":"https://api.github.com/repos/ocaml/opam/issues/comments/92863247","html_url":"https://github.com/ocaml/opam/issues/2109#issuecomment-92863247","issue_url":"https://api.github.com/repos/ocaml/opam/issues/2109","id":92863247,"user":{"login":"AltGr","id":807966,"avatar_url":"https://avatars.githubusercontent.com/u/807966?v=3","gravatar_id":"","url":"https://api.github.com/users/AltGr","html_url":"https://github.com/AltGr","followers_url":"https://api.github.com/users/AltGr/followers","following_url":"https://api.github.com/users/AltGr/following{/other_user}","gists_url":"https://api.github.com/users/AltGr/gists{/gist_id}","starred_url":"https://api.github.com/users/AltGr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AltGr/subscriptions","organizations_url":"https://api.github.com/users/AltGr/orgs","repos_url":"https://api.github.com/users/AltGr/repos","events_url":"https://api.github.com/users/AltGr/events{/privacy}","received_events_url":"https://api.github.com/users/AltGr/received_events","type":"User","site_admin":false},"created_at":"2015-04-14T14:03:19Z","updated_at":"2015-04-14T14:03:19Z","body":"Awesome, it's that simple ! Thanks!\r\nDoes that work even with older versions of aspcud / packup ?\r\nImplementing should be a matter of hours, maybe a bit more if we need to keep a backwards-compatible version.\r\n\r\n> A side note, as always: there are no \"quirks\" in the external solvers\r\n\r\nI know! hence the tone of my question :)\r\nThere are cases where the criteria don't allow to discriminate among equivalent solutions, though. I have no trouble understanding several reasons why introducing a biased way to pick one in that case would be a bad idea (feels like hiding a bug rather than solving it the right way). But the _temptation_ is always there :D. Anyway, since there _is_ after all a way to specify this in Cudf, everythingis cool!\r\n\r\nActually if that works well that could be a good candidate for backport and an incentive to release a 1.2.2\r\n\r\n@samoht: sounds like a good idea, but I would be cautious of adding any extra cleverness in the mechanism, it may make solutions (even more) difficult to understand, and fixing/improving suff more difficult. Also, there will always be a bias depending on the metric (number of intermediate versions ? Age ? Delay with the latest release ? Proportionate to the package's number of versions ? It's release frequency ?). Not at all saying we shouldn't do it -- but I'd rather plan ahead and have it as simple as possible until we have something sound."}}