-
Notifications
You must be signed in to change notification settings - Fork 1
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
Greedy merge and better size reduction #43
base: main
Are you sure you want to change the base?
Conversation
end | ||
|
||
function OptimalBranchingCore.size_reduction(p::MISProblem, m::D3Measure, cl::Clause{INT}, variables::Vector) where {INT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the other measures will fail to work. I think we should keep the previous one as a fallback if no speacial size_reduction
is defined.
Oh I noticed that this function is defined in another file, please move it here.
lib/OptimalBranchingMIS/src/types.jl
Outdated
sum += max(degree(p.g, v) - 2) - max(degree(p.g, v) - 2 - count(vx -> vx ∈ vertices_removed, neighbors(p.g, v)), 0) | ||
end | ||
# @show sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove that
using GenericTensorNetworks | ||
using OptimalBranchingCore: size_reduction | ||
|
||
@testset "size_reduction" begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing is tested here. Should compare this function with the naive way
if mis1 != mis2 | ||
println("g") | ||
end | ||
@show count1,count2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not show count here, also println("g") should be removed.
Random.seed!(1234) | ||
|
||
@testset "GreedyMerge" begin | ||
edges = [(1, 4), (1, 5), (3, 4), (2, 5), (4, 5), (1, 6), (2, 7), (3, 8)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should make sure that all bit strings are covered
return temp_clauses | ||
end | ||
|
||
function greedymerge(cls::Vector{Vector{Clause{INT}}}, problem::AbstractProblem, variables::Vector,m::AbstractMeasure) where {INT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please format your code
return [cl[1] for cl in cls[active_cls]] | ||
end | ||
|
||
function size_reduction(p::AbstractProblem, m::AbstractMeasure, cl::Clause{INT}, variables::Vector) where {INT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeated function and wrong format
lib/OptimalBranchingMIS/src/types.jl
Outdated
@@ -64,7 +64,7 @@ A struct representing a measure that calculates the sum of the maximum degree mi | |||
struct D3Measure <: AbstractMeasure end | |||
|
|||
""" | |||
measure(p::MISProblem, ::D3Measure) | |||
measure(p::MISProblem, ::D3Measure) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The leading spaces should not be removed. Please change it back.
|
i, j = popfirst!(merging_pairs) | ||
if i in active_cls && j in active_cls | ||
for ii in 1:length(cls[i]), jj in 1:length(cls[j]) | ||
if bdistance(cls[i][ii], cls[j][jj]) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No... This line is very stupid.
No description provided.