summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.h
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-08-01 15:51:37 +0900
committerJulian Andres Klode <julian.klode@canonical.com>2024-11-02 10:23:15 +0100
commitc1f69a64fd5070723ef425cc1255cde2a28966ad (patch)
treeefdaae43bd5570ab06580b5644be338681d1a70c /apt-pkg/solver3.h
parenta5a7b6905dc021d9773229e47ec60367e3e606d8 (diff)
solver3: Introduce new Assume() and Enqueue() helpers and use them
These are taken roughly from the MiniSAT paper. We still have a bit to go in actually encoding all clauses so the reasons are still variables, and Assume() isn't fully working yet. Adjust the existing Install()/Reject() code to use these functions, we already see additional lines in the log that we failed to log before, and this ensures more consistency. This is sort of still the wrong direction: Install()/Reject() do the propagation too; but that is tbd.
Diffstat (limited to 'apt-pkg/solver3.h')
-rw-r--r--apt-pkg/solver3.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h
index b0ced904a..527e6fc22 100644
--- a/apt-pkg/solver3.h
+++ b/apt-pkg/solver3.h
@@ -176,6 +176,11 @@ class Solver
// \brief Basic solver initializer. This cannot fail.
Solver(pkgCache &Cache, pkgDepCache::Policy &Policy);
+ // Assume that the variable is decided as specified.
+ bool Assume(Var var, bool decision, Var reason);
+ // Enqueue a decision fact
+ bool Enqueue(Var var, bool decision, Var reason);
+
// \brief Mark the package for install. This is annoying as it incurs a decision
bool Install(pkgCache::PkgIterator Pkg, Var reason, Group group);
// \brief Install a version.
@@ -241,6 +246,15 @@ struct APT::Solver::Var
{
return IsVersion == 0 && MapPtr == 0;
}
+
+ std::string toString(pkgCache &cache) const
+ {
+ if (auto P = Pkg(cache); not P.end())
+ return P.FullName();
+ if (auto V = Ver(cache); not V.end())
+ return V.ParentPkg().FullName() + "=" + V.VerStr();
+ return "(root)";
+ }
};
/**