Documentation

Complete reference for CLI usage and implementation details.

Setup

Set up development environment for the Optimal Charge Security Camera project.

Environment Setup

Create a virtual environment and install dependencies:

python3 -m venv .venv
source .venv/bin/activate
pip install .

This installs all required dependencies from pyproject.toml.

Model Profiler

The model profiler benchmarks YOLOv10 models for power consumption and performance.

Power & Latency Benchmarks

Power estimates are stored in model-profiler/power_profiles.json. Run it with

Note: Set SUDO_PASSWORD in .env.local file before running.

python3 model-profiler/benchmark_power.py

Change the iterations value in model-profiler/model.config.json to modify number of iterations.

Change the iter_sleep_sec value in model-profiler/model.config.json to modify sleep time between iterations. This time is subtracted out of calculations and is only used for throttling.

Accuracy

Accuracy values are also stored in model-profiler/power_profiles.json. They are scaled up from COCO mAP 50-95 values taken from model-profiler/model-data.csv, which was provided by Ultralytics directly from their official documentation. This scaling more accurately translates the values to percentages.

Visualization

Generate an accuracy vs latency graph based on the model profiles. Run it with

python3 results/model_results.py

The graph is saved to results/graphs/model_results.png.

Training Data Generation

Generate comprehensive training datasets using Oracle optimal solutions across parameter combinations.

Data Generation Workflow

The training data generation pipeline creates datasets by running Oracle simulations over a given set of parameter combinations.

python3 data/generate_data.py

Key configuration parameters in data/data.config.json:

  • User parameters: Accuracy/latency thresholds, reward weights
  • Battery configurations: Capacity and charge rates
  • Seasonal dates: Representative dates for different seasons
  • Output settings: Data splits, worker counts, chunk sizes

Output: Training datasets saved to data/training_data/ with train/val/test splits.

ML Training

Train neural network controllers using imitation learning from Oracle demonstrations.

Controller Training

Train 3-layer policy networks for joint model selection and charging decisions. Two training modes available:

python3 training/train.py

Key configuration via training/training.config.json:

  • Training mode: "per_controller" (uses controller-specific datasets)
  • Hyperparameters: Learning rate, batch size, epochs
  • Early stopping: Patience and minimum delta thresholds

Output: Trained models saved to training/models/ with parameter-specific naming.

Simulation Framework

Compare Oracle, Naive, and ML controller performance under various scenarios.

Single Simulation

Run single comparison of all three controllers using current configuration:

python3 simulation/run.py

Batch Evaluation

Run comprehensive evaluation across all trained models and seasonal test dates:

python3 simulation/batch_run.py

Key configuration via simulation/simulation.config.json:

  • System settings: Battery capacity, charge rate, task intervals
  • User requirements: Accuracy/latency thresholds
  • Reward weights: Success/miss/carbon scoring parameters
  • Data paths: Model profiles and energy data locations

Output: Simulation results saved to simulation/simulation_data/ with comprehensive metrics and graph data.

Results Generation

Generate results and performance graphs from simulation data:

python3 results/results.py

Key configuration via results/results.config.json:

  • Analysis settings: Metrics to compute and visualize
  • Graph configurations: Plot styling and formatting options
  • Output paths: Where to save generated graphs and reports

Output: Results and graphs saved to results/ directory with performance comparisons and visualizations.