Python bindings for SIMILAR2Logo multi-agent simulation framework
Project description
SIMILAR & JamFree: High-Performance Agent-Based Simulation Framework
SIMILAR is a powerful agent-based modeling framework with a Python DSL backed by a high-performance C++ engine. JamFree is a traffic simulation framework built on SIMILAR, featuring microscopic and macroscopic models with real-time data integration.
๐ Quick Start
Installation
# Clone the repository
git clone https://github.com/gildasmorvan/similar
cd similar
# Build C++ engine (recommended for 10-100x performance boost)
./build_cpp_engine.sh
# Install Python dependencies
pip install -r requirements.txt
๐ New to SIMILAR? See Getting Started Guide for a complete walkthrough!
โก Quick Commands? Check Quick Reference for a command cheat sheet!
Your First Simulation (SIMILAR2Logo)
Create my_first_sim.py:
from similar2logo.dsl import *
import random
class RandomWalker(Turtle):
def decide(self, perception):
influences = []
if random.random() < 0.3:
influences.append(self.influence_turn(random.uniform(-0.5, 0.5)))
influences.append(self.influence_move_forward(1.0))
return influences
# Create environment and simulation
env = Environment(100, 100, toroidal=True)
sim = Simulation(environment=env, title="Random Walk")
# Add 50 agents
for _ in range(50):
sim.add_agent(RandomWalker(
position=env.random_position(),
heading=env.random_heading()
))
# Run with web interface
sim.run_web(port=8080)
Run it:
python3 my_first_sim.py
# Open http://localhost:8080
Your First Traffic Simulation (JamFree)
cd cpp/jamfree
# Build JamFree
./build.sh
# Run web interface
./run_web_ui.sh
# Open http://localhost:5001
๐ What's Included
SIMILAR2Logo - Agent-Based Modeling
A Python DSL for creating agent-based simulations with:
- ๐ข Turtle Agents: Logo-style agents with perception and decision-making
- ๐ Environments: Toroidal/bounded worlds with pheromones and obstacles
- ๐ง Influences: Clean action system (move, turn, emit signals)
- โก C++ Engine: Automatic 10-100x speedup when available
- ๐ Web UI: Real-time visualization in browser
- ๐ 18+ Examples: From flocking to epidemiology
Examples: Boids, Ant Foraging, Virus Spread, Segregation, Predator-Prey, and more!
JamFree - Traffic Simulation
A comprehensive traffic simulation framework featuring:
- ๐ Microscopic Models: IDM car-following, MOBIL lane-changing
- ๐ Macroscopic Models: LWR, CTM continuum flow
- ๐ Hybrid Simulation: Automatic micro/macro switching
- ๐บ๏ธ OSM Integration: Real-world road networks
- ๐ก Real-Time Data: TomTom, HERE, OpenTraffic integration
- ๐ฏ Routing: A* pathfinding with turn-by-turn navigation
- โก GPU Acceleration: Metal GPU support (macOS)
- ๐ Web Interface: Interactive visualization
๐ฏ Key Features
Performance
- C++ Engine: Core simulation logic in optimized C++
- Python DSL: Easy-to-use Python interface
- Parallel Processing: Multi-threaded simulation
- GPU Support: Metal acceleration for large-scale traffic sims
- Adaptive Hybrid: Automatic micro/macro switching for optimal speed
Flexibility
- Multiple Paradigms: Microscopic, macroscopic, hybrid
- Real Data: OSM maps, traffic APIs, real-time integration
- Extensible: Easy to add new models and behaviors
- Cross-Platform: Linux, macOS, Windows
Usability
- Clean DSL: Intuitive Python API
- Web Visualization: No GUI installation needed
- Rich Examples: 18+ SIMILAR2Logo + traffic examples
- Documentation: Comprehensive guides and tutorials
๐ Documentation
๐ Complete Documentation Index - Find any document quickly!
SIMILAR2Logo
- Quick Start Guide - Get started in 5 minutes
- Examples README - All 18 examples explained
- DSL Reference - API documentation
- Implementation Status - What's implemented
JamFree
- JamFree README - Overview and concepts
- Quick Start - Get running fast
- Web UI Guide - Using the web interface
- Performance Guide - Optimization tips
- Routing & Traffic Data - Real-world integration
๐จ Examples
SIMILAR2Logo Examples
All located in examples/python/:
Basic
simple_random_walk.py- Basic movementcircle.py- Formation patternspassive_turtle.py- Physics simulation
Flocking & Collective
boids_dsl.py- Classic flocking behaviorboids_obstacles.py- Flocking with obstacle avoidanceant_foraging_dsl.py- Pheromone-based foraging
Biological
virus_spread.py- Epidemiology (SIR model)predator_prey.py- Lotka-Volterra dynamicsheatbugs.py- Temperature-seeking agents
Social & Urban
segregation_model.py- Schelling's modeltransport.py- Traffic simulation
Patterns & Emergence
turmite.py- Langton's Antmultiturmite.py- Multiple antsforest_fire.py- Cellular automaton
And more! See examples/python/README.md for the complete list.
JamFree Examples
Located in cpp/jamfree/examples/:
- Basic Simulation - Simple traffic flow
- OSM Integration - Real-world maps
- Hybrid Simulation - Micro/macro switching
- GPU Acceleration - Metal-accelerated simulation
- Routing - Path planning and navigation
๐ Running Examples
SIMILAR2Logo
# Run any example
python3 examples/python/boids_dsl.py
# With C++ engine verification
SIMILAR_VERBOSE=1 python3 examples/python/virus_spread.py
# Run all examples (testing)
python3 examples/python/run_examples.py
JamFree
cd cpp/jamfree
# Web interface (recommended)
./run_web_ui.sh
# Then open http://localhost:5001
# Command-line simulation
python3 examples/basic_simulation.py
# With performance stats
python3 examples/hybrid_simulation.py
๐ง Building from Source
SIMILAR2Logo C++ Engine
# Build C++ engine
./build_cpp_engine.sh
# Verify it works
SIMILAR_VERBOSE=1 python3 examples/python/boids_dsl.py
# Should see: โ Using C++ reaction engine
JamFree
cd cpp/jamfree
# Build core library
./build.sh
# Build with Python bindings
./build_python.sh
# Build with GPU support (macOS only)
./build_metal.sh
๐ Web Interfaces
SIMILAR2Logo Web UI
Most examples include a built-in web interface:
# In your simulation
sim.run_web(port=8080, steps_per_frame=1)
Then open http://localhost:8080
JamFree Web UI
Full-featured traffic simulation interface:
cd cpp/jamfree
./run_web_ui.sh
Features:
- ๐บ๏ธ Load OSM maps (upload or download)
- ๐ Configure vehicles and parameters
- โก Enable/disable optimizations
- ๐ Real-time performance metrics
- ๐จ Lane mode visualization (micro/macro)
๐ Performance
SIMILAR2Logo
With C++ engine enabled:
- 10-100x faster than pure Python
- Handles 1000+ agents in real-time
- Efficient spatial indexing
- Optimized influence resolution
JamFree
Performance optimizations:
- IDM Lookup Tables: 30-40% faster car-following
- Spatial Indexing: O(log N) neighbor queries
- Adaptive Hybrid: Auto micro/macro switching
- GPU Acceleration: Metal support for macOS
- Multithreading: Parallel vehicle updates
Example: 1000 vehicles on real OSM map at 10+ FPS
๐ฌ Research & Education
Perfect for:
- Agent-Based Modeling courses
- Complex Systems research
- Traffic Engineering studies
- Artificial Life experiments
- Swarm Intelligence research
- Computational Biology teaching
๐ค Contributing
We welcome contributions! To contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests and documentation
- Submit a pull request
See individual component READMEs for specific guidelines.
๐ License
This project is licensed under the CeCILL-B license - see LICENSE.txt for details.
CeCILL-B is a BSD-like license compatible with international and French law.
๐ฅ Authors
- Gildas Morvan - Original SIMILAR framework
- Contributors - See AUTHORS.txt
๐ Resources
Documentation
Academic References
- Traffic Flow Dynamics - Treiber & Kesting (2013)
- MOBIL Model - Kesting et al. (2007)
- Agent-Based Modeling - Wilensky & Rand (2015)
Related Projects
๐ฏ Project Structure
similar/
โโโ cpp/
โ โโโ similar2logo/ # C++ engine for SIMILAR2Logo
โ โโโ jamfree/ # JamFree traffic simulation
โ โโโ kernel/ # Core models (Vehicle, Lane, Road)
โ โโโ microscopic/ # IDM, MOBIL
โ โโโ macroscopic/ # LWR, CTM
โ โโโ hybrid/ # Adaptive simulation
โ โโโ gpu/ # Metal GPU acceleration
โ โโโ realdata/ # OSM parser, traffic APIs
โ โโโ python/ # Python bindings
โ โโโ examples/ # Example simulations
โโโ python/
โ โโโ similar2logo/ # Python DSL
โ โโโ dsl/ # High-level API
โ โโโ model.py # Core classes
โ โโโ parallel.py # Parallel engine
โโโ examples/
โ โโโ python/ # 18+ example simulations
โโโ docs/ # Additional documentation
๐ฆ Status
SIMILAR2Logo
โ Complete - All Java examples ported to Python DSL with C++ engine
JamFree
โ Production Ready
- Microscopic simulation (IDM, MOBIL)
- Macroscopic models (LWR, CTM)
- Hybrid adaptive simulation
- OSM integration
- Web UI with visualization
- GPU acceleration (macOS)
- Real-time traffic data integration
๐ Getting Help
- Issues: GitHub Issues
- Examples: Check
examples/python/for working code - Documentation: See individual README files
- Verbose Mode: Use
SIMILAR_VERBOSE=1to see what's happening
๐ก Tips
- Start simple: Try
simple_random_walk.pyfirst - Use C++ engine: Build it for major speedup
- Check examples: 18+ working examples to learn from
- Web UI: Great for visualization and debugging
- Read docs: Each component has detailed documentation
Happy Simulating! ๐
For more information, see:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file similar2logo-1.0.0.tar.gz.
File metadata
- Download URL: similar2logo-1.0.0.tar.gz
- Upload date:
- Size: 35.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5771ee5ffc612edb498c4a27afb187119b132b0682173cb757a37cf196af96a0
|
|
| MD5 |
028251d6fce8cfc48a708eaaaa02c81f
|
|
| BLAKE2b-256 |
8e375d163ddd6d0decae11e77c360f70a8edc9f750c5283bb12f3e2daa728f3c
|
File details
Details for the file similar2logo-1.0.0-py3-none-any.whl.
File metadata
- Download URL: similar2logo-1.0.0-py3-none-any.whl
- Upload date:
- Size: 635.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaffecffa84fed9b69aa567eb9d97bf9d541b661cd6506abe18adefdae217a06
|
|
| MD5 |
f86119407c5200e2289de8b7b8e970d8
|
|
| BLAKE2b-256 |
f5d079c4716bac2ba7d0e385ca6342ac205bfb93f664e9d731ac4a3b405a7d77
|