ChatGTP is being completely dense about this real-life carpentry puzzle

So I’m asking chatGPT help to expedite solving this simple carpentry problem:

I can use any number of 150x150 panels to cut into the pieces I need.
I want to use the least amount of panels, since they cost money, but I need all the pieces to be rectangular and in the precise measures I need.

So this is sort of a geometrical puzzle.

The pieces I need:

16 pieces 80x20
16 pieces 70x20
8 pieces 35x50
8 pieces 45x45
6 pieces 85x20

How can I efficiently cut the 150x150 panels to fit in these measures with the least amount of refuse?

Feel free to generate diagrams to illustrate your solution.

The answers so far have been nonsensical or plain wrong.

I don’t know if correcting the prompt somehow would help, or whether the problem requires a kind of visualization chatGPT is incapable of.

Some example answers:

Here’s how to approach the problem:

Step 1: Total Area Calculation

Let’s first calculate the total area needed for all the pieces:

  • 16×80×20=25,600 sq. units16 \times 80 \times 20 = 25,600 , \text{sq. units}16×80×20=25,600sq. units
  • 16×70×20=22,400 sq. units16 \times 70 \times 20 = 22,400 , \text{sq. units}16×70×20=22,400sq. units
  • 8×35×50=14,000 sq. units8 \times 35 \times 50 = 14,000 , \text{sq. units}8×35×50=14,000sq. units
  • 8×45×45=16,200 sq. units8 \times 45 \times 45 = 16,200 , \text{sq. units}8×45×45=16,200sq. units
  • 6×85×20=10,200 sq. units6 \times 85 \times 20 = 10,200 , \text{sq. units}6×85×20=10,200sq. units

Total area of pieces needed:
25,600+22,400+14,000+16,200+10,200=88,400 sq. units25,600 + 22,400 + 14,000 + 16,200 + 10,200 = 88,400 , \text{sq. units}25,600+22,400+14,000+16,200+10,200=88,400sq. units

Each 150x150 panel has an area of:
150×150=22,500 sq. units150 \times 150 = 22,500 , \text{sq. units}150×150=22,500sq. units

Now, divide the total area of pieces by the area of one panel to estimate the number of panels:
88,40022,500≈3.93\frac{88,400}{22,500} \approx 3.9322,50088,400​≈3.93

You will need 4 panels, but we must optimize the arrangement of pieces within each panel to minimize waste.

This logic is of course completely wrong. It is calculating the total area (what for?) and coming up with an unrealistic number of panels based on it.

Needless to say this “diagram” is pure hallucination…

After trying to explain in other words what I actually need, I still get plenty of errors, such as these:

Got it! Let’s walk through this step by step, cutting pieces from each 150x150 panel until we get all the pieces you need. We’ll aim to use as few panels as possible and keep waste minimal. Each panel will be cut into complete rectangles (no split pieces).

Step 1: First Panel

The largest pieces are a good place to start, as they limit the flexibility of future cuts. Start with the 85x20 pieces (6 pieces in total).

  • From the first panel:
    • Cut 5 pieces of 85x20 (since 150 ÷ 85 = 1 full piece width-wise).
    • You’re left with a 150x50 space.
    • In the 150x50 space, you can fit 2 pieces of 35x50 (150 ÷ 50 = 3 widths of 50).

First panel summary:

  • 5 pieces of 85x20
  • 2 pieces of 35x50
  • Some remaining refuse (narrow strips).

The sections left are actually a 65x150 piece, and a 80x35 piece. No 150x50 piece!!

Further efforts to explain the errors and suggesting how to operate instead, produce identical faulty results.

It seems chatGPT cannot do this right?

This is GPT-4o mind you.

Language models do not truly understand the real world; they simply act as if they do when processing language.

They also do not have a sense of numbers or areas being surprisingly large.

Concepts like direction or area in the real world are only secondary knowledge they acquire through language.

In this case, the model might better understand if you explain it as “a kind of game where the goal is to divide the panels most efficiently.”

Alternatively, presenting a different problem with the same rules but different numbers and seeing how the model responds might work.

It can sometimes be surprising that ChatGPT, despite knowing so much, can’t solve problems like this.

1 Like

I was curious what o1-mini would answer.

Optimizing Panel Cuts to Minimize Waste AI

To efficiently cut the required pieces from 150x150 panels with minimal waste, we need to strategically arrange the pieces on each panel. Here’s a step-by-step approach to optimize the layout:

1. Calculate Total Area Needed

