matlaboptimizationgeometrycomputational-geometrygeometry-surface

Rectangular Nesting - Convergence to optimal solution using Simulated Annealing


I'm using Simulated Annealing for Rectangular Nesting problem. I'm able to get good results, but the solution i got is DISCRETE. Even global optimum is not always obtained.

Problem Description:

Objective - To minimize the length of the infinite sheet (Width is constant) by changing the order in which parts are placed.

Problem i Face:

The output Results i get are DISCRETE(only 15 possible utilization %) instead of ANALOG (as there is 11!*2^11 possible solution -> We expect the results to be analog)

Path traveled by SA - MATLAB output enter image description here

Results I expect Generated for a different problem using the same SA code i used for this problem enter image description here

Reason i get a DISCRETE output can be seen from following image. There could be many possibility of sequences giving same length 55.

Efficiency calculated from Maximum Length enter image description here

I presume i could solve the problem if i change the way of calculating utilization% like this.

Efficiency calculated from Boundary cut Length enter image description here

Even though i figured out how to solve the problem, i don't know how to find the Boundary Cut AREA in order to find the efficiency. Anybody has a way to find the area under the red line? I need to avoid using Image Processing Toolbox

FYI: Rectangles are stored as x,y distance of the bottom-left position from Origin of each rectangle. i have the corresponding length, breadth values in another variable.


Solution

  • I figured it out, how to find Boundary-Cut Area without using Image Processing Toolbox. I would like to post this as an answer for others having similar problem. Better solutions are also welcome.

    Logic for placing of parts:

    Place the parts from Left-> Right, till the Right most end , then go to Left end and place the next part over the previous part, move Right and so on.

    Solution for finding Boundary Cut Area:

    I just create a Single Dimension Matrix whose length equal to the width of the sheet (In the above screen shot -> 200) By Default, i set their values to zero.

    boundaryLength = zeros(sheetWidth+1,1);   
    % sheetWidth+1 because matlab starts from the index 1 while my range is from 0-200
    

    Each time i place a part, i assign the range of values i.e from its xDist of the bottom left position till xDist of the bottom right position to yDist value of the top line.

    for i = 1:numberOfParts
        boundaryLength(xDist(i)+1:xDist(i)+width(Index(i))) = yDist(i)+ height(Index(i));
    end
    
    % Index is the order in which i place the part. 
    % Here in the above screenshot, my index value is [8, 2, 4, 11, 7, 5, 6, 10, 1, 9, 3]
    

    Now i have found out the maximum occupied length of every pixel throughout the sheet width. To find the area, i need to find the sum of the vector boundaryLength

    boundaryArea = sum(boundaryLength);
    

    Boundary-Cut Utilization for an example: enter image description here