Skip to content

gama-platform/gama-visualisation

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GAMA-Visualisation

Python Package Python 3.8+ License: MIT

GAMA-Visualisation is a comprehensive real-time visualization package for GAMA Platform simulations with advanced performance monitoring, animation capabilities, and integrated simulation control.

🎯 Purpose

This library enables researchers and developers to visualize GAMA agent-based simulations in real-time, providing powerful tools for monitoring performance, creating smooth animations, analyzing simulation behavior, and controlling simulation execution directly from Python.

⚑ Quick Start

Installation

pip install gama-visualisation

Prerequisites

  • Python 3.8+ with required dependencies
  • GAMA Platform (optional, for simulation control features): Install from gama-platform.org
# Optional: For GAMA simulation control
pip install gama-client

# Optional: For benchmarking and plotting features  
pip install "gama-visualisation[benchmark]"

Basic Usage

import gama_visualisation
from gama_visualisation import SnapshotViewer

# Create real-time snapshot viewer
viewer = SnapshotViewer(
    directory="path/to/simulation/snapshots",
    image_prefix="frame_",
    image_suffix=".png"
)

# Start real-time visualization
viewer.start()

Integrated Simulation Control

from gama_visualisation import SnapshotViewer, SimulationController

# Create viewer with integrated simulation control
viewer = SnapshotViewer("simulation_output/")
controller = SimulationController(
    snapshot_viewer=viewer,
    experiment_path="model.gaml",
    experiment_name="main_experiment"
)

# Start viewer with simulation control (press SPACEBAR to start simulation)
viewer.start()

Performance Benchmarking

from gama_visualisation.benchmarks import VisualizationBenchmark

# Create benchmark suite
benchmark = VisualizationBenchmark(
    output_dir="benchmark_results",
    enable_plotting=True
)

# Run comprehensive benchmarks
results = benchmark.run_full_benchmark_suite()

# Save results and generate plots
benchmark.save_results(results, format_type="json")

GAMA Configuration

For simulation control features, launch GAMA in server mode:

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

# Windows
gama-headless.bat -socket 6868

πŸ“ Project Structure

gama-visualisation/
β”œβ”€β”€ πŸ“ src/               # Main Python package source code
β”œβ”€β”€ πŸ“ tests/             # Comprehensive test suite
β”œβ”€β”€ πŸ“ examples/          # Complete examples and tutorials
β”œβ”€β”€ πŸ“ Moving Example/    # Advanced animation demonstration
β”œβ”€β”€ pyproject.toml        # Python package configuration
β”œβ”€β”€ LICENSE               # Package license
└── pytest.ini           # Testing configuration

πŸ“š Documentation and Examples

πŸš€ Tutorials and Examples

Example Description Documentation
Basic Example Real-time snapshot visualization πŸ“– Code
Simulation Control Integrated GAMA simulation management πŸ“– Code
Performance Analysis Benchmarking and optimization tools πŸ“– Code
Advanced Animation Procedural animation with Bezier curves πŸ“– Moving Example

πŸ“– Detailed Guides

πŸ”§ Core Components

SnapshotViewer

Real-time image sequence viewer with automatic file monitoring:

  • Watches directories for new simulation images
  • Provides smooth scaling and performance optimization
  • Displays real-time FPS and performance statistics
  • Supports keyboard interaction and window management

SimulationController

Integrated GAMA simulation management:

  • Connects to GAMA Platform server
  • Controls experiment lifecycle (start/stop/step)
  • Provides real-time status updates
  • Integrates seamlessly with SnapshotViewer

Performance Monitoring

Comprehensive system resource tracking:

  • CPU usage and memory consumption monitoring
  • Real-time FPS calculation and smoothing
  • Performance statistics and trend analysis
  • Configurable sampling rates and history retention

Benchmarking Suite

Professional performance analysis tools:

  • Image processing performance benchmarks
  • File monitoring efficiency tests
  • Memory stress testing and leak detection
  • Comparative analysis and reporting

πŸ›  Advanced Installation

From Source Code

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

Optional Dependencies

# For GAMA simulation control
pip install gama-client

# For benchmarking with plots
pip install "gama-visualisation[benchmark]"

# For development tools
pip install "gama-visualisation[dev]"

# Install all optional dependencies
pip install "gama-visualisation[all]"

πŸ§ͺ Testing and Validation

# Run complete test suite
python -m pytest tests/

# Quick functionality test
python setup_package.py --quick-test

# Run benchmark suite
python examples/benchmark_example.py --full-suite

# Quick performance check
python examples/benchmark_example.py --quick-only

βš™οΈ Configuration

Environment Variables

  • GAMA_SERVER_HOST: GAMA server hostname (default: localhost)
  • GAMA_SERVER_PORT: GAMA server port (default: 1001)
  • GAMA_VIZ_CONFIG: Path to configuration file

Configuration File

Create gama_viz_config.json for persistent settings:

{
  "viewer": {
    "max_fps_samples": 20,
    "throttle_delay": 0.05,
    "auto_scale": true,
    "show_fps": true
  },
  "performance": {
    "max_cache_size": 200,
    "enable_monitoring": true,
    "log_performance": true
  },
  "ui": {
    "window_width": 1200,
    "window_height": 800,
    "theme": "default",
    "font_size": 11
  }
}

πŸ“Š Performance

Expected performance on modern hardware:

  • Image Processing: 100+ FPS for 1080p images
  • File Monitoring: 1000+ files/second detection rate
  • Memory Usage: <100MB for typical visualizations
  • CPU Usage: <20% for real-time monitoring

🎨 Key Features

  • Real-time Visualization: Automatic directory monitoring with smooth image display
  • Performance Monitoring: FPS tracking, memory usage, and system resource analysis
  • Simulation Integration: Direct GAMA server communication and experiment control
  • Advanced Processing: Image enhancement, filtering, and procedural animations
  • Benchmarking Suite: Comprehensive performance analysis and optimization tools
  • Professional Package: Modern Python structure with type hints and full testing

🀝 Contributing

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

Development Setup

git clone https://github.com/gama-platform/gama-visualisation.git
cd gama-visualisation

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or
venv\\Scripts\\activate  # Windows

# Install in development mode
pip install -e ".[dev]"

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add comprehensive tests for new features
  • Update documentation for API changes
  • Use type hints for all public functions
  • Write clear commit messages

πŸ”— Useful Links


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

About

A tool to visualize gama simulations while in headless mode

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 87.2%
  • GAML 12.8%