First, let’s determine the total area required for all pieces:

  • 80x20 pieces: 16 pieces × 1,600 = 25,600
  • 70x20 pieces: 16 pieces × 1,400 = 22,400
  • 35x50 pieces: 8 pieces × 1,750 = 14,000
  • 45x45 pieces: 8 pieces × 2,025 = 16,200
  • 85x20 pieces: 6 pieces × 1,700 = 10,200

Total Area Required: 25,600 + 22,400 + 14,000 + 16,200 + 10,200 = 88,400 square units

Each 150x150 panel has an area of 22,500 square units. Ideally, you’d need:

88,400 / 22,500 ≈ 3.93 panels

Since you can’t use a fraction of a panel, 4 panels are necessary. However, precise arrangement is crucial to ensure all pieces fit with minimal waste.

2. Suggested Layout for Each Panel

Here’s a proposed layout distribution across 4 panels:


Panel 1:

  • 85x20 Pieces: 6 pieces
    • Arrangement: Place all 6 pieces vertically along one side.
    • Space Used: 6 × 20 (width) = 120 width, 85 height.
  • 35x50 Pieces: 2 pieces
    • Arrangement: Place horizontally beside the 85x20 pieces.
    • Space Used: 2 × 35 (width) = 70 width, 50 height.
  • Remaining Space: Utilize leftover space for small cuts or alignment.

Panel 2:

  • 80x20 Pieces: 16 pieces
    • Arrangement:
      • Place 8 pieces horizontally on the top (8 × 80 = 640 width; since the panel is 150 wide, arrange them in multiple rows).
      • Place the remaining 8 pieces vertically along the side.
    • Space Used: Optimized to fit within the panel dimensions.
  • 45x45 Pieces: 2 pieces
    • Arrangement: Place in the remaining spaces.
  • Remaining Space: Minimal waste; ensure pieces fit snugly.

Panel 3:

  • 70x20 Pieces: 16 pieces
    • Arrangement:
      • Place 8 pieces horizontally across the top (8 × 70 = 560 width; arrange in multiple rows).
      • Place the remaining 8 pieces vertically along the side.
    • Space Used: Optimized layout to fit within 150x150 dimensions.
  • 35x50 Pieces: 2 pieces
    • Arrangement: Fit into leftover spaces.
  • Remaining Space: Utilize for alignment or minor adjustments.

Panel 4:

  • 45x45 Pieces: 6 pieces
    • Arrangement:
      • Arrange in a grid (e.g., 3 rows × 2 columns).
      • Total space used: 90 (height) × 90 (width).
  • Remaining Space: Use for any leftover pieces or to adjust for precision cuts.

3. Tips for Optimization

  1. Use Cutting Software: For precise and efficient layouts, consider using specialized cutting optimization software like CutList Plus, MaxCut, or online tools like DeepNest. These tools can automatically generate layouts that minimize waste.

  2. Allow for Grain Direction: If the material has a grain (like wood), ensure all pieces respect the grain direction, which might impact how you can rotate pieces.

  3. Account for Kerf (Cutting Thickness): Remember to leave space for the width of the saw blade (kerf), typically around 1/8 inch, to ensure pieces remain precise.

  4. Batch Similar Sizes Together: Grouping similar-sized pieces can simplify the cutting process and reduce the number of panels needed.

  5. Double-Check Measurements: Before cutting, review the layout to ensure all pieces fit as planned and adjust as necessary to account for any discrepancies.

4. Potential Waste Management

Even with optimized layouts, some waste is inevitable. Aim to:

  • Recycle Offcuts: Use leftover pieces for smaller projects or reinforce parts.
  • Store Scraps for Future Use: Maintain a stock of scrap material for unexpected future needs.

Conclusion

By carefully planning the layout and possibly leveraging cutting optimization tools, you can efficiently use 4 panels to meet your requirements with minimal waste. Always verify each layout plan with precise measurements to ensure accuracy before executing the cuts.

But I wasn’t curious enough to check if the answer was right… sorry, worked last night.

It credibly imitates a correct answer, but it is wrong:

In a 150x150 panel you could only put 7 rows of 80 and 7 rows of 70 (7+8=15); even so there would never be space left for any 45x45 piece. You would only have a 10x150 piece left;
Similar errors are repeated in the rest of the answer.

verdict: hallucination.

1 Like

I think your first problem is, that you try to make it into “a real life scenario”. While AI will know a bit about carpentry, it will know infinitely more about math, so you should make it into a math problem.

Next thing is, that it is a “fuzzy” explanation, with an absolutely deterministic output. Basically what AI sucks at. This problem is a 100% math problem, and would definitely work much better simply by making an application that calculated it.

AI will know more about programming. It didn’t bite on my suggestion for heuristic simulated annealing with any substantial code output for efficiency, but will continue on the assumption provided to it that the AI will not be able to solve this alone.

