21 #include <ns3/mobility-building-info.h>
22 #include "ns3/mobility-model.h"
23 #include "ns3/buildings-helper.h"
24 #include "ns3/random-variable-stream.h"
25 #include "ns3/double.h"
26 #include "ns3/uinteger.h"
28 #include "ns3/boolean.h"
31 #include "ns3/building.h"
34 #include "ns3/building-list.h"
46 m_rand = CreateObject<UniformRandomVariable> ();
52 static TypeId tid =
TypeId (
"ns3::RandomBuildingPositionAllocator")
54 .SetGroupName (
"Mobility")
56 .AddAttribute (
"WithReplacement",
57 "If true, the building will be randomly selected with replacement. "
58 "If false, no replacement will occur, until the list of buildings "
59 "to select becomes empty, at which point it will be filled again "
60 "with the list of all buildings.",
63 MakeBooleanChecker ());
93 b->GetAttribute (
"Boundaries", bv);
114 m_rand = CreateObject<UniformRandomVariable> ();
120 static TypeId tid =
TypeId (
"ns3::RandomRoomPositionAllocator")
122 .SetGroupName (
"Mobility")
138 for (uint32_t rx = 1; rx <= (*bit)->GetNRoomsX (); ++rx)
140 for (uint32_t ry = 1; ry <= (*bit)->GetNRoomsY (); ++ry)
142 for (uint32_t f = 1; f <= (*bit)->GetNFloors (); ++f)
149 NS_LOG_LOGIC (
"adding room (" << rx <<
", " << ry <<
", " << f <<
")");
163 r.
b->GetAttribute (
"Boundaries", bv);
165 double rdx = (box.
xMax - box.
xMin) / r.
b->GetNRoomsX ();
166 double rdy = (box.
yMax - box.
yMin) / r.
b->GetNRoomsY ();
167 double rdz = (box.
zMax - box.
zMin) / r.
b->GetNFloors ();
168 double x1 = box.
xMin + rdx * (r.
roomx - 1);
170 double y1 = box.
yMin + rdy * (r.
roomy -1);
172 double z1 = box.
zMin + rdz * (r.
floor - 1);
175 <<
" (" << x1 <<
"," << x2 <<
") "
176 <<
"x (" << y1 <<
"," << y2 <<
") "
177 <<
"x (" << z1 <<
"," << z2 <<
") ");
202 NS_FATAL_ERROR (
" Constructor \"SameRoomPositionAllocator ()\" should not be used");
209 m_rand = CreateObject<UniformRandomVariable> ();
215 NS_ASSERT_MSG (mm,
"no mobility model aggregated to this node");
217 NS_ASSERT_MSG (bmm,
"MobilityBuildingInfo has not been aggregated to this node mobility model");
225 static TypeId tid =
TypeId (
"ns3::SameRoomPositionAllocator")
227 .SetGroupName (
"Mobility")
243 NS_LOG_LOGIC (
"considering node " << (*m_nodeIt)->GetId ());
245 NS_ASSERT_MSG (mm,
"no mobility model aggregated to this node");
247 NS_ASSERT_MSG (bmm,
"MobilityBuildingInfo has not been aggregated to this node mobility model");
250 uint32_t roomx = bmm->GetRoomNumberX ();
251 uint32_t roomy = bmm->GetRoomNumberY ();
252 uint32_t floor = bmm->GetFloorNumber ();
253 NS_LOG_LOGIC (
"considering building " << bmm->GetBuilding ()->GetId () <<
" room (" << roomx <<
", " << roomy <<
", " << floor <<
")");
258 b->GetAttribute (
"Boundaries", bv);
260 double rdx = (box.
xMax - box.
xMin) / b->GetNRoomsX ();
261 double rdy = (box.
yMax - box.
yMin) / b->GetNRoomsY ();
262 double rdz = (box.
zMax - box.
zMin) / b->GetNFloors ();
263 double x1 = box.
xMin + rdx * (roomx - 1);
264 double x2 = box.
xMin + rdx * roomx;
265 double y1 = box.
yMin + rdy * (roomy -1);
266 double y2 = box.
yMin + rdy * roomy;
267 double z1 = box.
zMin + rdz * (floor - 1);
268 double z2 = box.
zMin + rdz * floor;
270 <<
" (" << x1 <<
"," << x2 <<
") "
271 <<
"x (" << y1 <<
"," << y2 <<
") "
272 <<
"x (" << z1 <<
"," << z2 <<
") ");
298 m_rand = CreateObject<UniformRandomVariable> ();
308 static TypeId tid =
TypeId (
"ns3::FixedRoomPositionAllocator")
310 .SetGroupName (
"Mobility")
323 Box box =
bptr->GetBoundaries ();
324 double rdx = (box.xMax - box.xMin) /
bptr->GetNRoomsX ();
325 double rdy = (box.yMax - box.yMin) /
bptr->GetNRoomsY ();
326 double rdz = (box.zMax - box.zMin) /
bptr->GetNFloors ();
327 double x1 = box.xMin + rdx * (
roomx - 1);
328 double x2 = box.xMin + rdx *
roomx;
329 double y1 = box.yMin + rdy * (
roomy -1);
330 double y2 = box.yMin + rdy *
roomy;
331 double z1 = box.zMin + rdz * (
floor - 1);
332 double z2 = box.zMin + rdz *
floor;
334 <<
" (" << x1 <<
"," << x2 <<
") "
335 <<
"x (" << y1 <<
"," << y2 <<
") "
336 <<
"x (" << z1 <<
"," << z2 <<
") ");
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
FixedRoomPositionAllocator(uint32_t x, uint32_t y, uint32_t z, Ptr< Building > b)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
std::vector< Ptr< Node > >::const_iterator Iterator
static uint32_t GetNBuildings(void)
static Ptr< Building > GetBuilding(uint32_t n)
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Walks a given NodeContainer sequentially, and for each node allocate a new position randomly in the s...
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
static Iterator End(void)
static Iterator Begin(void)
virtual Vector GetNext(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
static void MakeConsistent(Ptr< MobilityModel > bmm)
Make the given mobility model consistent, by determining whether its position falls inside any of the...
Keep track of the current position and velocity of an object.
RandomBuildingPositionAllocator()
static TypeId GetTypeId(void)
Generate a random position uniformly distributed in the volume of a chosen room inside a chosen build...
Allocate each position by randomly chosing a building from the list of all buildings, and then randomly chosing a position inside the building.
int64_t AssignStreams(int64_t)
Assign a fixed random variable stream number to the random variables used by this model...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
virtual Vector GetNext(void) const
std::vector< Ptr< Building > >::const_iterator Iterator
hold objects of type ns3::Box
#define NS_LOG_LOGIC(msg)
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
keep track of a set of node pointers.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
SameRoomPositionAllocator()
Allocate each position by randomly chosing a room from the list of all buildings, and then randomly c...
#define NS_ASSERT_MSG(condition, message)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
std::vector< Ptr< Building > > m_buildingListWithoutReplacement
NS_LOG_COMPONENT_DEFINE("BuildingPositionAllocator")
mobility buildings information (to be used by mobility models)
static TypeId GetTypeId(void)
static TypeId GetTypeId(void)
virtual Vector GetNext(void) const
Ptr< T > GetObject(void) const
NodeContainer::Iterator m_nodeIt
virtual Vector GetNext(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
RandomRoomPositionAllocator()
int64_t AssignStreams(int64_t)
Assign a fixed random variable stream number to the random variables used by this model...
Allocate a set of positions.
std::vector< RoomInfo > m_roomListWithoutReplacement