![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 #include <RISE/scenario/pathloss/HashRNG.hpp> 00028 #include <WNS/distribution/Uniform.hpp> 00029 00030 #include <boost/random.hpp> 00031 #include <boost/functional/hash.hpp> 00032 #include <sstream> 00033 00034 using namespace rise::scenario::pathloss::detail; 00035 00036 HashRNG::HashRNG(unsigned int initialSeed, 00037 wns::Position p1, 00038 wns::Position p2, 00039 bool correlateBS, bool correlateUT): 00040 myHash(5381), 00041 uni(0.0, 1.0), 00042 dis(rng, uni) 00043 { 00044 // First take care of the initial seed 00045 combine(myHash, initialSeed); 00046 00047 // BS and UT are defined by the z coordinate 00048 // the higher one is the BS 00049 wns::Position bs; 00050 wns::Position ut; 00051 00052 if (p1.getZ() > p2.getZ()) 00053 { 00054 bs = p1; 00055 ut = p2; 00056 } 00057 else 00058 { 00059 bs = p2; 00060 ut = p1; 00061 } 00062 00063 if (correlateBS && correlateUT) 00064 { 00065 // Feed to seed, but such that swapping p1 and p2 yields the same results 00066 // channel is reciprocal 00067 double xMax = std::max(bs.getX(), ut.getX()); 00068 double xMin = std::min(bs.getX(), ut.getX()); 00069 double yMax = std::max(bs.getY(), ut.getY()); 00070 double yMin = std::min(bs.getY(), ut.getY()); 00071 double zMax = std::max(bs.getZ(), ut.getZ()); 00072 double zMin = std::min(bs.getZ(), ut.getZ()); 00073 00074 combine(myHash, xMax); 00075 combine(myHash, xMin); 00076 combine(myHash, yMax); 00077 combine(myHash, yMin); 00078 combine(myHash, zMax); 00079 combine(myHash, zMin); 00080 } 00081 else if (correlateBS) 00082 { 00083 combine(myHash, bs.getX()); 00084 combine(myHash, bs.getY()); 00085 combine(myHash, bs.getZ()); 00086 } 00087 else if (correlateUT) 00088 { 00089 combine(myHash, ut.getX()); 00090 combine(myHash, ut.getY()); 00091 combine(myHash, ut.getZ()); 00092 } 00093 else 00094 { 00095 assure(false, "Unsupported case in HashRNG. Correlate the RNG either to BS, UT or to both!"); 00096 } 00097 00098 rng.seed(myHash); 00099 } 00100 00101 double 00102 HashRNG::operator()() 00103 { 00104 return dis(); 00105 }
1.5.5