Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sdd smoothing #81

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/sdd/sdd_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,11 @@ import Base: xor
"Exclusive logical disjunction (XOR)"
xor(x::Sdd,y::Sdd) = (x ∧ ¬y) ∨ (y ∧ ¬x)

"Smooth an sdd to a StructLogicCircuit"
function smooth(root::Sdd)::StructLogicCircuit
lc = LogicCircuit(root)
plc = propagate_constants(lc, remove_unary=true)
slc = StructLogicCircuit(root.vtree, plc)
smooth(slc)
end

24 changes: 24 additions & 0 deletions test/sdd/sdds_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,28 @@ include("../helper/validate_sdd.jl")

end

end

@testset "sdd smoothing test" begin
cnfs = [
("easy","C17_mince",32,92,45)
("easy","majority_mince",32,132,61)
("easy","b1_mince",8,169,84)
("easy","cm152a_mince",2048,127,62)
("iscas89","s208.1.scan",262144,1942,927)
]


for (suite, name, count, size, nodes) in cnfs

cnf = zoo_cnf("$suite/$name.cnf")
vtree = zoo_vtree("$suite/$name.min.vtree");

mgr = SddMgr(vtree)
cnfΔ = compile(mgr, cnf)

smooth_slc = smooth(cnfΔ)
@test issmooth(smooth_slc)
@test respects_vtree(smooth_slc, vtree)
end
end