LCOV - code coverage report
Current view: top level - app/src/data/SUMO - EdgeData_Loader.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 37 0.0 %
Date: 2023-08-17 16:45:52 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include <stdexcept>
       2             : 
       3             : #include "Static/Solution.hpp"
       4             : #include "Static/supply/BPRNetwork.hpp"
       5             : #include "data/SUMO/EdgeData.hpp"
       6             : 
       7             : using namespace std;
       8             : using namespace SUMO;
       9             : 
      10             : typedef Static::Flow Flow;
      11             : 
      12             : // clang-format off
      13           0 : EdgeData EdgeData::Loader<
      14             :     const NetworkTAZs&,
      15             :     const Static::BPRNetwork&,
      16             :     const Static::Solution&,
      17             :     const Static::SUMOAdapter&
      18             : >::load(
      19             :     const NetworkTAZs &sumo,
      20             :     const Static::BPRNetwork &network,
      21             :     const Static::Solution &x,
      22             :     const Static::SUMOAdapter &adapter
      23             : ) {
      24             :     // clang-format on
      25             : 
      26           0 :     EdgeData  ret;
      27           0 :     Interval &interval = ret.createInterval(0, 3600);
      28             : 
      29           0 :     const vector<SUMO::Network::Edge::ID> &sumoEdges = adapter.getSumoEdges();
      30             : 
      31           0 :     for(const SUMO::Network::Edge::ID &sumoEdgeID: sumoEdges) {
      32           0 :         const Static::BPRNetwork::Edge::ID eID = adapter.toEdge(sumoEdgeID);
      33           0 :         const Static::BPRNetwork::Edge    &e   = network.getEdge(eID);
      34             : 
      35           0 :         const Static::BPRNetwork::Node v = adapter.toNodes(sumoEdgeID).second;
      36             : 
      37           0 :         const double N = (double)sumo.network.getEdge(sumoEdgeID).lanes.size();
      38             : 
      39           0 :         const Flow cap = e.c;
      40           0 :         const Flow f   = x.getFlowInEdge(eID);
      41           0 :         const Time c   = e.calculateCongestion(x);
      42             : 
      43           0 :         double t0  = e.calculateCost(Static::SolutionBase());
      44           0 :         double fft = f * t0, t = f * e.calculateCost(x);
      45           0 :         for(const Static::Network::Edge *edge: network.getAdj(v)) {
      46           0 :             Flow f_ = x.getFlowInEdge(edge->id);
      47           0 :             fft += f_ * edge->calculateCost(Static::SolutionBase());
      48           0 :             t += f_ * edge->calculateCost(x);
      49             :         }
      50             : 
      51           0 :         Time d;
      52           0 :         if(f <= 0.0) {
      53           0 :             fft = t = t0;
      54           0 :             d       = 1.0;
      55             :         } else {
      56           0 :             fft /= f;
      57           0 :             t /= f;
      58           0 :             d = t / fft;
      59             :         }
      60             : 
      61           0 :         Interval::Edge &edge = interval.createEdge(sumoEdgeID);
      62             : 
      63             :         // clang-format off
      64           0 :         edge.attributes.setAttribute("capacity"         , cap);
      65           0 :         edge.attributes.setAttribute("capacityPerLane"  , cap / N);
      66           0 :         edge.attributes.setAttribute("flow"             , f);
      67           0 :         edge.attributes.setAttribute("flowPerLane"      , f / N);
      68           0 :         edge.attributes.setAttribute("congestion"       , c);
      69           0 :         edge.attributes.setAttribute("t0"               , t0);
      70           0 :         edge.attributes.setAttribute("fft"              , fft);
      71           0 :         edge.attributes.setAttribute("traveltime"       , t);
      72           0 :         edge.attributes.setAttribute("delay"            , d);
      73           0 :         edge.attributes.setAttribute("log_delay"        , log2(d));
      74             :         // clang-format on
      75             :     }
      76             : 
      77           0 :     return ret;
      78             : }

Generated by: LCOV version 1.14