Random numbers

72 views
Skip to first unread message

Andrew Hardy

unread,
Jun 13, 2013, 12:10:09 PM6/13/13
to omn...@googlegroups.com

Hi Have random number generation in my program.

If the program is run with the same rng and same replica number and no
parameters are changed
then if I run it once then a second time the exact same sequence of
random numbers ocurr

the random numbers are having an intended impact on packet delivery

If I changed a section of the code, but that change does not change the
sequence through the program
or the order of any calls to the rng and the change is logically
equivelant then I would expect the
same random number order and the same results.

Is that right or does the act of actually just changing and rebuilding
the program have any impact in and
of that action itself on the random numbers generated?

If it should not have an impact in and of itself, then I will assume
something of the logic of my changed code
is unintendedly changing the order of the calls to the random number
sequence and therefore I will investigate
this code change since it is intended to be logically equivelant and the
observation suggests that it is not.



________________________________
Important Notice: the information in this email and any attachments is for the sole use of the intended recipient(s). If you are not an intended recipient, or a person responsible for delivering it to an intended recipient, you should delete it from your system immediately without disclosing its contents elsewhere and advise the sender by returning the email or by telephoning a number contained in the body of the email. No responsibility is accepted for loss or damage arising from viruses or changes made to this message after it was sent. The views contained in this email are those of the author and not necessarily those of Liverpool John Moores University.

Rudolf Hornig

unread,
Jun 14, 2013, 5:30:18 AM6/14/13
to omn...@googlegroups.com
See inline:


On Thursday, 13 June 2013 18:10:09 UTC+2, hardya wrote:

Hi Have random number generation in my program.

If the program is run with the same rng and same replica number and no
parameters are changed
then if I run it once then a second time the exact same sequence of
random numbers ocurr

Yes. That is how it should work. 


the random numbers are having an intended impact on packet delivery

If I changed a section of the code, but that change does not change the
sequence through the program
or the order of any calls to the rng and the change is logically
equivelant then I would expect the
same random number order and the same results.

Right, this is a correct assumption. 


Is that right or does the act of actually just changing and rebuilding
the program have any impact in and
of that action itself on the random numbers generated?
Not, rebuilding (even on a different platform!) should not change the numbers generated and must result exactly the same results and simulation trajectory. 

If it should not have an impact in and of itself, then I will assume
something of the logic of my changed code
is unintendedly changing the order of the calls to the random number
sequence and therefore I will investigate
this code change since it is intended to be logically equivelant and the
observation suggests that it is not.

Right, actually there is built-in support in OMNET for this, called "fingerprints" (look for it in the manual). In short, it generates a CRC value from the timpe, eventnumber etc, so at the end it will provide you a value, that can be noted in your INI file. OMNET can check whether the value generated by the simulation is the same that is stored in the INI file and will display an error if it does not.

In fact we use this feature heavily to write automated smoke test (on a jenkins server) that are run on each commit we make in INET. The test can mark each commit where the fingerprint checks failed. We tend to separate cosmetic and refactoring changes from the more fundemental ones, so it is easy to spot if we messed up something unintentionally.

Take a look how INET fingerprint tests are implemented, you may get some ideas from there.
Rudolf

Adriana V R

unread,
Nov 13, 2016, 10:30:45 PM11/13/16
to OMNeT++ Users
Hello, if the random numbers don't change, how can I get statistical results? The correct way of showing the results is running some experiments and calculating mean, standard deviaton and condifence interval between those experiments. But if each simulation has the same results, doesn't make senses calculate those things. So, am I doing something wrong? What are your suggestions?

Alfonso Ariza Quintana

unread,
Nov 14, 2016, 6:39:58 AM11/14/16
to omn...@googlegroups.com

You can change the initial seed, if the initial seed is different the sequence will be different.

If you set in the ini file repetitions

repeat = 5

 

The simulator will send every one of the repetitions with a different initial seed for the random number generator, this is in the manual.

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

Adriana V R

unread,
Nov 14, 2016, 10:42:23 AM11/14/16
to OMNeT++ Users
I am sorry, I didnt see it. I just saw the part about experiments, measurement and replication but i wasn't sure the replication changes the random numbers because of this part: "The tree shows that ("PureAloha", "$N=1,$mean=0.2", "#0, seed-set=0") was run three times. The results produced by these three executions should be identical, unless, for example, some parameter was modified in the ini file, or a bug got fixed in the C++ code."

So, will I just add the "repeat =10" inside of "[General]" and each repeatition will be different? The results will be an average of those repeatitions or I will get them separately?


[General]
network
= Wireless
record
-eventlog = true
sim
-time-limit = 500s
tkenv
-plugin-path = ../../../etc/plugins




**.constraintAreaMinX = 0m
**.constraintAreaMinY = 0m
**.constraintAreaMinZ = 0m
**.constraintAreaMaxX = 800m
**.constraintAreaMaxY = 600m
**.constraintAreaMaxZ = 0m


# mobility
**.wirelessHost[*].mobilityType = "MassMobility"
**.wirelessHost[*].mobility.initFromDisplayString = false
**.wirelessHost[*].mobility.changeInterval = truncnormal(2s, 0.5s)
**.wirelessHost[*].mobility.changeAngleBy = normal(0deg, 30deg)
**.wirelessHost[*].mobility.speed = truncnormal(20mps, 8mps)
**.wirelessHost[*].mobility.updateInterval = 10ms




**.addDefaultRoutes = false


**.*Host*.numUdpApps = 1


**.*Host*.udpApp[*].packetLen = 100B


**.wiredHost1.udpApp[*].typename = "UDPMasterSvr"
**.wiredHost1.udpApp[*].localPort = 1000
**.wiredHost1.udpApp[*].contentSize = 1200B
**.wiredHost1.udpApp[*].sendInterval = 0.2s


**.wiredHostS1.udpApp[*].typename = "UDPMasterSvrS1"
**.wiredHostS2.udpApp[*].typename = "UDPMasterSvrS2"
**.wiredHostS3.udpApp[*].typename = "UDPMasterSvrS3"
**.wiredHostS*.udpApp[*].localPort = 1000
**.wiredHostS*.udpApp[*].contentSize = 1200B
**.wiredHostS*.udpApp[*].sendInterval = 0.2s




**.wirelessHost[*].udpApp[*].typename = "UDPMasterCli"


**.wirelessHost[*].udpApp[*].startTime = default


And if I wanna running different experiments I just add the following code? How the results are recorded? 
Can I choose the config file in Windows in the "Configuration - Scenarios - Experiment label", correct?

Between two experiments the random numbers will be the same? 
For example:

Experiment 1, first: randomnumber 2; Experiment 2, first: randomnumber 2
Experiment 1, second: randomnumber 5; Experiment 2, second: randomnumber 5
Experiment 1, third: randomnumber 1; Experiment 2, thid: randomnumber 1


[Config WithSimilarity]
**.wirelessHost[*].udpApp[*].withSimilarity = true
repeat = 10

[Config withHierarchy]
extends = withSimilarity
**.wiredHostS*.udpApp[*].withHierarchy = true
repeat = 10

Alfonso Ariza Quintana

unread,
Nov 14, 2016, 12:50:50 PM11/14/16
to omn...@googlegroups.com

If you include in the ini file reapeat = 10

You will have active the Run number

 

Every one has a different initial seed

Adriana V R

unread,
Nov 14, 2016, 2:12:25 PM11/14/16
to OMNeT++ Users
Got it! Thank you sooo much!
Reply all
Reply to author
Forward
0 new messages