Defining rho interval when using UniformDiscPositionAllocator

345 views
Skip to first unread message

Narges Shojaedin

unread,
Sep 24, 2013, 6:08:50 PM9/24/13
to ns-3-...@googlegroups.com

Hi everyone,

I am willing to use UniformDiscPositionAllocator and define an interval for rho parameter.
When I run my program in which rho is defined in the following way, there is no problem.
MobilityHelper mobility;
  mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "rho", StringValue ("5000.0"));

  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.Install(ueNodes);
  mobility.Install(enbNodes);

However, I could not define an interval for rho while I did it for RandomDiscPositionAllocator as follows:

mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "Rho", StringValue ("ns3::UniformRandomVariable[Min=500|Max=5000]"));

How can I have the same value for rho when using UniformDiscPositionAllocator?
Please note that I am using ns-3.18.

Thanks in advance,
Narges

Konstantinos

unread,
Sep 24, 2013, 6:31:25 PM9/24/13
to ns-3-...@googlegroups.com
Hi Narges,

If you see the definition of 'rho' in UniformDiscPositionAllocator, it is of DoubleValue, while in the RandomDiscPositionAllocator it is a PointerValue.
So, if you want to use the UniformRandomVariable, you should create a random variable and take a double value from that as 'rho'.

something like this..

UniformRandomVariable rv = UniformRandomVariable();

then the 'rho' could be something like:
"rho", DoubleValue ( rv.GetValue(500, 5000) )

Regards,
K.

Narges Shojaedin

unread,
Sep 24, 2013, 7:16:13 PM9/24/13
to ns-3-...@googlegroups.com
Thanks so moch for your help.
I actually used something like your code:

Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable> ();

  mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "rho", DoubleValue ( var->GetValue(500, 5000) ));

I got error when I used exactly the one that you suggested.

I have another quick question. I expected to get the same result when using "rho", DoubleValue ( var->GetValue(0, 5000) ) and "rho", StringValue ("5000.0").
However, the results are different! Do you have any idea?

BR,
Narges

Konstantinos

unread,
Sep 24, 2013, 7:21:41 PM9/24/13
to ns-3-...@googlegroups.com


On Wednesday, September 25, 2013 12:16:13 AM UTC+1, Narges Shojaedin wrote:
Thanks so moch for your help.
I actually used something like your code:

Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable> ();
  mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "rho", DoubleValue ( var->GetValue(500, 5000) ));

I got error when I used exactly the one that you suggested.

I have another quick question. I expected to get the same result when using "rho", DoubleValue ( var->GetValue(0, 5000) ) and "rho", StringValue ("5000.0").
However, the results are different! Do you have any idea?

 
They are supposed to be different. The first gets a random value from 0 to 5000, while the second always gets 5000.

Narges Shojaedin

unread,
Sep 24, 2013, 7:31:09 PM9/24/13
to ns-3-...@googlegroups.com
In http://www.nsnam.org/doxygen/classns3_1_1_uniform_disc_position_allocator.html#details, it is mentioned that:
UniformDiscPositionAllocator allocates the positions randomly within a disc $ D $ lying on the plane $ z=0 $ and having center at coordinates $ (x,y,0) $ and radius $ \rho $.

So, based on this description, rho is the radius of disk and UEs are positioned uniformly and randomly within the disk! Am I right?

My goal is to distribute the UEs uniformly within a random distance to eNB from 500m to 5000m. Is that a right way to do that? If not, could you please help me and let me know how I can do that?

Thanks,
Narges

Konstantinos

unread,
Sep 25, 2013, 5:11:50 AM9/25/13
to ns-3-...@googlegroups.com
First of all, 

my answer regarding the two values was correct in principle but out-of-context. Meaning that the one was a random variable and the other a double value, but with respect to the UniformDistAllocator the result should be generally the same. 

You will not get exactly the same positions but if you take a large number of positions and average them they are similar. The reason why they are not the same is simply because they are two different random variables so they are supposed to generate different values.


On Wednesday, September 25, 2013 12:31:09 AM UTC+1, Narges Shojaedin wrote:
In http://www.nsnam.org/doxygen/classns3_1_1_uniform_disc_position_allocator.html#details, it is mentioned that:
UniformDiscPositionAllocator allocates the positions randomly within a disc $ D $ lying on the plane $ z=0 $ and having center at coordinates $ (x,y,0) $ and radius $ \rho $.

So, based on this description, rho is the radius of disk and UEs are positioned uniformly and randomly within the disk! Am I right?


yes
 
My goal is to distribute the UEs uniformly within a random distance to eNB from 500m to 5000m. Is that a right way to do that? If not, could you please help me and let me know how I can do that?


I haven't tested it, but didn't the RandomPositionAllocator worked for you? It says is random and not uniform, but you can control the type of random variable with Rho and Theta.

The other solution, is to tweak the code of UniformDisc... to also check that the distance is >500 not only <5000. This is done in line 481 of src/mobility/model/position-allocator.cc

Narges Shojaedin

unread,
Sep 25, 2013, 12:14:06 PM9/25/13
to ns-3-...@googlegroups.com
Hi Konstantinos,

Thanks so much for your help.
I'll try to tweak the code of UniformDiscPositionAllocator as you said.

Narges
Reply all
Reply to author
Forward
0 new messages