Adaptive Weight-Based Resource Allocation Framework for 6G IoT with THz Links and Intelligent Surfaces
Project description
AWRAF Toolkit: Adaptive Weight-Based Resource Allocation Framework for 6G IoT
A comprehensive Python toolkit for the Adaptive Weight-Based Resource Allocation Framework (AWRAF), designed for dynamic resource management in 6G IoT environments with Terahertz (THz) links and Intelligent Reflecting Surfaces (IRS).
๐ Features
- Realistic 6G Scenarios: Smart Healthcare (IRS-THz), Smart Transportation (V2X-THz), and Baseline IoT environments
- Adaptive Resource Allocation: Dynamic adjustment of allocation weights based on real-time system conditions
- Multiple Algorithms: AWRAF (Dynamic/Static), Greedy, and Reinforcement Learning baselines
- Statistical Validation: Comprehensive performance analysis with confidence intervals and t-tests
- Scalability Analysis: Performance evaluation under varying device and server loads
- Command-Line Interface: Easy-to-use CLI for quick simulations without coding
- Modern Python: Type hints, dataclasses, and clean architecture
๐ฆ Installation
From PyPI (Recommended)
pip install awraf-toolkit
From Source
git clone https://github.com/afrilab/awraf.git
cd awraf
pip install -e .
๐ฏ Quick Start
Option 1: Command Line (Easiest)
Run simulations directly from the command line:
# Install the package
pip install awraf-toolkit
# Quick demo
awraf-sim --demo
# Custom simulation
awraf-sim --scenarios "SMART_HEALTHCARE:50:10" --algorithms "AWRAF_DYNAMIC,GREEDY" --trials 30
Option 2: Python API
Use the Python interface for more control:
import numpy as np
from awraf import AWRAFSimulator, ScenarioType, AlgorithmType
from awraf import run_statistical_analysis, analyze_and_plot, print_summary_table
# Set random seeds for reproducibility
np.random.seed(42)
# Define your simulation parameters
scenarios = [
(ScenarioType.SMART_HEALTHCARE, 50, 10),
(ScenarioType.SMART_TRANSPORTATION, 60, 12),
(ScenarioType.BASELINE_IOT, 40, 10)
]
algorithms = [
AlgorithmType.AWRAF_DYNAMIC,
AlgorithmType.AWRAF_STATIC,
AlgorithmType.GREEDY,
AlgorithmType.RL_BASED
]
# Run comprehensive analysis
results = run_statistical_analysis(scenarios, algorithms, num_trials=30)
aggregated = analyze_and_plot(results, scenarios)
print_summary_table(aggregated, results)
๐ API Reference
Core Classes
| Class | Description | Key Methods |
|---|---|---|
AWRAFSimulator |
Main simulation engine for resource allocation | run_simulation(max_iterations=100) |
IoTDevice |
Represents IoT devices with 6G characteristics | Data class with device properties |
EdgeServer |
Represents edge servers with 6G capabilities | Data class with server properties |
ScenarioGenerator |
Generates realistic IoT scenarios | generate_scenario() |
RLAgent |
Q-learning agent for reinforcement learning | choose_action(state), update_q_table(...) |
Enums
| Enum | Values | Description |
|---|---|---|
ScenarioType |
SMART_HEALTHCARE, SMART_TRANSPORTATION, BASELINE_IOT |
Available IoT scenarios |
AlgorithmType |
AWRAF_DYNAMIC, AWRAF_STATIC, GREEDY, RL_BASED |
Resource allocation algorithms |
Main Functions
| Function | Parameters | Returns | Description |
|---|---|---|---|
run_statistical_analysis(scenarios, algorithms, num_trials=30) |
scenarios: List of (ScenarioType, devices, servers)algorithms: List of AlgorithmTypenum_trials: Number of simulation runs |
pandas.DataFrame |
Runs multiple simulation trials for statistical validation |
analyze_and_plot(df_stats, scenarios_config) |
df_stats: Statistical results DataFramescenarios_config: Scenarios configuration |
pandas.DataFrame |
Creates comprehensive plots and returns aggregated results |
print_summary_table(df_agg, df_stats) |
df_agg: Aggregated resultsdf_stats: Statistical results |
None |
Prints formatted performance comparison table |
Data Models
IoTDevice Attributes
device_id: Unique identifiertask_size: Computational task sizelatency_tolerance: Maximum acceptable latencyenergy_constraint: Energy consumption limitdevice_type: Type of IoT devicescenario: Associated scenario typemobility_speed: Device movement speedfederated_learning_capable: FL support flagthz_frequency: THz frequency banddata_to_upload: Data size for uplinkmodel_size_downlink: Model size for downlink
EdgeServer Attributes
server_id: Unique identifiercomputational_capacity: Processing powerbandwidth: Network bandwidthenergy_capacity: Energy storageserver_type: Type of edge serverirs_elements: Number of IRS elementsthz_bandwidth: THz bandwidth capacitysupports_federated_learning: FL support flagcurrent_load: Current computational loadallocated_devices: List of assigned devices
๐ฌ Usage Examples
Basic Simulation
from awraf import AWRAFSimulator, ScenarioType, AlgorithmType
# Create simulator for healthcare scenario
sim = AWRAFSimulator(
scenario_type=ScenarioType.SMART_HEALTHCARE,
algorithm=AlgorithmType.AWRAF_DYNAMIC,
num_devices=50,
num_servers=10
)
# Run simulation
history = sim.run_simulation(max_iterations=100)
# Access results
print(f"Average device utility: {np.mean(history['device_utility']):.3f}")
print(f"Success rate: {history['allocation_success_rate'][-1]*100:.1f}%")
Custom Scenario Analysis
from awraf import run_statistical_analysis, ScenarioType, AlgorithmType
# Define custom scenarios
custom_scenarios = [
(ScenarioType.SMART_HEALTHCARE, 100, 20), # 100 devices, 20 servers
(ScenarioType.SMART_TRANSPORTATION, 200, 40), # 200 devices, 40 servers
]
# Compare algorithms
algorithms = [AlgorithmType.AWRAF_DYNAMIC, AlgorithmType.GREEDY]
# Run analysis with 50 trials
results = run_statistical_analysis(custom_scenarios, algorithms, num_trials=50)
Performance Comparison
from awraf import analyze_and_plot, print_summary_table
# Analyze and visualize results
aggregated = analyze_and_plot(results, custom_scenarios)
# Print comprehensive summary
print_summary_table(aggregated, results)
๐ Output Analysis
The toolkit provides comprehensive analysis including:
- Device Utility: Normalized utility scores with confidence intervals
- Server Load: Load balancing efficiency across edge servers
- Allocation Success Rate: Percentage of successful resource allocations
- Communication Delay: Network latency analysis
- Scalability: Performance under varying device/server ratios
- Statistical Significance: T-test results comparing algorithms
๐๏ธ Project Structure
awraf-toolkit/
โโโ awraf/ # Main package
โ โโโ __init__.py # Package initialization
โ โโโ simulator.py # Core simulation engine
โ โโโ models.py # Data models (IoTDevice, EdgeServer)
โ โโโ enums.py # Enums for scenarios and algorithms
โ โโโ scenario.py # Scenario generation
โ โโโ algorithm.py # RL agent implementation
โ โโโ utils.py # Analysis and plotting utilities
โโโ examples/ # Usage examples
โ โโโ run_simulation.py # Complete simulation example
โโโ tests/ # Unit tests
โโโ README.md # This file
โโโ setup.py # Package configuration
โโโ requirements.txt # Dependencies
๐ฅ๏ธ Command-Line Interface (CLI)
The AWRAF Toolkit includes a powerful command-line interface that makes it easy to run simulations without writing Python code.
Installation & Usage
After installing the package, you'll have access to the awraf-sim command:
# Install the package
pip install awraf-toolkit
# Check if CLI is available
awraf-sim --help
Quick Demo
Run a quick demonstration with default scenarios:
awraf-sim --demo
This runs a 10-trial simulation with:
- Smart Healthcare: 30 devices, 6 servers
- Smart Transportation: 40 devices, 8 servers
- Baseline IoT: 25 devices, 5 servers
- Algorithms: AWRAF Dynamic vs Greedy
Custom Simulations
Basic Single Scenario
awraf-sim --scenarios "SMART_HEALTHCARE:50:10" --algorithms "AWRAF_DYNAMIC"
Multiple Scenarios & Algorithms
awraf-sim --scenarios "SMART_HEALTHCARE:50:10,SMART_TRANSPORTATION:60:12" --algorithms "AWRAF_DYNAMIC,GREEDY" --trials 50
With Custom Random Seed
awraf-sim --scenarios "BASELINE_IOT:100:20" --algorithms "AWRAF_DYNAMIC,RL_BASED" --trials 100 --seed 42
CLI Parameters
| Parameter | Description | Example | Default |
|---|---|---|---|
--scenarios |
Comma-separated scenarios in format "scenario:devices:servers" | "SMART_HEALTHCARE:50:10" |
Required |
--algorithms |
Comma-separated algorithms to compare | "AWRAF_DYNAMIC,GREEDY" |
Required |
--trials |
Number of simulation trials | 50 |
30 |
--demo |
Run demo with default settings | --demo |
False |
--seed |
Random seed for reproducibility | 42 |
Random |
Available Scenarios
SMART_HEALTHCARE: Healthcare IoT with IRS-THz capabilitiesSMART_TRANSPORTATION: V2X transportation with THz linksBASELINE_IOT: Standard IoT environment
Available Algorithms
AWRAF_DYNAMIC: AWRAF with adaptive weightsAWRAF_STATIC: AWRAF with fixed weightsGREEDY: Greedy resource allocationRL_BASED: Reinforcement learning approach
CLI Output
The CLI provides:
- ๐ Configuration Summary: Shows selected scenarios, algorithms, and trials
- โณ Progress Updates: Real-time trial progress
- ๐ Statistical Analysis: T-test results and performance metrics
- ๐จ Visualization: Comprehensive plots and charts
- ๐ Summary Table: Formatted performance comparison
Example CLI Session
$ awraf-sim --scenarios "SMART_HEALTHCARE:40:8" --algorithms "AWRAF_DYNAMIC,GREEDY" --trials 20
๐ Running AWRAF Toolkit Demo...
๐ Scenarios: ['SMART_HEALTHCARE(40 devices, 8 servers)']
๐ง Algorithms: ['AWRAF_DYNAMIC', 'GREEDY']
๐ Trials: 20
โณ Running statistical analysis...
Running Statistical Validation (20 trials)...
Trial 1/20...
Trial 2/20...
[...]
Trial 20/20...
๐ Generating plots and analysis...
--- T-Test Results (p-value for Device Utility) ---
Scenario: Smart Healthcare (IRS-THz)
vs Greedy Allocation: p-value = 0.0234 (Significant Improvement)
๐ Printing summary table...
[Comprehensive performance summary table]
โ
Analysis complete!
๐งช Testing
Run the test suite to ensure everything works correctly:
# Install in development mode
pip install -e .
# Run tests
python -m pytest tests/ -v
# Run example
python examples/run_simulation.py
# Test CLI
awraf-sim --demo
๐ Requirements
- Python 3.7+
- numpy
- matplotlib
- pandas
- seaborn
- scipy
- tabulate
๐ค Contributing
We welcome contributions! Please feel free to:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Citation
If you use this toolkit in your research, please cite:
@article{awraf2024,
title={AWRAF: An Energy-Aware Adaptive Weight-Based Resource Allocation Framework for IoT with THz Links and Intelligent Surfaces},
author={Agrawal, Kushagra and Ayaz, Ferheen and Goktas, Polat},
journal={arXiv preprint},
year={2024}
}
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 awraf_toolkit-0.1.0.tar.gz.
File metadata
- Download URL: awraf_toolkit-0.1.0.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbde2eb5c6daa93715755bc20cb47fc9ec4feb5e858072d975f9e80d5a77e22c
|
|
| MD5 |
fad25d57362edb0d74b8cfed4d69d27b
|
|
| BLAKE2b-256 |
fd0f6111ef3c23a7cf41d67a57316cf87e0230ace71644eab1df1cc9662c1a7f
|
File details
Details for the file awraf_toolkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: awraf_toolkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f154ced3f27f3609e3a6068bc88acc4bcd5710567a1eb94c29e3bbfda8d26b82
|
|
| MD5 |
fcfde3f8673953e4344cb80adb402661
|
|
| BLAKE2b-256 |
d0ce734fbee4311b2a4fe794de887c24221af5e274bd1c380578b32295210eeb
|