Writing the simulator's random seed or initial log into a file

Requests regarding how to set up experiments in ARGoS.
Elendurwen
Posts: 41
Joined: Sat Aug 24, 2013 5:08 pm
Contact:

Writing the simulator's random seed or initial log into a file

Postby Elendurwen » Fri Apr 24, 2015 9:00 pm

Hi, when the simulator starts, it outputs something like

Code: Select all

[INFO] Not using threads [INFO] Using random seed = 263127 [INFO] Using simulation clock tick = 0.1 [INFO] Total experiment length in clock ticks = unlimited [INFO] The physics engine "dyn2d" will perform 10 iterations per tick (dt = 0.01 sec)
I would like to get the value of that random seed and save it a file from my loop function, when it initialises. Or at least get all the info and save it. This is so that if I find a bug in a specific simulation run, I just re-run that particular case.

I couldn't find a way to do it, is there one? I have the output stream setup, I just need to fill in the following line:

Code: Select all

outputFileGlobal << ???
Thanks!

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Writing the simulator's random seed or initial log into a file

Postby pincy » Sat Apr 25, 2015 8:26 pm

Hi Elendurwen,

If you type

Code: Select all

$ argos3 -h
you'll see that there are two options to redirect [INFO] (stdout) and [WARNING] / [ERROR] (stderr) to file. The syntax is:

Code: Select all

$ argos3 -l INFOFILE -e ERRORFILE -c myexperiment.argos
By default, the output contains extra control characters to color the output green and red. You can prevent ARGoS from outputting these characters by passing the additional option -n:

Code: Select all

$ argos3 -n -l INFOFILE -e ERRORFILE -c myexperiment.argos
Once you have your INFOFILE, you can find the random seed with this one-liner:

Code: Select all

$ grep 'random seed' INFOFILE | cut -d' ' -f6
Alternatively, you can get the value of the current random seed directly from C++, e.g., within the loop functions. To achieve this, you can write:

Code: Select all

CSimulator::GetInstance().GetRandomSeed()
Cheers,
Carlo
I made ARGoS.


Return to “How to... ?”