o1-preview


1. Polynomial Time Approximation Algorithm with Bounded Ratio

The problem you’ve described is an instance of the Two-Dimensional Cutting Stock Problem, which is known to be NP-hard. However, there exists a polynomial-time approximation algorithm called the First-Fit Decreasing Height (FFDH) algorithm that can be applied to this problem. The FFDH algorithm has an approximation ratio of 1.7, meaning the solution it provides will use no more than 1.7 times the optimal number of panels.

FFDH Algorithm Steps:

  1. Sort Rectangles: Arrange all required pieces in decreasing order of their heights (keeping widths associated).
  2. Initialize Shelves: Start with a new panel and create horizontal shelves from top to bottom.
  3. Place Rectangles:
    • Place rectangles onto the current shelf from left to right until no more rectangles fit in terms of width.
    • If a rectangle doesn’t fit on the current shelf, start a new shelf below the current one.
    • The height of each shelf is determined by the tallest rectangle on that shelf.
  4. Manage Panels:
    • If the cumulative height of shelves exceeds the panel’s height, start packing in a new panel.

Application to Your Problem:

  • Rectangles Sorted by Height:

    Size (Width x Height) Quantity
    85 x 20 6
    80 x 20 16
    70 x 20 16
    35 x 50 8
    45 x 45 8
  • Packing Process:

    • Panel 1:
      • Shelf 1 (Height 85): Place 6 pieces of 85 x 20.
    • Panel 2:
      • Shelf 2 (Height 80): Place 7 pieces of 80 x 20.
    • Panel 3:
      • Shelf 3 (Height 80): Place remaining 9 pieces of 80 x 20 (7 on Shelf 3, 2 on Shelf 4).
      • Shelf 4 (Height 80): Place 2 pieces of 80 x 20 and 5 pieces of 70 x 20.
    • Panel 4:
      • Shelf 5 (Height 70): Place remaining 11 pieces of 70 x 20.
      • Shelf 6 (Height 70): Place 4 pieces of 70 x 20 and 2 pieces of 35 x 50.
    • Panel 5:
      • Shelf 7 (Height 50): Place 4 pieces of 35 x 50.
      • Shelf 8 (Height 50): Place 2 pieces of 35 x 50 and 1 piece of 45 x 45.
    • Panel 6:
      • Shelf 9 (Height 45): Place 3 pieces of 45 x 45.
      • Shelf 10 (Height 45): Place 3 pieces of 45 x 45.
    • Panel 7:
      • Shelf 11 (Height 45): Place remaining 1 piece of 45 x 45.
  • Result: Using the FFDH algorithm, all pieces can be cut from 7 panels, which is within the 1.7 approximation ratio of the optimal solution.

2. Heuristic Annealing Algorithmic Solution

While the FFDH algorithm provides a good approximation, further optimization can be achieved using heuristic methods like Simulated Annealing. This probabilistic technique searches for a global optimum by allowing occasional uphill moves (worse solutions) to escape local minima.

Simulated Annealing Steps:

  1. Initial Solution: Start with a feasible solution (e.g., the one provided by FFDH).
  2. Define Cost Function: The cost can be based on the number of panels used and total waste.
  3. Neighbor Solutions: Generate neighboring solutions by swapping pieces between shelves or rearranging the cutting patterns.
  4. Acceptance Criterion:
    • If the new solution has a lower cost, accept it.
    • If the new solution is worse, accept it with a probability that decreases over time (controlled by a “temperature” parameter).
  5. Cooling Schedule: Gradually decrease the temperature to reduce the acceptance of worse solutions over time.
  6. Termination: Stop when the system has sufficiently “cooled” or after a fixed number of iterations.

Benefits:

  • Flexibility: Can handle complex constraints and objective functions.
  • Optimization: Often finds better solutions than basic heuristics, potentially reducing the number of panels used.

3. Python Code for Performing the Calculation

Below is a Python implementation of the FFDH algorithm applied to your problem. This code models the panels, shelves, and pieces, and attempts to pack the pieces efficiently.

import math

# Define the dimensions of the panels
PANEL_WIDTH = 150
PANEL_HEIGHT = 150

# Define the pieces required
pieces = [
    {'width': 20, 'height': 85, 'quantity': 6},
    {'width': 20, 'height': 80, 'quantity': 16},
    {'width': 20, 'height': 70, 'quantity': 16},
    {'width': 35, 'height': 50, 'quantity': 8},
    {'width': 45, 'height': 45, 'quantity': 8}
]

# Expand the pieces into a list
rectangles = []
for piece in pieces:
    for _ in range(piece['quantity']):
        rectangles.append({'width': piece['width'], 'height': piece['height']})

