LCOV - code coverage report
Current view: top level - app/test/src/problem - cases.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 58 58 100.0 %
Date: 2023-08-17 16:45:52 Functions: 8 8 100.0 %

          Line data    Source code
       1             : #include "test/problem/cases.hpp"
       2             : 
       3             : #include <cmath>
       4             : 
       5             : #include "Static/Demand.hpp"
       6             : #include "Static/supply/CustomNetwork.hpp"
       7             : 
       8             : using namespace std;
       9             : 
      10           4 : Static::Network *getStaticNetworkTestCase1() {
      11           4 :     Static::CustomNetwork *network = new Static::CustomNetwork();
      12             : 
      13             :     // clang-format off
      14           4 :     network->addNode(1);
      15           4 :     network->addNode(2);
      16           4 :     network->addNode(3);
      17           8 :     network->addEdge(1, 1, 2,
      18           7 :         [](Static::Flow x){ return x*x + 2; },
      19          62 :         [](Static::Flow x){ return x*x*x/3.0 + x*2.0; }
      20             :     );
      21           8 :     network->addEdge(2, 1, 2,
      22           7 :         [](Static::Flow x){ return 3*x + 1; },
      23          63 :         [](Static::Flow x){ return (3.0/2.0) * x*x + x; }
      24             :     );
      25           8 :     network->addEdge(3, 2, 3,
      26           7 :         [](Static::Flow x){ return   x + 3; },
      27          63 :         [](Static::Flow x){ return 0.5 * x * x + 3.0*x; }
      28             :     );
      29             :     // clang-format on
      30             : 
      31           4 :     return network;
      32             : }
      33             : 
      34           2 : pair<Static::Network *, Static::Demand *> getStaticProblemTestCase1() {
      35           2 :     Static::Network *network = getStaticNetworkTestCase1();
      36             : 
      37           2 :     Static::Demand *demand = new Static::Demand();
      38           2 :     demand->addDemand(1, 3, 4);
      39             : 
      40           2 :     return {network, demand};
      41             : }
      42             : 
      43           1 : Static::Network *getStaticNetworkTestCase2() {
      44           1 :     const double alpha = 0.15, beta = 4.0;
      45           1 :     const double c1 = 4400.0, c2 = 2200.0;
      46           1 :     const double t1 = 20.0, t2 = 10.0;
      47             : 
      48           1 :     Static::CustomNetwork *network = new Static::CustomNetwork();
      49             : 
      50             :     // clang-format off
      51           1 :     network->addNode(1);
      52           1 :     network->addNode(2);
      53           2 :     network->addEdge(1, 1, 2,
      54           5 :         [alpha, beta, t1, c1](double x) { return t1 * (1.0 + alpha * pow(x / c1, beta)); },
      55          62 :         [alpha, beta, t1, c1](double x) { return t1 * x * ((alpha / (beta + 1)) * pow(x / c1, beta) + 1); }
      56             :     );
      57           2 :     network->addEdge(2, 1, 2,
      58           5 :         [alpha, beta, t2, c2](double x) { return t2 * (1.0 + alpha * pow(x / c2, beta)); },
      59          63 :         [alpha, beta, t2, c2](double x) { return t2 * x * ((alpha / (beta + 1)) * pow(x / c2, beta) + 1); }
      60             :     );
      61             :     // clang-format on
      62             : 
      63           1 :     return network;
      64             : }
      65             : 
      66           1 : pair<Static::Network *, Static::Demand *> getStaticProblemTestCase2() {
      67           1 :     Static::Network *network = getStaticNetworkTestCase2();
      68             : 
      69           1 :     Static::Demand *demand = new Static::Demand();
      70           1 :     demand->addDemand(1, 2, 7000);
      71             : 
      72           1 :     return {network, demand};
      73             : }
      74             : 
      75           1 : Static::Network *getStaticNetworkTestCase3() {
      76           1 :     Static::CustomNetwork *network = new Static::CustomNetwork();
      77             : 
      78           1 :     const double alpha = 0.15, beta = 4.0;
      79           1 :     const double t1 = 20.0, t2 = 10.0;
      80           1 :     const double c1 = 4400.0, c2 = 2200.0;
      81             : 
      82             :     // clang-format off
      83           1 :     network->addNode(1);
      84           1 :     network->addNode(2);
      85           2 :     network->addEdge(1, 1, 2,
      86             :         // [alpha, beta, t1, c1](double x){ return t1*(1.0 + alpha * (x/c1 + beta) * pow(x/c1, beta-1.0)); },
      87           3 :         [alpha, beta, t1, c1](double x) { return t1 * (1.0 + alpha * pow(x / c1, beta)); },
      88          31 :         [alpha, beta, t1, c1](double x) { return x * t1 * (1.0 + alpha * pow(x / c1, beta)); }
      89             :     );
      90           2 :     network->addEdge(2, 1, 2,
      91             :         // [alpha, beta, t2, c2](double x){ return t2*(1.0 + alpha * (x/c2 + beta) * pow(x/c2, beta-1.0)); },
      92           3 :         [alpha, beta, t2, c2](double x) { return t2 * (1.0 + alpha * pow(x / c2, beta)); },
      93          32 :         [alpha, beta, t2, c2](double x) { return x * t2 * (1.0 + alpha * pow(x / c2, beta)); }
      94             :     );
      95             :     // clang-format on
      96             : 
      97           1 :     return network;
      98             : }
      99             : 
     100           1 : pair<Static::Network *, Static::Demand *> getStaticProblemTestCase3() {
     101           1 :     Static::Network *network = getStaticNetworkTestCase3();
     102             : 
     103           1 :     Static::Demand *demand = new Static::Demand();
     104           1 :     demand->addDemand(1, 2, 7000);
     105             : 
     106           1 :     return {network, demand};
     107             : }

Generated by: LCOV version 1.14