21 #include "ns3/double.h"
22 #include "ns3/string.h"
23 #include "ns3/pointer.h"
24 #include "ns3/uinteger.h"
58 static TypeId tid =
TypeId (
"ns3::ListPositionAllocator")
60 .AddConstructor<ListPositionAllocator> ()
96 static TypeId tid =
TypeId (
"ns3::GridPositionAllocator")
98 .SetGroupName (
"Mobility")
100 .AddAttribute (
"GridWidth",
"The number of objects layed out on a line.",
103 MakeUintegerChecker<uint32_t> ())
104 .AddAttribute (
"MinX",
"The x coordinate where the grid starts.",
107 MakeDoubleChecker<double> ())
108 .AddAttribute (
"MinY",
"The y coordinate where the grid starts.",
111 MakeDoubleChecker<double> ())
112 .AddAttribute (
"DeltaX",
"The x space between objects.",
115 MakeDoubleChecker<double> ())
116 .AddAttribute (
"DeltaY",
"The y space between objects.",
119 MakeDoubleChecker<double> ())
120 .AddAttribute (
"LayoutType",
"The type of layout.",
198 double x = 0.0, y = 0.0;
210 return Vector (x, y, 0.0);
225 static TypeId tid =
TypeId (
"ns3::RandomRectanglePositionAllocator")
227 .SetGroupName (
"Mobility")
230 "A random variable which represents the x coordinate of a position in a random rectangle.",
231 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
233 MakePointerChecker<RandomVariableStream> ())
235 "A random variable which represents the y coordinate of a position in a random rectangle.",
236 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
238 MakePointerChecker<RandomVariableStream> ());
265 return Vector (x, y, 0.0);
282 static TypeId tid =
TypeId (
"ns3::RandomBoxPositionAllocator")
284 .SetGroupName (
"Mobility")
287 "A random variable which represents the x coordinate of a position in a random box.",
288 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
290 MakePointerChecker<RandomVariableStream> ())
292 "A random variable which represents the y coordinate of a position in a random box.",
293 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
295 MakePointerChecker<RandomVariableStream> ())
297 "A random variable which represents the z coordinate of a position in a random box.",
298 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
300 MakePointerChecker<RandomVariableStream> ());
351 static TypeId tid =
TypeId (
"ns3::RandomDiscPositionAllocator")
353 .SetGroupName (
"Mobility")
355 .AddAttribute (
"Theta",
356 "A random variable which represents the angle (gradients) of a position in a random disc.",
357 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=6.2830]"),
359 MakePointerChecker<RandomVariableStream> ())
360 .AddAttribute (
"Rho",
361 "A random variable which represents the radius of a position in a random disc.",
362 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=200.0]"),
364 MakePointerChecker<RandomVariableStream> ())
366 "The x coordinate of the center of the random position disc.",
369 MakeDoubleChecker<double> ())
371 "The y coordinate of the center of the random position disc.",
374 MakeDoubleChecker<double> ())
411 double x =
m_x + std::cos (theta) * rho;
412 double y =
m_y + std::sin (theta) * rho;
414 return Vector (x, y, 0.0);
433 static TypeId tid =
TypeId (
"ns3::UniformDiscPositionAllocator")
435 .SetGroupName (
"Mobility")
437 .AddAttribute (
"rho",
438 "The radius of the disc",
441 MakeDoubleChecker<double> ())
443 "The x coordinate of the center of the disc.",
446 MakeDoubleChecker<double> ())
448 "The y coordinate of the center of the disc.",
451 MakeDoubleChecker<double> ())
458 m_rv = CreateObject<UniformRandomVariable> ();
488 while (std::sqrt (x*x + y*y) >
m_rho);
493 return Vector (x, y, 0.0);
In column-first mode, positions are allocated on the first column until N positions have been allocat...
Ptr< RandomVariableStream > m_y
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Ptr< RandomVariableStream > m_y
double GetMinY(void) const
void SetDeltaX(double deltaX)
static TypeId GetTypeId(void)
hold variables of type string
Ptr< RandomVariableStream > m_theta
void SetMinX(double xMin)
virtual ~PositionAllocator()
void SetZ(Ptr< RandomVariableStream > z)
double GetDeltaY(void) const
enum LayoutType GetLayoutType(void) const
virtual Vector GetNext(void) const
std::vector< Vector > m_positions
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Ptr< RandomVariableStream > m_rho
void SetMinY(double yMin)
static TypeId GetTypeId(void)
virtual ~RandomBoxPositionAllocator()
double GetDeltaX(void) const
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
static TypeId GetTypeId(void)
std::vector< Vector >::const_iterator m_current
void SetRho(Ptr< RandomVariableStream > rho)
virtual Vector GetNext(void) const
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
virtual Vector GetNext(void) const
static TypeId GetTypeId(void)
void SetDeltaY(double deltaY)
hold variables of type 'enum'
Ptr< RandomVariableStream > m_x
void SetY(Ptr< RandomVariableStream > y)
Hold an unsigned integer type.
virtual ~RandomRectanglePositionAllocator()
NS_LOG_COMPONENT_DEFINE("PositionAllocator")
Allocate positions on a rectangular 2d grid.
void SetTheta(Ptr< RandomVariableStream > theta)
Allocate positions from a deterministic list specified by the user.
virtual Vector GetNext(void) const
void SetY(Ptr< RandomVariableStream > y)
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
RandomDiscPositionAllocator()
static TypeId GetTypeId(void)
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
RandomRectanglePositionAllocator()
enum LayoutType m_layoutType
static TypeId GetTypeId(void)
Allocate random positions within a rectangle according to a pair of random variables.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
In row-first mode, positions are allocated on the first row until N positions have been allocated...
#define NS_LOG_DEBUG(msg)
void SetLayoutType(enum LayoutType layoutType)
virtual Vector GetNext(void) const
uint32_t GetN(void) const
void SetX(Ptr< RandomVariableStream > x)
void SetX(Ptr< RandomVariableStream > x)
Allocate random positions within a 3D box according to a set of three random variables.
RandomBoxPositionAllocator()
a base class which provides memory management and object aggregation
Hold a floating point type.
a unique identifier for an interface.
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
TypeId SetParent(TypeId tid)
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
LayoutType
Determine whether positions are allocated row first or column first.
virtual ~RandomDiscPositionAllocator()
Ptr< RandomVariableStream > m_z
double GetMinX(void) const
Ptr< RandomVariableStream > m_x
Allocate a set of positions.