Commit 47bd27ce authored by Karel Koci's avatar Karel Koci 🤘

Add debug messages for dependency computations steps

parent ffda1dff
......@@ -24,6 +24,7 @@ local setmetatable = setmetatable
local unpack = unpack
local table = table
local picosat = picosat
local DBG = DBG
module "sat"
......@@ -91,6 +92,11 @@ local function __index(sat, key)
return sat._picosat[key]
end
local function clause(sat, ...)
DBG('SAT add clause: ' .. table.concat({...}, ', '))
return sat._picosat:clause(...)
end
--[[
Creates new sat object. It is extension for picosat, so you can call all methods
from picosat in addition to "new_batch".
......@@ -100,9 +106,10 @@ function new()
local sat = {
tp = "sat",
_picosat = picosat,
new_batch = new_batch
new_batch = new_batch,
clause = clause
}
for _, c in pairs({ 'var', 'clause', 'assume', 'satisfiable', 'max_satisfiable' }) do
for _, c in pairs({ 'var', 'assume', 'satisfiable', 'max_satisfiable' }) do
sat[c] = function(sat, ...)
return sat._picosat[c](sat._picosat, unpack({...}))
end
......
......@@ -71,8 +71,8 @@ local function build_deps(sat, satmap, pkgs, requests)
end
-- Create new variable for this package and new sat clauses batch
local pkg_var = sat:var()
DBG("SAT add package " .. name .. " with var: " .. tostring(pkg_var))
satmap.pkg2sat[name] = pkg_var
DBG("Adding dependencies for package " .. name)
local pkg = pkgs[name]
local candidate
if pkg and pkg.candidates and next(pkg.candidates) then
......@@ -347,6 +347,7 @@ function required_pkgs(pkgs, requests)
end
-- Install critical packages requests (set all critical packages to be true)
DBG("Resolving critical packages")
for _, req in ipairs(reqs_critical) do
sat:clause(satmap.req2sat[req])
end
......@@ -356,6 +357,7 @@ function required_pkgs(pkgs, requests)
end
-- Install and Uninstall requests.
DBG("Resolving Install and Uninstall requests")
for _, reqs in ipairs(reqs_prior) do
for _, req in pairs(reqs) do
-- Assume all request for this priority
......@@ -365,6 +367,7 @@ function required_pkgs(pkgs, requests)
end
-- Deny any packages missing or without candidates if possible
DBG("Denying packages without any candidate")
for name, var in pairs(satmap.pkg2sat) do
local pkg = pkgs[name]
if not pkg or not pkg.candidates or not next(pkg.candidates) then
......@@ -374,12 +377,14 @@ function required_pkgs(pkgs, requests)
clause_max_satisfiable()
-- Chose alternatives with penalty variables
DBG("Forcing penalty on expressions with free alternatives")
for var, _ in pairs(satmap.penaltysat) do
sat:assume(var)
end
clause_max_satisfiable()
-- Now solve all packages selections from dependencies of already selected packages
DBG("Deducing minimal set of required packages")
for _, var in pairs(satmap.pkg2sat) do
-- We assume false (not selected) for all packages
sat:assume(-var)
......
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