Links into nodes: post processing algorithm - Reduced echelon form#1326
Links into nodes: post processing algorithm - Reduced echelon form#1326figueroa1395 wants to merge 17 commits intomainfrom
Conversation
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
power_grid_model_c/power_grid_model/include/power_grid_model/link_solver.hpp
Outdated
Show resolved
Hide resolved
power_grid_model_c/power_grid_model/include/power_grid_model/link_solver.hpp
Show resolved
Hide resolved
power_grid_model_c/power_grid_model/include/power_grid_model/link_solver.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
power_grid_model_c/power_grid_model/include/power_grid_model/link_solver.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
power_grid_model_c/power_grid_model/include/power_grid_model/link_solver.hpp
Show resolved
Hide resolved
power_grid_model_c/power_grid_model/include/power_grid_model/link_solver.hpp
Show resolved
Hide resolved
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
|
|
|
||
| enum class EdgeDirection : IntS { Away = -1, Towards = 1 }; | ||
|
|
||
| struct COOSparseMatrix { |
There was a problem hiding this comment.
please add a docstring to explain the abbreviation COO
| bool get_value(IntS& value, uint64_t row_idx, uint64_t col_idx) const { | ||
| assert(row_number != 0 && "row_number must be set before getting values from data_map"); | ||
| if (auto const it = data_map.find(row_idx * row_number + col_idx); it != data_map.end()) { | ||
| value = it->second; | ||
| return true; | ||
| } | ||
| return false; | ||
| } |
There was a problem hiding this comment.
is there a reason you want to use a target value pattern rather than a throwing value? it may be good to instead use std::optional instead. Yes it is slightly less memory efficient, but it is much more readable and better indicating the intention
| assert(row_number != 0 && "row_number must be set before adding values in data_map"); | ||
| auto const key = row_idx * row_number + col_idx; | ||
| if (auto const it = data_map.find(key); it != data_map.end()) { | ||
| it->second = static_cast<IntS>(it->second + value); |
There was a problem hiding this comment.
| it->second = static_cast<IntS>(it->second + value); | |
| it->second = narrow_cast<IntS>(it->second + value); |
| [[nodiscard]] constexpr Idx from_node(BranchIdx const& edge) { return edge[0]; } | ||
| [[nodiscard]] constexpr Idx& from_node(BranchIdx& edge) { return edge[0]; } | ||
| [[nodiscard]] constexpr Idx to_node(BranchIdx const& edge) { return edge[1]; } | ||
| [[nodiscard]] constexpr Idx& to_node(BranchIdx& edge) { return edge[1]; } |
There was a problem hiding this comment.
we don't use nodiscard yet in the rest of our code. NOTE: i am very much in favor of using it, but I remember a discussion in which we said we did not want to use it. We can revisit if we want to.
| // unordered_set for O(1) insert/erase during reattachment | ||
| [[nodiscard]] inline auto build_adjacency_map(std::span<BranchIdx> edges) -> AdjacencyMap { | ||
| AdjacencyMap adjacency_map{}; | ||
| for (auto const& [raw_index, edge] : enumerate(std::as_const(edges))) { |
There was a problem hiding this comment.
please resolve the sonar cloud warning (see also #1257)



In this PR I introduce the first step of the post processing algorithm of merging links into nodes feature.
The things that need to happen are: