pcgym


Namepcgym JSON
Version 0.1.8 PyPI version JSON
download
home_pageNone
SummaryReinforcement learning suite of process control problems.
upload_time2024-12-03 13:42:08
maintainerNone
docs_urlNone
authorNone
requires_python~=3.11
licenseMIT License Copyright (c) 2024 Maximilian Bloor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords reinforcement-learning process-control jax casadi control
VCS
bugtrack_url
requirements ruff numpy tqdm cloudpickle matplotlib gymnasium casadi jax equinox diffrax do-mpc
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
  <a href="https://github.com/MaximilianB2/pc-gym/blob/main/docs/img/pc-gym-blue-Ai.png">
    <img src="https://github.com/MaximilianB2/pc-gym/blob/main/docs/img/pc-gym-blue-Ai.png"/></a><br>
  <b>Reinforcement learning environments for process control </b><br>
</h1>
<p align="center">
      <a href="https://www.python.org/doc/versions/">
        <img src="https://img.shields.io/badge/python-3.10-blue.svg" /></a>  
      <a href="https://opensource.org/license/mit">
        <img src="https://img.shields.io/badge/license-MIT-orange" /></a>
      <a href="https://github.com/astral-sh/ruff">
        <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" /></a>
</p>


## Quick start ⚡
Setup a CSTR environment with a setpoint change

```python 
import pcgym

# Simulation variables
nsteps = 100
T = 25

# Setpoint
SP = {'Ca': [0.85 for i in range(int(nsteps/2))] + [0.9 for i in range(int(nsteps/2))]} 

# Action and observation Space
action_space = {'low': np.array([295]), 'high': np.array([302])}
observation_space = {'low': np.array([0.7,300,0.8]),'high': np.array([1,350,0.9])}

# Construct the environment parameter dictionary
env_params = {
    'N': nsteps, # Number of time steps
    'tsim':T, # Simulation Time
    'SP' :SP, 
    'o_space' : observation_space, 
    'a_space' : action_space, 
    'x0': np.array([0.8, 330, 0.8]), # Initial conditions [Ca, T, Ca_SP]
    'model': 'cstr_ode', # Select the model
}

# Create environment
env = pcgym.make_env(env_params)

# Reset the environment
obs, state = env.reset()

# Sample a random action
action = env.action_space.sample()

# Perform a step in the environment
obs, rew, done, term, info = env.step(action)
```
## Documentation

