A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
rng-seed-manager.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 Mathieu Lacage
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
*/
7
8
#ifndef RNG_SEED_MANAGER_H
9
#define RNG_SEED_MANAGER_H
10
11
#include <stdint.h>
12
13
/**
14
* @file
15
* @ingroup randomvariable
16
* ns3::RngSeedManager declaration.
17
*/
18
19
namespace
ns3
20
{
21
22
/**
23
* @ingroup randomvariable
24
*
25
* Manage the seed number and run number of the underlying
26
* random number generator, and automatic assignment of stream numbers.
27
*/
28
class
RngSeedManager
29
{
30
public
:
31
/**
32
* @brief Set the seed.
33
*
34
* This sets the global initial seed which will be used all
35
* subsequently instantiated RandomVariableStream objects.
36
*
37
* @code
38
* RngSeedManager::SetSeed(15);
39
* UniformVariable x(2,3); // These will give the same output every time
40
* ExponentialVariable y(120); // as long as the seed stays the same.
41
* @endcode
42
* @param [in] seed The seed value to use.
43
*
44
* @note While the underlying RNG takes six integer values as a seed;
45
* it is sufficient to set these all to the same integer, so we provide
46
* a simpler interface here that just takes one integer.
47
*
48
* @hidecaller
49
*/
50
static
void
SetSeed
(
uint32_t
seed);
51
52
/**
53
* @brief Get the current seed value which will be used by all
54
* subsequently instantiated RandomVariableStream objects.
55
*
56
* @return The seed value.
57
*
58
* This returns the current seed value.
59
*/
60
static
uint32_t
GetSeed
();
61
62
/**
63
* @brief Set the run number of simulation.
64
*
65
* @code
66
* RngSeedManager::SetSeed(12);
67
* int N = atol(argv[1]); // Read in run number from command line.
68
* RngSeedManager::SetRun(N);
69
* UniformVariable x(0,10);
70
* ExponentialVariable y(2902);
71
* @endcode
72
* In this example, \c N could successively be equal to 1,2,3, _etc._
73
* and the user would continue to get independent runs out of the
74
* single simulation. For this simple example, the following might work:
75
* @code
76
* ./simulation 0
77
* ...Results for run 0:...
78
*
79
* ./simulation 1
80
* ...Results for run 1:...
81
* @endcode
82
*
83
* @param [in] run The run number.
84
* @hidecaller
85
*/
86
static
void
SetRun
(uint64_t run);
87
/**
88
* @brief Get the current run number.
89
* @returns The current run number
90
* @see SetRun
91
*/
92
static
uint64_t
GetRun
();
93
94
/**
95
* Get the next automatically assigned stream index.
96
* @returns The next stream index.
97
*/
98
static
uint64_t
GetNextStreamIndex
();
99
100
/**
101
* Resets the global stream index counter.
102
*/
103
static
void
ResetNextStreamIndex
();
104
};
105
106
/** Alias for compatibility. */
107
typedef
RngSeedManager
SeedManager
;
108
109
}
// namespace ns3
110
111
#endif
/* RNG_SEED_MANAGER_H */
ns3::RngSeedManager
Manage the seed number and run number of the underlying random number generator, and automatic assign...
Definition
rng-seed-manager.h:29
ns3::RngSeedManager::SetRun
static void SetRun(uint64_t run)
Set the run number of simulation.
Definition
rng-seed-manager.cc:78
ns3::RngSeedManager::ResetNextStreamIndex
static void ResetNextStreamIndex()
Resets the global stream index counter.
Definition
rng-seed-manager.cc:104
ns3::RngSeedManager::SetSeed
static void SetSeed(uint32_t seed)
Set the seed.
Definition
rng-seed-manager.cc:71
ns3::RngSeedManager::GetNextStreamIndex
static uint64_t GetNextStreamIndex()
Get the next automatically assigned stream index.
Definition
rng-seed-manager.cc:95
ns3::RngSeedManager::GetRun
static uint64_t GetRun()
Get the current run number.
Definition
rng-seed-manager.cc:85
ns3::RngSeedManager::GetSeed
static uint32_t GetSeed()
Get the current seed value which will be used by all subsequently instantiated RandomVariableStream o...
Definition
rng-seed-manager.cc:62
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SeedManager
RngSeedManager SeedManager
Alias for compatibility.
Definition
rng-seed-manager.h:107
src
core
model
rng-seed-manager.h
Generated on
for ns-3 by
1.15.0