Constructing a world allocates quite a lot of memory in pretty small chunks, hence the time it takes.
Resetting the world timer will probably cause problems. Can you just set a new quit time instead?
A fast reset strategy to try is this:
1. save your controller state. The "old world" is now done.
2. SetPose() on your position models to put them where you want them
3. Run the simulation long enough to update all your sensor models to get rid of any state from the "previous world". This could be very short.
4. initalize your controllers
5. start running in this "new world"
To cope with the global clock still measuring time since construction, your controllers should measure time relative to the time they were initialized.
If you need to run a lot of worlds in parallel, consider fork()ing after constructing a world. Your OS's copy-on-write memory system may help out compared to running several copies from the shell. I haven't tried this, but it might work.
On 2012-02-19, at 9:38 AM, Alex Wood wrote:
> I am needed to preform several hundred simulations to train a neural
> network, to do this I am using Stage only without a GUI and the
> libstage library to control everything.
> Currently I am destroying the world and recreating it to reset the
> simulation. This takes a while and makes training run at a snails
> I am guessing there is a simple way to reset the robots position and
> world timer without destroying the world(anything else I should be
> My program is based on the libstage example file stest.cc and here is
> the relevant code:
> (Same code in past bin for nice syntax highlighting that we all love -
> float runSim(vector<float> cromo)
> std::string worldFile = "/home/alex/Stage/worlds/simple.world";
> const int popsize = 1;
> char *ptest;
> int ntest = 1;
> char **pptest=ptest;
> char ***ppptest = &pptest;
> // initialize libstage
> Stg::Init( &ntest, ppptest );
> float simFitnessTotal = 0;
> //run three trials and get the average fitness
> for (int i=0; i<3; i++)
> Stg::World* world = new Stg::World("Stage Benchmark Program");
> world->Load( worldFile );
> if (world->PastQuitTime())
> cout << "past quit time" << endl;
> // create the logic and connect it to the world
> Logic logic(popsize);
> simFitnessTotal += logic.trialFitness();
> float finalFitness = simFitnessTotal/3;
> cout << "final fitness: " << finalFitness << endl;
> return finalFitness;
> I have a feeling the answer is a lot simpler then I originally thought.
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> Playerstage-users mailing list