sbaldu / DynamicalSystemFramework

Framework for modelling dynamical complex systems

Home Page:https://sbaldu.github.io/DynamicalSystemFramework/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UpdatePaths is not correctly setting paths

Grufoony opened this issue · comments

I noticed utilizing the framework that some rows of the updatePaths function are empty...
In particular, this test fails on the preview branch:

SUBCASE("updatePaths - equal length") {
    /// GIVEN: a dynamics object
    /// WHEN: we update the paths
    /// THEN: the paths are updated correctly
    Street s1{0, 1, 5., std::make_pair(0, 1)};
    Street s2{1, 1, 5., std::make_pair(1, 2)};
    Street s3{2, 1, 5., std::make_pair(0, 3)};
    Street s4{3, 1, 5., std::make_pair(3, 2)};
    Graph graph2;
    graph2.addStreets(s1, s2, s3, s4);
    graph2.buildAdj();
    Dynamics dynamics{graph2};
    Itineary itinerary{0, 0, 2};
    dynamics.addItinerary(itinerary);
    dynamics.updatePaths();
    CHECK_EQ(dynamics.itineraries().size(), 1);
    CHECK_EQ(dynamics.itineraries().at(0)->path().size(), 4);
    CHECK_EQ(dynamics.itineraries().at(0)->path().getRowDim(), 4);
    CHECK_EQ(dynamics.itineraries().at(0)->path().getColDim(), 4);
    CHECK(dynamics.itineraries().at(0)->path()(0, 1));
    CHECK(dynamics.itineraries().at(0)->path()(1, 2));
    CHECK(dynamics.itineraries().at(0)->path()(0, 3));
    CHECK(dynamics.itineraries().at(0)->path()(3, 2));
    for (auto const& it : dynamics.itineraries()) {
      auto const& path = it.second->path();
      for (uint16_t i{0}; i < path.getColDim(); ++i) {
        CHECK(path.getRow(i).size());
      }
    }
  }

with message

TEST CASE:  Dynamics
  updatePaths - equal length

/home/grufoony/dsf/test/Test_dynamics.cpp:158: ERROR: CHECK( path.getRow(i).size() ) is NOT correct!
  values: CHECK( 0 )

This is weird: the operator() seems to work fine while the getRow() function seems to be broken... maybe this could be also a SparseMatrix problem.
I'm going to investigate.

Confirmed

Ok I think I got the point.
Many itineraries may have the same path, because the path is uniquely defined by the destination of the trip.
For this reason, it cannot be a unique_ptr.