Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Repository
Machine Learning for Optimal Power Flow
Basic Info
Statistics
- Stars: 14
- Watchers: 2
- Forks: 3
- Open Issues: 5
- Releases: 0
Metadata Files
README.md
Copyright Georgia Tech 2024
ML4OPF
ML4OPF is a Python package for developing machine learning proxy models for optimal power flow. It is built on top of PyTorch and PyTorch Lightning, and is designed to be modular and extensible. The main components are:
formulations: The main interface to the OPF formulations ACOPF, DCOPF, and Economic Dispatch.- Each OPF formulation has three main component classes:
OPFProblem,OPFViolation, andOPFModel. TheOPFProblemclass loads and parses data from disk, theOPFViolationclass calculates constraints residuals, incidence matrices, objective value, etc., and theOPFModelclass is an abstract base class for proxy models.
- Each OPF formulation has three main component classes:
loss_functions: Various loss functions including LDFLoss and the self-supervised ObjectiveLoss.layers: Various feasibility recovery layers including BoundRepair and HyperSimplexRepair.models: Various proxy models including BasicNeuralNet, LDFNeuralNet, and E2ELR.parsers: Parsers for data generated by AI4OPT/PGLearn.jl.viz: Visualization helpers for plots and tables.
Documentation based on docstrings is live here.
Installation
To install ml4opf on macOS (CPU/MPS) and Windows (CPU), run:
```bash
pip install git+ssh://git@github.com/AI4OPT/ML4OPF.git
or, to install with optional dependencies (options: "all", "dev", "viz"):
pip install "ml4opf[all] @ git+ssh://git@github.com/AI4OPT/ML4OPF.git"
If you don't already have PyTorch on Linux (CPU/CUDA/ROCm) or Windows (CUDA), make sure to provide the correct `--index-url` which you can find [here](https://pytorch.org/get-started/locally/). For example, to install from scratch with CUDA 12.6 and all optional dependencies:
bash
pip install "ml4opf[all] @ git+ssh://git@github.com/AI4OPT/ML4OPF.git" \
--index-url https://download.pytorch.org/whl/cu126 \
--extra-index-url https://pypi.python.org/simple/
```
For development, the recommended installation method is using Conda environment files provided at environment.yml and environment_cuda.yml:
bash
git clone git@github.com:AI4OPT/ML4OPF.git # clone this repo
cd ML4OPF # cd into the repo
conda env create -f environment.yml # create the environment
conda activate ml4opf # activate the environment
pip install -e ".[all]" # install ML4OPF
Usage
Training a BasicNeuralNet for ACOPF
```python import torch
load data
from ml4opf import ACProblem
data_path = ...
problem = ACProblem(data_path)
make a basic neural network model
from ml4opf.models.basic_nn import ACBasicNeuralNet # requires pytorch-lightning
config = { "optimizer": "adam", "learningrate": 1e-3, "loss": "mse", "hiddensizes": [500,300,500], "activation": "sigmoid", "boundrepair": "none" # optionally clamp outputs to bounds (choices: "sigmoid", "relu", "clamp") }
model = ACBasicNeuralNet(config, problem)
model.train(trainerkwargs={'maxepochs': 100, 'accelerator': 'auto'}) # pass args to the PyTorch Lightning Trainer
evals = model.evaluate_model()
from ml4opf.viz import makestatsdf print(makestatsdf(evals))
model.savecheckpoint("./basic300bus") # creates a folder called "basic_300bus" with a file "trainer.ckpt" in it. ```
Manually Loading Data
```python import torch
from ml4opf import ACProblem
data_path = ...
parse HDF5/JSON
problem = ACProblem(data_path)
get train/test set:
traindata = problem.traindata testdata = problem.testdata
traindata['input/pd'].shape # torch.Size([52863, 201]) testdata['input/pd'].shape # torch.Size([5000, 201])
if needed, convert the HDF5 data to a tree dictionary instead of a flat dictionary:
from ml4opf.parsers import PGLearnParser h5tree = PGLearnParser.maketree(traindata) # this tree structure should # exactly mimic the # structure of the HDF5 file. h5tree['input']['pd'].shape # torch.Size([52863, 201]) ```
Acknowledgements
This material is based upon work supported by the National Science Foundation AI Institute for Advances in Optimization (AI4OPT) under Grant No. 2112533 and the National Science Foundation Graduate Research Fellowship under Grant No. DGE-2039655. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
Owner
- Name: AI4OPT
- Login: AI4OPT
- Kind: organization
- Website: https://www.ai4opt.org/
- Repositories: 1
- Profile: https://github.com/AI4OPT
Citation (CITATION.cff)
cff-version: 1.2.0
title: ML4OPF
message: If you use this software, please cite it as below.
type: software
authors:
- given-names: Michael
family-names: Klamkin
email: klam@gatech.edu
affiliation: >-
Artificial Intelligence Institute for Advances in
Optimization
orcid: 'https://orcid.org/0000-0002-2131-8603'
repository-code: 'https://github.com/AI4OPT/ML4OPF'
license: MIT
GitHub Events
Total
- Issues event: 21
- Watch event: 14
- Delete event: 17
- Issue comment event: 13
- Push event: 48
- Pull request review event: 5
- Pull request review comment event: 5
- Pull request event: 32
- Fork event: 5
- Create event: 17
Last Year
- Issues event: 21
- Watch event: 14
- Delete event: 17
- Issue comment event: 13
- Push event: 48
- Pull request review event: 5
- Pull request review comment event: 5
- Pull request event: 32
- Fork event: 5
- Create event: 17
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 4
- Total pull requests: 9
- Average time to close issues: about 1 month
- Average time to close pull requests: about 19 hours
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 0.5
- Average comments per pull request: 0.11
- Merged pull requests: 9
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 9
- Average time to close issues: about 1 month
- Average time to close pull requests: about 19 hours
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.5
- Average comments per pull request: 0.11
- Merged pull requests: 9
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- klamike (10)
- mtanneau (3)
Pull Request Authors
- klamike (18)
- mtanneau (4)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/setup-python v2 composite
- ./.github/actions/build * composite
- actions/checkout v2 composite
- ./.github/actions/build * composite
- actions/checkout v2 composite
- h5py *
- lightning *
- torch *