A self-partitioning graph framework for distributed, autonomous data management in Industrial IoT (IIoT) and multi-source data stream systems. The system employs advanced machine learning techniques including Graph Neural Networks (GNN) and Reinforcement Learning (RL) to achieve optimal graph partitioning.
- Multi-strategy approach:
- Spectral clustering for initial partitioning
- GNN-based strategy with attention mechanism
- RL-based dynamic partitioning
- Hybrid approach combining multiple strategies
- Decentralized autonomous agents
- Multi-head attention mechanism
- Quantized neural networks for efficiency
- Experience replay for improved learning
- Comprehensive metric system
- Real-time visualization and monitoring
- Checkpoint management
- Extensive test coverage
- Cross-platform compatibility (Windows, macOS, Linux)
- Python >= 3.8
- PyTorch >= 1.9.0
- NetworkX >= 2.6.0
- Additional dependencies in requirements.txt
- Create and activate a virtual environment:
# On macOS/Linux
python3 -m venv venv
source venv/bin/activate
# On Windows
python -m venv venv
.\venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Verify installation by running tests:
python -m pytest src/tests- Default parameters are in
src/config/system_config.py - Override parameters using YAML files in
configs/ - Example configurations provided in
configs/test_config.yaml
Basic syntax:
python main.py [options]
Available options:
-h, --help show this help message and exit
--config CONFIG Path to configuration YAML file
--runs RUNS Number of experiment runs (overrides config)
--experiment_name EXPERIMENT_NAME
Experiment name for logging
--strategy {dynamic,spectral,hybrid,gnn}
Partitioning strategy to use
--no_parallel Disable parallel processing for multiple runs
- Basic experiment with default configuration:
python main.py --experiment_name basic_test- Run with specific strategy and configuration:
python main.py --config configs/test_config.yaml --strategy hybrid --experiment_name hybrid_test --runs 10- Run with different strategies:
python main.py --config configs/test_config.yaml --strategy spectral --experiment_name spectral_test
python main.py --config configs/test_config.yaml --strategy dynamic --experiment_name dynamic_test
python main.py --config configs/test_config.yaml --strategy gnn --experiment_name gnn_test- Run multiple experiments:
python main.py --config configs/test_config.yaml --strategy hybrid --experiment_name hybrid_multi --runs 5- Run without parallel processing:
python main.py --config configs/test_config.yaml --experiment_name sequential_test --runs 3 --no_parallelNote: All graph parameters (number of nodes, edge probability, etc.) and algorithm parameters should be specified in the YAML configuration files under configs/.
- Start TensorBoard:
tensorboard --logdir runs/- View results in browser:
- Open: http://localhost:6006
- Monitor metrics, visualizations, and training progress
To clean all generated files (output, plots, logs, etc.):
python CleanUp.pyThe system has been tested and is compatible with:
- macOS
- Windows
- Linux
- Automatic system compatibility checks run at startup to verify permissions
- Path handling is platform-independent using Python's
pathlib.Path - Directory and file operations handle Windows-specific errors
src/agents/: Agent implementations (base, local, global)src/config/: System configurationsrc/core/: Core graph and partition classessrc/models/: GNN model implementationsrc/strategies/: Partitioning strategiessrc/utils/: Helper functions and metricssrc/tests/: Test suite
src/core/: Foundation classes- Graph data structures
- Partition management
- Serialization utilities
src/agents/: Autonomous agents- Base agent framework
- Local RL agents
- Global coordination
src/models/: Neural networks- GNN implementation
- Attention mechanisms
- Quantized layers
src/strategies/: Partitioning approaches- Base strategy interface
- Dynamic RL-based partitioning
- Spectral clustering
- Hybrid implementation
- GNN-based approach
src/utils/: Utilities- Metric calculations
- Visualization tools
- Helper functions
- Cross-platform file operations
src/config/: Configuration- System settings
- Training parameters
src/tests/: Testing- Unit tests
- Integration tests
- Performance benchmarks
- Code Map: Detailed code structure and architecture
- Index: Quick reference and API guide
- TODO: Development roadmap and progress
# Run all tests
python -m pytest src/tests/
# Run specific test category
python -m pytest src/tests/test_strategies.py
# Run individual test
python -m pytest src/tests/test_strategies.py::test_spectral_strategy
# Run benchmark test with verbose output
python -m pytest src/tests/test_strategies.py::test_benchmark_strategies -v
# Run tests with coverage report
python -m pytest --cov=src src/tests/
# Run tests with detailed coverage
python -m pytest --cov=src --cov-report=term-missing src/tests/# Run all benchmarks
python -m pytest src/tests/ --benchmark-only
# Run specific benchmark
python -m pytest src/tests/test_strategies.py::test_benchmark_strategies --benchmark-only
# Run benchmark with statistics
python -m pytest src/tests/test_strategies.py::test_benchmark_strategies --benchmark-only --benchmark-columns=min,max,mean,stddevPlease read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- Graph neural network implementation inspired by PyTorch Geometric
- Reinforcement learning components based on stable-baselines3
- Visualization tools built with TensorBoard