Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. bool cmp (double d2d)
  2. {
  3. bool flag;
  4. double probLos;
  5. Ptr<UniformRandomVariable> m_uniformVar;
  6. m_uniformVar = CreateObject<UniformRandomVariable> ();
  7. m_uniformVar->SetAttribute ("Min", DoubleValue (0));
  8. m_uniformVar->SetAttribute ("Max", DoubleValue (1));
  9. double PRef = m_uniformVar->GetValue ();
  10.  
  11. if (d2d <= 5)
  12. {
  13. //NS_LOG_INFO("2D Distance: " << distance2D);
  14. probLos = 1;
  15. NS_LOG_INFO("probLos <=5 : " << probLos);
  16. }
  17. else if (d2d <= 49)
  18. {
  19. //NS_LOG_INFO("2D Distance: " << distance2D);
  20.  
  21. probLos = exp (-(d2d - 5) / 70.8);
  22. NS_LOG_INFO("probLos<=49: " << probLos);
  23. }
  24. else
  25. {
  26. probLos = exp (-(d2d - 49) / 211.7) * 0.54;
  27. NS_LOG_INFO("probLos<=50: " << probLos);
  28. }
  29.  
  30. //comapre the Random variable with probability loss.
  31. if (PRef<probLos)
  32. {
  33. flag= true;
  34. }
  35.  
  36. return flag;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement