clallier commited on
Commit
5400759
ยท
verified ยท
1 Parent(s): c128ee1

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. README.md +165 -0
  2. constraints.parquet +3 -0
  3. download_dataset.py +158 -0
  4. parts.parquet +3 -0
  5. shapes.parquet +3 -0
  6. tasks.parquet +3 -0
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - tabular-classification
5
+ - regression
6
+ tags:
7
+ - operations-research
8
+ - 2d-nesting
9
+ - irregular-strip-packing
10
+ - geometry
11
+ - graph-neural-networks
12
+ - surrogate-modeling
13
+ pretty_name: Nesting Tasks Dataset for 2D Nesting Efficiency Estimation
14
+ dataset_info:
15
+ splits:
16
+ - name: train
17
+ num_examples: 100000
18
+ ---
19
+
20
+ # Nesting Tasks Dataset for 2D Nesting Efficiency Estimation
21
+
22
+ This is the official Hugging Face Hub version of the **2D Nesting Tasks Dataset** originally published on Zenodo ([DOI: 10.5281/zenodo.7030786](https://doi.org/10.5281/zenodo.7030786)), in 2022, during the my PhD research.
23
+
24
+ ## ๐Ÿ‘ฅ Authors & Affiliations
25
+
26
+ * **Corentin Lallier** (University of Bordeaux / @ Lectra) โ€” [๐ŸŽ“ Google Scholar](https://scholar.google.com/citations?user=73Tg-wkAAAAJ) | [๐Ÿ’ผ LinkedIn](https://www.linkedin.com/in/corentin-lallier/) | [๐Ÿ’ป GitHub](https://github.com/clallier) | [๐Ÿ†” ORCID](https://orcid.org/0000-0003-0518-8308)
27
+ * **Laurent Vรฉzard** (Data Science Manager @ Lectra) โ€” [๐ŸŽ“ Google Scholar](https://scholar.google.com/citations?hl=fr&user=gQv0TgMAAAAJ) | [๐Ÿ’ผ LinkedIn](https://www.linkedin.com/in/laurent-v%C3%A9zard-36822280/)
28
+ * **Bruno Pinaud** (Associate Professor @ University of Bordeaux / LaBRI) โ€” [๐Ÿซ LaBRI Page](http://www.labri.fr/~bpinaud/) | [๐Ÿ†” ORCID](https://orcid.org/0000-0003-4814-3273)
29
+ * **Guillaume Blin** (Professor @ University of Bordeaux / LaBRI) โ€” [๐Ÿซ LaBRI Page](http://www.labri.fr/~gblin/) | [๐Ÿ†” ORCID](https://orcid.org/0000-0002-0708-0838)
30
+
31
+ ---
32
+
33
+ This dataset is designed for training **machine learning surrogate models** (such as Graph Neural Networks) to estimate 2D irregular nesting efficiency (material utilization) without running computationally expensive operations research packing heuristics.
34
+
35
+ ---
36
+
37
+ ## ๐Ÿ“‚ Dataset Summary
38
+
39
+ 2D irregular cutting and packing (nesting) is a critical optimization problem in industries like textiles, apparel, and sheet-metal manufacturing. Traditionally, calculating the layout and material utilization of a set of irregular polygons requires running complex nesting heuristics, which can take seconds to minutes per run.
40
+
41
+ This dataset provides **100,000 unique nesting tasks** containing high-level task descriptions, irregular polygon shapes, constraints, and target nesting efficiencies. This enables the training of neural networks to predict material utilization instantly, facilitating rapid layout evaluations.
42
+
43
+ ---
44
+
45
+ ## ๐Ÿงฌ Data Schema & Description
46
+
47
+ The dataset is divided into four modern, secure, and highly optimized **Apache Parquet** files:
48
+
49
+ ### 1. `tasks.parquet` (Nesting high-level descriptors)
50
+ Contains global metrics and metadata for each nesting task.
51
+
52
+ | Column | Type | Description |
53
+ | :--- | :--- | :--- |
54
+ | `efficiency` | `float` | **The target label to predict.** Given in percentage (`%`). |
55
+ | `duration` | `integer` | Nesting algorithm convergence time in seconds (`s`). |
56
+ | `sheet_width` | `integer` | Width of the nesting area (unit: $m^{-4}$). |
57
+ | `sheet_length`| `integer` | Length of the nesting area (unit: $m^{-4}$). |
58
+ | `sheet_type` | `integer` | Specific nesting classification category. |
59
+ | `tasks_index` | `integer` | **Join key** connecting tables across files. |
60
+ | `is_train` / `is_val` / `is_test` | `boolean` | Masks indicating standard partitions for training, validation, and testing. |
61
+
62
+ ---
63
+
64
+ ### 2. `parts.parquet` (Description of parts to be nested)
65
+ Describes the specific instances of parts allocated to each nesting task.
66
+
67
+ | Column | Type | Description |
68
+ | :--- | :--- | :--- |
69
+ | `tasks_index` | `integer` | Reference to `tasks_index` in the `tasks` file. |
70
+ | `parts_id` | `integer` | Unique identifier for the part within its specific nesting task. |
71
+ | `shape_hash` | `integer` | Hash of the part's shape, serving as the **join key** to the `shapes` file. |
72
+
73
+ ---
74
+
75
+ ### 3. `shapes.parquet` (Coordinate shapes of irregular polygons)
76
+ Detailed geometry coordinate boundaries for all irregular parts.
77
+
78
+ | Column | Type | Description |
79
+ | :--- | :--- | :--- |
80
+ | `shape_hash` | `integer` | Unique hash identifier of the shape geometry. |
81
+ | `raw` | `list of integers` | Alternating sequence of $(x, y)$ coordinates defining the shape outline. |
82
+ | `sizes` | `list of integers` | Vertex sizes of any sub-shapes or inner boundaries. |
83
+
84
+ ---
85
+
86
+ ### 4. `constraints.parquet` (Spacing, rotation, and alignment parameters)
87
+ Geometric spacing boundaries and physical placement constraints.
88
+
89
+ | Column | Type | Description |
90
+ | :--- | :--- | :--- |
91
+ | `type` | `string` | Specific constraint category type identifier. |
92
+ | `tasks_index` | `integer` | Reference to the nesting task `tasks_index`. |
93
+ | `parts_1`, `parts_2` | `list of integers` | Part IDs involved in the constraint. |
94
+ | `p1_x, p1_y / p2_x, p2_y` | `list of floats` | Spacing anchors and offset coordinates on each part. |
95
+ | `r1_start, r1_end, r1_flip_x`| `list of floats` | Allowed rotation range and flip settings. |
96
+ | `y_min, y_max` | `list of floats` | Allowed positioning range on the $y$-axis. |
97
+
98
+ ---
99
+
100
+ ## ๐Ÿš€ How to Load and Explore the Dataset
101
+
102
+ Since the dataset is stored in standard Apache Parquet format, loading takes a single line of python code:
103
+
104
+ ```python
105
+ import pandas as pd
106
+
107
+ # Load the high-level nesting tasks and labels
108
+ tasks_df = pd.read_parquet('tasks.parquet')
109
+
110
+ # Load corresponding geometric parts
111
+ parts_df = pd.read_parquet('parts.parquet')
112
+
113
+ # Load irregular polygon shape definitions
114
+ shapes_df = pd.read_parquet('shapes.parquet')
115
+
116
+ # Load spacing and alignment constraints
117
+ constraints_df = pd.read_parquet('constraints.parquet')
118
+
119
+ # Filter splits using the pre-defined boolean masks in tasks.parquet
120
+ train_df = tasks_df[tasks_df['is_train']]
121
+ val_df = tasks_df[tasks_df['is_val']]
122
+ test_df = tasks_df[tasks_df['is_test']]
123
+
124
+ print(f"Loaded {len(tasks_df)} irregular nesting tasks:")
125
+ print(f" ๐ŸŸข Train instances : {len(train_df)}")
126
+ print(f" ๐ŸŸก Validation instances : {len(val_df)}")
127
+ print(f" ๐Ÿ”ด Test instances : {len(test_df)}")
128
+ ```
129
+
130
+ ---
131
+
132
+ ## ๐Ÿ› ๏ธ Handling Missing Values (Nulls)
133
+
134
+ In the binary Apache Parquet format, missing optional parameters (such as unassigned `x_offset` or `y_min` values in `constraints.parquet`) are stored natively as **`NULL`** slots using Parquet's definition levels.
135
+
136
+ Different programming languages and frameworks load these binary `NULL`s into their own native type-safe representations:
137
+
138
+ * **Python (Pandas):**
139
+ * Native numerical columns (like `x_offset` of type `float64`) represent missing values as **`NaN`** (float representation).
140
+ * Object or list columns (like `y_min` of type `object`) represent missing values as **`None`**.
141
+ * *Tip:* You can check for both formats simultaneously using a single call to `df.isna()` or `df.isnull()`.
142
+ * **Rust (Polars / Arrow):**
143
+ * Parsed directly into native, type-safe optional wrappers: **`Option<f64>`** for float parameters and **`Option<Vec<f64>>`** for geometric coordinate lists.
144
+ * **C++ (Arrow):**
145
+ * Represented as null slots in the Arrow array validity bitmap (`IsValid(index) == false`).
146
+
147
+
148
+ ---
149
+
150
+ ## ๐Ÿ“œ Citation & Credits
151
+
152
+ If you use this dataset in your research or industrial applications, please cite the original Zenodo record:
153
+
154
+ ```bibtex
155
+ @dataset{lallier2022nesting,
156
+ author = {Lallier, Corentin and V{\'e}zard, Laurent and Pinaud, Bruno and Blin, Guillaume},
157
+ title = {Nesting tasks dataset for 2d-nesting efficiency estimation},
158
+ month = aug,
159
+ year = 2022,
160
+ publisher = {Zenodo},
161
+ version = {1.1.0},
162
+ doi = {10.5281/zenodo.7030786},
163
+ url = {https://doi.org/10.5281/zenodo.7030786}
164
+ }
165
+ ```
constraints.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:35147f906ebbcf613f6b3f96ccf688659f68ea2422236768199f2100a8bb1875
3
+ size 7580727
download_dataset.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # dependencies = [
3
+ # "pandas",
4
+ # "pyarrow",
5
+ # "hf",
6
+ # ]
7
+ # ///
8
+
9
+ """Downloader script to fetch the Nesting Tasks Dataset from Zenodo."""
10
+
11
+ import os
12
+ import urllib.request
13
+ import time
14
+
15
+
16
+ def download_file(url: str, dest_path: str) -> None:
17
+ """Downloads a file with clean progress printouts.
18
+
19
+ Args:
20
+ url (str): The direct download URL.
21
+ dest_path (str): File destination path.
22
+ """
23
+ print(f"๐Ÿ“ฅ Downloading {os.path.basename(dest_path)}...")
24
+ start_time = time.time()
25
+
26
+ def reporthook(count, block_size, total_size):
27
+ if total_size <= 0:
28
+ return
29
+ current_progress = count * block_size
30
+ percent = min(100, int(current_progress * 100 / total_size))
31
+ # Keep progress line on same terminal line
32
+ print(
33
+ f"\r [{'=' * (percent // 5)}{' ' * (20 - percent // 5)}] {percent}% ({current_progress / (1024 * 1024):.1f}MB / {total_size / (1024 * 1024):.1f}MB)",
34
+ end="",
35
+ flush=True,
36
+ )
37
+
38
+ urllib.request.urlretrieve(url, dest_path, reporthook) # nosec B310
39
+ duration = time.time() - start_time
40
+ print(f"\n โœ… Completed in {duration:.1f}s!\n")
41
+
42
+
43
+ def convert_to_parquet() -> None:
44
+ """Loads gzipped pickles with pandas and saves them as modern Parquet files.
45
+
46
+ Cleans up the raw .gz files afterwards to keep the repository secure and light.
47
+ """
48
+ import pandas as pd
49
+
50
+ files = ["tasks", "parts", "constraints", "shapes"]
51
+ print("============================================================")
52
+ print("๐Ÿ”„ Converting Pickle splits to Parquet format...")
53
+ print("============================================================")
54
+
55
+ for name in files:
56
+ pickle_file = f"{name}.gz"
57
+ parquet_file = f"{name}.parquet"
58
+
59
+ if not os.path.exists(pickle_file):
60
+ continue
61
+
62
+ print(f"โšก Processing '{pickle_file}' -> '{parquet_file}'...")
63
+ try:
64
+ # 1. Read pickled dataframe
65
+ df = pd.read_pickle(pickle_file)
66
+
67
+ # 2. Write to Parquet (removing pandas index to keep schema clean)
68
+ df.to_parquet(parquet_file, index=False)
69
+ print(f" โœ… Saved {parquet_file}")
70
+
71
+ # 3. Clean up the insecure raw pickle file
72
+ os.remove(pickle_file)
73
+ print(f" ๐Ÿ—‘๏ธ Removed raw {pickle_file}")
74
+ except Exception as err:
75
+ print(f" โŒ Failed to convert {pickle_file}: {err}")
76
+ return
77
+ print()
78
+
79
+
80
+ def main() -> None:
81
+ """Orchestrates the downloading of the Zenodo dataset files."""
82
+ print("============================================================")
83
+ print("๐Ÿ“ฆ Zenodo Nesting Tasks Dataset Downloader")
84
+ print("============================================================")
85
+
86
+ # 1. Zenodo records API endpoints for version 1.1 of Lallier et al. (2022)
87
+ files_to_download = {
88
+ "tasks.gz": "https://zenodo.org/api/records/7030786/files/tasks.gz/content",
89
+ "parts.gz": "https://zenodo.org/api/records/7030786/files/parts.gz/content",
90
+ "constraints.gz": "https://zenodo.org/api/records/7030786/files/constraints.gz/content",
91
+ "shapes.gz": "https://zenodo.org/api/records/7030786/files/shapes.gz/content",
92
+ }
93
+
94
+ # 2. Iterate and download each file directly into workspace
95
+ for filename, url in files_to_download.items():
96
+ # Check if either the converted parquet or the raw .gz file already exists
97
+ parquet_name = filename.replace(".gz", ".parquet")
98
+ if os.path.exists(parquet_name):
99
+ print(
100
+ f"โ„น๏ธ File '{parquet_name}' already exists locally (converted). Skipping download.\n"
101
+ )
102
+ elif os.path.exists(filename):
103
+ print(
104
+ f"โ„น๏ธ File '{filename}' already exists locally (raw .gz). Skipping download.\n"
105
+ )
106
+ else:
107
+ try:
108
+ download_file(url, filename)
109
+ except Exception as err:
110
+ print(f"โŒ Failed to download {filename}: {err}")
111
+ return
112
+
113
+ # 3. Perform automatic conversion and cleanup
114
+ convert_to_parquet()
115
+
116
+ # 4. Validate and pretty-print heads of all parquet files
117
+ print_dataset_head()
118
+
119
+ print("============================================================")
120
+ print("๐ŸŽ‰ All dataset splits converted to Parquet successfully!")
121
+ print("============================================================")
122
+ print("๐Ÿ’ก Next Step: To push this dataset to your Hugging Face profile, run:")
123
+ print(" $ uv run hf upload clallier/nesting-tasks-2d . --repo-type=dataset")
124
+ print("============================================================")
125
+
126
+
127
+ def print_dataset_head() -> None:
128
+ """Loads and pretty-prints the first 10 rows of all Parquet files to verify conversion."""
129
+ import pandas as pd
130
+
131
+ # Configure pandas to show all columns without wrapping or ellipsis
132
+ pd.set_option("display.max_columns", None)
133
+ pd.set_option("display.width", 1000)
134
+
135
+ files = ["tasks", "parts", "constraints", "shapes"]
136
+ print("============================================================")
137
+ print("๐Ÿ”ฌ Verifying Parquet Schemas (First 10 rows of each split)")
138
+ print("============================================================")
139
+
140
+ for name in files:
141
+ parquet_file = f"{name}.parquet"
142
+ if not os.path.exists(parquet_file):
143
+ print(f"โš ๏ธ Warning: '{parquet_file}' not found for validation.\n")
144
+ continue
145
+
146
+ print(f"\n๐Ÿ“„ Split: {parquet_file}")
147
+ print("------------------------------------------------------------")
148
+ try:
149
+ df = pd.read_parquet(parquet_file)
150
+ print(df.head(10))
151
+ except Exception as err:
152
+ print(f"โŒ Failed to read {parquet_file}: {err}")
153
+ print("------------------------------------------------------------")
154
+ print()
155
+
156
+
157
+ if __name__ == "__main__":
158
+ main()
parts.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:131ec25d1f02100c05ad92282f1c76b058bc4d00ad05686e6d5510ce06b22017
3
+ size 16956526
shapes.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf09a0d2c815ff2fba814e309c33649bc909210c260dcf8c51650cf2afb0bf74
3
+ size 141312398
tasks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:610d13b456f6353113ac39c28499ea2000b84c03995f8ae126256e96c8aca718
3
+ size 1891739