klamike commited on
Commit
6ec97f3
·
verified ·
1 Parent(s): f2bbce6

Convert dataset to Parquet (part 00005-of-00006) (#6)

Browse files

- Convert dataset to Parquet (part 00005-of-00006) (9f1675264b976fb58af969bf329dabbd18cbbdf0)
- Delete data file (a332bb4511a3ca4165061d54b782c435193490eb)
- Delete data file (7b9ca58fa78187031a2934ad1c3d5f5e4dc7695e)
- Delete loading script (df4efc2c59565d791e7e36676d9021db55764d4e)
- Delete data file (693c032b7d6389852bb4dd47f36fa4c48a2c7556)
- Delete data file (7decd71731f19ee76bb0bb45de7c2a87c3b006d5)
- Delete data file (f9af1566e8c0dcf073002c1ff472b07cce09d7c3)
- Delete data file (a35d1cfcc2ee70a91ed8d799609d3e03d054dfc4)
- Delete data file (b99bd2850ca4c3251a134c4d9751f60eb7d6ed7c)
- Delete data file (90a49e467ce874b6cc6508b9e17cb49e0c7a380e)
- Delete data file (560664c92d8580383982e84b2c593871519d7ecd)
- Delete data file (27ed65236f44cfdefb25948d79c8255f5807a2cd)
- Delete data file (d044d8ee791aebdda3af802ed071065dad3c0ae1)
- Delete data file (86ca3f4178b1a0103b4f9f105226a549e679d23a)
- Delete data file (c17feb04df3ae1301df02c541f87221f8ccab906)
- Delete data file (a1b2a685eceb2f38c431665294f4b634e5e9c4af)
- Delete data file (95bdd8f7a1909b71a3e593b98fd9d233ac335f53)
- Delete data file (3aefd419519bccc9807f1333ff0214b683ac03e4)
- Delete data file (9a6f99e8c53ead18230970cad124bdd65d2ba9d8)
- Delete data file (d0bd82b3c77369b389dc851c8c2e4263e5bd0661)
- Delete data file (9a38f64cb864255212943333bd71a0eb7a79444c)
- Delete data file (017e95041632a0d8dffff8a9c8b9f45113488791)
- Delete data file (3d6866b001b93a60656f05c18a357febba83a646)
- Delete data file (ff87270b2aab00ed91a6479f39f29337d404bb5f)
- Delete data file (b4f8a9fa92af86218ee9d3cfe359338e1d8b6c8a)
- Delete data file (ce45c5e5ca7773044d4abd54c5f7ae8b72eb124c)
- Delete data file (153d4edf5101b748fb45e78150021d4e0c607a45)
- Delete data file (7538bbff3dcdada7e8c8702f14b856b582833e5d)
- Delete data file (b158d84514f81257bff5886f13e4a957578269be)
- Delete data file (6f9cc7abd90636fa934c142e124147dc6c511d5c)
- Delete data file (3e46931b8b5ffb0c475f373e729a36cb4ccae53a)
- Delete data file (0e7ed6f6843fcefbac797d38b5a7cc58f74e6f1e)
- Delete data file (bf93c052b67932914bb64d60bf934a9805827fde)
- Delete data file (8ddbcc4e2b3b0b294f5121ab4bfb14199972de04)

infeasible/ACOPF/meta.h5.gz → 1888_rte-nminus1/test-00044-of-00052.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:dc566bf8406c86d1da68da2f06282caabda8f3f25dae33bb469e8953974c9fe6
3
- size 837400
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1972e48bb56479b57922f6bb2de709437b074c34955f731e6f162238d1dd078b
3
+ size 480305195
case.json.gz → 1888_rte-nminus1/test-00045-of-00052.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e2efeabd39013336fabc3a8ecef880c14ea30b1272e210afba3aef4cc4ce918a
3
- size 1448840
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af69a3d429b537e322eb55c4f094e61137ad65aba03e7115487d42a064b3a09a
3
+ size 480336940
infeasible/DCOPF/dual.h5.gz → 1888_rte-nminus1/test-00046-of-00052.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:69e929c5cd85be6da5e05881e78570d55333f81e592e5e7157f45ca0a70b38ba
3
- size 97482363
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d16cb7f62215abb74deb6e0db0beeed2c09d20de4e6574e588f340ca70964aa
3
+ size 480297664
infeasible/DCOPF/meta.h5.gz → 1888_rte-nminus1/test-00047-of-00052.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:15b22025b63bbbca0e5c16694ec92c7dd0822d1e1fe4009428fe24e2c6bf6b8a
3
- size 822451
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:344e83725e59b5347ac3f85985a8cea6b8518d0a5712332e7e2b033bce3ad387
3
+ size 480313761
1888_rte-nminus1/test-00048-of-00052.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4026627c41176c4e8c4dc58ed05342ea4238bfc735ac8639d8e5cf28b852c73c
3
+ size 480276662
1888_rte-nminus1/test-00049-of-00052.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d1686f085d8a8e37b49381069e8a6e02aea55ed38064b85896eadeb6a8364cb
3
+ size 480407618
1888_rte-nminus1/test-00050-of-00052.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab4b5d171e18062b9a0d01aa008b18029510d8541ec0b6c9f4fe12f651c2b392
3
+ size 480260814
1888_rte-nminus1/test-00051-of-00052.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee5a0e7dded15ea7e660118002256deb6b6890dc1bc788eb57dc48210dbcc226
3
+ size 480271003
PGLearn-Medium-1888_rte-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 = "1888_rte-nminus1"
24
- SIZES = CaseSizes(n_bus=1888, n_load=1000, n_gen=290, n_branch=2531)
25
- NUM_TRAIN = 180415
26
- NUM_TEST = 45104
27
- NUM_INFEASIBLE = 24481
28
- SPLITFILES = {}
29
-
30
- URL = "https://huggingface.co/datasets/PGLearn/PGLearn-Medium-1888_rte-nminus1"
31
- DESCRIPTION = """\
32
- The 1888_rte-nminus1 PGLearn optimal power flow dataset, part of the PGLearn-Medium 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-Medium-1888_rte-nminus1/blob/script/case.json.gz
40
- """
41
- USE_ML4OPF_WARNING = """
42
- ================================================================================================
43
- Loading PGLearn-Medium-1888_rte-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-Medium-1888_rte-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 PGLearnMedium1888_rteNminus1Config(hfd.BuilderConfig):
98
- """BuilderConfig for PGLearn-Medium-1888_rte-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(PGLearnMedium1888_rteNminus1Config, 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 PGLearnMedium1888_rteNminus1(hfd.ArrowBasedBuilder):
208
- """DatasetBuilder for PGLearn-Medium-1888_rte-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-Medium-1888_rte-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 = PGLearnMedium1888_rteNminus1Config
224
- DEFAULT_CONFIG_NAME=CASENAME
225
- BUILDER_CONFIGS = [
226
- PGLearnMedium1888_rteNminus1Config(
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: 25667812510
290
  num_examples: 45104
291
- download_size: 102149649896
292
  dataset_size: 128338493470
 
 
 
 
 
 
 
 
293
  ---
 
288
  - name: test
289
  num_bytes: 25667812510
290
  num_examples: 45104
291
+ download_size: 124865355237
292
  dataset_size: 128338493470
293
+ configs:
294
+ - config_name: 1888_rte-nminus1
295
+ data_files:
296
+ - split: train
297
+ path: 1888_rte-nminus1/train-*
298
+ - split: test
299
+ path: 1888_rte-nminus1/test-*
300
+ default: true
301
  ---
config.toml DELETED
@@ -1,56 +0,0 @@
1
- export_dir = "data/pglearn/1888_rte-n1"
2
- # Name of the reference PGLib case. Must be a valid PGLib case name.
3
- pglib_case = "pglib_opf_case1888_rte"
4
- floating_point_type = "Float32"
5
-
6
- [sampler]
7
- # data sampler options
8
- [sampler.load]
9
- noise_type = "ScaledUniform"
10
- l = 0.7 # Lower bound of base load factor
11
- u = 1.1 # Upper bound of base load factor
12
- sigma = 0.20 # Relative (multiplicative) noise level.
13
-
14
- [sampler.status]
15
- type = "Nminus1"
16
-
17
- [OPF]
18
-
19
- [OPF.ACOPF]
20
- type = "ACOPF"
21
- solver.name = "Ipopt"
22
- solver.attributes.tol = 1e-6
23
- solver.attributes.linear_solver = "ma27"
24
-
25
- [OPF.DCOPF]
26
- # Formulation/solver options
27
- type = "DCOPF"
28
- solver.name = "HiGHS"
29
-
30
- [OPF.SOCOPF]
31
- type = "SOCOPF"
32
- solver.name = "Clarabel"
33
- # Tight tolerances
34
- solver.attributes.tol_gap_abs = 1e-6
35
- solver.attributes.tol_gap_rel = 1e-6
36
- solver.attributes.tol_feas = 1e-6
37
- solver.attributes.tol_infeas_rel = 1e-6
38
- solver.attributes.tol_ktratio = 1e-6
39
- # Reduced accuracy settings
40
- solver.attributes.reduced_tol_gap_abs = 1e-6
41
- solver.attributes.reduced_tol_gap_rel = 1e-6
42
- solver.attributes.reduced_tol_feas = 1e-6
43
- solver.attributes.reduced_tol_infeas_abs = 1e-6
44
- solver.attributes.reduced_tol_infeas_rel = 1e-6
45
- solver.attributes.reduced_tol_ktratio = 1e-6
46
-
47
- [slurm]
48
- n_samples = 250000
49
- n_jobs = 44
50
- minibatch_size = 32
51
- cpus_per_task = 8
52
- queue = "embers"
53
- charge_account = "gts-phentenryck3-ai4opt"
54
- sysimage_memory = "128G"
55
- sampler_memory = "8G"
56
- extract_memory = "500G"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infeasible/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4feb013a8f765c576de4ccd216b52caa86ebda54d03b1a80314cd7f42f752987
3
- size 3030776409
 
 
 
 
infeasible/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4a2659938eab2d943f8287a565714cad7bc4c60372a97f27e7ad07e717a16773
3
- size 1271229522
 
 
 
 
infeasible/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c81e5a77d3a6135f5e2354661374d77f102894fdb16a1fbbfcc4ab42edb514a5
3
- size 358038710
 
 
 
 
infeasible/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:16e6995a8cba90ec055dabfd5e0f04561c511a22e0edfcec35490c83b2a4ecba
3
- size 5065663232
 
 
 
 
infeasible/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cfee40f18699dc3f34c5533770be2a8532b88b8b08e110fd67573b8da9056dab
3
- size 864152
 
 
 
 
infeasible/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:656d2ece52a22a882e30b93fc245566fd2ee7a48f9c61c534a98d3b252a87cec
3
- size 1471810201
 
 
 
 
infeasible/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5702fa4238d304c9c54936aef0f13a0b870c900847197961b93c90f6ee19e784
3
- size 180968220
 
 
 
 
test/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8b8c017dd9b3cae3490e661ffde3097118456d7d30c555ab1c1b41f3cc523068
3
- size 4945508704
 
 
 
 
test/ACOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a8f9ccd4ff1381eec435a154189e4b6761c44a04ba79344900c6293a30d78f4e
3
- size 1540584
 
 
 
 
test/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:68c90382b4458871d144119f4808a1e43fe768287b3e83de57ee8c2842a10a71
3
- size 2241259187
 
 
 
 
test/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:217ce2476301254380d932959b1503ed5f6335f25725f1ef0177cacfc352542d
3
- size 187627680
 
 
 
 
test/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c3acab3b5defae3b729a74885b1f29cd429f992972ef8f7e2e831014fd774571
3
- size 1502351
 
 
 
 
test/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:505eb2ac4f20afc138727923afca2918726305454f75d8500268e3beaf406c33
3
- size 664276613
 
 
 
 
test/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:6472cf0090f99728ae601f0a83931e9c716f9c3284c142ccd9fe9de8229b2be1
3
- size 9332505105
 
 
 
 
test/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cee4ffdd40d1d5a75f6556f9c85f4940358a6df3eaec71755877ea65bc4d1d95
3
- size 1542571
 
 
 
 
test/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:498a9af94fc4908ab5c23b01e8fdb283df3fcd3b5af4306c45496f081f4381f7
3
- size 2720736437
 
 
 
 
test/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:05b47b9bfabd860e1699b3a4ff875795146ea32c4a9deb5173b2268ea68db19e
3
- size 333549612
 
 
 
 
train/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cf73c5b6b044f46636aea13e5378398d87e4f41ee101276b8dc2adf7b48ed7d2
3
- size 19782095077
 
 
 
 
train/ACOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9769f031a8756201ff293ef9b229e56971dd1042e1d0c94fbb1e98d377d2dae6
3
- size 6128878
 
 
 
 
train/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:be4a3ea1cdfdbdf312f5cc8714036ec05518c9b636167bc60d1e2ff10a4edb75
3
- size 8964836902
 
 
 
 
train/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:18264a7eaf01ea5e664a2c0fb84e07957605055fbf211b100f47d63fb9833030
3
- size 751346938
 
 
 
 
train/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a08a7e56ca9cb28a6a5ad71943b5a8bd8c7287d9b652dc5207a7b3ef057c51ad
3
- size 5970248
 
 
 
 
train/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e72a2f5b4400292f45c7ea0388bc9c3f467993c8da97f7fe46a7b3eec3f41ad
3
- size 2657085676
 
 
 
 
train/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fc9f66eb9992ac6523b522654774f4eb7294bb0ad81454d2e8756a65ed6048a3
3
- size 37329289456
 
 
 
 
train/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:53b1939ad83e7d8ca26f0e16171d2ad5b4c6bc86273fef487a991214aec6290a
3
- size 6134953
 
 
 
 
train/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:882ad8a133cfd910b30048217f4b6b0a039b06f0e1d149e5cece42eff4242ade
3
- size 10882539525
 
 
 
 
train/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4d20881665c26b9d0aa5915f1184a94106bcd25e2ed4c780e6bec563f241df0d
3
- size 1334173399