Skip to content

Commit 7fce8dc

Browse files
committed
v0.3.0: Move g/F computation to C, eliminate Fd decision storage, overhaul visualization
C extension (_solver.c): - Extract g-table and F-table computation from Python into C (fill_g_core, fill_F_core), giving ~28% speedup on these phases - Fix critical int32 overflow in 4D stride computation: for sheets larger than ~180x180, the product (H0+1)*(W0+1)*(H0+1) exceeds INT_MAX. All strides now use int64_t - Add defect access macros (DEF_X, DEF_Y, etc.) replacing raw defects[d*6+0] indexing - Streamline defect-aligned cut loop with early x/y overlap skip Fd memory reduction (3x): Previously, three 4D arrays were stored for defected rectangles: Fd_values (int32) — optimal value at each (w,h,x,y) Fd_type (int32) — which decision was taken (cut_x, cut_y, fill, ...) Fd_param (int32) — decision parameter (cut position or item index) Total: 12 bytes per cell. Now only Fd_values (4 bytes per cell) is stored. The decision type and parameter are no longer needed at solve time — they are re-derived during reconstruction by checking which candidate cut reproduces the stored optimal value. This is cheap (only visited cells are reconstructed) and eliminates 2/3 of the Fd memory. For a 200x100 sheet: 201^2 * 101^2 ≈ 412M cells Before: 412M * 12 bytes = 4.7 GB After: 412M * 4 bytes = 1.6 GB Python solver (dp_solver.py): - All three DP phases (g, F, Fd) now call C with Python fallbacks - Fd arrays allocated lazily (only when the sheet has defects) - F_type array changed from int32 to int8 (decision codes fit in 3 bits) - Reconstruction rewritten to work without stored Fd decisions: re-checks candidate cuts against target value to find the optimal split Visualization (visualize.py): - Replace TABLEAU_COLORS with a 20-color vibrant palette for better contrast - Depth-scaling cut line widths instead of uniform 1.5pt - Smart tick label spacing with sparse labeling to prevent overlap - Figure width increased from 8 to 12 inches - Dual output: SVG (vector) + PNG (raster)
2 parents 5bd6c72 + a68ced8 commit 7fce8dc

4 files changed

Lines changed: 582 additions & 385 deletions

File tree

.vscode/c_cpp_properties.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"name": "Linux",
55
"includePath": [
66
"${workspaceFolder}/**",
7-
"/usr/include/python3.12",
8-
"/home/nicola/guillotine-cutter/.venv/lib/python3.12/site-packages/numpy/core/include"
7+
"/usr/include/python3.12"
98
],
109
"defines": [],
11-
"compilerPath": "/usr/bin/gcc",
12-
"cStandard": "c11",
13-
"intelliSenseMode": "linux-gcc-x64"
10+
"compilerPath": "/usr/bin/clang",
11+
"cStandard": "c17",
12+
"cppStandard": "c++17",
13+
"intelliSenseMode": "linux-clang-x64"
1414
}
1515
],
1616
"version": 4
17-
}
17+
}

0 commit comments

Comments
 (0)