-
Couldn't load subscription status.
- Fork 6
Revisit the post-processing #267
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
Open
amontoison
wants to merge
8
commits into
main
Choose a base branch
from
am/postprocessing_v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
126f4bb
Revisit post-processing
amontoison d095cef
Implement postprocess_star_bicoloring and postprocess_acyclic_bicoloring
amontoison 97ebbf8
Update test/suitesparse.jl
amontoison 4c41a68
Update AdjacencyGraph
amontoison 3753c76
Remove the field bicoloring in AdjacencyGraph
amontoison bd9545a
Remove the field bicoloring in AdjacencyGraph
amontoison c1724ab
Update test/suitesparse.jl
amontoison a0176ac
Add an heuristic for :all_colors
amontoison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,11 +69,12 @@ It is passed as an argument to the main function [`coloring`](@ref). | |||||
|
|
||||||
| # Constructors | ||||||
|
|
||||||
| GreedyColoringAlgorithm{decompression}(order=NaturalOrder(); postprocessing=false) | ||||||
| GreedyColoringAlgorithm(order=NaturalOrder(); postprocessing=false, decompression=:direct) | ||||||
| GreedyColoringAlgorithm{decompression}(order=NaturalOrder(); postprocessing=false, postprocessing_minimizes=:all_colors) | ||||||
| GreedyColoringAlgorithm(order=NaturalOrder(); postprocessing=false, postprocessing_minimizes=:all_colors, decompression=:direct) | ||||||
|
|
||||||
| - `order::Union{AbstractOrder,Tuple}`: the order in which the columns or rows are colored, which can impact the number of colors. Can also be a tuple of different orders to try out, from which the best order (the one with the lowest total number of colors) will be used. | ||||||
| - `postprocessing::Bool`: whether or not the coloring will be refined by assigning the neutral color `0` to some vertices. | ||||||
| - `postprocessing::Bool`: whether or not the coloring will be refined by assigning the neutral color `0` to some vertices. This option does not affect row or column colorings. | ||||||
| - `postprocessing_minimizes::Symbol`: either `:all_colors`, `:row_colors` or `:column_colors`. This option only applies to star and acyclic bicolorings. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The user-facing documentation does not mention star/acyclic terminology |
||||||
| - `decompression::Symbol`: either `:direct` or `:substitution`. Usually `:substitution` leads to fewer colors, at the cost of a more expensive coloring (and decompression). When `:substitution` is not applicable, it falls back on `:direct` decompression. | ||||||
|
|
||||||
| !!! warning | ||||||
|
|
@@ -98,27 +99,30 @@ struct GreedyColoringAlgorithm{decompression,N,O<:NTuple{N,AbstractOrder}} <: | |||||
| ADTypes.AbstractColoringAlgorithm | ||||||
| orders::O | ||||||
| postprocessing::Bool | ||||||
| postprocessing_minimizes::Symbol | ||||||
|
|
||||||
| function GreedyColoringAlgorithm{decompression}( | ||||||
| order_or_orders::Union{AbstractOrder,Tuple}=NaturalOrder(); | ||||||
| postprocessing::Bool=false, | ||||||
| postprocessing_minimizes::Symbol=:all_colors, | ||||||
| ) where {decompression} | ||||||
| check_valid_algorithm(decompression) | ||||||
| if order_or_orders isa AbstractOrder | ||||||
| orders = (order_or_orders,) | ||||||
| else | ||||||
| orders = order_or_orders | ||||||
| end | ||||||
| return new{decompression,length(orders),typeof(orders)}(orders, postprocessing) | ||||||
| return new{decompression,length(orders),typeof(orders)}(orders, postprocessing, postprocessing_minimizes) | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| function GreedyColoringAlgorithm( | ||||||
| order_or_orders::Union{AbstractOrder,Tuple}=NaturalOrder(); | ||||||
| postprocessing::Bool=false, | ||||||
| decompression::Symbol=:direct, | ||||||
| postprocessing_minimizes::Symbol=:all_colors, | ||||||
| ) | ||||||
| return GreedyColoringAlgorithm{decompression}(order_or_orders; postprocessing) | ||||||
| return GreedyColoringAlgorithm{decompression}(order_or_orders; postprocessing, postprocessing_minimizes) | ||||||
| end | ||||||
|
|
||||||
| ## Coloring | ||||||
|
|
@@ -279,7 +283,7 @@ function _coloring( | |||||
| symmetric_pattern::Bool; | ||||||
| forced_colors::Union{AbstractVector{<:Integer},Nothing}=nothing, | ||||||
| ) | ||||||
| ag = AdjacencyGraph(A; has_diagonal=true) | ||||||
| ag = AdjacencyGraph(A; has_diagonal=true, original_size=size(A)) | ||||||
| color_and_star_set_by_order = map(algo.orders) do order | ||||||
| vertices_in_order = vertices(ag, order) | ||||||
| return star_coloring(ag, vertices_in_order, algo.postprocessing; forced_colors) | ||||||
|
|
@@ -300,7 +304,7 @@ function _coloring( | |||||
| decompression_eltype::Type{R}, | ||||||
| symmetric_pattern::Bool, | ||||||
| ) where {R} | ||||||
| ag = AdjacencyGraph(A; has_diagonal=true) | ||||||
| ag = AdjacencyGraph(A; has_diagonal=true, original_size=size(A)) | ||||||
| color_and_tree_set_by_order = map(algo.orders) do order | ||||||
| vertices_in_order = vertices(ag, order) | ||||||
| return acyclic_coloring(ag, vertices_in_order, algo.postprocessing) | ||||||
|
|
@@ -323,11 +327,12 @@ function _coloring( | |||||
| forced_colors::Union{AbstractVector{<:Integer},Nothing}=nothing, | ||||||
| ) where {R} | ||||||
| A_and_Aᵀ, edge_to_index = bidirectional_pattern(A; symmetric_pattern) | ||||||
| ag = AdjacencyGraph(A_and_Aᵀ, edge_to_index; has_diagonal=false) | ||||||
| ag = AdjacencyGraph(A_and_Aᵀ, edge_to_index; has_diagonal=false, original_size=size(A)) | ||||||
| postprocessing_minimizes = algo.postprocessing_minimizes | ||||||
| outputs_by_order = map(algo.orders) do order | ||||||
| vertices_in_order = vertices(ag, order) | ||||||
| _color, _star_set = star_coloring( | ||||||
| ag, vertices_in_order, algo.postprocessing; forced_colors | ||||||
| ag, vertices_in_order, algo.postprocessing; postprocessing_minimizes, forced_colors | ||||||
| ) | ||||||
| (_row_color, _column_color, _symmetric_to_row, _symmetric_to_column) = remap_colors( | ||||||
| eltype(ag), _color, maximum(_color), size(A)... | ||||||
|
|
@@ -370,10 +375,11 @@ function _coloring( | |||||
| symmetric_pattern::Bool, | ||||||
| ) where {R} | ||||||
| A_and_Aᵀ, edge_to_index = bidirectional_pattern(A; symmetric_pattern) | ||||||
| ag = AdjacencyGraph(A_and_Aᵀ, edge_to_index; has_diagonal=false) | ||||||
| ag = AdjacencyGraph(A_and_Aᵀ, edge_to_index; has_diagonal=false, original_size=size(A)) | ||||||
| postprocessing_minimizes = algo.postprocessing_minimizes | ||||||
| outputs_by_order = map(algo.orders) do order | ||||||
| vertices_in_order = vertices(ag, order) | ||||||
| _color, _tree_set = acyclic_coloring(ag, vertices_in_order, algo.postprocessing) | ||||||
| _color, _tree_set = acyclic_coloring(ag, vertices_in_order, algo.postprocessing; postprocessing_minimizes) | ||||||
| (_row_color, _column_color, _symmetric_to_row, _symmetric_to_column) = remap_colors( | ||||||
| eltype(ag), _color, maximum(_color), size(A)... | ||||||
| ) | ||||||
|
|
||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
has_diagonalshould be renamed intoaugmented_graphor something to that effect