klamike commited on
Commit
24ce1d9
·
verified ·
1 Parent(s): 943f0d1

Convert dataset to Parquet (#1)

Browse files

- Convert dataset to Parquet (7544eb8a2f915a384f1d6974e7e5407904a2941b)
- Delete data file (96cb339dc7441e45aef7f6841a3e1b532403d6de)
- Delete loading script (b0a400923eafe3d629fa313fa74d39b3ccd1ad49)
- Delete data file (6d32b8438c57a038daffcda46f4aaaa3411d6701)
- Delete data file (aa662bec6f2308d7a9f6f4e1d89cfe067469a086)
- Delete data file (ea1e5eba47c91c29228840a8e3fec9e4128aff6f)
- Delete data file (83d577cd2f6de64644547f853c37b0520fc91f93)
- Delete data file (a0f7d50fd623c0b6742e9b9accfc004e90222ee3)
- Delete data file (71e043e83571116a5aa7bb5644ec45be14179579)
- Delete data file (c2b0d48e6e646b4586a89f77921179df26aadfcd)
- Delete data file (a9f82303a387c8f29f4d769b0937e838b071cf46)
- Delete data file (31806c5fac4f2c8d9730ce0b394fd89d376e8396)
- Delete data file (f84582e8b99d55e13f33e5f66aa423414dd98d43)
- Delete data file (93ceb237e0aa21c3d4833621d6fa313080de9522)
- Delete data file (446661667cbfececfdc71885123e2ac94ce9b180)
- Delete data file (5a2bd249b0b908fedc5067035959641a748f40c3)
- Delete data file (70e02c52bd03b1ae423a35ffc111b818ed27d61e)
- Delete data file (ef59ff7c97d18c86aaa0c71b44a84dac0234cd72)
- Delete data file (a7fca7088a196ef91330118609344d73bbabaf95)
- Delete data file (63f50fa142bf76200d2d292893ce0e369ec2abc6)
- Delete data file (804eb48a9feb2eda7d14f54cd65a7f6abc8d3dcc)
- Delete data file (333c5bb95f6eea6cf6ec5c1e3d742bf394c667ee)
- Delete data file (a669c44a3aeb0d008ac0e80eb03738d300059035)
- Delete data file (5ca70458c73ad1b0e1aff73d9f312fec99c14d36)
- Delete data file (be4e481e5de3f7941fdb543652d81cf2ff30e316)
- Delete data file (731980f2f205ac9973bcd0f49fd54f7aad1c008e)
- Delete data file (ce51ac7e059765da55220e4a0c51bd8a10a89133)
- Delete data file (200565b2be3dccfe70146d695af452ebcb00afdf)
- Delete data file (e72656d228a673d239b062c6c4f46a7b0c5c1bdd)
- Delete data file (a65e567a28c69ef57b43b3f6d7868a8403be86d5)
- Delete data file (47b61dffbe5f0e55bb6dbd38d7e8817f8c530cd1)
- Delete data file (d6ea761a7bbc7c3879ec73a2f14808df00497c44)
- Delete data file (1f9780e6bac00cfea0525531f9e4ed474eb994d3)
- Delete data file (0d117ec15c4dd85d78720f3b1a2703a71cfd4c8c)

infeasible/ACOPF/meta.h5.gz → 30_ieee-nminus1/test-00000-of-00002.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:86958e36326eeb3f02dc292b86879782297718c9af671be6ded75e88618818cf
3
- size 3198291
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fb60b98dcb45695fd6890bc759ca58a9f83109a83542fc4671f6a47bee2c6d5
3
+ size 499900339
case.json.gz → 30_ieee-nminus1/test-00001-of-00002.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9b477fa50364291d368c7ea81456d5253ae2b574c2d00f9f66a9152fca5d51ad
3
- size 24637
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e22266681bfa5327e1d4863b938f8577f41c8a4b3406eae0e9eb6722bb81f767
3
+ size 499901031
infeasible/ACOPF/primal.h5.gz → 30_ieee-nminus1/train-00000-of-00007.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1b654bad522f64ba1c2fca6cd19171b616ca60beffbbdcbcc662e12c18491b3d
3
- size 80864740
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44d90f4e9f6e8e0b8666e15548ea744d24874742274245d40dbb1c563f674b4e
3
+ size 571389851
infeasible/ACOPF/dual.h5.gz → 30_ieee-nminus1/train-00001-of-00007.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:69aa3706c23233228bfdddcd2131a6c4ca9b83a15b72afe63c0869fe3eaac1bd
3
- size 181723839
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37a3528ec050c64041e21ac018281f84d1d0f7f6abd027b738f9b6bc7256b4b4
3
+ size 571407209
30_ieee-nminus1/train-00002-of-00007.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba334e34114c62c6308e6845b500ab900f29bdd2fd7cbd0cb45e0931567ce4ae
3
+ size 571379526
30_ieee-nminus1/train-00003-of-00007.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc8044c15c1110d437c6fb8113b7e5d46b8a996799ce082d484d3ee6e2c6fcad
3
+ size 571375022
30_ieee-nminus1/train-00004-of-00007.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfc877e9b15f0aa3692a133061930520ede85ed7aefc51af8a6b8d1d55326896
3
+ size 571401296
30_ieee-nminus1/train-00005-of-00007.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e7b1513148f3153e2d9ad2b490a512d9b37226fb74d1f88fa26ea20b14587e2
3
+ size 571407092
30_ieee-nminus1/train-00006-of-00007.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:980667ee682f03908e0b964ffd9bb815ff0490ba8107c11598c81bcbf3a789b1
3
+ size 571390122
PGLearn-Small-30_ieee-nminus1.py DELETED
@@ -1,427 +0,0 @@
1
- from __future__ import annotations
2
- from dataclasses import dataclass
3
- from pathlib import Path
4
- import json
5
- import shutil
6
-
7
- import datasets as hfd
8
- import h5py
9
- import pgzip as gzip
10
- import pyarrow as pa
11
-
12
- # ┌──────────────┐
13
- # │ Metadata │
14
- # └──────────────┘
15
-
16
- @dataclass
17
- class CaseSizes:
18
- n_bus: int
19
- n_load: int
20
- n_gen: int
21
- n_branch: int
22
-
23
- CASENAME = "30_ieee-nminus1"
24
- SIZES = CaseSizes(n_bus=30, n_load=21, n_gen=6, n_branch=41)
25
- NUM_TRAIN = 321126
26
- NUM_TEST = 80282
27
- NUM_INFEASIBLE = 98592
28
- SPLITFILES = {}
29
-
30
- URL = "https://huggingface.co/datasets/PGLearn/PGLearn-Small-30_ieee-nminus1"
31
- DESCRIPTION = """\
32
- The 30_ieee-nminus1 PGLearn optimal power flow dataset, part of the PGLearn-Small collection. \
33
- """
34
- VERSION = hfd.Version("1.0.0")
35
- DEFAULT_CONFIG_DESCRIPTION="""\
36
- This configuration contains feasible input, primal solution, and dual solution data \
37
- for the ACOPF and DCOPF formulations on the {case} system. For case data, \
38
- download the case.json.gz file from the `script` branch of the repository. \
39
- https://huggingface.co/datasets/PGLearn/PGLearn-Small-30_ieee-nminus1/blob/script/case.json.gz
40
- """
41
- USE_ML4OPF_WARNING = """
42
- ================================================================================================
43
- Loading PGLearn-Small-30_ieee-nminus1 through the `datasets.load_dataset` function may be slow.
44
-
45
- Consider using ML4OPF to directly convert to `torch.Tensor`; for more info see:
46
- https://github.com/AI4OPT/ML4OPF?tab=readme-ov-file#manually-loading-data
47
-
48
- Or, use `huggingface_hub.snapshot_download` and an HDF5 reader; for more info see:
49
- https://huggingface.co/datasets/PGLearn/PGLearn-Small-30_ieee-nminus1#downloading-individual-files
50
- ================================================================================================
51
- """
52
- CITATION = """\
53
- @article{klamkinpglearn,
54
- title={{PGLearn - An Open-Source Learning Toolkit for Optimal Power Flow}},
55
- author={Klamkin, Michael and Tanneau, Mathieu and Van Hentenryck, Pascal},
56
- year={2025},
57
- }\
58
- """
59
-
60
- IS_COMPRESSED = True
61
-
62
- # ┌──────────────────┐
63
- # │ Formulations │
64
- # └──────────────────┘
65
-
66
- def acopf_features(sizes: CaseSizes, primal: bool, dual: bool, meta: bool):
67
- features = {}
68
- if primal: features.update(acopf_primal_features(sizes))
69
- if dual: features.update(acopf_dual_features(sizes))
70
- if meta: features.update({f"ACOPF/{k}": v for k, v in META_FEATURES.items()})
71
- return features
72
-
73
- def dcopf_features(sizes: CaseSizes, primal: bool, dual: bool, meta: bool):
74
- features = {}
75
- if primal: features.update(dcopf_primal_features(sizes))
76
- if dual: features.update(dcopf_dual_features(sizes))
77
- if meta: features.update({f"DCOPF/{k}": v for k, v in META_FEATURES.items()})
78
- return features
79
-
80
- def socopf_features(sizes: CaseSizes, primal: bool, dual: bool, meta: bool):
81
- features = {}
82
- if primal: features.update(socopf_primal_features(sizes))
83
- if dual: features.update(socopf_dual_features(sizes))
84
- if meta: features.update({f"SOCOPF/{k}": v for k, v in META_FEATURES.items()})
85
- return features
86
-
87
- FORMULATIONS_TO_FEATURES = {
88
- "ACOPF": acopf_features,
89
- "DCOPF": dcopf_features,
90
- "SOCOPF": socopf_features,
91
- }
92
-
93
- # ┌───────────────────┐
94
- # │ BuilderConfig │
95
- # └───────────────────┘
96
-
97
- class PGLearnSmall30_ieeeNminus1Config(hfd.BuilderConfig):
98
- """BuilderConfig for PGLearn-Small-30_ieee-nminus1.
99
- By default, primal solution data, metadata, input, casejson, are included for the train and test splits.
100
-
101
- To modify the default configuration, pass attributes of this class to `datasets.load_dataset`:
102
-
103
- Attributes:
104
- formulations (list[str]): The formulation(s) to include, e.g. ["ACOPF", "DCOPF"]
105
- primal (bool, optional): Include primal solution data. Defaults to True.
106
- dual (bool, optional): Include dual solution data. Defaults to False.
107
- meta (bool, optional): Include metadata. Defaults to True.
108
- input (bool, optional): Include input data. Defaults to True.
109
- casejson (bool, optional): Include case.json data. Defaults to True.
110
- train (bool, optional): Include training samples. Defaults to True.
111
- test (bool, optional): Include testing samples. Defaults to True.
112
- infeasible (bool, optional): Include infeasible samples. Defaults to False.
113
- """
114
- def __init__(self,
115
- formulations: list[str],
116
- primal: bool=True, dual: bool=False, meta: bool=True, input: bool = True, casejson: bool=True,
117
- train: bool=True, test: bool=True, infeasible: bool=False,
118
- compressed: bool=IS_COMPRESSED, **kwargs
119
- ):
120
- super(PGLearnSmall30_ieeeNminus1Config, self).__init__(version=VERSION, **kwargs)
121
-
122
- self.case = CASENAME
123
- self.formulations = formulations
124
-
125
- self.primal = primal
126
- self.dual = dual
127
- self.meta = meta
128
- self.input = input
129
- self.casejson = casejson
130
-
131
- self.train = train
132
- self.test = test
133
- self.infeasible = infeasible
134
-
135
- self.gz_ext = ".gz" if compressed else ""
136
-
137
- @property
138
- def size(self):
139
- return SIZES
140
-
141
- @property
142
- def features(self):
143
- features = {}
144
- if self.casejson: features.update(case_features())
145
- if self.input: features.update(input_features(SIZES))
146
- for formulation in self.formulations:
147
- features.update(FORMULATIONS_TO_FEATURES[formulation](SIZES, self.primal, self.dual, self.meta))
148
- return hfd.Features(features)
149
-
150
- @property
151
- def splits(self):
152
- splits: dict[hfd.Split, dict[str, str | int]] = {}
153
- if self.train:
154
- splits[hfd.Split.TRAIN] = {
155
- "name": "train",
156
- "num_examples": NUM_TRAIN
157
- }
158
- if self.test:
159
- splits[hfd.Split.TEST] = {
160
- "name": "test",
161
- "num_examples": NUM_TEST
162
- }
163
- if self.infeasible:
164
- splits[hfd.Split("infeasible")] = {
165
- "name": "infeasible",
166
- "num_examples": NUM_INFEASIBLE
167
- }
168
- return splits
169
-
170
- @property
171
- def urls(self):
172
- urls: dict[str, None | str | list] = {
173
- "case": None, "train": [], "test": [], "infeasible": [],
174
- }
175
-
176
- if self.casejson:
177
- urls["case"] = f"case.json" + self.gz_ext
178
- else:
179
- urls.pop("case")
180
-
181
- split_names = []
182
- if self.train: split_names.append("train")
183
- if self.test: split_names.append("test")
184
- if self.infeasible: split_names.append("infeasible")
185
-
186
- for split in split_names:
187
- if self.input: urls[split].append(f"{split}/input.h5" + self.gz_ext)
188
- for formulation in self.formulations:
189
- if self.primal:
190
- filename = f"{split}/{formulation}/primal.h5" + self.gz_ext
191
- if filename in SPLITFILES: urls[split].append(SPLITFILES[filename])
192
- else: urls[split].append(filename)
193
- if self.dual:
194
- filename = f"{split}/{formulation}/dual.h5" + self.gz_ext
195
- if filename in SPLITFILES: urls[split].append(SPLITFILES[filename])
196
- else: urls[split].append(filename)
197
- if self.meta:
198
- filename = f"{split}/{formulation}/meta.h5" + self.gz_ext
199
- if filename in SPLITFILES: urls[split].append(SPLITFILES[filename])
200
- else: urls[split].append(filename)
201
- return urls
202
-
203
- # ┌────────────────────┐
204
- # │ DatasetBuilder │
205
- # └────────────────────┘
206
-
207
- class PGLearnSmall30_ieeeNminus1(hfd.ArrowBasedBuilder):
208
- """DatasetBuilder for PGLearn-Small-30_ieee-nminus1.
209
- The main interface is `datasets.load_dataset` with `trust_remote_code=True`, e.g.
210
-
211
- ```python
212
- from datasets import load_dataset
213
- ds = load_dataset("PGLearn/PGLearn-Small-30_ieee-nminus1", trust_remote_code=True,
214
- # modify the default configuration by passing kwargs
215
- formulations=["DCOPF"],
216
- dual=False,
217
- meta=False,
218
- )
219
- ```
220
- """
221
-
222
- DEFAULT_WRITER_BATCH_SIZE = 10000
223
- BUILDER_CONFIG_CLASS = PGLearnSmall30_ieeeNminus1Config
224
- DEFAULT_CONFIG_NAME=CASENAME
225
- BUILDER_CONFIGS = [
226
- PGLearnSmall30_ieeeNminus1Config(
227
- name=CASENAME, description=DEFAULT_CONFIG_DESCRIPTION.format(case=CASENAME),
228
- formulations=list(FORMULATIONS_TO_FEATURES.keys()),
229
- primal=True, dual=True, meta=True, input=True, casejson=False,
230
- train=True, test=True, infeasible=False,
231
- )
232
- ]
233
-
234
- def _info(self):
235
- return hfd.DatasetInfo(
236
- features=self.config.features, splits=self.config.splits,
237
- description=DESCRIPTION + self.config.description,
238
- homepage=URL, citation=CITATION,
239
- )
240
-
241
- def _split_generators(self, dl_manager: hfd.DownloadManager):
242
- hfd.logging.get_logger().warning(USE_ML4OPF_WARNING)
243
-
244
- filepaths = dl_manager.download_and_extract(self.config.urls)
245
-
246
- splits: list[hfd.SplitGenerator] = []
247
- if self.config.train:
248
- splits.append(hfd.SplitGenerator(
249
- name=hfd.Split.TRAIN,
250
- gen_kwargs=dict(case_file=filepaths.get("case", None), data_files=tuple(filepaths["train"]), n_samples=NUM_TRAIN),
251
- ))
252
- if self.config.test:
253
- splits.append(hfd.SplitGenerator(
254
- name=hfd.Split.TEST,
255
- gen_kwargs=dict(case_file=filepaths.get("case", None), data_files=tuple(filepaths["test"]), n_samples=NUM_TEST),
256
- ))
257
- if self.config.infeasible:
258
- splits.append(hfd.SplitGenerator(
259
- name=hfd.Split("infeasible"),
260
- gen_kwargs=dict(case_file=filepaths.get("case", None), data_files=tuple(filepaths["infeasible"]), n_samples=NUM_INFEASIBLE),
261
- ))
262
- return splits
263
-
264
- def _generate_tables(self, case_file: str | None, data_files: tuple[hfd.utils.track.tracked_str | list[hfd.utils.track.tracked_str]], n_samples: int):
265
- case_data: str | None = json.dumps(json.load(open_maybe_gzip_cat(case_file))) if case_file is not None else None
266
- data: dict[str, h5py.File] = {}
267
- for file in data_files:
268
- v = h5py.File(open_maybe_gzip_cat(file), "r")
269
- if isinstance(file, list):
270
- k = "/".join(Path(file[0].get_origin()).parts[-3:-1]).split(".")[0]
271
- else:
272
- k = "/".join(Path(file.get_origin()).parts[-2:]).split(".")[0]
273
- data[k] = v
274
- for k in list(data.keys()):
275
- if "/input" in k: data[k.split("/", 1)[1]] = data.pop(k)
276
-
277
- batch_size = self._writer_batch_size or self.DEFAULT_WRITER_BATCH_SIZE
278
- for i in range(0, n_samples, batch_size):
279
- effective_batch_size = min(batch_size, n_samples - i)
280
-
281
- sample_data = {
282
- f"{dk}/{k}":
283
- hfd.features.features.numpy_to_pyarrow_listarray(v[i:i + effective_batch_size, ...])
284
- for dk, d in data.items() for k, v in d.items() if f"{dk}/{k}" in self.config.features
285
- }
286
-
287
- if case_data is not None:
288
- sample_data["case/json"] = pa.array([case_data] * effective_batch_size)
289
-
290
- yield i, pa.Table.from_pydict(sample_data)
291
-
292
- for f in data.values():
293
- f.close()
294
-
295
- # ┌──────────────┐
296
- # │ Features │
297
- # └──────────────┘
298
-
299
- FLOAT_TYPE = "float32"
300
- INT_TYPE = "int64"
301
- BOOL_TYPE = "bool"
302
- STRING_TYPE = "string"
303
-
304
- def case_features():
305
- # FIXME: better way to share schema of case data -- need to treat jagged arrays
306
- return {
307
- "case/json": hfd.Value(STRING_TYPE),
308
- }
309
-
310
- META_FEATURES = {
311
- "meta/seed": hfd.Value(dtype=INT_TYPE),
312
- "meta/formulation": hfd.Value(dtype=STRING_TYPE),
313
- "meta/primal_objective_value": hfd.Value(dtype=FLOAT_TYPE),
314
- "meta/dual_objective_value": hfd.Value(dtype=FLOAT_TYPE),
315
- "meta/primal_status": hfd.Value(dtype=STRING_TYPE),
316
- "meta/dual_status": hfd.Value(dtype=STRING_TYPE),
317
- "meta/termination_status": hfd.Value(dtype=STRING_TYPE),
318
- "meta/build_time": hfd.Value(dtype=FLOAT_TYPE),
319
- "meta/extract_time": hfd.Value(dtype=FLOAT_TYPE),
320
- "meta/solve_time": hfd.Value(dtype=FLOAT_TYPE),
321
- }
322
-
323
- def input_features(sizes: CaseSizes):
324
- return {
325
- "input/pd": hfd.Sequence(length=sizes.n_load, feature=hfd.Value(dtype=FLOAT_TYPE)),
326
- "input/qd": hfd.Sequence(length=sizes.n_load, feature=hfd.Value(dtype=FLOAT_TYPE)),
327
- "input/gen_status": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=BOOL_TYPE)),
328
- "input/branch_status": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=BOOL_TYPE)),
329
- "input/seed": hfd.Value(dtype=INT_TYPE),
330
- }
331
-
332
- def acopf_primal_features(sizes: CaseSizes):
333
- return {
334
- "ACOPF/primal/vm": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
335
- "ACOPF/primal/va": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
336
- "ACOPF/primal/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
337
- "ACOPF/primal/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
338
- "ACOPF/primal/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
339
- "ACOPF/primal/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
340
- "ACOPF/primal/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
341
- "ACOPF/primal/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
342
- }
343
- def acopf_dual_features(sizes: CaseSizes):
344
- return {
345
- "ACOPF/dual/kcl_p": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
346
- "ACOPF/dual/kcl_q": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
347
- "ACOPF/dual/vm": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
348
- "ACOPF/dual/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
349
- "ACOPF/dual/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
350
- "ACOPF/dual/ohm_pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
351
- "ACOPF/dual/ohm_pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
352
- "ACOPF/dual/ohm_qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
353
- "ACOPF/dual/ohm_qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
354
- "ACOPF/dual/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
355
- "ACOPF/dual/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
356
- "ACOPF/dual/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
357
- "ACOPF/dual/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
358
- "ACOPF/dual/va_diff": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
359
- "ACOPF/dual/sm_fr": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
360
- "ACOPF/dual/sm_to": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
361
- "ACOPF/dual/slack_bus": hfd.Value(dtype=FLOAT_TYPE),
362
- }
363
- def dcopf_primal_features(sizes: CaseSizes):
364
- return {
365
- "DCOPF/primal/va": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
366
- "DCOPF/primal/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
367
- "DCOPF/primal/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
368
- }
369
- def dcopf_dual_features(sizes: CaseSizes):
370
- return {
371
- "DCOPF/dual/kcl_p": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
372
- "DCOPF/dual/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
373
- "DCOPF/dual/ohm_pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
374
- "DCOPF/dual/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
375
- "DCOPF/dual/va_diff": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
376
- "DCOPF/dual/slack_bus": hfd.Value(dtype=FLOAT_TYPE),
377
- }
378
- def socopf_primal_features(sizes: CaseSizes):
379
- return {
380
- "SOCOPF/primal/w": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
381
- "SOCOPF/primal/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
382
- "SOCOPF/primal/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
383
- "SOCOPF/primal/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
384
- "SOCOPF/primal/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
385
- "SOCOPF/primal/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
386
- "SOCOPF/primal/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
387
- "SOCOPF/primal/wr": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
388
- "SOCOPF/primal/wi": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
389
- }
390
- def socopf_dual_features(sizes: CaseSizes):
391
- return {
392
- "SOCOPF/dual/kcl_p": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
393
- "SOCOPF/dual/kcl_q": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
394
- "SOCOPF/dual/w": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
395
- "SOCOPF/dual/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
396
- "SOCOPF/dual/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
397
- "SOCOPF/dual/ohm_pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
398
- "SOCOPF/dual/ohm_pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
399
- "SOCOPF/dual/ohm_qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
400
- "SOCOPF/dual/ohm_qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
401
- "SOCOPF/dual/jabr": hfd.Array2D(shape=(sizes.n_branch, 4), dtype=FLOAT_TYPE),
402
- "SOCOPF/dual/sm_fr": hfd.Array2D(shape=(sizes.n_branch, 3), dtype=FLOAT_TYPE),
403
- "SOCOPF/dual/sm_to": hfd.Array2D(shape=(sizes.n_branch, 3), dtype=FLOAT_TYPE),
404
- "SOCOPF/dual/va_diff": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
405
- "SOCOPF/dual/wr": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
406
- "SOCOPF/dual/wi": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
407
- "SOCOPF/dual/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
408
- "SOCOPF/dual/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
409
- "SOCOPF/dual/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
410
- "SOCOPF/dual/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
411
- }
412
-
413
- # ┌────────────���──┐
414
- # │ Utilities │
415
- # └───────────────┘
416
-
417
- def open_maybe_gzip_cat(path: str | list):
418
- if isinstance(path, list):
419
- dest = Path(path[0]).parent.with_suffix(".h5")
420
- if not dest.exists():
421
- with open(dest, "wb") as dest_f:
422
- for piece in path:
423
- with open(piece, "rb") as piece_f:
424
- shutil.copyfileobj(piece_f, dest_f)
425
- shutil.rmtree(Path(piece).parent)
426
- path = dest.as_posix()
427
- return gzip.open(path, "rb") if path.endswith(".gz") else open(path, "rb")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -288,6 +288,14 @@ dataset_info:
288
  - name: test
