File size: 3,943 Bytes
fa60d04
 
 
 
 
 
 
 
 
36686bc
fa60d04
 
 
 
 
 
 
 
 
 
 
7893974
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa60d04
 
 
 
 
 
 
 
 
 
 
 
 
36686bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
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 [OPFGenerator](https://github.com/AI4OPT/OPFGenerator);
please see the [OPFGenerator documentation](https://ai4opt.github.io/OPFGenerator/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.