This project was developed during the internship at Caltech, focusing on the integration of neural networks with optimal power flow (OPF) problems in smart grid systems. The work combines deep learning techniques with convex optimization to solve complex power distribution challenges in electrical grids.
This repository implements a decision-aware uncertainty quantification framework for power grid optimization, utilizing parallel LSTM networks for demand forecasting and CVXPY-based optimization for optimal power flow solutions.
-
trainer.py: Implements the neural network training pipeline using parallel LSTMs to predict power demand with uncertainty quantification, integrating with the optimization module for end-to-end learning. -
cvxpy_protocol.py: Provides the optimal power flow solver using CVXPY optimization, handling three-phase electrical grid constraints, linear distribution flow, and operational limits for Caltech's campus power grid.
-
Install the environment from YAML:
conda env create -f environment.yaml conda activate optnn
-
Configure the power grid settings:
Edit
scripts/config.yamlto modify:- Grid topology (
adj_matrix) - Node classifications (
node_class) - Admittance matrices (
Y_A) - Time periods (
T) - Power demand parameters
- Grid topology (
-
Run the training:
cd scripts python trainer.py
-
scripts/: Main training and optimization codetrainer.py: Neural network training with LSTM-based demand forecastingcvxpy_protocol.py: Optimal power flow optimization solverconfig.yaml: Grid configuration parametersmodel.py: Neural network architecture definitionsdata_loader.py: Data preprocessing and loading utilities
-
data/: Dataset and configuration filespower_1014-0114_with_weather.csv: Historical power demand data with weather featuresteaser.jpg: Project visualization
-
decision-aware-uq/: Additional uncertainty quantification research code
- Parallel LSTM Networks: Multi-variable time series forecasting for power demand
- Uncertainty Quantification: Probabilistic predictions with confidence intervals
- CVXPY Integration: Seamless integration between neural networks and convex optimization
- Three-Phase Power Flow: Complete modeling of three-phase electrical systems
- Real-time Pricing: Integration of dynamic electricity pricing in optimization
- Python 3.8+
- PyTorch
- CVXPY
- NumPy
- Matplotlib
- YAML
See environment.yaml for complete dependency list.
