This is a rebar cutting stock optimization system that solves the cutting stock problem for steel reinforcement bars using depth-first search algorithms and integer linear programming.
# Run the Streamlit web interface
streamlit run cutting_optimizer_streamlit.py
# Run command-line optimizer
python cutting_optimizer_ver2.py
The system requires these Python packages:
streamlit
: Web interfacepulp
: Integer linear programming solveropenpyxl
: Excel file processingpandas
: Data processing
Modify the diameter
variable in the main functions (typically 'D10', 'D13', 'D16', 'D19', 'D22').
-
Optimizers:
cutting_optimizer_streamlit.py
: Main web interface with integrated optimizationcutting_optimizer_ver2.py
: Command-line version with Excel integration
-
Data Processing:
read_xlsx.py
: Excel parser for cutting requirements with multi-sheet supportresult_sheet.py
: Results output to Excel format
- Depth-First Search (DFS): Generates all valid cutting combinations within material constraints using recursive exploration
- Integer Linear Programming (ILP): Optimizes cutting patterns using PuLP library to minimize waste
The system supports five standard rebar diameters with predefined stock lengths:
BASE_PATTERNS = {
'D10': [4000, 4500, 5500, 6000],
'D13': [3000, 4000, 4500, 5500, 6000, 7500],
'D16': [4000, 4500, 5500, 6000, 7000],
'D19': [3500, 4000, 4500, 5500, 6000],
'D22': [4000, 4500, 5500, 6000]
}
- Input: Excel files with cutting requirements (
required_cuts.xlsx
) - Processing: Extract rebar diameter data using
find_cell_position()
andget_diameter_column_index()
- Combination Generation: Use DFS to find valid cutting patterns within stock constraints
- Optimization: Solve ILP problem with 120-second timeout to minimize waste
- Output: Display cutting instructions with yield rates and material usage statistics
- Input files: Excel files with "鉄筋径" (rebar diameter) headers
- Result files: Located in
result/
directory with processing results and comparisons
- Combination generation is computationally expensive for large problems
- Default optimization timeout: 120 seconds
- Results include processing time and yield rate calculations
- DFS uses pruning to avoid exploring invalid branches when current_sum > max_sum