PGLearn-Small / README.md
klamike's picture
download instructions (#2)
7893974 verified
metadata
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); 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.

Downloading the entire dataset

  1. Install huggingface_hub (see official installation instructions)
    pip install --upgrade huggingface_hub
    
  2. Download the dataset. It is recommended to save files to a local directory
    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
    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), in lieu of step 2. above.

  • To download only the 14_ieee and 30_ieee cases:

    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)

    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

    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; please see the OPFGenerator documentation 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.