This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
UXsim++ is a fast mesoscopic traffic simulator written in C++ with Python bindings.
Architecture: Three-layer design
trafficpp/traffi.cpp+traffi.h: C++ simulation coretrafficpp/bindings.cpp: pybind11 Python bindingsuxsimpp.py: High-level Python API wrapper
# Create virtual environment and install development dependencies
python -m venv venv && source venv/bin/activate
pip install scikit-build-core pybind11 cmake ninja pytest build
# Development installation (editable)
pip install -e .# Run C++ unit tests first (must pass before Python tests)
g++ tests/test_03_gridnetwork.cpp -o test03 && ./test03
# Run Python integration and verification tests
pytest tests/test_verification.py -v
# Run tests in parallel
pytest -n auto tests/test_functions.py --durations=0 -v# Build distribution packages
python -m build
# Clean rebuild (if needed)
pip uninstall uxsimpp && pip install -e .- C++ Changes: Modify
uxsimpp/trafficpp/traffi.cpportraffi.h - Test C++: Run C++ unit tests to verify core logic
- Update Bindings: Modify
uxsimpp/trafficpp/bindings.cppif new C++ functions need Python exposure - Rebuild:
pip install -e .to recompile C++ extensions - Test Integration: Run Python tests to verify Python-C++ integration
C++ Core Classes (traffi.cpp):
World: Main simulation containerNode: Network intersectionsLink: Road segments connecting nodesVehicle: Individual vehicles with routing
Python API (uxsimpp.py):
- Imports C++ classes via
from . import trafficppy - Provides functions like
newWorld(),addNode(),addLink(),adddemand() - Additional utilities in
analyzer.pyandutils.py
Critical Files for Changes:
uxsimpp/trafficpp/traffi.cpp: Core simulation algorithmsuxsimpp/trafficpp/bindings.cpp: Python-C++ interfaceuxsimpp/uxsimpp.py: Main Python API
- C++17 standard required
- CMake ≥3.15
- Python ≥3.9
- Core dependencies: numpy, matplotlib, pillow, tqdm, scipy, pandas
- Build dependencies: scikit-build-core, pybind11, cmake, ninja
Always test C++ unit tests before Python integration tests. The C++ tests are faster and will catch core logic issues early. Python tests verify the complete Python-C++ integration works correctly.
When using Python in Linux (including WSL), always use the virtual environment venv that can be activated by
source venv/bin/activate- Adding new dependencies is not recommended. Requests users permission if necessary.
- Comments should be simple and concise. Simple codes do not require comments.
- Let the code fail fast with standard Python/C++ errors unless absolutely necessary. Avoid try-catch blocks or defensive programming with if-checks before operations
- Do not break a long comment sentence across multiple lines. Only insert line breaks at the end of a complete sentence.