LCOV - code coverage report
Current view: top level - app/src/Static/supply - CustomNetwork.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 31 31 100.0 %
Date: 2023-08-17 16:45:52 Functions: 10 10 100.0 %

          Line data    Source code
       1             : #include "Static/supply/CustomNetwork.hpp"
       2             : 
       3             : #include <cstdio>
       4             : #include <fstream>
       5             : #include <iostream>
       6             : 
       7             : #pragma GCC diagnostic push
       8             : #pragma GCC diagnostic ignored "-Wswitch-default"
       9             : #pragma GCC diagnostic ignored "-Wunused-parameter"
      10             : #include <rapidxml.hpp>
      11             : #include <rapidxml_print.hpp>
      12             : #pragma GCC diagnostic pop
      13             : 
      14             : #include "Static/SUMOAdapter.hpp"
      15             : #include "Static/Solution.hpp"
      16             : 
      17             : using namespace std;
      18             : using namespace rapidxml;
      19             : using namespace Static;
      20             : 
      21             : typedef CustomNetwork::Node Node;
      22             : typedef CustomNetwork::Edge Edge;
      23             : 
      24          16 : CustomNetwork::Edge::Edge(ID id_, Node u_, Node v_, CostFunction f_, CostFunction fGlobal_):
      25             :     Network::Edge(id_, u_, v_),
      26             :     cost(f_),
      27          16 :     costGlobal(fGlobal_) {}
      28             : 
      29          37 : Time CustomNetwork::Edge::calculateCost(const Solution &x) const {
      30          37 :     Flow f = x.getFlowInEdge(id);
      31          37 :     return cost(f);
      32             : }
      33             : 
      34         376 : Time CustomNetwork::Edge::calculateCostGlobal(const Solution &x) const {
      35         376 :     Flow f = x.getFlowInEdge(id);
      36         376 :     return costGlobal(f);
      37             : }
      38             : 
      39          16 : void CustomNetwork::addNode(Node u) {
      40          16 :     adj[u];
      41          16 : }
      42             : 
      43          16 : void CustomNetwork::addEdge(Edge::ID id, Node u, Node v, CostFunction f, CostFunction fGlobal) {
      44          32 :     Edge *e = new Edge(id, u, v, f, fGlobal);
      45          16 :     adj[u].push_back(e);
      46          16 :     edges[id] = e;
      47          16 : }
      48             : 
      49          11 : vector<Node> CustomNetwork::getNodes() const {
      50          11 :     vector<Node> ret;
      51          11 :     ret.reserve(adj.size());
      52          39 :     for(const auto &[u, _]: adj)
      53          28 :         ret.push_back(u);
      54          11 :     return ret;
      55             : }
      56             : 
      57         388 : Edge &CustomNetwork::getEdge(Edge::ID e) const {
      58         388 :     return *edges.at(e);
      59             : }
      60             : 
      61          25 : vector<Network::Edge *> CustomNetwork::getAdj(Node u) const {
      62          25 :     const auto &v = adj.at(u);
      63          25 :     return vector<Network::Edge *>(v.begin(), v.end());
      64             : }
      65             : 
      66          12 : CustomNetwork::~CustomNetwork() {
      67          22 :     for(const auto &p: edges)
      68          16 :         delete p.second;
      69          12 : }

Generated by: LCOV version 1.14