You can read the full documentation [here](https://maximilianb2.github.io/pc-gym/)!

## Installation ⏳

The latest pc-gym version can be installed from PyPI:

```bash
pip install pcgym
```

## Examples
Example notebooks with training walkthroughs, implementing constraints, disturbances and the policy evaluation tool can be found [here](https://github.com/MaximilianB2/pc-gym/tree/main/example_notebooks).

## Implemented Process Control Environments 🎛️

|          Environment          | Reference | Source | Documentation |
|:-----------------------------:|:---------:|:------:|---------------|
|              CSTR             | [Hedengren, 2022](https://github.com/APMonitor/pdc/blob/master/CSTR_Control.ipynb)     | [Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py)      |               |
|       First Order Sytem       |      N/A  | [Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py)        |               |
| Multistage Extraction Column  |  [Ingham et al, 2007 (pg 471)](https://onlinelibrary.wiley.com/doi/book/10.1002/9783527614219)         | [Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py)        |               |
| Nonsmooth Control|[Lim,1969](https://pubs.acs.org/doi/epdf/10.1021/i260031a007)|[Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py) ||

## Paper 📚
The associated pre-print paper can be found [here](https://arxiv.org/abs/2410.22093). If you use our software in your work please cite the following:
```
@article{bloor2024pcgymbenchmarkenvironmentsprocess,
      title={PC-Gym: Benchmark Environments For Process Control Problems}, 
      author={Maximilian Bloor and José Torraca and Ilya Orson Sandoval and Akhil Ahmed and Martha White and Mehmet Mercangöz and Calvin Tsay and Ehecatl Antonio Del Rio Chanona and Max Mowbray},
      year={2024},
      eprint={2410.22093},
      archivePrefix={arXiv},
      primaryClass={eess.SY},
      url={https://arxiv.org/abs/2410.22093}, 
}
```
## Other Great Gyms 🔍
- ✨[safe-control-gym](https://github.com/utiasDSL/safe-control-gym) 
- ✨[safety-gymnasium](https://github.com/PKU-Alignment/safety-gymnasium)
- ✨[gymnax](https://github.com/RobertTLange/gymnax)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pcgym",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.11",
    "maintainer_email": null,
    "keywords": "reinforcement-learning, process-control, jax, casadi, control",
    "author": null,
    "author_email": "Max Bloor <max.bloor@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/06/e2/48be12a2805afaafbd90abbece99cbaf09f360be34ca254d5f18e529e038/pcgym-0.1.8.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\r\n  <a href=\"https://github.com/MaximilianB2/pc-gym/blob/main/docs/img/pc-gym-blue-Ai.png\">\r\n    <img src=\"https://github.com/MaximilianB2/pc-gym/blob/main/docs/img/pc-gym-blue-Ai.png\"/></a><br>\r\n  <b>Reinforcement learning environments for process control </b><br>\r\n</h1>\r\n<p align=\"center\">\r\n      <a href=\"https://www.python.org/doc/versions/\">\r\n        <img src=\"https://img.shields.io/badge/python-3.10-blue.svg\" /></a>  \r\n      <a href=\"https://opensource.org/license/mit\">\r\n        <img src=\"https://img.shields.io/badge/license-MIT-orange\" /></a>\r\n      <a href=\"https://github.com/astral-sh/ruff\">\r\n        <img src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\" /></a>\r\n</p>\r\n\r\n\r\n## Quick start \u26a1\r\nSetup a CSTR environment with a setpoint change\r\n\r\n```python \r\nimport pcgym\r\n\r\n# Simulation variables\r\nnsteps = 100\r\nT = 25\r\n\r\n# Setpoint\r\nSP = {'Ca': [0.85 for i in range(int(nsteps/2))] + [0.9 for i in range(int(nsteps/2))]} \r\n\r\n# Action and observation Space\r\naction_space = {'low': np.array([295]), 'high': np.array([302])}\r\nobservation_space = {'low': np.array([0.7,300,0.8]),'high': np.array([1,350,0.9])}\r\n\r\n# Construct the environment parameter dictionary\r\nenv_params = {\r\n    'N': nsteps, # Number of time steps\r\n    'tsim':T, # Simulation Time\r\n    'SP' :SP, \r\n    'o_space' : observation_space, \r\n    'a_space' : action_space, \r\n    'x0': np.array([0.8, 330, 0.8]), # Initial conditions [Ca, T, Ca_SP]\r\n    'model': 'cstr_ode', # Select the model\r\n}\r\n\r\n# Create environment\r\nenv = pcgym.make_env(env_params)\r\n\r\n# Reset the environment\r\nobs, state = env.reset()\r\n\r\n# Sample a random action\r\naction = env.action_space.sample()\r\n\r\n# Perform a step in the environment\r\nobs, rew, done, term, info = env.step(action)\r\n```\r\n## Documentation\r\n\r\nYou can read the full documentation [here](https://maximilianb2.github.io/pc-gym/)!\r\n\r\n## Installation \u23f3\r\n\r\nThe latest pc-gym version can be installed from PyPI:\r\n\r\n```bash\r\npip install pcgym\r\n```\r\n\r\n## Examples\r\nExample notebooks with training walkthroughs, implementing constraints, disturbances and the policy evaluation tool can be found [here](https://github.com/MaximilianB2/pc-gym/tree/main/example_notebooks).\r\n\r\n## Implemented Process Control Environments \ud83c\udf9b\ufe0f\r\n\r\n|          Environment          | Reference | Source | Documentation |\r\n|:-----------------------------:|:---------:|:------:|---------------|\r\n|              CSTR             | [Hedengren, 2022](https://github.com/APMonitor/pdc/blob/master/CSTR_Control.ipynb)     | [Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py)      |               |\r\n|       First Order Sytem       |      N/A  | [Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py)        |               |\r\n| Multistage Extraction Column  |  [Ingham et al, 2007 (pg 471)](https://onlinelibrary.wiley.com/doi/book/10.1002/9783527614219)         | [Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py)        |               |\r\n| Nonsmooth Control|[Lim,1969](https://pubs.acs.org/doi/epdf/10.1021/i260031a007)|[Source](https://github.com/MaximilianB2/pc-gym/blob/main/src/pcgym/model_classes.py) ||\r\n\r\n## Paper \ud83d\udcda\r\nThe associated pre-print paper can be found [here](https://arxiv.org/abs/2410.22093). If you use our software in your work please cite the following:\r\n```\r\n@article{bloor2024pcgymbenchmarkenvironmentsprocess,\r\n      title={PC-Gym: Benchmark Environments For Process Control Problems}, \r\n      author={Maximilian Bloor and Jos\u00e9 Torraca and Ilya Orson Sandoval and Akhil Ahmed and Martha White and Mehmet Mercang\u00f6z and Calvin Tsay and Ehecatl Antonio Del Rio Chanona and Max Mowbray},\r\n      year={2024},\r\n      eprint={2410.22093},\r\n      archivePrefix={arXiv},\r\n      primaryClass={eess.SY},\r\n      url={https://arxiv.org/abs/2410.22093}, \r\n}\r\n```\r\n## Other Great Gyms \ud83d\udd0d\r\n- \u2728[safe-control-gym](https://github.com/utiasDSL/safe-control-gym) \r\n- \u2728[safety-gymnasium](https://github.com/PKU-Alignment/safety-gymnasium)\r\n- \u2728[gymnax](https://github.com/RobertTLange/gymnax)\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Maximilian Bloor  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Reinforcement learning suite of process control problems.",
    "version": "0.1.8",
    "project_urls": {
        "Documentation": "https://maximilianb2.github.io/pc-gym/",
        "Repository": "https://github.com/MaximilianB2/pc-gym"
    },
    "split_keywords": [
        "reinforcement-learning",
        " process-control",
        " jax",
        " casadi",
        " control"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d56178a417cc09e9cdc8a71f02c2b1620e331157cd4f6f34e868834a8bf5872",
                "md5": "a0813f260075f24d6d3ba0f6363b1715",
                "sha256": "3eb3c1c9beb979d7cceee04ac1466a6c2c6f2a4fc3e96909e683c1fe56d5e557"
            },
            "downloads": -1,
            "filename": "pcgym-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a0813f260075f24d6d3ba0f6363b1715",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.11",
            "size": 28869,
            "upload_time": "2024-12-03T13:42:07",
            "upload_time_iso_8601": "2024-12-03T13:42:07.677903Z",
            "url": "https://files.pythonhosted.org/packages/5d/56/178a417cc09e9cdc8a71f02c2b1620e331157cd4f6f34e868834a8bf5872/pcgym-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06e248be12a2805afaafbd90abbece99cbaf09f360be34ca254d5f18e529e038",
                "md5": "5e5bbb42983dce579fc9486402402364",
                "sha256": "12dc57a5324bf1b92964abc1663259e032ad5ca4cc71d5c1a1d680998e5460f4"
            },
            "downloads": -1,
            "filename": "pcgym-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "5e5bbb42983dce579fc9486402402364",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.11",
            "size": 29387,
            "upload_time": "2024-12-03T13:42:08",
            "upload_time_iso_8601": "2024-12-03T13:42:08.785108Z",
            "url": "https://files.pythonhosted.org/packages/06/e2/48be12a2805afaafbd90abbece99cbaf09f360be34ca254d5f18e529e038/pcgym-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-03 13:42:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MaximilianB2",
    "github_project": "pc-gym",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "ruff",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "tqdm",
            "specs": []
        },
        {
            "name": "cloudpickle",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "gymnasium",
            "specs": []
        },
        {
            "name": "casadi",
            "specs": []
        },
        {
            "name": "jax",
            "specs": []
        },
        {
            "name": "equinox",
            "specs": []
        },
        {
            "name": "diffrax",
            "specs": []
        },
        {
            "name": "do-mpc",
            "specs": []
        }
    ],
    "lcname": "pcgym"
}
        
Elapsed time: 0.53072s