let choose_criteria ?(criteria=None) ~conffile solver request =
  let conf = 
    if Sys.file_exists conffile then
      parse_conf_file conffile 
    else []
  in
  let default_criteria =
    try List.assoc solver conf
    with Not_found ->
      try List.assoc "*" conf 
      with Not_found -> [
        ("install""-removed,-changed");
        ("remove""-removed,-changed");
        ("upgrade","-new,-removed,-notuptodate");
        ("dist-upgrade","-notuptodate,-new,-removed");
        ("trendy","-removed,-notuptodate,-unsat_recommends,-new");
        ("paranoid","-removed,-changed")
      ]
  in
  match criteria,request.Edsp.preferences with
  |None, c when c <> "" -> (try List.assoc c default_criteria with Not_found -> c)
  |Some c,_ when c <> "" -> (try List.assoc c default_criteria with Not_found -> c)
  |_,_ when request.Edsp.upgrade -> List.assoc "upgrade" default_criteria
  |_,_ when request.Edsp.distupgrade -> List.assoc "dist-upgrade" default_criteria
  |_,_ when request.Edsp.install <> [] -> List.assoc "install" default_criteria
  |_,_ when request.Edsp.remove <> [] -> List.assoc "remove" default_criteria
  |_,_ -> List.assoc "paranoid" default_criteria