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

[Bug] Centering, scaling and clamping the population in iCEM #172

Closed
marbaga opened this issue Dec 7, 2022 · 1 comment · Fixed by #174
Closed

[Bug] Centering, scaling and clamping the population in iCEM #172

marbaga opened this issue Dec 7, 2022 · 1 comment · Fixed by #174
Labels
bug Something isn't working

Comments

@marbaga
Copy link
Contributor

marbaga commented Dec 7, 2022

Steps to reproduce

  1. Run any example configuration using iCEM as action optimizer, e.g. python -m mbrl.examples.main algorithm=mbpo overrides=pets_icem_cartpole

Observed Results

After sampling according to a powerlaw PSD in iCEM, the population is centered on the mean, scaled to the variance and clamped to be within the action space. This process uses the dummy variable population2. However, it appears that the result is not assigned back to the population variable, and it is hence ignored during the rest of the optimization procedure. As a result, I believe that the population is not correctly sampled, and the objective function can be evaluated on actions that potentially do not belong to the action space.

Expected Results

Centering, scaling and clamping should be applied directly to population instead of population2.

Relevant Code

The relevant lines are L438-L441 in mbrl/planning/trajectory_opt.py

population2 = torch.minimum(
population * torch.sqrt(var) + mu, self.upper_bound
)
population2 = torch.maximum(population2, self.lower_bound)

which I believe could be changed to

          population = torch.minimum(
              population * torch.sqrt(var) + mu, self.upper_bound
          )
          population = torch.maximum(population, self.lower_bound)
@marbaga marbaga added the bug Something isn't working label Dec 7, 2022
@luisenp
Copy link
Contributor

luisenp commented Jan 12, 2023

Hi @marbaga. Thanks for reporting this. Would you be interested in opening a pull request with the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants