diff --git a/include/Algorithms/PathFinding/DominatingThetaPath.hpp b/include/Algorithms/PathFinding/DominatingThetaPath.hpp index 15d44d8c..eddf3f25 100644 --- a/include/Algorithms/PathFinding/DominatingThetaPath.hpp +++ b/include/Algorithms/PathFinding/DominatingThetaPath.hpp @@ -200,47 +200,48 @@ 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(); - 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; @@ -264,7 +265,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 +410,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(); @@ -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 } ///@} diff --git a/include/Auxiliary/Timer.hpp b/include/Auxiliary/Timer.hpp index 73165f9f..274446f3 100644 --- a/include/Auxiliary/Timer.hpp +++ b/include/Auxiliary/Timer.hpp @@ -19,15 +19,19 @@ #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 + #include + #include +// Apple and iOS. #elif defined(__APPLE__) && defined(__MACH__) - #include - #include - #include + #include + #include + #include +// Windows. +#elif defined (_WIN32) || defined (_WIN64) + #include + #include #endif namespace egoa::Auxiliary { 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_; }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9760a39a..c6332a4d 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)