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

Greedy merge and better size reduction #43

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

nzy1997
Copy link
Collaborator

@nzy1997 nzy1997 commented Jan 3, 2025

No description provided.

end

function OptimalBranchingCore.size_reduction(p::MISProblem, m::D3Measure, cl::Clause{INT}, variables::Vector) where {INT}
Copy link
Collaborator

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.

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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)]
Copy link
Collaborator

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}
Copy link
Collaborator

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}
Copy link
Collaborator

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

@@ -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)
Copy link
Collaborator

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.

@GiggleLiu
Copy link
Collaborator

  1. I checked the bottleneck case, greedy method does not work at all, it does not merge any clause.
  2. The output of mergegreedy is hard to read, please consider following the convension and return an object.

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
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants