Gerbmerge-Can someone please help me understand the algorithm behind it? - Page 1
Forum section: electronics / projects

author: djsb
author_rank: Super Contributor
timestamp: February 18, 2017, 05:45:10 pm
content: Is there anyone here who can help me to understand how the algorithm behind Gerbmerge works. I'm interested in the general top level black box overview of how several Gerber designs are sorted and arranged in a fixed area. I don't have any experience of python so can't really understand how any of the Gerbmerge python code works. Even the simplest of explanation would be a start as I would really like to understand how this works.Here is a fork of the official code by a contributor to this forumhttps://github.com/unwireddevices/gerbmergeand a post discussing this projecthttps://www.eevblog.com/forum/manufacture/gerbmerge-1-9-4-(a-command-line-tool-to-merge-multiple-rs-274x-gerber-files)/Can anyone help? Thanks.

author: awallin
author_rank: Frequent Contributor
timestamp: February 19, 2017, 08:43:22 am
content: Quote from: djsb on February 18, 2017, 05:45:10 pma quick look would suggest there are two automatic tiling algorithms:https://github.com/unwireddevices/gerbmerge/blob/master/gerbmerge/tilesearch1.pybrute force algorithm.I would guess this tries out different permutations and evaluates a score for each one, then select the best when you think you found a good enough one or you ran out of time.https://github.com/unwireddevices/gerbmerge/blob/master/gerbmerge/tilesearch2.pyrandom placement and evaluation.here instead of systematically going through permutations you pick at random. surprisingly there is theory that says that picking at random is actually quite efficient when the search space has enough dimensions (here that would be e.g. x,y-coordinates and rotation for each job).the tiling/nesting problem is 'hard' - for some nice computer science theoretical definition of 'hard' - so any of the usual (approximate) optimization approaches could be tried, e.g. genetic algorithms, simulated annealing, ant-colony/swarm, etc.googling for "nesting problem in computational geometry" gives a lot of hits... if you restrict input shapes to rectangles then there might be some clever algorithms that do quite well.

author: djsb
author_rank: Super Contributor
timestamp: February 19, 2017, 10:34:00 am
content: Thanks for your reply.So is this a 2d bin packing problem or some other algorithm? I had a read of thishttp://www.martinbroadhurst.com/bin-packing.htmland it made some sense but it involved adding additional "bins". I only have one fixed area (the PCB panel) that I need to fill with "elements" (the individual PCB Gerber layout) so only one bin is needed. Additional attempts need to be made in order to get the best result.I also came across thishttp://www.aaai.org/Papers/AAAI/2002/AAAI02-110.pdfand herehttp://www.sfu.ca/~gwa5/pdf/2007_02.pdfwhich mentions improving the utilisation of sheet materialsAlsohttp://crpit.com/confpapers/CRPITV65Nielsen.pdfandhttp://vmk.ugatu.ac.ru/c%26p/article/Imahori/FAST%20NEIGHBORHOOD(Imahori).pdfGood explanation here of the basic NFP (no fit polygon) concept and a possible way of arranging board outline layershttps://github.com/Jack000/SVGnestalthough none of these helps me to understand how Gerbmerge works.Suppose I'll just have to get stuck into learning python. I wonder if there is any code that can help me to explore these nesting algorithms graphically?