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
static
void
SetSeed
(
uint32_t
seed);
49
50
/**
51
* \brief Get the current seed value which will be used by all
52
* subsequently instantiated RandomVariableStream objects.
53
*
54
* \return The seed value.
55
*
56
* This returns the current seed value.
57
*/
58
static
uint32_t
GetSeed
();
59
60
/**
61
* \brief Set the run number of simulation.
62
*
63
* \code
64
* RngSeedManager::SetSeed(12);
65
* int N = atol(argv[1]); // Read in run number from command line.
66
* RngSeedManager::SetRun(N);
67
* UniformVariable x(0,10);
68
* ExponentialVariable y(2902);
69
* \endcode
70
* In this example, \c N could successively be equal to 1,2,3, _etc._
71
* and the user would continue to get independent runs out of the
72
* single simulation. For this simple example, the following might work:
73
* \code
74
* ./simulation 0
75
* ...Results for run 0:...
76
*
77
* ./simulation 1
78
* ...Results for run 1:...
79
* \endcode
80
*
81
* \param [in] run The run number.
82
*/
83
static
void
SetRun
(uint64_t run);
84
/**
85
* \brief Get the current run number.
86
* \returns The current run number
87
* \see SetRun
88
*/
89
static
uint64_t
GetRun
();
90
91
/**
92
* Get the next automatically assigned stream index.
93
* \returns The next stream index.
94
*/
95
static
uint64_t
GetNextStreamIndex
();
96
97
/**
98
* Resets the global stream index counter.
99
*/
100
static
void
ResetNextStreamIndex
();
101
};
102
103
/** Alias for compatibility. */
104
typedef
RngSeedManager
SeedManager
;
105
106
}
// namespace ns3
107
108
#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:79
ns3::RngSeedManager::ResetNextStreamIndex
static void ResetNextStreamIndex()
Resets the global stream index counter.
Definition
rng-seed-manager.cc:105
ns3::RngSeedManager::SetSeed
static void SetSeed(uint32_t seed)
Set the seed.
Definition
rng-seed-manager.cc:72
ns3::RngSeedManager::GetNextStreamIndex
static uint64_t GetNextStreamIndex()
Get the next automatically assigned stream index.
Definition
rng-seed-manager.cc:96
ns3::RngSeedManager::GetRun
static uint64_t GetRun()
Get the current run number.
Definition
rng-seed-manager.cc:86
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:63
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:104
src
core
model
rng-seed-manager.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0