Improved Cross Entropy Method (iCEM) implemented in pytorch
Project description
PyTorch MPPI Implementation
This repository implements the improved Cross Entropy Method (iCEM) with approximate dynamics in pytorch, from this paper.
MPPI typically requires actual trajectory samples, but this paper showed that it could be done with approximate dynamics (such as with a neural network) using importance sampling.
Thus it can be used in place of other trajectory optimization methods such as the Cross Entropy Method (CEM), or random shooting.
Related projects
- pytorch CEM - alternative sampling based MPC
- pytorch MPPI - alternative sampling based MPC
- iCEM - original paper's numpy implementation and experiments code
Installation
pip install pytorch-icem
for running tests, install with
pip install pytorch-icem[test]
for development, clone the repository then install in editable mode
pip install -e .
Usage
See tests/pendulum_approximate_continuous.py for usage with a neural network approximating
the pendulum dynamics. Basic use case is shown below
from pytorch_icem import iCEM
# create controller with chosen parameters
ctrl = icem.iCEM(dynamics, terminal_cost, nx, nu, sigma=sigma,
warmup_iters=10, online_iters=10,
num_samples=N_SAMPLES, num_elites=10, horizon=TIMESTEPS, device=d, )
# assuming you have a gym-like env
obs = env.reset()
for i in range(100):
action = ctrl.command(obs)
obs, reward, done, _, _ = env.step(action.cpu().numpy())
Requirements
- pytorch (>= 1.0)
next state <- dynamics(state, action)function (doesn't have to be true dynamics)stateisK x nx,actionisK x nu
trajectory cost <- cost(state, action)function for the whole state action trajectory, T is the horizoncostisK x 1, state isK x T x nx,actionisK x T x nu
Features
- Parallel/batch pytorch implementation for accelerated sampling
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytorch_icem-0.1.0.tar.gz.
File metadata
- Download URL: pytorch_icem-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ab86b351e2b8eb367d1698444a58d8112b1bbff98cab293d9d41b87ba422c35
|
|
| MD5 |
581e488445e5733eb708a32978186903
|
|
| BLAKE2b-256 |
67ebf93cc1583c0da784722c76845dfd296792b6ca3353359e63329d52d5b0d3
|
File details
Details for the file pytorch_icem-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytorch_icem-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d22309e0b8879b1e4f88787687631c03f1a7f01c639a7cc7134f87951794e180
|
|
| MD5 |
757eb6c5305739460192307fc79f12d5
|
|
| BLAKE2b-256 |
be95e79c59148f2528ee0a2f2e2d47067b26827a1dcdb82e8bcad819f0129aaf
|