289
  num_bytes: 773105626
290
  num_examples: 80282
291
- download_size: 3049813999
292
  dataset_size: 3865508866
 
 
 
 
 
 
 
 
293
  ---
 
288
  - name: test
289
  num_bytes: 773105626
290
  num_examples: 80282
291
+ download_size: 4999551488
292
  dataset_size: 3865508866
293
+ configs:
294
+ - config_name: 30_ieee-nminus1
295
+ data_files:
296
+ - split: train
297
+ path: 30_ieee-nminus1/train-*
298
+ - split: test
299
+ path: 30_ieee-nminus1/test-*
300
+ default: true
301
  ---
config.toml DELETED
@@ -1,44 +0,0 @@
1
- # Name of the reference PGLib case. Must be a valid PGLib case name.
2
- pglib_case = "pglib_opf_case30_ieee"
3
- floating_point_type = "Float32"
4
-
5
- [sampler]
6
- # data sampler options
7
- [sampler.load]
8
- noise_type = "ScaledUniform"
9
- l = 0.6 # Lower bound of base load factor
10
- u = 1.0 # Upper bound of base load factor
11
- sigma = 0.20 # Relative (multiplicative) noise level.
12
-
13
- [sampler.status]
14
- type = "Nminus1"
15
-
16
- [OPF]
17
-
18
- [OPF.ACOPF]
19
- type = "ACOPF"
20
- solver.name = "Ipopt"
21
- solver.attributes.tol = 1e-6
22
- solver.attributes.linear_solver = "ma27"
23
-
24
- [OPF.DCOPF]
25
- # Formulation/solver options
26
- type = "DCOPF"
27
- solver.name = "HiGHS"
28
-
29
- [OPF.SOCOPF]
30
- type = "SOCOPF"
31
- solver.name = "Clarabel"
32
- # Tight tolerances
33
- solver.attributes.tol_gap_abs = 1e-6
34
- solver.attributes.tol_gap_rel = 1e-6
35
- solver.attributes.tol_feas = 1e-6
36
- solver.attributes.tol_infeas_rel = 1e-6
37
- solver.attributes.tol_ktratio = 1e-6
38
- # Reduced accuracy settings
39
- solver.attributes.reduced_tol_gap_abs = 1e-6
40
- solver.attributes.reduced_tol_gap_rel = 1e-6
41
- solver.attributes.reduced_tol_feas = 1e-6
42
- solver.attributes.reduced_tol_infeas_abs = 1e-6
43
- solver.attributes.reduced_tol_infeas_rel = 1e-6
44
- solver.attributes.reduced_tol_ktratio = 1e-6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infeasible/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ef4de4bab5d53ca923ac4d9d98283afd0500aadd7ba514fa2d79e863373acfbf
3
- size 2153438
 
 
 
 
infeasible/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c71eb4d601b35f1b23e036c143b2bb70ab1079afc85d50b45e7877b713e4a8d
3
- size 2829257
 
 
 
 
infeasible/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d6eea86cc700967a8ea9f70d381504ee7661d331ca665062973301d0a353a806
3
- size 4555971
 
 
 
 
infeasible/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4ce235badb3f80562b6005fb1ddbf422ad2502e8314c8a09213fd2eb8ddc2aed
3
- size 355426063
 
 
 
 
infeasible/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7d6bb8cf185f9f899f5687ed6497c963301983b62d7fb3bd087ec62652fa075e
3
- size 3281082
 
 
 
 
infeasible/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c07e2c624e8d91c8339a527130ea3498d444d71acbd16d24423fbf4ac51ed8b4
3
- size 30146073
 
 
 
 
infeasible/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:be8bbf3dffdf42c19b57afbea552f63e325ccbfc18f4701f922000a19c8dd05e
3
- size 15213225
 
 
 
 
test/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d5871cec22a34592b69903ffaa67320763ffb79b2cc652e2f190c124a994030f
3
- size 147071564
 
 
 
 
test/ACOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:de4aa9e4458d4c0e1460fa86e26247053f1e80aec5fd8d0cd013d88bfbddc855
3
- size 2641217
 
 
 
 
test/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c5659566a1048b76053d8e42a32b080d30aaaac462deef49aa7a0c0d43105538
3
- size 65318220
 
 
 
 
test/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:25cbe862d3ed9f3981d676babdada23235a30232a8773edb9c79ed9dc23228fc
3
- size 1028583
 
 
 
 
test/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5ac9269b3e2cc07f683257cafd438e9b018636a6de1a96416ca15218beb50580
3
- size 2576137
 
 
 
 
test/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:395b03d17d1d1445616450c5182b8951203da5357539441e780d5be9eb74cf60
3
- size 19584866
 
 
 
 
test/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d21d1cd1a25698a9fed4652e804bfda4ac0636a9514f5b1e93111a2fdc1dda48
3
- size 274785747
 
 
 
 
test/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:226d971f49088e448e048361785e497fbc90d0d231b8027da386d3403cda554e
3
- size 2699340
 
 
 
 
test/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:58f855ee729dd82f39e3887144a3fb5e0327c0b632ee80f0b42ce88aa88f037c
3
- size 81879368
 
 
 
 
test/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1ea4816764b2b7ebf399833aea7180e218c5f461302ab92be36a7c499d1a5b98
3
- size 12433870
 
 
 
 
train/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9deb69ebdd4732abcebe92f3c65751d5ccd231528ed8801f95696cb577eb40d4
3
- size 588277428
 
 
 
 
train/ACOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4744cb29637051c03043b58e8628e873113e899c8cbae3e07b3621af11639b87
3
- size 10513433
 
 
 
 
train/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:6db604e046fc59a6d6d529bfa92d66764ef994390b0f2d2253c6366f0caf9014
3
- size 261256922
 
 
 
 
train/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8b7b748801524b465e7737b96ac815f65322748c2183db15f638fba9f5da31e8
3
- size 4112004
 
 
 
 
train/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:851cd1129afa1ce7764104f2ca730b8bd9d7b76d823b6a48762269a46c048b55
3
- size 10252898
 
 
 
 
train/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:68ddbf6e2e0d5ce14586509061b08aa86708889d2c037546bfaab4e77e4c8ef7
3
- size 78336518
 
 
 
 
train/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:76aec12d3a442f2a3c80e8196ab7b730bcbaece4022bc7a95bace6394dedd279
3
- size 1099073557
 
 
 
 
train/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c2c390a9d9beed8caf8346601e6420fa3167eb7d0605691dd0fff5569df3f2a1
3
- size 10747628
 
 
 
 
train/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fc95d83b4832b798820dde458766ebe65534c3936d5ae556c699c8ee7f5c7757
3
- size 327510427
 
 
 
 
train/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fb0039d80b0715c01fb5736f2c29c1cfbde0833cdd42015f832e3e89fcad6101
3
- size 49714272