Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global exotica seed #626

Open
christian-rauch opened this issue Jul 9, 2019 · 5 comments
Open

global exotica seed #626

christian-rauch opened this issue Jul 9, 2019 · 5 comments
Assignees

Comments

@christian-rauch
Copy link
Collaborator

I added a KinematicTree::SetSeed method in #487 to allow reproducible sampling of configurations.

A call to KinematicTree::BuildTree resets the random number generator:

generator_ = std::mt19937(rd_());
and requires to set the seed again.

Q1: Is this reset of the generator_ required? Can it be removed or should we replace rd_() by the user set seed?

I think it would be good if EXOTica would keep a global seed for all random number generator that may be used in solvers, tasks, etc., to enable reproducible results and easier debugging. This seed would be determined once at the beginning and all random number generators would need to use the same seed, e.g. an exotica::seed() that either returns a random or static user chosen seed.

Q2: Does this sound feasible? What would be a good approach to make sure that all random number generators use the same seed?

@christian-rauch christian-rauch changed the title global seed KinematicTree global exotica seed Jul 9, 2019
@wxmerkt
Copy link
Collaborator

wxmerkt commented Jul 9, 2019

A call to KinematicTree::BuildTree resets the random number generator:

A call to KinematicTree::BuildTree happens only on Instantiate, which happens only when you create a new Scene, which happens only when you create a problem. As thus, does it really reset? [I may be missing something here]

@christian-rauch
Copy link
Collaborator Author

Indeed, I create the problem more than once. Sometimes I do this to obtain properties of the kinematic tree, before configuring the actual task. As a workaround, you could reset the seed every time the problem is created.

However, I think in my particular problem the issue is that the seed for the KinematicTree is only set after Setup::CreateProblem has been called. Solvers, etc. that are Instantiated during CreateProblem are using an unseeded KinematicTree. I am working around this by providing the seed manually to the initialiser and seeding KinematicTree before using KinematicTree::SetSeed.

This does not scale well, if you have many more random number generators in exotica. I am therefore wondering if EXOTica should have a global seed that is determined when it is instantiated. This global-seed would then be used to draw new seeds for any generator in EXOTica. This way, you can reset generators, but deterministically.

@wxmerkt
Copy link
Collaborator

wxmerkt commented Jul 10, 2019

Makes sense - where would you suggest to place it?

@christian-rauch
Copy link
Collaborator Author

Since there are many entry points to initialise exotica, I am not sure about this. It appears to me that CreateSolver is always called first, i.e. the Setup class should store that seed and make it available via a getter Setup::GetSeed().
From a quick search, std::random_device is only used in three places: Renderable, KinematicTree and RandomColor. Do you have an idea where randomness is used elsewhere?

@wxmerkt
Copy link
Collaborator

wxmerkt commented Jul 10, 2019

OMPL solvers. I think Setup may be the best place to store. You can also create Problems and Scenes without a Solver, so Setup is the place to go.

@christian-rauch christian-rauch self-assigned this Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants