klamike commited on
Commit
bca3eee
·
verified ·
1 Parent(s): d1c07a6

Convert dataset to Parquet (part 00011-of-00012) (#12)

Browse files

- Convert dataset to Parquet (part 00011-of-00012) (d295b55e497a7fc3c6629422be11a8f8ddfd9c45)
- Delete data file (2e22fbdbfada2b89176ba008d31ea9202ab23eeb)
- Delete data file (f9f6c37f8c3b097a557a28339a3cf1b919d93f84)
- Delete loading script (95b13933b008def1148b09ed8fb5cd7d1f9970dd)
- Delete data file (8e9cce47c5c52a942bf624c84f7b28efc2834aa7)
- Delete data file (4c3d4fa39d6df3ebca2403299ede4094078e29bb)
- Delete data file (f5252fbc93ce95109873222813c98b94f4cd2dfc)
- Delete data file (1c28bda31aa478d7380b27448a353ce107555f91)
- Delete data file (e84a7ffe0714fe592979bccf34042a8cb851b1ae)
- Delete data file (95eb958fc4ac1222a43249c4082c1e80556bcb5d)
- Delete data file (a3f0b5ce6a76442583190db1eb56567598a7ddf4)
- Delete data file (e153d99df3ba4d8afa0c58300583655c2d00200b)
- Delete data file (e6031cea636f8066567ad50caf0c478877915081)
- Delete data file (756a59eba07f4ad5358212ae402b8bcd4aa54568)
- Delete data file (6360a17873d4ba3c53e4af237dd48c260eccd2a1)
- Delete data file (91e38a811a3dcffd58da3491a5f0ec2e1874edf6)
- Delete data file (313c27566f9c6c3ba1b4a4a6517ffdf761becca8)
- Delete data file (bcc7e54ef5d77345634cc8587cd0b6ec19d2b720)
- Delete data file (b4e477e40d674622e93b53b1bf5acb94a8bfb7aa)
- Delete data file (56f6c52e57eaa1ca90ebacf00dafe7a0382c8fbf)
- Delete data file (5de5a0701426b00b71784302968e92f1e7e8bfdd)
- Delete data file (1234217c3a973c6217b3e96606a99715d57b017a)
- Delete data file (cfb25c7244cca220238500f85bea51fdbd62b518)
- Delete data file (a345104cfe370992b4275154fa6e7c54ae4e1346)
- Delete data file (7ae54d42a59a347a46225c0f66a6a3152a0fdccb)
- Delete data file (99662f286d4ab7b038397b34c319eeaef7dfb875)
- Delete data file (a01a011ba65340af1e9a9141f21d0c3b839dda65)
- Delete data file (4338732086f06aec1f1654d9efe7268b76f7262a)
- Delete data file (be0336a2d836953b9ab8f945a7fa066508f5388d)
- Delete data file (ac17ece9f61d8d2b511dcb8757d1e5da681c3f9d)
- Delete data file (0598815a025703d938531a06b672d9efae22e90c)
- Delete data file (ed7d4a55f3850c4519ad88ae8bc2c43e3918c4cd)
- Delete data file (9441c69963fa03bac2a72edf92414eb650a9a5c0)
- Delete data file (307dade183f6e74444866050183d3862e437a0be)
- Delete data file (ba87ea63137dd6836072119600434a24677c1270)
- Delete data file (efb993496f2e1887f65e0ba8239f51b0c920732c)

infeasible/ACOPF/meta.h5.gz → 9241_pegase/test-00105-of-00112.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b236b74ce39ecddfbfcd04261e50aabaaeed0ea145974bdc3e4eb55ed693b92a
3
- size 694636
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fffd6d20390660ba5ffd33312e12c1b47d3d088fd23f29a0ed66e13187c6d244
3
+ size 495074099
case.json.gz → 9241_pegase/test-00106-of-00112.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:329c320caaa60358aabd7b788c334c5ccde691db3be04de2b61f41a2ab90f174
3
- size 9154663
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6975382ba4c4662127488ce169dd525713384877c7a8aadf2660ca9ebb5aaaf9
3
+ size 495266802
infeasible/DCOPF/meta.h5.gz → 9241_pegase/test-00107-of-00112.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9b8286ecfb697c596a5531f2c58d4233ac7291d2ac1d68d37af15655809e4e28
3
- size 683104
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:815a55cf413c4b8b9fb38704c2e54a236ac553ed60302546dc0f3df6d0c5bdd8
3
+ size 495041057
infeasible/SOCOPF/meta.h5.gz → 9241_pegase/test-00108-of-00112.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9a803e975ff7645fce4102fa0128fc6614c921e3c8a20497a3612f894a997deb
3
- size 596167
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55fac25f9ecf0c7e711114df0222d807540e4d1cccca4d21fb922fad1361fce7
3
+ size 495147761
9241_pegase/test-00109-of-00112.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1efff660d488b6a41d339ca9be394e37b0c90f5a431ccd90c736ecaffb16c0c
3
+ size 495152140
9241_pegase/test-00110-of-00112.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:750182826d79fd5efd1729752fd5d7e03a13e544e337d10f80f4f6b5ef03ed84
3
+ size 495055570
9241_pegase/test-00111-of-00112.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4840b4020043e1914c82f056e1051b83271f0d0325ab83d298fa5ec56431bb0
3
+ size 495178898
PGLearn-Large-9241_pegase.py DELETED
@@ -1,429 +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 = "9241_pegase"
24
- SIZES = CaseSizes(n_bus=9241, n_load=4895, n_gen=1445, n_branch=16049)
25
- NUM_TRAIN = 64309
26
- NUM_TEST = 16078
27
- NUM_INFEASIBLE = 19631
28
- SPLITFILES = {
29
- "train/SOCOPF/dual.h5.gz": ["train/SOCOPF/dual/xaa", "train/SOCOPF/dual/xab", "train/SOCOPF/dual/xac"],
30
- }
31
-
32
- URL = "https://huggingface.co/datasets/PGLearn/PGLearn-Large-9241_pegase"
33
- DESCRIPTION = """\
34
- The 9241_pegase PGLearn optimal power flow dataset, part of the PGLearn-Large collection. \
35
- """
36
- VERSION = hfd.Version("1.0.0")
37
- DEFAULT_CONFIG_DESCRIPTION="""\
38
- This configuration contains feasible input, primal solution, and dual solution data \
39
- for the ACOPF, DCOPF, and SOCOPF formulations on the {case} system. For case data, \
40
- download the case.json.gz file from the `script` branch of the repository. \
41
- https://huggingface.co/datasets/PGLearn/PGLearn-Large-9241_pegase/blob/script/case.json.gz
42
- """
43
- USE_ML4OPF_WARNING = """
44
- ================================================================================================
45
- Loading PGLearn-Large-9241_pegase through the `datasets.load_dataset` function may be slow.
46
-
47
- Consider using ML4OPF to directly convert to `torch.Tensor`; for more info see:
48
- https://github.com/AI4OPT/ML4OPF?tab=readme-ov-file#manually-loading-data
49
-
50
- Or, use `huggingface_hub.snapshot_download` and an HDF5 reader; for more info see:
51
- https://huggingface.co/datasets/PGLearn/PGLearn-Large-9241_pegase#downloading-individual-files
52
- ================================================================================================
53
- """
54
- CITATION = """\
55
- @article{klamkinpglearn,
56
- title={{PGLearn - An Open-Source Learning Toolkit for Optimal Power Flow}},
57
- author={Klamkin, Michael and Tanneau, Mathieu and Van Hentenryck, Pascal},
58
- year={2025},
59
- }\
60
- """
61
-
62
- IS_COMPRESSED = True
63
-
64
- # ┌──────────────────┐
65
- # │ Formulations │
66
- # └──────────────────┘
67
-
68
- def acopf_features(sizes: CaseSizes, primal: bool, dual: bool, meta: bool):
69
- features = {}
70
- if primal: features.update(acopf_primal_features(sizes))
71
- if dual: features.update(acopf_dual_features(sizes))
72
- if meta: features.update({f"ACOPF/{k}": v for k, v in META_FEATURES.items()})
73
- return features
74
-
75
- def dcopf_features(sizes: CaseSizes, primal: bool, dual: bool, meta: bool):
76
- features = {}
77
- if primal: features.update(dcopf_primal_features(sizes))
78
- if dual: features.update(dcopf_dual_features(sizes))
79
- if meta: features.update({f"DCOPF/{k}": v for k, v in META_FEATURES.items()})
80
- return features
81
-
82
- def socopf_features(sizes: CaseSizes, primal: bool, dual: bool, meta: bool):
83
- features = {}
84
- if primal: features.update(socopf_primal_features(sizes))
85
- if dual: features.update(socopf_dual_features(sizes))
86
- if meta: features.update({f"SOCOPF/{k}": v for k, v in META_FEATURES.items()})
87
- return features
88
-
89
- FORMULATIONS_TO_FEATURES = {
90
- "ACOPF": acopf_features,
91
- "DCOPF": dcopf_features,
92
- "SOCOPF": socopf_features,
93
- }
94
-
95
- # ┌───────────────────┐
96
- # │ BuilderConfig │
97
- # └───────────────────┘
98
-
99
- class PGLearnLarge9241_pegaseConfig(hfd.BuilderConfig):
100
- """BuilderConfig for PGLearn-Large-9241_pegase.
101
- By default, primal solution data, metadata, input, casejson, are included for the train and test splits.
102
-
103
- To modify the default configuration, pass attributes of this class to `datasets.load_dataset`:
104
-
105
- Attributes:
106
- formulations (list[str]): The formulation(s) to include, e.g. ["ACOPF", "DCOPF"]
107
- primal (bool, optional): Include primal solution data. Defaults to True.
108
- dual (bool, optional): Include dual solution data. Defaults to False.
109
- meta (bool, optional): Include metadata. Defaults to True.
110
- input (bool, optional): Include input data. Defaults to True.
111
- casejson (bool, optional): Include case.json data. Defaults to True.
112
- train (bool, optional): Include training samples. Defaults to True.
113
- test (bool, optional): Include testing samples. Defaults to True.
114
- infeasible (bool, optional): Include infeasible samples. Defaults to False.
115
- """
116
- def __init__(self,
117
- formulations: list[str],
118
- primal: bool=True, dual: bool=False, meta: bool=True, input: bool = True, casejson: bool=True,
119
- train: bool=True, test: bool=True, infeasible: bool=False,
120
- compressed: bool=IS_COMPRESSED, **kwargs
121
- ):
122
- super(PGLearnLarge9241_pegaseConfig, self).__init__(version=VERSION, **kwargs)
123
-
124
- self.case = CASENAME
125
- self.formulations = formulations
126
-
127
- self.primal = primal
128
- self.dual = dual
129
- self.meta = meta
130
- self.input = input
131
- self.casejson = casejson
132
-
133
- self.train = train
134
- self.test = test
135
- self.infeasible = infeasible
136
-
137
- self.gz_ext = ".gz" if compressed else ""
138
-
139
- @property
140
- def size(self):
141
- return SIZES
142
-
143
- @property
144
- def features(self):
145
- features = {}
146
- if self.casejson: features.update(case_features())
147
- if self.input: features.update(input_features(SIZES))
148
- for formulation in self.formulations:
149
- features.update(FORMULATIONS_TO_FEATURES[formulation](SIZES, self.primal, self.dual, self.meta))
150
- return hfd.Features(features)
151
-
152
- @property
153
- def splits(self):
154
- splits: dict[hfd.Split, dict[str, str | int]] = {}
155
- if self.train:
156
- splits[hfd.Split.TRAIN] = {
157
- "name": "train",
158
- "num_examples": NUM_TRAIN
159
- }
160
- if self.test:
161
- splits[hfd.Split.TEST] = {
162
- "name": "test",
163
- "num_examples": NUM_TEST
164
- }
165
- if self.infeasible:
166
- splits[hfd.Split("infeasible")] = {
167
- "name": "infeasible",
168
- "num_examples": NUM_INFEASIBLE
169
- }
170
- return splits
171
-
172
- @property
173
- def urls(self):
174
- urls: dict[str, None | str | list] = {
175
- "case": None, "train": [], "test": [], "infeasible": [],
176
- }
177
-
178
- if self.casejson:
179
- urls["case"] = f"case.json" + self.gz_ext
180
- else:
181
- urls.pop("case")
182
-
183
- split_names = []
184
- if self.train: split_names.append("train")
185
- if self.test: split_names.append("test")
186
- if self.infeasible: split_names.append("infeasible")
187
-
188
- for split in split_names:
189
- if self.input: urls[split].append(f"{split}/input.h5" + self.gz_ext)
190
- for formulation in self.formulations:
191
- if self.primal:
192
- filename = f"{split}/{formulation}/primal.h5" + self.gz_ext
193
- if filename in SPLITFILES: urls[split].append(SPLITFILES[filename])
194
- else: urls[split].append(filename)
195
- if self.dual:
196
- filename = f"{split}/{formulation}/dual.h5" + self.gz_ext
197
- if filename in SPLITFILES: urls[split].append(SPLITFILES[filename])
198
- else: urls[split].append(filename)
199
- if self.meta:
200
- filename = f"{split}/{formulation}/meta.h5" + self.gz_ext
201
- if filename in SPLITFILES: urls[split].append(SPLITFILES[filename])
202
- else: urls[split].append(filename)
203
- return urls
204
-
205
- # ┌────────────────────┐
206
- # │ DatasetBuilder │
207
- # └────────────────────┘
208
-
209
- class PGLearnLarge9241_pegase(hfd.ArrowBasedBuilder):
210
- """DatasetBuilder for PGLearn-Large-9241_pegase.
211
- The main interface is `datasets.load_dataset` with `trust_remote_code=True`, e.g.
212
-
213
- ```python
214
- from datasets import load_dataset
215
- ds = load_dataset("PGLearn/PGLearn-Large-9241_pegase", trust_remote_code=True,
216
- # modify the default configuration by passing kwargs
217
- formulations=["DCOPF"],
218
- dual=False,
219
- meta=False,
220
- )
221
- ```
222
- """
223
-
224
- DEFAULT_WRITER_BATCH_SIZE = 10000
225
- BUILDER_CONFIG_CLASS = PGLearnLarge9241_pegaseConfig
226
- DEFAULT_CONFIG_NAME=CASENAME
227
- BUILDER_CONFIGS = [
228
- PGLearnLarge9241_pegaseConfig(
229
- name=CASENAME, description=DEFAULT_CONFIG_DESCRIPTION.format(case=CASENAME),
230
- formulations=list(FORMULATIONS_TO_FEATURES.keys()),
231
- primal=True, dual=True, meta=True, input=True, casejson=False,
232
- train=True, test=True, infeasible=False,
233
- )
234
- ]
235
-
236
- def _info(self):
237
- return hfd.DatasetInfo(
238
- features=self.config.features, splits=self.config.splits,
239
- description=DESCRIPTION + self.config.description,
240
- homepage=URL, citation=CITATION,
241
- )
242
-
243
- def _split_generators(self, dl_manager: hfd.DownloadManager):
244
- hfd.logging.get_logger().warning(USE_ML4OPF_WARNING)
245
-
246
- filepaths = dl_manager.download_and_extract(self.config.urls)
247
-
248
- splits: list[hfd.SplitGenerator] = []
249
- if self.config.train:
250
- splits.append(hfd.SplitGenerator(
251
- name=hfd.Split.TRAIN,
252
- gen_kwargs=dict(case_file=filepaths.get("case", None), data_files=tuple(filepaths["train"]), n_samples=NUM_TRAIN),
253
- ))
254
- if self.config.test:
255
- splits.append(hfd.SplitGenerator(
256
- name=hfd.Split.TEST,
257
- gen_kwargs=dict(case_file=filepaths.get("case", None), data_files=tuple(filepaths["test"]), n_samples=NUM_TEST),
258
- ))
259
- if self.config.infeasible:
260
- splits.append(hfd.SplitGenerator(
261
- name=hfd.Split("infeasible"),
262
- gen_kwargs=dict(case_file=filepaths.get("case", None), data_files=tuple(filepaths["infeasible"]), n_samples=NUM_INFEASIBLE),
263
- ))
264
- return splits
265
-
266
- 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):
267
- case_data: str | None = json.dumps(json.load(open_maybe_gzip_cat(case_file))) if case_file is not None else None
268
- data: dict[str, h5py.File] = {}
269
- for file in data_files:
270
- v = h5py.File(open_maybe_gzip_cat(file), "r")
271
- if isinstance(file, list):
272
- k = "/".join(Path(file[0].get_origin()).parts[-3:-1]).split(".")[0]
273
- else:
274
- k = "/".join(Path(file.get_origin()).parts[-2:]).split(".")[0]
275
- data[k] = v
276
- for k in list(data.keys()):
277
- if "/input" in k: data[k.split("/", 1)[1]] = data.pop(k)
278
-
279
- batch_size = self._writer_batch_size or self.DEFAULT_WRITER_BATCH_SIZE
280
- for i in range(0, n_samples, batch_size):
281
- effective_batch_size = min(batch_size, n_samples - i)
282
-
283
- sample_data = {
284
- f"{dk}/{k}":
285
- hfd.features.features.numpy_to_pyarrow_listarray(v[i:i + effective_batch_size, ...])
286
- for dk, d in data.items() for k, v in d.items() if f"{dk}/{k}" in self.config.features
287
- }
288
-
289
- if case_data is not None:
290
- sample_data["case/json"] = pa.array([case_data] * effective_batch_size)
291
-
292
- yield i, pa.Table.from_pydict(sample_data)
293
-
294
- for f in data.values():
295
- f.close()
296
-
297
- # ┌──────────────┐
298
- # │ Features │
299
- # └──────────────┘
300
-
301
- FLOAT_TYPE = "float32"
302
- INT_TYPE = "int64"
303
- BOOL_TYPE = "bool"
304
- STRING_TYPE = "string"
305
-
306
- def case_features():
307
- # FIXME: better way to share schema of case data -- need to treat jagged arrays
308
- return {
309
- "case/json": hfd.Value(STRING_TYPE),
310
- }
311
-
312
- META_FEATURES = {
313
- "meta/seed": hfd.Value(dtype=INT_TYPE),
314
- "meta/formulation": hfd.Value(dtype=STRING_TYPE),
315
- "meta/primal_objective_value": hfd.Value(dtype=FLOAT_TYPE),
316
- "meta/dual_objective_value": hfd.Value(dtype=FLOAT_TYPE),
317
- "meta/primal_status": hfd.Value(dtype=STRING_TYPE),
318
- "meta/dual_status": hfd.Value(dtype=STRING_TYPE),
319
- "meta/termination_status": hfd.Value(dtype=STRING_TYPE),
320
- "meta/build_time": hfd.Value(dtype=FLOAT_TYPE),
321
- "meta/extract_time": hfd.Value(dtype=FLOAT_TYPE),
322
- "meta/solve_time": hfd.Value(dtype=FLOAT_TYPE),
323
- }
324
-
325
- def input_features(sizes: CaseSizes):
326
- return {
327
- "input/pd": hfd.Sequence(length=sizes.n_load, feature=hfd.Value(dtype=FLOAT_TYPE)),
328
- "input/qd": hfd.Sequence(length=sizes.n_load, feature=hfd.Value(dtype=FLOAT_TYPE)),
329
- "input/gen_status": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=BOOL_TYPE)),
330
- "input/branch_status": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=BOOL_TYPE)),
331
- "input/seed": hfd.Value(dtype=INT_TYPE),
332
- }
333
-
334
- def acopf_primal_features(sizes: CaseSizes):
335
- return {
336
- "ACOPF/primal/vm": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
337
- "ACOPF/primal/va": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
338
- "ACOPF/primal/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
339
- "ACOPF/primal/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
340
- "ACOPF/primal/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
341
- "ACOPF/primal/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
342
- "ACOPF/primal/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
343
- "ACOPF/primal/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
344
- }
345
- def acopf_dual_features(sizes: CaseSizes):
346
- return {
347
- "ACOPF/dual/kcl_p": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
348
- "ACOPF/dual/kcl_q": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
349
- "ACOPF/dual/vm": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
350
- "ACOPF/dual/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
351
- "ACOPF/dual/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
352
- "ACOPF/dual/ohm_pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
353
- "ACOPF/dual/ohm_pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
354
- "ACOPF/dual/ohm_qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
355
- "ACOPF/dual/ohm_qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
356
- "ACOPF/dual/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
357
- "ACOPF/dual/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
358
- "ACOPF/dual/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
359
- "ACOPF/dual/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
360
- "ACOPF/dual/va_diff": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
361
- "ACOPF/dual/sm_fr": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
362
- "ACOPF/dual/sm_to": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
363
- "ACOPF/dual/slack_bus": hfd.Value(dtype=FLOAT_TYPE),
364
- }
365
- def dcopf_primal_features(sizes: CaseSizes):
366
- return {
367
- "DCOPF/primal/va": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
368
- "DCOPF/primal/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
369
- "DCOPF/primal/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
370
- }
371
- def dcopf_dual_features(sizes: CaseSizes):
372
- return {
373
- "DCOPF/dual/kcl_p": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
374
- "DCOPF/dual/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
375
- "DCOPF/dual/ohm_pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
376
- "DCOPF/dual/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
377
- "DCOPF/dual/va_diff": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
378
- "DCOPF/dual/slack_bus": hfd.Value(dtype=FLOAT_TYPE),
379
- }
380
- def socopf_primal_features(sizes: CaseSizes):
381
- return {
382
- "SOCOPF/primal/w": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
383
- "SOCOPF/primal/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
384
- "SOCOPF/primal/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
385
- "SOCOPF/primal/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
386
- "SOCOPF/primal/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
387
- "SOCOPF/primal/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
388
- "SOCOPF/primal/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
389
- "SOCOPF/primal/wr": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
390
- "SOCOPF/primal/wi": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
391
- }
392
- def socopf_dual_features(sizes: CaseSizes):
393
- return {
394
- "SOCOPF/dual/kcl_p": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
395
- "SOCOPF/dual/kcl_q": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
396
- "SOCOPF/dual/w": hfd.Sequence(length=sizes.n_bus, feature=hfd.Value(dtype=FLOAT_TYPE)),
397
- "SOCOPF/dual/pg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
398
- "SOCOPF/dual/qg": hfd.Sequence(length=sizes.n_gen, feature=hfd.Value(dtype=FLOAT_TYPE)),
399
- "SOCOPF/dual/ohm_pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
400
- "SOCOPF/dual/ohm_pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
401
- "SOCOPF/dual/ohm_qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
402
- "SOCOPF/dual/ohm_qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
403
- "SOCOPF/dual/jabr": hfd.Array2D(shape=(sizes.n_branch, 4), dtype=FLOAT_TYPE),
404
- "SOCOPF/dual/sm_fr": hfd.Array2D(shape=(sizes.n_branch, 3), dtype=FLOAT_TYPE),
405
- "SOCOPF/dual/sm_to": hfd.Array2D(shape=(sizes.n_branch, 3), dtype=FLOAT_TYPE),
406
- "SOCOPF/dual/va_diff": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
407
- "SOCOPF/dual/wr": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
408
- "SOCOPF/dual/wi": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
409
- "SOCOPF/dual/pf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
410
- "SOCOPF/dual/pt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
411
- "SOCOPF/dual/qf": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
412
- "SOCOPF/dual/qt": hfd.Sequence(length=sizes.n_branch, feature=hfd.Value(dtype=FLOAT_TYPE)),
413
- }
414
-
415
- # ┌───────────────┐
416
- # │ Utilities │
417
- # └───────────────┘
418
-
419
- def open_maybe_gzip_cat(path: str | list):
420
- if isinstance(path, list):
421
- dest = Path(path[0]).parent.with_suffix(".h5")
422
- if not dest.exists():
423
- with open(dest, "wb") as dest_f:
424
- for piece in path:
425
- with open(piece, "rb") as piece_f:
426
- shutil.copyfileobj(piece_f, dest_f)
427
- shutil.rmtree(Path(piece).parent)
428
- path = dest.as_posix()
429
- 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: 55615711263
290
  num_examples: 16078
291
- download_size: 242538350400
292
  dataset_size: 278068178958
 
 
 
 
 
 
 
 
293
  ---
 
288
  - name: test
289
  num_bytes: 55615711263
290
  num_examples: 16078
291
+ download_size: 278172833149
292
  dataset_size: 278068178958
293
+ configs:
294
+ - config_name: 9241_pegase
295
+ data_files:
296
+ - split: train
297
+ path: 9241_pegase/train-*
298
+ - split: test
299
+ path: 9241_pegase/test-*
300
+ default: true
301
  ---
config.toml DELETED
@@ -1,54 +0,0 @@
1
- export_dir = "data/pglearn/9241_pegase"
2
- # Name of the reference PGLib case. Must be a valid PGLib case name.
3
- pglib_case = "pglib_opf_case9241_pegase"
4
- floating_point_type = "Float32"
5
-
6
- [sampler]
7
- # data sampler options
8
- [sampler.load]
9
- noise_type = "ScaledUniform"
10
- l = 0.6 # Lower bound of base load factor
11
- u = 1.0 # Upper bound of base load factor
12
- sigma = 0.20 # Relative (multiplicative) noise level.
13
-
14
-
15
- [OPF]
16
-
17
- [OPF.ACOPF]
18
- type = "ACOPF"
19
- solver.name = "Ipopt"
20
- solver.attributes.tol = 1e-6
21
- solver.attributes.linear_solver = "ma27"
22
-
23
- [OPF.DCOPF]
24
- # Formulation/solver options
25
- type = "DCOPF"
26
- solver.name = "HiGHS"
27
-
28
- [OPF.SOCOPF]
29
- type = "SOCOPF"
30
- solver.name = "Clarabel"
31
- # Tight tolerances
32
- solver.attributes.tol_gap_abs = 1e-6
33
- solver.attributes.tol_gap_rel = 1e-6
34
- solver.attributes.tol_feas = 1e-6
35
- solver.attributes.tol_infeas_rel = 1e-6
36
- solver.attributes.tol_ktratio = 1e-6
37
- # Reduced accuracy settings
38
- solver.attributes.reduced_tol_gap_abs = 1e-6
39
- solver.attributes.reduced_tol_gap_rel = 1e-6
40
- solver.attributes.reduced_tol_feas = 1e-6
41
- solver.attributes.reduced_tol_infeas_abs = 1e-6
42
- solver.attributes.reduced_tol_infeas_rel = 1e-6
43
- solver.attributes.reduced_tol_ktratio = 1e-6
44
-
45
- [slurm]
46
- n_samples = 250000
47
- n_jobs = 44
48
- minibatch_size = 32
49
- cpus_per_task = 8
50
- queue = "embers"
51
- charge_account = "gts-phentenryck3-ai4opt"
52
- sysimage_memory = "128G"
53
- sampler_memory = "8G"
54
- 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:691c9dc1e5c2c8b8a7e8fd926c6ff5eca891e1839fea71d7dc854bd29a5b097d
3
- size 13591905928
 
 
 
 
infeasible/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bad9edfaa6017040f6d087cb3747a1b73401034045eba83f42a2e4710de5d51e
3
- size 6067978519
 
 
 
 
infeasible/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2c8d7b4cfb0d6e0c210bb6c5de8a278cfcce6ea68b66d7afbfaf3e1b6c5eb169
3
- size 1493048959
 
 
 
 
infeasible/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3121c356c723c8e78b26d139dc7438e0a40c11381c7d04bbb689bb210cb58d15
3
- size 1662274637
 
 
 
 
infeasible/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7d378441502ca2bd35688e37ef0413c3b1dae3f8c60a2ae293d41a56037265f4
3
- size 25240760107
 
 
 
 
infeasible/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c12b1ed6f300395f4de6c4c1666fb501ef86da6a4099016deac24ce88ad805e6
3
- size 7602493486
 
 
 
 
infeasible/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5bb4a8fe425d67c3875817257d61d48df32313111553852834abbf4e37e5c26c
3
- size 709475360
 
 
 
 
test/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9993f32a2328658c7a398bdd9e1affeda92749382c0963e603ea2a16f2617e66
3
- size 10974565123
 
 
 
 
test/ACOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:059a46419a7cbb7a22e337cae042aeda5330b246dc30d360dde0f649a7c219fb
3
- size 547718
 
 
 
 
test/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4994afae7d292117aad89e70d2204d86ba25f0430180a7f0223f3d49124a8c2f
3
- size 4951113837
 
 
 
 
test/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:455c7d42473fed9847d476d19cf7ee38ca0767445ca82f551b9427c855b02da4
3
- size 1292805643
 
 
 
 
test/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4b9e2d707c1003480a71006cf2e039da72f8d47301d7d9468f6259dc72481de2
3
- size 551155
 
 
 
 
test/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5054b799a285646d78ce92565763df0ef43e4f33c6926156b5d16baeb50d1a46
3
- size 1437479103
 
 
 
 
test/SOCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:db576d7336798f81619c2912531d819c3cc2e6c2db266a3f35bb95ed3c8f3cbe
3
- size 20628664463
 
 
 
 
test/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9f9ed39579409298d24be1ef91614dfa98c863dd51dadffeec6470963f0144ae
3
- size 549581
 
 
 
 
test/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8021d63174ac8939e0d1a8e93110b550a1a412836f6127cdc61a1a011ca23ff7
3
- size 6230273304
 
 
 
 
test/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bd19a7692b2a45c43874b154ce0861533bd77206dfad2c7279fd1e550c78ac51
3
- size 581042861
 
 
 
 
train/ACOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3a42778da89687bdb8c4a79b177fa1ba2af12a45daf5936b1d606f38b1c575b7
3
- size 43895744321
 
 
 
 
train/ACOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1911df724c5f55c01b27545f72729f04df38fe980d9680d1cd5285529c0c7d27
3
- size 2161836
 
 
 
 
train/ACOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:297199b5461834d3d23aaaade4852720a6e95ed9cb92f61eec779fcdb8f8cb43
3
- size 19803124522
 
 
 
 
train/DCOPF/dual.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b637a869cc9b02163eca7816ec2fccb5dad9f5d36527ab969739a94662de1b98
3
- size 5170963864
 
 
 
 
train/DCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d1484d7f6ef9e07c3ebe18f86311ed14c8a565f20e487561b77ebaeba37490a1
3
- size 2169377
 
 
 
 
train/DCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f814bdcb869b749adb6e2f823e502e9c247fa70ef918f79ba8287e99d4d5a16c
3
- size 5749500723
 
 
 
 
train/SOCOPF/dual/xaa DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8b23082e8abfe3070d89411ad209b493a3fe690941c7e8eaa82756474ef7854c
3
- size 32212254720
 
 
 
 
train/SOCOPF/dual/xab DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:59a139ae4e2181ac0a475b9b180034b7c5346da9136359d07bdcd86bbfc32aee
3
- size 32212254720
 
 
 
 
train/SOCOPF/dual/xac DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:08f1dc681a3f984b74b6e79e110b93c07606b46ecb428ac2865c940526eb96e0
3
- size 30146256264
 
 
 
 
train/SOCOPF/meta.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:203dee18e38827a7f98beda63265d9602e88f74b4a598a96e2e016716f6834ea
3
- size 2164022
 
 
 
 
train/SOCOPF/primal.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d280031d75f19f1af1d599266ea11962e9649707a5f17292fb42b2ae2f0197dc
3
- size 24920099597
 
 
 
 
train/input.h5.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:adb85fdbfe303750cb194b0bb3cd48b9ccb11a3ce777897deeae04fd5a03659a
3
- size 2324063646