| | --- |
| | license: cc-by-sa-4.0 |
| | tags: |
| | - energy |
| | - optimization |
| | - optimal_power_flow |
| | - power_grid |
| | pretty_name: PGLearn Optimal Power Flow (small) |
| | size_categories: |
| | - 1M<n<10M |
| | task_categories: |
| | - tabular-regression |
| | viewer: false |
| | --- |
| | |
| | # PGLearn optimal power flow (small) dataset |
| |
|
| | This dataset contains input data and solutions for small-size Optimal Power Flow (OPF) problems. |
| | Original case files are based on instances from Power Grid Lib -- Optimal Power Flow ([PGLib OPF](https://github.com/power-grid-lib/pglib-opf)); |
| | this dataset comprises instances corresponding to systems with up to 300 buses. |
| |
|
| | ## Download instructions |
| |
|
| | The recommended way to download this dataset is through the [HuggingFace client library](https://huggingface.co/docs/hub/datasets-downloading#using-the-hugging-face-client-library). |
| |
|
| | ### Downloading the entire dataset |
| |
|
| | 1. Install `huggingface_hub` (see official [installation instructions](https://huggingface.co/docs/huggingface_hub/installation)) |
| | ```bash |
| | pip install --upgrade huggingface_hub |
| | ``` |
| | 2. Download the dataset. |
| | It is recommended to save files to a local directory |
| | ```py |
| | from huggingface_hub import snapshot_download |
| | REPO_ID = "PGLearn/PGLearn-Small" |
| | LOCAL_DIR = "<path/to/local/directory>" |
| | snapshot_download(repo_id=REPO_ID, repo_type="dataset", local_dir=LOCAL_DIR) |
| | ``` |
| | Note that by default, `snapshot_download` saves files to a local cache. |
| | 3. De-compress all the files |
| | ```bash |
| | cd <path/to/local/directory> |
| | find ./ -type f -name "*.gz" -exec unpigz -v {} + |
| | ``` |
| | |
| | ### Downloading individual files |
| |
|
| | The entire PGLearn-Small collection takes about 180GB of disk space (compressed). |
| |
|
| | To avoid large disk usage and long download times, it is possible to download only a subset of the files. |
| | This approach is recommended for users who only require a subset of the dataset, for instance: |
| | * a subset of cases |
| | * a specific OPF formulation (e.g. only ACOPF) |
| | * only primal solutions (as opposed to primal and dual) |
| |
|
| | This can be achieved by using the `allow_patterns` and `ignore_patterns` parameters (see [official documentation](https://huggingface.co/docs/huggingface_hub/guides/download#filter-files-to-download)), |
| | in lieu of step 2. above. |
| |
|
| | * To download only the `14_ieee` and `30_ieee` cases: |
| | ```py |
| | REPO_ID = "PGLearn/PGLearn-Small" |
| | CASES = ["14_ieee", "30_ieee"] |
| | LOCAL_DIR = "<path/to/local/dir>" |
| | |
| | snapshot_download(repo_id=REPO_ID, allow_patterns=[f"{case}/" for case in CASES], repo_type="dataset", local_dir=LOCAL_DIR) |
| | ``` |
| | * To download a specific OPF formulation |
| | (the repository structure makes it simpler to exclude non-desired OPF formulations) |
| | ```py |
| | REPO_ID = "PGLearn/PGLearn-Small" |
| | ALL_OPFS = ["ACOPF", "DCOPF", "SOCOPF"] |
| | SELECTED_OPFS = ["ACOPF", "DCOPF"] |
| | LOCAL_DIR = "<path/to/local/dir>" |
| | |
| | snapshot_download(repo_id=REPO_ID, ignore_patterns=[f"*/{opf}/*" for opf in ALL_OPFS if opf not in SELECTED_OPFS], repo_type="dataset", local_dir=LOCAL_DIR) |
| | ``` |
| | |
| | * To download only primal solutions |
| | ```py |
| | REPO_ID = "PGLearn/PGLearn-Small" |
| | LOCAL_DIR = "<path/to/local/dir>" |
| | |
| | snapshot_download(repo_id=REPO_ID, ignore_patterns="*dual.h5.gz", repo_type="dataset", local_dir=LOCAL_DIR) |
| | ``` |
| | |
| |
|
| | ## Contents |
| |
|
| | For each system (e.g., `14_ieee`, `118_ieee`), the dataset provides multiple OPF instances, |
| | and corresponding primal and dual solutions for the following OPF formulations |
| | * AC-OPF (nonlinear, non-convex) |
| | * DC-OPF approximation (linear, convex) |
| | * Second-Order Cone (SOC) relaxation of AC-OPF (nonlinear, convex) |
| |
|
| | This dataset was created using [PGLearn.jl](https://github.com/AI4OPT/PGLearn.jl); |
| | please see the [PGLearn.jl documentation](https://ai4opt.github.io/PGLearn.jl/dev/) for details on mathematical formulations. |
| |
|
| | ## Use cases |
| |
|
| | The primary intended use case of this dataset is to learn a mapping from input data to primal and/or dual solutions. |