LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2012 Mathieu Lacage | 3 * Copyright (c) 2012 Mathieu Lacage |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 */ | 18 */ |
19 | 19 |
20 #include "rng-seed-manager.h" | 20 #include "rng-seed-manager.h" |
21 #include "global-value.h" | 21 #include "global-value.h" |
22 #include "attribute-helper.h" | 22 #include "attribute-helper.h" |
23 #include "integer.h" | 23 #include "uinteger.h" |
24 #include "config.h" | 24 #include "config.h" |
25 #include "log.h" | 25 #include "log.h" |
26 | 26 |
27 /** | 27 /** |
28 * \file | 28 * \file |
29 * \ingroup randomvariable | 29 * \ingroup randomvariable |
30 * ns3::RngSeedManager implementation. | 30 * ns3::RngSeedManager implementation. |
31 */ | 31 */ |
32 | 32 |
33 namespace ns3 { | 33 namespace ns3 { |
(...skipping 10 matching lines...) Expand all Loading... |
44 * \relates RngSeedManager | 44 * \relates RngSeedManager |
45 * The random number generator seed number global value. This is used to | 45 * The random number generator seed number global value. This is used to |
46 * generate an new master PRNG sequence. It is typically not modified | 46 * generate an new master PRNG sequence. It is typically not modified |
47 * by user programs; the variable RngRun is preferred for independent | 47 * by user programs; the variable RngRun is preferred for independent |
48 * replications. | 48 * replications. |
49 * | 49 * |
50 * This is accessible as "--RngSeed" from CommandLine. | 50 * This is accessible as "--RngSeed" from CommandLine. |
51 */ | 51 */ |
52 static ns3::GlobalValue g_rngSeed ("RngSeed",· | 52 static ns3::GlobalValue g_rngSeed ("RngSeed",· |
53 "The global seed of all rng streams", | 53 "The global seed of all rng streams", |
54 ns3::IntegerValue(1), | 54 ns3::UintegerValue(1), |
55 ns3::MakeIntegerChecker<uint32_t> ()); | 55 ns3::MakeUintegerChecker<uint32_t> ()); |
56 /** | 56 /** |
57 * \relates RngSeedManager | 57 * \relates RngSeedManager |
58 * The random number generator substream index. This is used to generate | 58 * The random number generator substream index. This is used to generate |
59 * new PRNG sequences for all streams (random variables) in such a manner | 59 * new PRNG sequences for all streams (random variables) in such a manner |
60 * that the streams remain uncorrelated. Incrementing this variable can | 60 * that the streams remain uncorrelated. Incrementing this variable can |
61 * be used for independent replications. | 61 * be used for independent replications. |
62 * | 62 * |
63 * This is accessible as "--RngRun" from CommandLine. | 63 * This is accessible as "--RngRun" from CommandLine. |
64 */ | 64 */ |
65 static ns3::GlobalValue g_rngRun ("RngRun",· | 65 static ns3::GlobalValue g_rngRun ("RngRun",· |
66 "The substream index used for all streams", | 66 "The substream index used for all streams", |
67 ns3::IntegerValue (1), | 67 ns3::UintegerValue (1), |
68 ns3::MakeIntegerChecker<int64_t> ()); | 68 ns3::MakeUintegerChecker<uint64_t> ()); |
69 | 69 |
70 | 70 |
71 uint32_t RngSeedManager::GetSeed (void) | 71 uint32_t RngSeedManager::GetSeed (void) |
72 { | 72 { |
73 NS_LOG_FUNCTION_NOARGS (); | 73 NS_LOG_FUNCTION_NOARGS (); |
74 IntegerValue seedValue; | 74 UintegerValue seedValue; |
75 g_rngSeed.GetValue (seedValue); | 75 g_rngSeed.GetValue (seedValue); |
76 return static_cast<uint32_t>(seedValue.Get ()); | 76 return static_cast<uint32_t> (seedValue.Get ()); |
77 } | 77 } |
78 void· | 78 void· |
79 RngSeedManager::SetSeed (uint32_t seed) | 79 RngSeedManager::SetSeed (uint32_t seed) |
80 { | 80 { |
81 NS_LOG_FUNCTION (seed); | 81 NS_LOG_FUNCTION (seed); |
82 Config::SetGlobal ("RngSeed", IntegerValue(seed)); | 82 Config::SetGlobal ("RngSeed", UintegerValue(seed)); |
83 } | 83 } |
84 | 84 |
85 void RngSeedManager::SetRun (uint64_t run) | 85 void RngSeedManager::SetRun (uint64_t run) |
86 { | 86 { |
87 NS_LOG_FUNCTION (run); | 87 NS_LOG_FUNCTION (run); |
88 Config::SetGlobal ("RngRun", IntegerValue (run)); | 88 Config::SetGlobal ("RngRun", UintegerValue (run)); |
89 } | 89 } |
90 | 90 |
91 uint64_t RngSeedManager::GetRun () | 91 uint64_t RngSeedManager::GetRun () |
92 { | 92 { |
93 NS_LOG_FUNCTION_NOARGS (); | 93 NS_LOG_FUNCTION_NOARGS (); |
94 IntegerValue value; | 94 UintegerValue value; |
95 g_rngRun.GetValue (value); | 95 g_rngRun.GetValue (value); |
96 uint64_t run = value.Get(); | 96 uint64_t run = value.Get(); |
97 return run; | 97 return run; |
98 } | 98 } |
99 | 99 |
100 uint64_t RngSeedManager::GetNextStreamIndex (void) | 100 uint64_t RngSeedManager::GetNextStreamIndex (void) |
101 { | 101 { |
102 NS_LOG_FUNCTION_NOARGS (); | 102 NS_LOG_FUNCTION_NOARGS (); |
103 uint64_t next = g_nextStreamIndex; | 103 uint64_t next = g_nextStreamIndex; |
104 g_nextStreamIndex++; | 104 g_nextStreamIndex++; |
105 return next; | 105 return next; |
106 } | 106 } |
107 | 107 |
108 } // namespace ns3 | 108 } // namespace ns3 |
LEFT | RIGHT |