|
|
import glob |
|
|
import os |
|
|
import datasets |
|
|
from huggingface_hub import snapshot_download |
|
|
|
|
|
_CITATION = """TO BE ADDED.""" |
|
|
|
|
|
_DESCRIPTION = """ |
|
|
HeuriGen is a collection of combinatorial-optimization problems |
|
|
for benchmarking heuristic-program generation by LLMs. |
|
|
""" |
|
|
|
|
|
REPO_ID = "heurigen/heurigen-data" |
|
|
|
|
|
|
|
|
class HeuriGenConfig(datasets.BuilderConfig): |
|
|
def __init__(self, **kwargs): |
|
|
super().__init__(version=datasets.Version("0.1.0"), **kwargs) |
|
|
|
|
|
|
|
|
_BUILDER_CONFIGS = [ |
|
|
HeuriGenConfig( |
|
|
name="operator_scheduling", description="DFG operator-scheduling instances" |
|
|
), |
|
|
HeuriGenConfig( |
|
|
name="technology_mapping", |
|
|
description="Logic-network technology-mapping instances", |
|
|
), |
|
|
HeuriGenConfig( |
|
|
name="global_routing", description="Netlist global-routing instances" |
|
|
), |
|
|
HeuriGenConfig( |
|
|
name="egraph_extraction", description="E-graph extraction instances" |
|
|
), |
|
|
HeuriGenConfig(name="intra_op_parallel", description="Intra-op parallel instances"), |
|
|
HeuriGenConfig( |
|
|
name="protein_sequence_design", description="Protein sequence design instances" |
|
|
), |
|
|
HeuriGenConfig(name="pedigree", description="Pedigree problem instances"), |
|
|
HeuriGenConfig( |
|
|
name="pickup_delivery_time_windows", description="Pickup-delivery-time-windows (PDPTW) instances" |
|
|
), |
|
|
HeuriGenConfig(name="crew_pairing", description="Crew pairing instances"), |
|
|
HeuriGenConfig(name="frequency_assignment", description="Frequency assignment instances"), |
|
|
] |
|
|
|
|
|
|
|
|
class HeuriGen(datasets.GeneratorBasedBuilder): |
|
|
BUILDER_CONFIGS = _BUILDER_CONFIGS |
|
|
DEFAULT_CONFIG_NAME = "operator_scheduling" |
|
|
|
|
|
def _info(self): |
|
|
return datasets.DatasetInfo( |
|
|
description=_DESCRIPTION, |
|
|
citation=_CITATION, |
|
|
features=datasets.Features( |
|
|
{ |
|
|
"file_path": datasets.Value("string"), |
|
|
} |
|
|
), |
|
|
supervised_keys=None, |
|
|
homepage=f"https://huggingface.co/datasets/{REPO_ID}", |
|
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
local_root = snapshot_download( |
|
|
repo_id=REPO_ID, |
|
|
repo_type="dataset", |
|
|
revision="main", |
|
|
allow_patterns=[f"{self.config.name}/**"], |
|
|
local_dir=dl_manager.manual_dir, |
|
|
) |
|
|
base = os.path.join(local_root, self.config.name) |
|
|
|
|
|
|
|
|
def files(pattern): |
|
|
all_files = [] |
|
|
for path in glob.glob(os.path.join(base, pattern), recursive=True): |
|
|
if os.path.isfile(path): |
|
|
all_files.append(os.path.abspath(path)) |
|
|
return sorted(all_files) |
|
|
|
|
|
demo_paths = files("demo/**/*") |
|
|
eval_paths = files("eval/**/*") |
|
|
|
|
|
return [ |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TRAIN, |
|
|
gen_kwargs={"files": demo_paths}, |
|
|
), |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TEST, |
|
|
gen_kwargs={"files": eval_paths}, |
|
|
), |
|
|
] |
|
|
|
|
|
def _generate_examples(self, files): |
|
|
for idx, path in enumerate(files): |
|
|
yield idx, {"file_path": path} |
|
|
|