From 4f5b0fe1d6af3a5cce15636b9c5307438a9c2d9f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 20 May 2025 11:42:34 +0200 Subject: solver3: Remove Work::choice Instead of having the historic choice here, follow MiniSAT and use the assigned variable from the tail. This should also make the Assume() function work now, albeit we still need to actually migrate to it. This is a first step towards refactoring the Solve() loop to use a propagate/find next literal/assume it kind of loop, albeit there is a bit more to prepare there as we need to also reinsert work items when backtracking. --- apt-pkg/solver3.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'apt-pkg/solver3.cc') diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index abc0af314..b97e3b694 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -901,13 +901,13 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p return clause; } -void APT::Solver::Push(Work work) +void APT::Solver::Push(Var var, Work work) { if (unlikely(debug >= 2)) std::cerr << "Trying choice for " << work.toString(cache) << std::endl; choices.push_back(solved.size()); - solved.push_back(Solved{Var(), std::move(work)}); + solved.push_back(Solved{var, std::move(work)}); } void APT::Solver::UndoOne() @@ -958,7 +958,7 @@ bool APT::Solver::Pop() assert(choices.back() < solved.size()); int itemsToUndo = solved.size() - choices.back(); - auto choice = solved[choices.back()].work->choice; + auto choice = solved[choices.back()].assigned; for (; itemsToUndo; --itemsToUndo) UndoOne(); @@ -1059,8 +1059,7 @@ bool APT::Solver::Solve() } if (item.size > 1 || item.clause->optional) { - item.choice = sol; - Push(item); + Push(sol, item); } if (unlikely(debug >= 3)) std::cerr << "(try it: " << sol.toString(cache) << ")\n"; -- cgit v1.2.3-70-g09d2