src/buildings/test/buildings-shadowing-test.cc
author Marco Miozzo <marco.miozzo@cttc.es>
Mon, 05 Mar 2012 10:51:08 +0100
changeset 8661 e7c0de1585b0
parent 8643 3c7d21485f21
child 8769 292e9e8345cf
permissions -rw-r--r--
Update Buildings module tests with new interface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     2
/*
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     3
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     4
*
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     5
* This program is free software; you can redistribute it and/or modify
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     6
* it under the terms of the GNU General Public License version 2 as
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     7
* published by the Free Software Foundation;
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     8
*
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     9
* This program is distributed in the hope that it will be useful,
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    12
* GNU General Public License for more details.
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    13
*
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    14
* You should have received a copy of the GNU General Public License
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    15
* along with this program; if not, write to the Free Software
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    17
*
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    18
* Author: Marco Miozzo <marco.miozzo@cttc.es>
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    19
*/
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    20
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    21
#include "ns3/simulator.h"
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    22
#include "ns3/log.h"
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    23
#include "ns3/buildings-shadowing-test.h"
8643
3c7d21485f21 Update BuildingPropagationLossModel for working in Hybrid and Simple modes
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8343
diff changeset
    24
#include <ns3/hybrid-buildings-propagation-loss-model.h>
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    25
#include "ns3/string.h"
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    26
#include "ns3/double.h"
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    27
#include <ns3/building.h>
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    28
#include <ns3/enum.h>
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    29
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    30
NS_LOG_COMPONENT_DEFINE ("BuildingsShadowingTest");
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    31
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    32
using namespace ns3;
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    33
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    34
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    35
/**
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    36
* Test 1.1 Shadowing compound test
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    37
*/
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    38
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    39
/**
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    40
* This TestSuite tests the shadowing model of BuildingPathlossModel 
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    41
* by reproducing several communication scenarios 
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    42
*/
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    43
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    44
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    45
BuildingsShadowingTestSuite::BuildingsShadowingTestSuite ()
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    46
  : TestSuite ("buildings-shadowing-test", SYSTEM)
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    47
{
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    48
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    49
  LogComponentEnable ("BuildingsShadowingTest", LOG_LEVEL_ALL);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    50
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    51
  // Test #1 Outdoor Model
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
    52
  AddTestCase (new BuildingsShadowingTestCase (1, 2, 148.86, 7.0, "Outdoor Shadowing"));
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    53
8223
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
    54
  // Test #2 Indoor model
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
    55
  AddTestCase (new BuildingsShadowingTestCase (5, 6, 88.5724, 8.0, "Indoor Shadowing"));
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    56
8223
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
    57
  // Test #3 Indoor -> Outdoor
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    58
  AddTestCase (new BuildingsShadowingTestCase (9, 10, 85.0012, 8.6, "Indoor -> Outdoor Shadowing"));
8228
d8694ee58788 Test on shadowing finalized and passed
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8223
diff changeset
    59
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    60
}
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    61
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    62
static BuildingsShadowingTestSuite buildingsShadowingTestSuite;
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    63
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    64
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    65
/**
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    66
* TestCase
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    67
*/
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    68
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
    69
BuildingsShadowingTestCase::BuildingsShadowingTestCase ( uint16_t m1, uint16_t m2, double refValue, double sigmaRef, std::string name)
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    70
  : TestCase ("SHADOWING calculation: " + name),
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
    71
    m_mobilityModelIndex1 (m1),
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
    72
    m_mobilityModelIndex2 (m2),
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    73
    m_lossRef (refValue),
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    74
    m_sigmaRef (sigmaRef)
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    75
{
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    76
}
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    77
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    78
BuildingsShadowingTestCase::~BuildingsShadowingTestCase ()
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    79
{
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    80
}
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    81
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    82
void
8248
986f7db9f056 Move Buildings related class to buildings folder
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8228
diff changeset
    83
BuildingsShadowingTestCase::DoRun (void)
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    84
{
8223
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
    85
//     LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
    86
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    87
  //   LogComponentEnable ("LteEnbRrc", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    88
  //   LogComponentEnable ("LteUeRrc", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    89
  //   LogComponentEnable ("LteEnbMac", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    90
  //   LogComponentEnable ("LteUeMac", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    91
  //   LogComponentEnable ("LteRlc", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    92
  //   LogComponentEnable ("RrPacketScheduler", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    93
  // 
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    94
  //   LogComponentEnable ("LtePhy", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    95
  //   LogComponentEnable ("LteEnbPhy", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    96
  //   LogComponentEnable ("LteUePhy", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    97
  // 
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    98
  //   LogComponentEnable ("LteSpectrumPhy", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    99
  //   LogComponentEnable ("LteInterference", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   100
  //   LogComponentEnable ("LteSinrChunkProcessor", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   101
  // 
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   102
  //   LogComponentEnable ("LtePropagationLossModel", logLevel);
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   103
  //   LogComponentEnable ("LossModel", logLevel);
8223
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   104
//     LogComponentEnable ("ShadowingLossModel", logLevel);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   105
//   LogComponentEnable ("PenetrationLossModel", logLevel);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   106
//   LogComponentEnable ("MultipathLossModel", logLevel);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   107
//   LogComponentEnable ("PathLossModel", logLevel);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   108
//
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   109
//   LogComponentEnable ("LteNetDevice", logLevel);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   110
//   LogComponentEnable ("LteUeNetDevice", logLevel);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   111
//   LogComponentEnable ("LteEnbNetDevice", logLevel);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   112
8223
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   113
//   LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   114
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   115
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   116
  Ptr<MobilityModel> mma = CreateMobilityModel (m_mobilityModelIndex1);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   117
  Ptr<MobilityModel> mmb = CreateMobilityModel (m_mobilityModelIndex2);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   118
8223
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   119
  std::vector<double> loss;
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   120
  double sum = 0.0;
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   121
  double sumSquared = 0.0;
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   122
  int samples = 10000;
eedea1c39ddd Shadowing test updated -> passed.
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8221
diff changeset
   123
  for (int i = 0; i < samples; i++)
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   124
    {
8643
3c7d21485f21 Update BuildingPropagationLossModel for working in Hybrid and Simple modes
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8343
diff changeset
   125
      Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> ();
3c7d21485f21 Update BuildingPropagationLossModel for working in Hybrid and Simple modes
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8343
diff changeset
   126
      loss.push_back (propagationLossModel->DoCalcRxPower (0.0, mma, mmb) + m_lossRef);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   127
      sum += loss.at (loss.size () - 1);
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   128
      sumSquared += (loss.at (loss.size () - 1) * loss.at (loss.size () - 1));
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   129
    }
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   130
  double mean = sum / samples;
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   131
  double sigma = sqrt (sumSquared / samples - (mean * mean));
8228
d8694ee58788 Test on shadowing finalized and passed
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8223
diff changeset
   132
  // test whether the distribution falls in the 99% confidence interval, as expected with a nornal distribution
d8694ee58788 Test on shadowing finalized and passed
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8223
diff changeset
   133
  double ci = (2.575829303549 * sigma) / sqrt (samples);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   134
8228
d8694ee58788 Test on shadowing finalized and passed
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8223
diff changeset
   135
  NS_LOG_INFO ("Mean from simulation " << mean << ", sigma " << sigma << ", reference value " << m_sigmaRef << ", CI(99%) " << ci);
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   136
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   137
  NS_TEST_ASSERT_MSG_EQ_TOL (fabs (mean), 0.0, ci, "Wrong shadowing distribution !");
8343
eedd3a7c4c1b buildings-shadowing-test now passing valgrind test
Nicola Baldo <nbaldo@cttc.es>
parents: 8332
diff changeset
   138
  Simulator::Destroy ();
8221
2cf1345bb23f add test on shadowing (draft version)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   139
}
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   140
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   141
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   142
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   143
Ptr<MobilityModel>
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   144
BuildingsShadowingTestCase::CreateMobilityModel (uint16_t index)
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   145
{
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   146
  /*
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   147
   * The purpose of this method is to defer the creation of the
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   148
   * MobilityModel instances to when DoRun() is called. In a previous
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   149
   * version, MobilityModel instances where created directly in the
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   150
   * constructor of the test suite, which caused subtle bugs due to
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   151
   * "static initialization order fiasco". An example of such a subtle
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   152
   * bug is that logging via NS_LOG failed for some modules.
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   153
   * 
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   154
   */
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   155
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   156
  double distance = 2000;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   157
  double hm = 1;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   158
  double hb = 30;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   159
  Ptr<BuildingsMobilityModel> mm1 = CreateObject<BuildingsMobilityModel> ();
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   160
  mm1->SetPosition (Vector (0.0, 0.0, hb));
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   161
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   162
  Ptr<BuildingsMobilityModel> mm2 = CreateObject<BuildingsMobilityModel> ();
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   163
  mm2->SetPosition (Vector (distance, 0.0, hm));
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   164
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   165
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   166
  distance = 30;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   167
  double henbHeight = 10.0;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   168
  Ptr<BuildingsMobilityModel> mm5 = CreateObject<BuildingsMobilityModel> ();
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   169
  mm5->SetPosition (Vector (0.0, 0.0, henbHeight));
8661
e7c0de1585b0 Update Buildings module tests with new interface
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8643
diff changeset
   170
  static Ptr<Building> building1 = Create<Building> ();
e7c0de1585b0 Update Buildings module tests with new interface
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8643
diff changeset
   171
  building1->SetBoundaries (Box (0.0, 10.0, 0.0, 10.0, 0.0, 20.0 /*, 1, 1, 1*/));
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   172
  building1->SetBuildingType (Building::Residential);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   173
  building1->SetExtWallsType (Building::ConcreteWithWindows);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   174
  mm5->SetIndoor (building1);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   175
  Ptr<BuildingsMobilityModel> mm6 = CreateObject<BuildingsMobilityModel> ();
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   176
  mm6->SetPosition (Vector (distance, 0.0, hm));
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   177
  mm6->SetIndoor (building1);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   178
  mm6->SetFloorNumber (2);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   179
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   180
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   181
  distance = 100;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   182
  Ptr<BuildingsMobilityModel> mm9 = CreateObject<BuildingsMobilityModel> ();
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   183
  mm9->SetPosition (Vector (0.0, 0.0, henbHeight));
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   184
  mm9->SetIndoor (building1);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   185
  mm9->SetFloorNumber (2);
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   186
  Ptr<BuildingsMobilityModel> mm10 = CreateObject<BuildingsMobilityModel> ();
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   187
  mm10->SetPosition (Vector (distance, 0.0, hm));
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   188
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   189
  switch (index)
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   190
    {
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   191
    case 1:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   192
      return mm1;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   193
      break;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   194
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   195
    case 2:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   196
      return mm2;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   197
      break;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   198
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   199
    case 5:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   200
      return mm5;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   201
      break;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   202
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   203
    case 6:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   204
      return mm6;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   205
      break;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   206
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   207
    case 9:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   208
      return mm9;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   209
      break;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   210
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   211
    case 10:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   212
      return mm10;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   213
      break;
8332
c6d3c7862cfb Style fixed in buildings module
mmiozzo
parents: 8318
diff changeset
   214
8318
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   215
    default:
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   216
      return 0;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   217
      break;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   218
    }
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   219
  return 0;
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   220
368cccf883a6 fixes bug LENA-174: NS_LOG does not work for some log component with test-runner
Nicola Baldo <nbaldo@cttc.es>
parents: 8317
diff changeset
   221
}