ArrogantGao / OptimalBranching.jl

Automated Discovery of Optimal Branching Rules for the Branch-and-bound algorithm
MIT License
0 stars 0 forks source link

Polish interfaces in OptimalBranchingCore #15

Closed GiggleLiu closed 2 hours ago

GiggleLiu commented 10 hours ago
julia> using OptimalBranchingCore

julia> tbl = BranchingTable(5, [
        [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0]],
        [[0, 0, 1, 0, 1]],
        [[0, 1, 0, 1, 0]],
        [[1, 1, 1, 0, 0]]])
BranchingTable{BitBasis.LongLongUInt{1}}
10000, 01000
10100
01010
00111

julia> candidates = collect(OptimalBranchingCore.candidate_clauses(tbl))
14-element Vector{Clause{BitBasis.LongLongUInt{1}}}:
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#2 ∧ ¬#3 ∧ ¬#4 ∧ #5
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#3 ∧ #4 ∧ ¬#5
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#2 ∧ #3 ∧ ¬#4 ∧ #5
 Clause{BitBasis.LongLongUInt{1}}: #1 ∧ #2 ∧ #3 ∧ ¬#4 ∧ ¬#5
 Clause{BitBasis.LongLongUInt{1}}: #2 ∧ ¬#5
 Clause{BitBasis.LongLongUInt{1}}: #3 ∧ ¬#4
 Clause{BitBasis.LongLongUInt{1}}: ¬#1
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#2 ∧ ¬#4 ∧ #5
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#2 ∧ ¬#3 ∧ #4 ∧ ¬#5
 Clause{BitBasis.LongLongUInt{1}}: ¬#5
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#2
 Clause{BitBasis.LongLongUInt{1}}: ¬#4
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#3
 Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ #2 ∧ ¬#3 ∧ #4 ∧ ¬#5

julia> Δρ = [length(literals(sc)) for sc in candidates]
14-element Vector{Int64}:
 5
 4
 5
 5
 2
 2
 1
 4
 5
 1
 2
 1
 2
 5

julia> res_ip = OptimalBranchingCore.minimize_γ(tbl, candidates, Δρ, IPSolver())
OptimalBranchingResult{BitBasis.LongLongUInt{1}, Int64}([4, 2, 3], DNF{BitBasis.LongLongUInt{1}}(Clause{BitBasis.LongLongUInt{1}}[Clause{BitBasis.LongLongUInt{1}}: #1 ∧ #2 ∧ #3 ∧ ¬#4 ∧ ¬#5, Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#3 ∧ #4 ∧ ¬#5, Clause{BitBasis.LongLongUInt{1}}: ¬#1 ∧ ¬#2 ∧ #3 ∧ ¬#4 ∧ #5]), [5, 4, 5], 1.2671683045421243)
codecov[bot] commented 9 hours ago

Codecov Report

Attention: Patch coverage is 87.09677% with 8 lines in your changes missing coverage. Please review.

Project coverage is 90.38%. Comparing base (bfe46f2) to head (4bb25c8). Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
lib/OptimalBranchingCore/src/branch.jl 0.00% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #15 +/- ## ========================================== - Coverage 90.73% 90.38% -0.35% ========================================== Files 18 18 Lines 777 780 +3 ========================================== Hits 705 705 - Misses 72 75 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

GiggleLiu commented 9 hours ago

This PR is used to support the appenx. The motivation is to make the results more readable.

ArrogantGao commented 4 hours ago

for the example to be used in the article, I suggest something like this: https://github.com/ArrogantGao/OptimalBranching_benchmark/tree/main/rule_discovery Showing how we discover the rule on a graph can be more direct forward.