let init_solver_pool map pool closure =
let cudfpool = strip_cudf_pool pool in
let convert (dll,cl) =
let sdll =
List.map (fun (vpkgs,uidl) ->
(vpkgs,List.map map#vartoint uidl)
) dll
in
let scl =
(* ignore conflicts that are not in the closure.
* if nobody depends on a conflict package, then it is irrelevant.
* This requires a leap of faith in the user ability to build an
* appropriate closure. If the closure is wrong, you are on your own *)
List.map (fun (vpkg,uidl) ->
let l =
List.filter_map (fun uid ->
try Some(map#vartoint uid)
with Not_found -> begin
debug "Dropping Conflict %s" (Cudf_types_pp.string_of_vpkg vpkg) ;
None
end
) uidl
in
(vpkg, l)
) cl
in (sdll,scl)
in
(* while in init_pool_univ we create a pool that is bigger
* then the universe to keep into consideration the space
* needed to encode the global contraint, here we assume that
* the pool is already of the correct size and the closure
* contains also the globalid *)
let globalid = Array.length cudfpool in
let solverpool =
let size = List.length closure in
Array.init size (fun sid ->
if sid = globalid then
convert cudfpool.(globalid)
else
let uid = map#inttovar sid in
let (dll,cl) = cudfpool.(uid) in
convert (dll,cl)
)
in
SolverPool solverpool