Commit 0f895650 authored by Timo Teräs's avatar Timo Teräs

solver: fix regression from "calculate branch minimum penalty early"

Forgot to reset per-name penalty when it got locked by apply_decision.
This also fine tunes compare_package_preference() to always prefer
packages specified on command line speeding up calculation certain
complicated solutions.
parent 00fd7b07
...@@ -325,6 +325,12 @@ static int compare_package_preference(unsigned short solver_flags, ...@@ -325,6 +325,12 @@ static int compare_package_preference(unsigned short solver_flags,
struct apk_package *pkgA, struct apk_package *pkgA,
struct apk_package *pkgB) struct apk_package *pkgB)
{ {
/* specified on command line directly */
if (pkgA->filename && !pkgB->filename)
return 1;
if (pkgB->filename && !pkgA->filename)
return -1;
if (solver_flags & APK_SOLVERF_PREFER_TAG) { if (solver_flags & APK_SOLVERF_PREFER_TAG) {
/* preferred repository pinning */ /* preferred repository pinning */
if ((pkgA->repos & preferred_repos) && !(pkgB->repos & preferred_repos)) if ((pkgA->repos & preferred_repos) && !(pkgB->repos & preferred_repos))
...@@ -333,11 +339,11 @@ static int compare_package_preference(unsigned short solver_flags, ...@@ -333,11 +339,11 @@ static int compare_package_preference(unsigned short solver_flags,
return -1; return -1;
} else { } else {
/* preferred repository pinning */ /* preferred repository pinning */
if ((pkgA->ipkg || pkgA->filename || (pkgA->repos & preferred_repos)) && if ((pkgA->ipkg || (pkgA->repos & preferred_repos)) &&
!(pkgB->ipkg || pkgB->filename || (pkgB->repos & preferred_repos))) !(pkgB->ipkg || (pkgB->repos & preferred_repos)))
return 1; return 1;
if ((pkgB->ipkg || pkgA->filename || (pkgB->repos & preferred_repos)) && if ((pkgB->ipkg || (pkgB->repos & preferred_repos)) &&
!(pkgA->ipkg || pkgB->filename || (pkgA->repos & preferred_repos))) !(pkgA->ipkg || (pkgA->repos & preferred_repos)))
return -1; return -1;
} }
...@@ -504,9 +510,6 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name) ...@@ -504,9 +510,6 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name)
dbg_printf("%s: deleted from unsolved: %d requirers, %d install_ifs, %d options, %d skipped\n", dbg_printf("%s: deleted from unsolved: %d requirers, %d install_ifs, %d options, %d skipped\n",
name->name, ns->requirers, ns->install_ifs, options, skipped_options); name->name, ns->requirers, ns->install_ifs, options, skipped_options);
} else { } else {
dbg_printf("%s: added to unsolved: %d requirers, %d install_ifs, %d options (next topology %d)\n",
name->name, ns->requirers, ns->install_ifs, options,
best_topology);
if (!list_hashed(&ns->unsolved_list)) if (!list_hashed(&ns->unsolved_list))
list_add(&ns->unsolved_list, &ss->unsolved_list_head); list_add(&ns->unsolved_list, &ss->unsolved_list_head);
if (!ns->locked) { if (!ns->locked) {
...@@ -517,6 +520,11 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name) ...@@ -517,6 +520,11 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name)
.unsatisfiable = preferred_ps->conflicts, .unsatisfiable = preferred_ps->conflicts,
.preference = get_preference(ss, preferred_pkg, FALSE), .preference = get_preference(ss, preferred_pkg, FALSE),
}; };
dbg_printf("%s: min.penalty for name {%d, %d} from pkg " PKG_VER_FMT "\n",
name->name,
ns->minimum_penalty.unsatisfiable,
ns->minimum_penalty.preference,
PKG_VER_PRINTF(preferred_pkg));
} else { } else {
ns->minimum_penalty = (struct apk_score) { ns->minimum_penalty = (struct apk_score) {
.unsatisfiable = ns->requirers, .unsatisfiable = ns->requirers,
...@@ -525,6 +533,9 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name) ...@@ -525,6 +533,9 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name)
} }
addscore(&ss->minimum_penalty, &ns->minimum_penalty); addscore(&ss->minimum_penalty, &ns->minimum_penalty);
} }
dbg_printf("%s: added to unsolved: %d requirers, %d install_ifs, %d options (next topology %d)\n",
name->name, ns->requirers, ns->install_ifs, options,
best_topology);
} }
return options + skipped_options; return options + skipped_options;
...@@ -568,6 +579,9 @@ static void apply_decision(struct apk_solver_state *ss, ...@@ -568,6 +579,9 @@ static void apply_decision(struct apk_solver_state *ss,
(ps->flags & APK_PKGSTF_INSTALL) ? "INSTALL" : "NO_INSTALL"); (ps->flags & APK_PKGSTF_INSTALL) ? "INSTALL" : "NO_INSTALL");
if (ps->flags & APK_PKGSTF_INSTALL) { if (ps->flags & APK_PKGSTF_INSTALL) {
subscore(&ss->minimum_penalty, &ns->minimum_penalty);
ns->minimum_penalty = (struct apk_score) { 0, 0 };
ss->assigned_names++; ss->assigned_names++;
ss->score.unsatisfiable += ps->conflicts; ss->score.unsatisfiable += ps->conflicts;
ss->score.preference += get_preference(ss, pkg, FALSE); ss->score.preference += get_preference(ss, pkg, FALSE);
......
2 unsatisfiable dependencies (solution with 4 names) 1 unsatisfiable dependencies (solution with 4 names)
world: d<1.5 world: d<1.5
b-1: d<2.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment