remove static random variable from buildings module
This commit is contained in:
@@ -34,26 +34,17 @@
|
||||
NS_LOG_COMPONENT_DEFINE ("BuildingsPropagationLossModel");
|
||||
|
||||
namespace ns3 {
|
||||
Ptr<NormalRandomVariable> BuildingsPropagationLossModel::ShadowingLoss::m_randVariable = CreateObject<NormalRandomVariable> ();
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (BuildingsPropagationLossModel);
|
||||
|
||||
|
||||
BuildingsPropagationLossModel::ShadowingLoss::ShadowingLoss ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BuildingsPropagationLossModel::ShadowingLoss::ShadowingLoss (double mean, double sigma, Ptr<MobilityModel> receiver)
|
||||
: m_receiver (receiver)
|
||||
BuildingsPropagationLossModel::ShadowingLoss::ShadowingLoss (double shadowingValue, Ptr<MobilityModel> receiver)
|
||||
: m_shadowingValue (shadowingValue), m_receiver (receiver)
|
||||
{
|
||||
// NormalRandomVariable class wants mean and variance (sigma is a
|
||||
// standard deviation)
|
||||
m_randVariable->SetAttribute ("Mean", DoubleValue (mean));
|
||||
m_randVariable->SetAttribute ("Variance", DoubleValue (sigma * sigma));
|
||||
|
||||
m_shadowingValue = m_randVariable->GetValue ();
|
||||
NS_LOG_INFO (this << " New Shadowing: sigma " << sigma << " value " << m_shadowingValue);
|
||||
NS_LOG_INFO (this << " New Shadowing value " << m_shadowingValue);
|
||||
}
|
||||
|
||||
double
|
||||
@@ -68,13 +59,6 @@ BuildingsPropagationLossModel::ShadowingLoss::GetReceiver () const
|
||||
return m_receiver;
|
||||
}
|
||||
|
||||
int64_t
|
||||
BuildingsPropagationLossModel::ShadowingLoss::AssignStreams (int64_t stream)
|
||||
{
|
||||
m_randVariable->SetStream (stream);
|
||||
return 1;
|
||||
}
|
||||
|
||||
TypeId
|
||||
BuildingsPropagationLossModel::GetTypeId (void)
|
||||
{
|
||||
@@ -110,6 +94,10 @@ BuildingsPropagationLossModel::GetTypeId (void)
|
||||
return tid;
|
||||
}
|
||||
|
||||
BuildingsPropagationLossModel::BuildingsPropagationLossModel ()
|
||||
{
|
||||
m_randVariable = CreateObject<NormalRandomVariable> ();
|
||||
}
|
||||
|
||||
double
|
||||
BuildingsPropagationLossModel::ExternalWallLoss (Ptr<BuildingsMobilityModel> a) const
|
||||
@@ -176,7 +164,9 @@ const
|
||||
{
|
||||
double sigma = EvaluateSigma (a1, b1);
|
||||
// side effect: will create new entry
|
||||
ait->second[b] = ShadowingLoss (0.0, sigma, b);
|
||||
// sigma is standard deviation, not variance
|
||||
double shadowingValue = m_randVariable->GetValue (0.0, (sigma*sigma));
|
||||
ait->second[b] = ShadowingLoss (shadowingValue, b);
|
||||
return (ait->second[b].GetLoss ());
|
||||
}
|
||||
}
|
||||
@@ -184,7 +174,9 @@ const
|
||||
{
|
||||
double sigma = EvaluateSigma (a1, b1);
|
||||
// side effect: will create new entries in both maps
|
||||
m_shadowingLossMap[a][b] = ShadowingLoss (0.0, sigma, b);
|
||||
// sigma is standard deviation, not variance
|
||||
double shadowingValue = m_randVariable->GetValue (0.0, (sigma*sigma));
|
||||
m_shadowingLossMap[a][b] = ShadowingLoss (shadowingValue, b);
|
||||
return (m_shadowingLossMap[a][b].GetLoss ());
|
||||
}
|
||||
}
|
||||
@@ -229,7 +221,8 @@ BuildingsPropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr<MobilityMod
|
||||
int64_t
|
||||
BuildingsPropagationLossModel::DoAssignStreams (int64_t stream)
|
||||
{
|
||||
return ShadowingLoss::AssignStreams (stream);
|
||||
m_randVariable->SetStream (stream);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ class BuildingsPropagationLossModel : public PropagationLossModel
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
BuildingsPropagationLossModel ();
|
||||
/**
|
||||
* \param a the mobility model of the source
|
||||
* \param b the mobility model of the destination
|
||||
@@ -82,15 +83,12 @@ protected:
|
||||
{
|
||||
public:
|
||||
ShadowingLoss ();
|
||||
ShadowingLoss (double mean, double sigma, Ptr<MobilityModel> receiver);
|
||||
ShadowingLoss (double shadowingValue, Ptr<MobilityModel> receiver);
|
||||
double GetLoss () const;
|
||||
Ptr<MobilityModel> GetReceiver (void) const;
|
||||
static int64_t AssignStreams (int64_t stream);
|
||||
protected:
|
||||
Ptr<MobilityModel> m_receiver;
|
||||
static Ptr<NormalRandomVariable> m_randVariable;
|
||||
|
||||
double m_shadowingValue;
|
||||
Ptr<MobilityModel> m_receiver;
|
||||
};
|
||||
|
||||
mutable std::map<Ptr<MobilityModel>, std::map<Ptr<MobilityModel>, ShadowingLoss> > m_shadowingLossMap;
|
||||
@@ -100,6 +98,7 @@ protected:
|
||||
double m_shadowingSigmaExtWalls;
|
||||
double m_shadowingSigmaOutdoor;
|
||||
double m_shadowingSigmaIndoor;
|
||||
Ptr<NormalRandomVariable> m_randVariable;
|
||||
|
||||
virtual int64_t DoAssignStreams (int64_t stream);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user