From 7c2020884e8adde41624fcb9a2222d955ceb75b9 Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Wed, 3 Jan 2024 02:31:07 -0800 Subject: [PATCH 1/8] Activate tests for Dominating Theta Path --- tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 58e4bafc..a4521381 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -53,9 +53,9 @@ add_test(NAME TestBlockCutTree COMMAND TestBlockCutTree) #################################################################################### # Tests for PATH FINDING ALGORITHMS ################################################ #################################################################################### -# add_executable(TestDominatingThetaPath Algorithms/PathFinding/TestDominatingThetaPath.cpp) -# target_link_libraries(TestDominatingThetaPath EGOA gtest gtest_main gmock_main) -# add_test(NAME TestDominatingThetaPath COMMAND TestDominatingThetaPath) +add_executable(TestDominatingThetaPath Algorithms/PathFinding/TestDominatingThetaPath.cpp) +target_link_libraries(TestDominatingThetaPath EGOA gtest gtest_main gmock_main) +add_test(NAME TestDominatingThetaPath COMMAND TestDominatingThetaPath) # add_executable(TestBetweennessCentrality Algorithms/Centralities/TestBetweennessCentrality.cpp) # target_link_libraries(TestBetweennessCentrality EGOA gtest gtest_main gmock_main) From 2a838185cf6bfe768056a62c4ea8db14fa6106bd Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Sat, 6 Jan 2024 02:30:09 -0800 Subject: [PATCH 2/8] Use for now --- include/Algorithms/PathFinding/DominatingThetaPath.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Algorithms/PathFinding/DominatingThetaPath.hpp b/include/Algorithms/PathFinding/DominatingThetaPath.hpp index 15d44d8c..2141e891 100644 --- a/include/Algorithms/PathFinding/DominatingThetaPath.hpp +++ b/include/Algorithms/PathFinding/DominatingThetaPath.hpp @@ -200,7 +200,7 @@ class DominatingThetaPath final { std::vector edges; Types::real result = \ - labelSets_[target].for_all_optima( + labelSets_[target].for_all_optima( [ this, &vertices, &edges, &isVertexInSubgraph, &isEdgeInSubgraph ]( TLabel const & optLabel ) { Types::labelId labelId = optLabel.Index(); @@ -264,7 +264,7 @@ class DominatingThetaPath final { // Iterate over all optima Types::real result = \ - labelSets_[target].for_all_optima([ this, & parent = parent ]( TLabel const & optLabel ) + labelSets_[target].for_all_optima([ this, & parent = parent ]( TLabel const & optLabel ) { // Add a row for another label path from target t parent.emplace_back( std::vector() ); @@ -409,7 +409,7 @@ class DominatingThetaPath final { numberOfPathsPerVertex.resize( graph_.NumberOfVertices(), 0 ); - labelSets_[target].for_all_optima ( + labelSets_[target].for_all_optima ( [&]( TLabel const & optLabel ) { Types::labelId labelId = optLabel.Index(); From bbadbaee26b9de1232f15738961db853ee731382 Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Sat, 6 Jan 2024 03:26:45 -0800 Subject: [PATCH 3/8] Add template keyword --- include/Algorithms/PathFinding/DominatingThetaPath.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Algorithms/PathFinding/DominatingThetaPath.hpp b/include/Algorithms/PathFinding/DominatingThetaPath.hpp index 2141e891..2a2cdbd5 100644 --- a/include/Algorithms/PathFinding/DominatingThetaPath.hpp +++ b/include/Algorithms/PathFinding/DominatingThetaPath.hpp @@ -200,7 +200,7 @@ class DominatingThetaPath final { std::vector edges; Types::real result = \ - labelSets_[target].for_all_optima( + labelSets_[target].template for_all_optima( [ this, &vertices, &edges, &isVertexInSubgraph, &isEdgeInSubgraph ]( TLabel const & optLabel ) { Types::labelId labelId = optLabel.Index(); @@ -264,7 +264,7 @@ class DominatingThetaPath final { // Iterate over all optima Types::real result = \ - labelSets_[target].for_all_optima([ this, & parent = parent ]( TLabel const & optLabel ) + labelSets_[target].template for_all_optima([ this, & parent = parent ]( TLabel const & optLabel ) { // Add a row for another label path from target t parent.emplace_back( std::vector() ); @@ -409,7 +409,7 @@ class DominatingThetaPath final { numberOfPathsPerVertex.resize( graph_.NumberOfVertices(), 0 ); - labelSets_[target].for_all_optima ( + labelSets_[target].template for_all_optima ( [&]( TLabel const & optLabel ) { Types::labelId labelId = optLabel.Index(); From a94499309633f6735548ed7f142a08ac79b50114 Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Sat, 6 Jan 2024 03:40:44 -0800 Subject: [PATCH 4/8] Update lambda function alignment --- .../PathFinding/DominatingThetaPath.hpp | 121 +++++++++--------- 1 file changed, 62 insertions(+), 59 deletions(-) diff --git a/include/Algorithms/PathFinding/DominatingThetaPath.hpp b/include/Algorithms/PathFinding/DominatingThetaPath.hpp index 2a2cdbd5..f1f0ccd1 100644 --- a/include/Algorithms/PathFinding/DominatingThetaPath.hpp +++ b/include/Algorithms/PathFinding/DominatingThetaPath.hpp @@ -202,45 +202,46 @@ class DominatingThetaPath final { Types::real result = \ labelSets_[target].template for_all_optima( [ this, &vertices, &edges, &isVertexInSubgraph, &isEdgeInSubgraph ]( TLabel const & optLabel ) - { - Types::labelId labelId = optLabel.Index(); - TVertexId vertexId = optLabel.Vertex(); - - do - { - TLabel const & label = LabelAt( vertexId, labelId ); - labelId = label.Index(); - - ESSENTIAL_ASSERT ( graph_.VertexExists( vertexId ) ); - - if ( !isVertexInSubgraph[vertexId] ) { - isVertexInSubgraph[vertexId] = true; - vertices.push_back(vertexId); - } - - if ( label.PreviousVertex() != Const::NONE ) - { // @todo multiple edges? It would be easier if the labels stored edges - Types::edgeId edge = graph_.EdgeId ( vertexId, label.PreviousVertex() ); - if ( edge == Const::NONE ) - { - edge = graph_.EdgeId ( label.PreviousVertex(), vertexId ); - ESSENTIAL_ASSERT( edge != Const::NONE ); - } + Types::labelId labelId = optLabel.Index(); + TVertexId vertexId = optLabel.Vertex(); - if (!isEdgeInSubgraph[edge]) + do { - isEdgeInSubgraph[edge] = true; - edges.push_back(edge); - } + TLabel const & label = LabelAt( vertexId, labelId ); + labelId = label.Index(); + + ESSENTIAL_ASSERT ( graph_.VertexExists( vertexId ) ); + + if ( !isVertexInSubgraph[vertexId] ) + { + isVertexInSubgraph[vertexId] = true; + vertices.push_back(vertexId); + } + + if ( label.PreviousVertex() != Const::NONE ) + { // @todo multiple edges? It would be easier if the labels stored edges + Types::edgeId edge = graph_.EdgeId ( vertexId, label.PreviousVertex() ); + if ( edge == Const::NONE ) + { + edge = graph_.EdgeId ( label.PreviousVertex(), vertexId ); + ESSENTIAL_ASSERT( edge != Const::NONE ); + } + + if (!isEdgeInSubgraph[edge]) + { + isEdgeInSubgraph[edge] = true; + edges.push_back(edge); + } + } + + vertexId = label.PreviousVertex(); + labelId = label.PreviousLabel(); + + } while ( labelId != Const::NONE + && vertexId != Const::NONE ); } - - vertexId = label.PreviousVertex(); - labelId = label.PreviousLabel(); - - } while ( labelId != Const::NONE - && vertexId != Const::NONE ); - }); + ); resultSubgraph = Subgraph(&graph_, vertices, edges); return result; @@ -476,38 +477,40 @@ class DominatingThetaPath final { Types::count numberOfOptimalLabels = LabelSetAt(target).Optima().size(); // Divide by this value Types::real weightOfPath = static_cast(1) / numberOfOptimalLabels; - labelSets_[target].template for_all_optima( [&]( TLabel const & optLabel ) - { - Types::labelId labelId = optLabel.Index(); - TVertexId vertexId = target; + labelSets_[target].template for_all_optima( + [&]( TLabel const & optLabel ) + { + Types::labelId labelId = optLabel.Index(); + TVertexId vertexId = target; - do { - TLabel & label = LabelAt( vertexId, labelId ); - labelId = label.Index(); + do { + TLabel & label = LabelAt( vertexId, labelId ); + labelId = label.Index(); - if ( ( label.PreviousLabel() == Const::NONE ) - || ( label.PreviousVertex() == Const::NONE ) - || ( vertexId == Const::NONE ) - ) break; // Label is already on path + if ( ( label.PreviousLabel() == Const::NONE ) + || ( label.PreviousVertex() == Const::NONE ) + || ( vertexId == Const::NONE ) + ) break; // Label is already on path - // Increase number of paths at "edgeId" - TEdgeId edgeId = ( graph_.EdgeId( label.PreviousVertex(), vertexId ) != Const::NONE ) - ? graph_.EdgeId( label.PreviousVertex(), vertexId ) - : graph_.EdgeId( vertexId, label.PreviousVertex() ); + // Increase number of paths at "edgeId" + TEdgeId edgeId = ( graph_.EdgeId( label.PreviousVertex(), vertexId ) != Const::NONE ) + ? graph_.EdgeId( label.PreviousVertex(), vertexId ) + : graph_.EdgeId( vertexId, label.PreviousVertex() ); - ESSENTIAL_ASSERT ( edgeId != Const::NONE ); + ESSENTIAL_ASSERT ( edgeId != Const::NONE ); - ++numberOfPathsPerEdge[edgeId]; + ++numberOfPathsPerEdge[edgeId]; - relativeNumberOfPathsPerEdge[edgeId] += weightOfPath; + relativeNumberOfPathsPerEdge[edgeId] += weightOfPath; - // Extract next label on the DTP - vertexId = label.PreviousVertex(); - labelId = label.PreviousLabel(); + // Extract next label on the DTP + vertexId = label.PreviousVertex(); + labelId = label.PreviousLabel(); - } while ( labelId != Const::NONE - && vertexId != Const::NONE ); - }); // For all labels in DTP at target vertex + } while ( labelId != Const::NONE + && vertexId != Const::NONE ); + } + ); // For all labels in DTP at target vertex } ///@} From d88e047417d49cf74a77c13b078e8b75679cc115 Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Sat, 6 Jan 2024 03:41:06 -0800 Subject: [PATCH 5/8] Update test path --- tests/Algorithms/PathFinding/TestDominatingThetaPath.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Algorithms/PathFinding/TestDominatingThetaPath.hpp b/tests/Algorithms/PathFinding/TestDominatingThetaPath.hpp index e522a838..8a44cd49 100644 --- a/tests/Algorithms/PathFinding/TestDominatingThetaPath.hpp +++ b/tests/Algorithms/PathFinding/TestDominatingThetaPath.hpp @@ -140,8 +140,8 @@ class TestDTPPowerGridSpecific : public TestDominatingThetaPath { TPowerGrid network_; TPowerGrid const & constNetwork_ = network_; - Types::string const TestCaseAcm2018MtsfFigure4a_ = "../../framework/tests/Data/PowerGrids/ieee_2018_acm_eEnergy_MTSF_Figure4a.m"; - Types::string const TestCaseAcm2018MtsfFigure4b_ = "../../framework/tests/Data/PowerGrids/ieee_2018_acm_eEnergy_MTSF_Figure4b.m"; + Types::string const TestCaseAcm2018MtsfFigure4a_ = "../../tests/Data/PowerGrids/ieee_2018_acm_eEnergy_MTSF_Figure4a.m"; + Types::string const TestCaseAcm2018MtsfFigure4b_ = "../../tests/Data/PowerGrids/ieee_2018_acm_eEnergy_MTSF_Figure4b.m"; Types::vertexId const source_ = 0; TDtpTheta dtpTheta_; }; From fc0a9453a3e99a10ddcc24b004d182fbbbb03b32 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:41:15 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- include/Algorithms/PathFinding/DominatingThetaPath.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Algorithms/PathFinding/DominatingThetaPath.hpp b/include/Algorithms/PathFinding/DominatingThetaPath.hpp index f1f0ccd1..eddf3f25 100644 --- a/include/Algorithms/PathFinding/DominatingThetaPath.hpp +++ b/include/Algorithms/PathFinding/DominatingThetaPath.hpp @@ -477,7 +477,7 @@ class DominatingThetaPath final { Types::count numberOfOptimalLabels = LabelSetAt(target).Optima().size(); // Divide by this value Types::real weightOfPath = static_cast(1) / numberOfOptimalLabels; - labelSets_[target].template for_all_optima( + labelSets_[target].template for_all_optima( [&]( TLabel const & optLabel ) { Types::labelId labelId = optLabel.Index(); From 2eb5e44f593637293b3e85f4671b0279f3f89546 Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Sun, 14 Jan 2024 08:27:30 -0800 Subject: [PATCH 7/8] Add header for windows 32 and 64 Changes to be committed: modified: include/Auxiliary/Timer.hpp --- include/Auxiliary/Timer.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/Auxiliary/Timer.hpp b/include/Auxiliary/Timer.hpp index 73165f9f..40090245 100644 --- a/include/Auxiliary/Timer.hpp +++ b/include/Auxiliary/Timer.hpp @@ -21,13 +21,17 @@ // Linux operation systems such as Debian, Ubuntu, Gentoo, Fedora, openSUSE, RedHat, or Centos #if defined (__linux__) - #include - #include + #include + #include // Apple and iOS #elif defined(__APPLE__) && defined(__MACH__) - #include - #include - #include + #include + #include + #include +#elif defined (_WIN32) || defined (_WIN64) + #include + #include + #include #endif namespace egoa::Auxiliary { From 1fceb2e4542fbdc763e1aa365a7608aba569a84e Mon Sep 17 00:00:00 2001 From: Franziska Wegner Date: Sun, 14 Jan 2024 12:24:59 -0800 Subject: [PATCH 8/8] Remove non windows include sys/time.h Changes to be committed: modified: include/Auxiliary/Timer.hpp --- include/Auxiliary/Timer.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Auxiliary/Timer.hpp b/include/Auxiliary/Timer.hpp index 40090245..274446f3 100644 --- a/include/Auxiliary/Timer.hpp +++ b/include/Auxiliary/Timer.hpp @@ -19,18 +19,18 @@ #include "Constants.hpp" #include "Types.hpp" -// Linux operation systems such as Debian, Ubuntu, Gentoo, Fedora, openSUSE, RedHat, or Centos +// Linux operation systems such as Debian, Ubuntu, Gentoo, Fedora, openSUSE, RedHat, or Centos. #if defined (__linux__) #include #include -// Apple and iOS +// Apple and iOS. #elif defined(__APPLE__) && defined(__MACH__) #include #include #include +// Windows. #elif defined (_WIN32) || defined (_WIN64) #include - #include #include #endif