AI4OPT / ML4OPF

Machine Learning for Optimal Power Flow
MIT License
5 stars 4 forks source link

Unable to open 300_ieee sample data #14

Closed mtanneau closed 1 month ago

mtanneau commented 1 month ago

I tried to import data from the sample 300_ieee data in tests/test_data, following the starter code provided in the README:

import torch

# load data
from ml4opf import ACPProblem

data_path = "tests/test_data"
network = "300_ieee"

problem = ACPProblem(data_path, network)

this raised the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ML4OPF/ml4opf/formulations/acp/problem.py", line 13, in __init__
    super().__init__(data_directory, case_name, dataset_name, **parse_kwargs)
  File "ML4OPF/ml4opf/formulations/problem.py", line 74, in __init__
    self.parse(**parse_kwargs)
  File "ML4OPF/ml4opf/formulations/problem.py", line 105, in parse
    ).parse(
      ^^^^^^
  File "ML4OPF/ml4opf/parsers/parse_h5.py", line 187, in parse
    test = self.extract_test_set(dat, test_set_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ML4OPF/ml4opf/parsers/parse_h5.py", line 353, in extract_test_set
    n >= test_set_size
AssertionError: Test set size 5000 is larger than the total number of points 34 after all filters.

I guess this is because the sample data contains less than the default 5000 points expected by the parser.

I did not encounter any issue with the 14_ieee sample data in tests/test_data/OPDFdata

klamike commented 1 month ago

That is expected; this data is meant to only be used internally for testing -- it has only 100 samples. If for some reason you really want to use this data, you can set the test_set_size kwarg to something small like in the tests: https://github.com/AI4OPT/ML4OPF/blob/ad4ee4a73525b41e7927ab2c4f5d90495ccacbc8/tests/formulations/acp/test_acp_model.py#L12