Skip to main content

GAMA-Gymnasium

Python Package License DOI

GAMA-Gymnasium is a generic Gymnasium environment that enables the integration of simulations from the GAMA 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

pip install gama-gymnasium

Prerequisites

  • GAMA Platform: Install GAMA from gama-platform.org
  • Python 3.8+ with required dependencies
pip install gama-client gymnasium

Basic Usage

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()

GymAgent

The GymAgent is a GAMA agent that is required in the model to enable interaction between the simulation's learning agent and the Gymnasium environment. It has nine variables and one action. The GymAgent is a GAMA agent required in the model to allow the interaction between the learning agent of the simulation and Gymnasium environments. It have 9 variables and 1 action

Structure of the agent:

species GymAgent{
	map<string, unknown> action_space;
	map<string, unknown> observation_space;

	unknown state;
	float reward;
	bool terminated;
	bool truncated;
	map<string, unknown> info;

	unknown next_action;

	map<string, unknown> data;

	action update_data {
		data <- [
			"State"::state,
			"Reward"::reward,
			"Terminated"::terminated,
			"Truncated"::truncated,
			"Info"::info
		];
	}
}

GAMA Configuration

  1. Add the GAMA component to your model: Make sure you have added the species GymAgent described above to your model:

    species GymAgent;
    

    Set up the action_space and observation_space:

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

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

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

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

# Windows
gama-headless.bat -socket 6868

📁 Project Structure

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
CartPole DQN Deep Q-Network implementation on CartPole environment 📖 README
Frozen Lake Q-Learning An example of Q-Learning purely in gama

📖 Detailed Guides

🛠 Advanced Installation

From Source Code

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

🧪 Testing and Validation

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

🤝 Contributing

Contributions are welcome! Check the issues to see how you can help.

🔗 Useful Links


For more technical details and practical examples, check the documentation in the examples/ and src/ folders, or explore our comprehensive testing framework.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gama_gymnasium-1.0.2.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gama_gymnasium-1.0.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file gama_gymnasium-1.0.2.tar.gz.

File metadata

  • Download URL: gama_gymnasium-1.0.2.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for gama_gymnasium-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7d1e8ee4e24899821ffbc10186787d5ddeb9d905feb147f7dd1ecb6452117198
MD5 72279533926a71fcfc5e00065cbab84b
BLAKE2b-256 4e7ea6a635426c65efbb4108ae957f1cd39e748bc0a8acd8718b592f46dcfb67

See more details on using hashes here.

Provenance

The following attestation bundles were made for gama_gymnasium-1.0.2.tar.gz:

Publisher: release.yml on gama-platform/gama-gymnasium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gama_gymnasium-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: gama_gymnasium-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for gama_gymnasium-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aae7c21c87b62dc23d62e10432f3f1e86a2fb567ea5d6ac86c45e0d0c40879be
MD5 61e5754514351beaff34ef917e8503d1
BLAKE2b-256 faa17dd42b6ae87187de4c480ddf6dad80165b7b6117f6ee513b408df184be05

See more details on using hashes here.

Provenance

The following attestation bundles were made for gama_gymnasium-1.0.2-py3-none-any.whl:

Publisher: release.yml on gama-platform/gama-gymnasium

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page