summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-05-20 11:42:34 +0200
committerJulian Andres Klode <jak@debian.org>2025-05-26 12:08:29 +0200
commit4f5b0fe1d6af3a5cce15636b9c5307438a9c2d9f (patch)
treed070825c55b40dead2f75dadbdfd69756b07943c /apt-pkg/solver3.cc
parentc6f49402c2f8aed20b538263d80ecb6fed179b18 (diff)
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.
Diffstat (limited to 'apt-pkg/solver3.cc')
-rw-r--r--apt-pkg/solver3.cc9
1 files changed, 4 insertions, 5 deletions
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";