Spaces:
Runtime error
Runtime error
Update utils/build_dataset.py
Browse files- utils/build_dataset.py +23 -1
utils/build_dataset.py
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
|
|
| 1 |
from fleet_beam_search_3.dataloader import VRP_Dataset
|
| 2 |
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
from fleet_beam_search_3.dataloader import VRP_Dataset
|
| 3 |
|
| 4 |
|
| 5 |
+
def build_and_save_dataset(save_path: str, dataset_size: int = 1000):
|
| 6 |
+
"""
|
| 7 |
+
Builds a VRP dataset and saves it to the given path.
|
| 8 |
+
|
| 9 |
+
Args:
|
| 10 |
+
save_path (str): Destination file path to save dataset.
|
| 11 |
+
dataset_size (int): Number of samples in the dataset.
|
| 12 |
+
"""
|
| 13 |
+
dataset = VRP_Dataset(dataset_size=dataset_size)
|
| 14 |
+
|
| 15 |
+
# Check if dataset has a save method or export function
|
| 16 |
+
if hasattr(dataset, "save") and callable(dataset.save):
|
| 17 |
+
dataset.save(save_path)
|
| 18 |
+
print(f"Dataset saved to: {save_path}")
|
| 19 |
+
else:
|
| 20 |
+
raise NotImplementedError("Dataset object lacks a save() method.")
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
output_path = "data/generated_vrp_dataset.pkl"
|
| 25 |
+
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
| 26 |
+
build_and_save_dataset(save_path=output_path, dataset_size=1000)
|