# Sort rectangles by decreasing height
rectangles.sort(key=lambda x: x['height'], reverse=True)

# Function to pack rectangles using FFDH
def pack_rectangles(rectangles):
    panels = []
    current_panel = []
    current_shelf = {'height': 0, 'width_used': 0, 'rectangles': []}
    current_height = 0

    for rect in rectangles:
        # Check if rectangle fits in current shelf
        if (current_shelf['width_used'] + rect['width'] <= PANEL_WIDTH) and (rect['height'] <= current_shelf['height']):
            # Place rectangle in current shelf
            current_shelf['rectangles'].append(rect)
            current_shelf['width_used'] += rect['width']
        else:
            # Start a new shelf if rectangle height is less than panel height
            if rect['height'] <= PANEL_HEIGHT - current_height:
                # Finish current shelf and start a new one
                if current_shelf['rectangles']:
                    current_panel.append(current_shelf)
                    current_height += current_shelf['height']
                current_shelf = {'height': rect['height'], 'width_used': rect['width'], 'rectangles': [rect]}
            else:
                # Start a new panel
                if current_panel:
                    panels.append(current_panel)
                current_panel = []
                current_height = 0
                current_shelf = {'height': rect['height'], 'width_used': rect['width'], 'rectangles': [rect]}
        # Check if current panel is full
        if current_height + current_shelf['height'] > PANEL_HEIGHT:
            panels.append(current_panel)
            current_panel = []
            current_height = 0

    # Add the last shelf and panel
    if current_shelf['rectangles']:
        current_panel.append(current_shelf)
    if current_panel:
        panels.append(current_panel)

    return panels

# Pack the rectangles
panels = pack_rectangles(rectangles)

# Print the result
print(f"Total panels used: {len(panels)}\n")
for i, panel in enumerate(panels):
    print(f"Panel {i+1}:")
    panel_height = 0
    for shelf in panel:
        print(f"  Shelf (Height {shelf['height']}):")
        shelf_width = 0
        for rect in shelf['rectangles']:
            print(f"    Rectangle {rect['width']}x{rect['height']}")
            shelf_width += rect['width']
        print(f"    Shelf width used: {shelf_width}/{PANEL_WIDTH}")
        panel_height += shelf['height']
    print(f"  Panel height used: {panel_height}/{PANEL_HEIGHT}\n")

Explanation of the Code:

  • Data Preparation:
    • The required pieces are expanded into a list of rectangles.
    • Rectangles are sorted in decreasing order of height.
  • Packing Function (pack_rectangles):
    • Iterates over each rectangle and attempts to place it on the current shelf.
    • If it doesn’t fit, it tries to create a new shelf.
    • If the shelf doesn’t fit in the current panel, it starts a new panel.
  • Output:
    • Prints the total number of panels used.
    • Details each panel, shelf, and rectangles within.

Notes:

  • Assumptions:
    • Rectangles cannot be rotated.
    • All cuts are straight and from one side to the other (guillotine cuts).
  • Extensions:
    • The code can be extended with optimization heuristics like Simulated Annealing.
    • Additional constraints (e.g., kerf width, grain direction) can be incorporated.

Conclusion:

By applying the FFDH algorithm, we achieve a feasible solution within a known approximation ratio. For further optimization, heuristic methods like Simulated Annealing can be employed to potentially reduce the number of panels used and minimize waste.

Stellar answer : )

I could argue, that you still solved it by using math and logic, but then I would be a douche.

This of course is very impressive, although the resulting cuts from the script are quite wasteful, all extra sections are discarded and never reused, even if they are quite big.

For example a panel cut like this:

Shelf (Height 80):
Rectangle 20x80
Rectangle 20x80
Rectangle 20x80
Rectangle 20x80
Rectangle 20x80
Rectangle 20x80
Rectangle 20x80

is quite absurd… we have a width of 150, so an equal number of 20x70 shelves would fit perfectly within the same panel…

We have to admit this is very far from what a person would do, with a bit of intuition and trial-and-error, to efficiently use the panels.

But I’ll try to coach GPT into making some changes to that script. Going the programming way might be a good idea.

After many many tries, gpt seems stuck in a decadent loop in which it doesn’t seem able to improve its own script.

it can’t figure out how to use less than 7 panels to achieve the sections required, unless it commits some blatant error.

However, I know for a fact 5 panels are sufficient, as I have empirically measured it myself:

GPT cannot come up with this :point_up_2:

2 Likes

Computational combinatorics is an entire field, not a question for an AI…

17x17

Where can I download the book with the rules of what I can and cannot ask AI?

1 Like