Commit 7393f38a authored by Andres Löh's avatar Andres Löh
Browse files

Extend comments on goal choice heuristics.

parent eed12c62
......@@ -351,10 +351,18 @@ deferWeakFlagChoices = trav go
-- | Transformation that sorts choice nodes so that
-- child nodes with a small branching degree are preferred.
--
-- Only approximates the number of choices in the branches.
-- In particular, we try to take any goal immediately if it has
-- a branching degree of 0 (guaranteed failure) or 1 (no other
-- choice possible).
-- Only approximates the number of choices in the branches
-- using dchoices which classifies every goal by the number
-- of active choices:
--
-- - 0 (guaranteed failure) or 1 (no other option) active choice
-- - 2 active choices
-- - 3 or more active choices
--
-- We pick the minimum goal according to this approximation.
-- In particular, if we encounter any goal in the first class
-- (0 or 1 option), we do not look any further and choose it
-- immediately.
--
-- Returns at most one choice.
--
......
......@@ -137,12 +137,27 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
$ buildTree idx (independentGoals sc) userGoals
-- Counting conflicts and reordering goals interferes, as both are strategies to
-- change the order of goals. When count-conflicts is set, we therefore interpret
-- reorder-goals to only prefer goals with 0 or 1 enabled choice.
-- change the order of goals.
--
-- In the past, we used P.firstGoal to trim down the goal choice nodes to just a
-- single option. This was a way to work around a space leak that was unnecessary
-- and is now fixed, so we no longer do it.
-- We therefore change the strategy based on whether --count-conflicts is set or
-- not:
--
-- - when --count-conflicts is set, we use preferReallyEasyGoalChoices, which
-- prefers (keeps) goals only if the have 0 or 1 enabled choice.
--
-- - when --count-conflicts is not set, we use preferEasyGoalChoices, which
-- (next to preferring goals with 0 or 1 enabled choice)
-- also prefers goals that have 2 enabled choices over goals with more than
-- two enabled choices.
--
-- In the past, we furthermore used P.firstGoal to trim down the goal choice nodes
-- to just a single option. This was a way to work around a space leak that was
-- unnecessary and is now fixed, so we no longer do it.
--
-- If --count-conflicts is active, it will then choose among the remaining goals
-- the one that has been responsible for the most conflicts so far.
--
-- Otherwise, we simply choose the first remaining goal.
--
goalChoiceHeuristics
| asBool (reorderGoals sc) && asBool (countConflicts sc) = P.preferReallyEasyGoalChoices
......
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