gama-gymnasium


Namegama-gymnasium JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA Gymnasium environment for reinforcement learning with GAMA agent-based simulations
upload_time2025-07-17 04:09:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 IRD - INRAE 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 agent-based-modeling gama gymnasium reinforcement-learning rl simulation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GAMA-Gymnasium

[![Python Package](https://img.shields.io/pypi/v/gama-gymnasium)](https://pypi.org/project/gama-gymnasium/)
[![License](https://img.shields.io/github/license/gama-platform/gama-gymnasium)](LICENSE)

**GAMA-Gymnasium** is a generic [Gymnasium](https://gymnasium.farama.org/) environment that enables the integration of simulations from the [GAMA](https://gama-platform.org/) modeling platform with reinforcement learning algorithms.

## ๐ŸŽฏ Purpose

This library allows researchers and developers to easily use GAMA models as reinforcement learning environments, leveraging the power of GAMA for agent-based modeling and the Python ecosystem for AI.

## โšก Quick Start

### Installation

```bash
pip install gama-gymnasium
```

### Prerequisites

- **GAMA Platform**: Install GAMA from [gama-platform.org](https://gama-platform.org/download)
- **Python 3.8+** with required dependencies

```bash
pip install gama-client gymnasium
```

### Basic Usage

```python
import gama_gymnasium
import gymnasium as gym

# Create the environment
env = gym.make('gama-gymnasium-v0', 
               gama_model_path='your_model.gaml',
               gama_port=6868)

# Use as a standard Gymnasium environment
obs, info = env.reset()
for _ in range(100):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()
```

### GymansiumLink Skill

The `GymansiumLink` skill is a GAMA skill of the `gama_gymnasium` plugin that allows GAMA agents to interact with Gymnasium environments. It adds 8 varriables and 1 action to the agent

Structure of the skill:

```gaml
species GymAgent skills:[GymnasiumLink]{
    map action_space;
    map observation_space

    unknown state;
    float reward;
    boolean terminated;
    boolean truncated;
    map info;

    unknown next_action;

    action update_data;
}
```

### GAMA Configuration

1. **Add the GAMA component** to your model:
   Make sure you have the GAMA plugin gama_gymnasium and add a species `GymAgent` with the skill `GymnasiumLink` to your model:

   ```gaml
   species GymAgent skills:[GymnasiumLink];
   ```

   Set up the `action_space` and `observation_space`:

   ```gaml
   global {
       init{
           create GymAgent;
           GymAgent[0].action_space <- ["type"::"Discrete", "n"::4];
           GymAgent[0].observation_space <- ["type"::"Box", "low"::0, "high"::grid_size, "shape"::[2], "dtype"::"int"];
       }
   }
   ```

   Update the gym agent's data after the action is completed:

   ```gaml
   ask GymAgent[0] {
       do update_data;
   }
   ```
2. **Launch GAMA in server mode**:

```bash
# Linux/MacOS
./gama-headless.sh -socket 6868

# Windows
gama-headless.bat -socket 6868
```

## ๐Ÿ“ Project Structure

```text
gama-gymnasium/
โ”œโ”€โ”€ ๐Ÿ“ src/                # Main Python package source code
โ”œโ”€โ”€ ๐Ÿ“ tests/              # Comprehensive test suite
โ”œโ”€โ”€ ๐Ÿ“ examples/           # Complete examples and tutorials
โ”œโ”€โ”€ pyproject.toml	  # Python package configuration
โ”œโ”€โ”€ LICENSE               # Package license
โ””โ”€โ”€ ๏ฟฝ pytest.ini         # Testing configuration
```

## ๐Ÿ“š Documentation and Examples

### ๐Ÿš€ Tutorials and Examples

| Example                          | Description                                           | Documentation                                          |
| -------------------------------- | ----------------------------------------------------- | ------------------------------------------------------ |
| **Basic Example**          | Introduction to GAMA-Gymnasium integration            | [๐Ÿ“– README](examples/basic_example/README.md)             |
| **CartPole DQN**           | Deep Q-Network implementation on CartPole environment | [๐Ÿ“– README](examples/cartpole%20DQN/README.md)            |
| **Frozen Lake Q-Learning** | Q-Learning on Frozen Lake environment                 | [๐Ÿ“– README](examples/frozen%20lake%20QLearning/README.md) |

### ๐Ÿ“– Detailed Guides

- **[Basic Example Guide](examples/basic_example/README.md)**: Complete tutorial for creating your first environment
- **[Direct GAMA Test](examples/basic_example/README_basic_test.md)**: Low-level communication with GAMA
- **[Source Code Documentation](src/README.md)**: Technical documentation of the package structure
- **[Testing Guide](tests/README.md)**: Comprehensive testing framework and best practices

## ๐Ÿ›  Advanced Installation

### From Source Code

```bash
git clone https://github.com/gama-platform/gama-gymnasium.git
cd gama-gymnasium
pip install -e src/ 
```

## ๐Ÿงช Testing and Validation

```bash
# Run tests
python tests/test_manager.py --quick
```

## ๐Ÿค Contributing

Contributions are welcome! Check the [issues](https://github.com/gama-platform/gama-gymnasium/issues) to see how you can help.

## ๐Ÿ”— Useful Links

- [GAMA Platform](https://gama-platform.org/)
- [Gymnasium Documentation](https://gymnasium.farama.org/)
- [GAMA-Client PyPI](https://pypi.org/project/gama-client/)

---

For more technical details and practical examples, check the documentation in the [`examples/`](examples/) and [`src/`](src/) folders, or explore our comprehensive [testing framework](tests/README.md).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gama-gymnasium",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "agent-based-modeling, gama, gymnasium, reinforcement-learning, rl, simulation",
    "author": null,
    "author_email": "Baptiste Lesquoy <baptiste.lesquoy@ird.fr>, Meritxell Vinyals <meritxell.vinyals@inrae.fr>",
    "download_url": "https://files.pythonhosted.org/packages/ed/a2/9b026c1ba7f74432beafd7489554968cba4c0746ae4749a3e8c58f1e63a5/gama_gymnasium-0.1.1.tar.gz",
    "platform": null,
    "description": "# GAMA-Gymnasium\n\n[![Python Package](https://img.shields.io/pypi/v/gama-gymnasium)](https://pypi.org/project/gama-gymnasium/)\n[![License](https://img.shields.io/github/license/gama-platform/gama-gymnasium)](LICENSE)\n\n**GAMA-Gymnasium** is a generic [Gymnasium](https://gymnasium.farama.org/) environment that enables the integration of simulations from the [GAMA](https://gama-platform.org/) modeling platform with reinforcement learning algorithms.\n\n## \ud83c\udfaf Purpose\n\nThis library allows researchers and developers to easily use GAMA models as reinforcement learning environments, leveraging the power of GAMA for agent-based modeling and the Python ecosystem for AI.\n\n## \u26a1 Quick Start\n\n### Installation\n\n```bash\npip install gama-gymnasium\n```\n\n### Prerequisites\n\n- **GAMA Platform**: Install GAMA from [gama-platform.org](https://gama-platform.org/download)\n- **Python 3.8+** with required dependencies\n\n```bash\npip install gama-client gymnasium\n```\n\n### Basic Usage\n\n```python\nimport gama_gymnasium\nimport gymnasium as gym\n\n# Create the environment\nenv = gym.make('gama-gymnasium-v0', \n               gama_model_path='your_model.gaml',\n               gama_port=6868)\n\n# Use as a standard Gymnasium environment\nobs, info = env.reset()\nfor _ in range(100):\n    action = env.action_space.sample()\n    obs, reward, terminated, truncated, info = env.step(action)\n    if terminated or truncated:\n        obs, info = env.reset()\n```\n\n### GymansiumLink Skill\n\nThe `GymansiumLink` skill is a GAMA skill of the `gama_gymnasium` plugin that allows GAMA agents to interact with Gymnasium environments. It adds 8 varriables and 1 action to the agent\n\nStructure of the skill:\n\n```gaml\nspecies GymAgent skills:[GymnasiumLink]{\n    map action_space;\n    map observation_space\n\n    unknown state;\n    float reward;\n    boolean terminated;\n    boolean truncated;\n    map info;\n\n    unknown next_action;\n\n    action update_data;\n}\n```\n\n### GAMA Configuration\n\n1. **Add the GAMA component** to your model:\n   Make sure you have the GAMA plugin gama_gymnasium and add a species `GymAgent` with the skill `GymnasiumLink` to your model:\n\n   ```gaml\n   species GymAgent skills:[GymnasiumLink];\n   ```\n\n   Set up the `action_space` and `observation_space`:\n\n   ```gaml\n   global {\n       init{\n           create GymAgent;\n           GymAgent[0].action_space <- [\"type\"::\"Discrete\", \"n\"::4];\n           GymAgent[0].observation_space <- [\"type\"::\"Box\", \"low\"::0, \"high\"::grid_size, \"shape\"::[2], \"dtype\"::\"int\"];\n       }\n   }\n   ```\n\n   Update the gym agent's data after the action is completed:\n\n   ```gaml\n   ask GymAgent[0] {\n       do update_data;\n   }\n   ```\n2. **Launch GAMA in server mode**:\n\n```bash\n# Linux/MacOS\n./gama-headless.sh -socket 6868\n\n# Windows\ngama-headless.bat -socket 6868\n```\n\n## \ud83d\udcc1 Project Structure\n\n```text\ngama-gymnasium/\n\u251c\u2500\u2500 \ud83d\udcc1 src/                # Main Python package source code\n\u251c\u2500\u2500 \ud83d\udcc1 tests/              # Comprehensive test suite\n\u251c\u2500\u2500 \ud83d\udcc1 examples/           # Complete examples and tutorials\n\u251c\u2500\u2500 pyproject.toml\t  # Python package configuration\n\u251c\u2500\u2500 LICENSE               # Package license\n\u2514\u2500\u2500 \ufffd pytest.ini         # Testing configuration\n```\n\n## \ud83d\udcda Documentation and Examples\n\n### \ud83d\ude80 Tutorials and Examples\n\n| Example                          | Description                                           | Documentation                                          |\n| -------------------------------- | ----------------------------------------------------- | ------------------------------------------------------ |\n| **Basic Example**          | Introduction to GAMA-Gymnasium integration            | [\ud83d\udcd6 README](examples/basic_example/README.md)             |\n| **CartPole DQN**           | Deep Q-Network implementation on CartPole environment | [\ud83d\udcd6 README](examples/cartpole%20DQN/README.md)            |\n| **Frozen Lake Q-Learning** | Q-Learning on Frozen Lake environment                 | [\ud83d\udcd6 README](examples/frozen%20lake%20QLearning/README.md) |\n\n### \ud83d\udcd6 Detailed Guides\n\n- **[Basic Example Guide](examples/basic_example/README.md)**: Complete tutorial for creating your first environment\n- **[Direct GAMA Test](examples/basic_example/README_basic_test.md)**: Low-level communication with GAMA\n- **[Source Code Documentation](src/README.md)**: Technical documentation of the package structure\n- **[Testing Guide](tests/README.md)**: Comprehensive testing framework and best practices\n\n## \ud83d\udee0 Advanced Installation\n\n### From Source Code\n\n```bash\ngit clone https://github.com/gama-platform/gama-gymnasium.git\ncd gama-gymnasium\npip install -e src/ \n```\n\n## \ud83e\uddea Testing and Validation\n\n```bash\n# Run tests\npython tests/test_manager.py --quick\n```\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Check the [issues](https://github.com/gama-platform/gama-gymnasium/issues) to see how you can help.\n\n## \ud83d\udd17 Useful Links\n\n- [GAMA Platform](https://gama-platform.org/)\n- [Gymnasium Documentation](https://gymnasium.farama.org/)\n- [GAMA-Client PyPI](https://pypi.org/project/gama-client/)\n\n---\n\nFor more technical details and practical examples, check the documentation in the [`examples/`](examples/) and [`src/`](src/) folders, or explore our comprehensive [testing framework](tests/README.md).\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024 IRD - INRAE\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "A Gymnasium environment for reinforcement learning with GAMA agent-based simulations",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/gama-platform/gama-gymnasium/issues",
        "Documentation": "https://github.com/gama-platform/gama-gymnasium#readme",
        "GAMA Platform": "https://gama-platform.org/",
        "Homepage": "https://github.com/gama-platform/gama-gymnasium",
        "Repository": "https://github.com/gama-platform/gama-gymnasium"
    },
    "split_keywords": [
        "agent-based-modeling",
        " gama",
        " gymnasium",
        " reinforcement-learning",
        " rl",
        " simulation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3fe1e31143f6bbcff2ef351633d7fc1bcaf0edb3570b025d3797d0a39dcce8c6",
                "md5": "108464fe6b37e643374f4765de22487d",
                "sha256": "e1cc3e6bc7d4ae4ea04582bf95ba61e60c9f7a3e70a17bfa9f249ad829d5fb0e"
            },
            "downloads": -1,
            "filename": "gama_gymnasium-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "108464fe6b37e643374f4765de22487d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10382,
            "upload_time": "2025-07-17T04:09:05",
            "upload_time_iso_8601": "2025-07-17T04:09:05.123251Z",
            "url": "https://files.pythonhosted.org/packages/3f/e1/e31143f6bbcff2ef351633d7fc1bcaf0edb3570b025d3797d0a39dcce8c6/gama_gymnasium-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "eda29b026c1ba7f74432beafd7489554968cba4c0746ae4749a3e8c58f1e63a5",
                "md5": "2b48b102cae498a23bd98e446aacf5d0",
                "sha256": "2074fe57131a9a7f2269799197602112dde8a2e2e2ce487b54a21a379fa4211f"
            },
            "downloads": -1,
            "filename": "gama_gymnasium-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2b48b102cae498a23bd98e446aacf5d0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9578,
            "upload_time": "2025-07-17T04:09:06",
            "upload_time_iso_8601": "2025-07-17T04:09:06.442760Z",
            "url": "https://files.pythonhosted.org/packages/ed/a2/9b026c1ba7f74432beafd7489554968cba4c0746ae4749a3e8c58f1e63a5/gama_gymnasium-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-17 04:09:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gama-platform",
    "github_project": "gama-gymnasium",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gama-gymnasium"
}
        
Elapsed time: 0.42828s