Multiple seeds

Requests regarding how to set up experiments in ARGoS.
AshwinRaviraj
Posts: 13
Joined: Mon Apr 19, 2021 9:40 pm

Multiple seeds

Postby AshwinRaviraj » Mon Apr 19, 2021 9:48 pm

Hi,
Is it possible to give an experiment multiple seeds, so when the experiment finishes it will restart with the next seed.
Or do I need to make a new .argos file and then run it with the new seed?

Best,
Ashwin

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

Re: Multiple seeds

Postby pincy » Mon Apr 19, 2021 10:05 pm

You can set the seed to 0. When you press the reset button, or call CSimulator::Reset(), a new one will be picked at random (see the code).

If you need the experiments to be repeatable, yet to use multiple seeds, a better approach is to create a template .argos file that you can fill in with a command like sed. This is what I usually do.
I made ARGoS.

AshwinRaviraj
Posts: 13
Joined: Mon Apr 19, 2021 9:40 pm

Re: Multiple seeds

Postby AshwinRaviraj » Mon Apr 19, 2021 10:17 pm

Thank you!

So, would it be in the loop function /controller that I would need to pass the seed?
And how would it be possible for me to tell the controller to initiate the new experiment with the seed?

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

Re: Multiple seeds

Postby pincy » Mon Apr 19, 2021 10:35 pm

You configure this in the .argos file. See the commented file here.

ARGoS is different from other simulators. No individual robot controls the simulator.
I made ARGoS.

AshwinRaviraj
Posts: 13
Joined: Mon Apr 19, 2021 9:40 pm

Re: Multiple seeds

Postby AshwinRaviraj » Mon Apr 19, 2021 10:44 pm

I see, thank you for your help!

AshwinRaviraj
Posts: 13
Joined: Mon Apr 19, 2021 9:40 pm

Re: Multiple seeds

Postby AshwinRaviraj » Wed Apr 21, 2021 10:43 am

After I Reset the loopfunction and start a new experiment, it looks like the controller is not getting reset?
How can I ensure that when I call cSimulation::Reset that the controller also will get reset?

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

Re: Multiple seeds

Postby pincy » Wed Apr 21, 2021 2:06 pm

The controller is reset, see the code here. Also, because this is a different question, please create a new topic.
I made ARGoS.

AshwinRaviraj
Posts: 13
Joined: Mon Apr 19, 2021 9:40 pm

Re: Multiple seeds

Postby AshwinRaviraj » Wed Apr 28, 2021 12:27 pm

Is this the correct way to reset an experiment and then giving it a new random seed, because it look like it can see that the agents are being placed the exact same place every time I reset the experiment..

Code: Select all

CSimulator &cSimulator = CSimulator::GetInstance(); cSimulator.SetExperimentFileName(PATH); cSimulator.LoadExperiment(); int ran = 124; for (int i = 0; i < iter; i++) { cSimulator.Execute(); ran = rand() % (max - min + 1) + min; cSimulator.Reset(ran); }
I can't figure out why the position of the robots are the same. Am I doing something wrong?

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

Re: Multiple seeds

Postby pincy » Wed Apr 28, 2021 1:48 pm

The simplest way to have ARGoS pick a different random at each Reset() is to set the random seed to 0 in the .argos file.
I made ARGoS.

AshwinRaviraj
Posts: 13
Joined: Mon Apr 19, 2021 9:40 pm

Re: Multiple seeds

Postby AshwinRaviraj » Wed Apr 28, 2021 2:17 pm

True, that would be the simplest, but is it possible to set the seed to a value of own choosing?
The reason for this is because I would like to use the same seed for different .argos file setup.
- Yes I guess, I could hard code that exact seed, but is there someway to give the seed, just like the Reset() function?


Return to “How to... ?”