{"id":15293011,"url":"https://github.com/um-arm-lab/pytorch_icem","last_synced_at":"2025-10-30T05:13:51.441Z","repository":{"id":212735539,"uuid":"732190133","full_name":"UM-ARM-Lab/pytorch_icem","owner":"UM-ARM-Lab","description":"Parallelized pytorch implementation of iCEM","archived":false,"fork":false,"pushed_at":"2024-04-09T13:40:19.000Z","size":11,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-27T03:22:32.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UM-ARM-Lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-15T21:57:46.000Z","updated_at":"2024-12-15T04:20:48.000Z","dependencies_parsed_at":"2023-12-15T22:54:58.102Z","dependency_job_id":"78f8c6b8-a90b-49f8-a8df-94b896f5804d","html_url":"https://github.com/UM-ARM-Lab/pytorch_icem","commit_stats":null,"previous_names":["um-arm-lab/pytorch_icem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UM-ARM-Lab%2Fpytorch_icem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UM-ARM-Lab%2Fpytorch_icem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UM-ARM-Lab%2Fpytorch_icem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UM-ARM-Lab%2Fpytorch_icem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UM-ARM-Lab","download_url":"https://codeload.github.com/UM-ARM-Lab/pytorch_icem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248711072,"owners_count":21149288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-30T16:37:42.431Z","updated_at":"2025-10-30T05:13:46.400Z","avatar_url":"https://github.com/UM-ARM-Lab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyTorch iCEM Implementation\nThis repository implements the improved Cross Entropy Method (iCEM) \nwith approximate dynamics in pytorch, from [this paper](https://martius-lab.github.io/iCEM/). \n\nMPPI typically requires actual\ntrajectory samples, but [this paper](https://martius-lab.github.io/iCEM/)\nshowed that it could be done with approximate dynamics (such as with a neural network)\nusing importance sampling.\n\nThus it can be used in place of other trajectory optimization methods\nsuch as the Cross Entropy Method (CEM), or random shooting.\n\n\n# Related projects\n- [pytorch CEM](https://github.com/LemonPi/pytorch_cem) - alternative sampling based MPC\n- [pytorch MPPI](https://github.com/UM-ARM-Lab/pytorch_mppi) - alternative sampling based MPC \n- [iCEM](https://github.com/martius-lab/iCEM) - original paper's numpy implementation and experiments code\n\n\n# Installation\n```shell\npip install pytorch-icem\n```\nfor running tests, install with\n```shell\npip install pytorch-icem[test]\n```\nfor development, clone the repository then install in editable mode\n```shell\npip install -e .\n```\n\n# Usage\nSee `tests/pendulum_approximate_continuous.py` for usage with a neural network approximating\nthe pendulum dynamics. Basic use case is shown below\n\n```python\nfrom pytorch_icem import iCEM\n\n# create controller with chosen parameters\nctrl = icem.iCEM(dynamics, terminal_cost, nx, nu, sigma=sigma,\n                 warmup_iters=10, online_iters=10,\n                 num_samples=N_SAMPLES, num_elites=10, horizon=TIMESTEPS, device=d, )\n\n# assuming you have a gym-like env\nobs = env.reset()\nfor i in range(100):\n    action = ctrl.command(obs)\n    obs, reward, done, _, _ = env.step(action.cpu().numpy())\n```\n\n# Requirements\n- pytorch (\u003e= 1.0)\n- `next state \u003c- dynamics(state, action)` function (doesn't have to be true dynamics)\n    - `state` is `K x nx`, `action` is `K x nu`\n- `trajectory cost \u003c- cost(state, action)` function for the whole state action trajectory, T is the horizon\n    - `cost` is `K x 1`, state is `K x T x nx`, `action` is `K x T x nu`\n\n# Features\n- Parallel/batch pytorch implementation for accelerated sampling\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fum-arm-lab%2Fpytorch_icem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fum-arm-lab%2Fpytorch_icem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fum-arm-lab%2Fpytorch_icem/lists"}