A simulation of a blockchain-inspired system where miners perform computational tasks, validate results, and receive rewards based on performance, renewable energy usage, and verification contributions.
- Multiple types of computational tasks (addition, multiplication, sorting, searching)
- Score-based miner selection
- Renewable energy usage bonuses
- Consensus-based validation system
- Token rewards distribution
- Real-time visualization of system metrics
- Python 3.7+
- matplotlib
- numpy
- Clone the repository
- Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Run the simulation:
python main.py
The simulation will:
- Create miners with random renewable energy proportions
- Generate and distribute computational tasks
- Execute tasks and validate solutions
- Distribute rewards based on performance
- Generate visualizations of system metrics
The simulation generates four plots:
- Miner scores over time
- Average renewable energy usage
- Task success rate
- Final token distribution
Plots are saved as 'simulation_results.png' in the project directory.
task.py
: Defines computational tasks and their executionminer.py
: Implements miner behavior and scoringdistribution.py
: Handles task distribution logicvalidation.py
: Manages solution validation and rewardsvisualization.py
: Creates system metrics visualizationsmain.py
: Orchestrates the simulation
You can modify the simulation parameters in main.py
:
- Number of miners
- Number of tasks
- Reward multiplier (k)
- Task input sizes