Looking for a unicorn today because my google-foo ...
# cfml-general
m
Looking for a unicorn today because my google-foo seems to be off today. Has anyone seen a cold fusion routine/cfc/module, paid or free that does virtual packing - aka a solution for the dreaded "Bin Packing Algorithm". Frankly my "fit in available volume and then check available dims" is just too intensive for lots of small packages in a big box.
t
Watching. 🙂
e
well.. send $$ my way as my laptop is toast. that being said, something like this: <cfset itemsDirectory = "C:\sample\items"> <cfdirectory directory="#itemsDirectory#" name="itemFiles"> <cfset items = []> <cfloop query="itemFiles"> <cfif itemFiles.name contains ".txt"> <cffile action="read" file="#itemsDirectory#\#itemFiles.name#" variable="fileContents"> <cfset ArrayAppend(items, fileContents)> </cfif> </cfloop> <cfset binSize = 10> <cfset bins = []> <cfloop index="i" from="1" to="#ArrayLen(items)#"> <cfset item = items[i]> <cfset foundBin = false> <cfloop index="j" from="1" to="#ArrayLen(bins)#"> <cfif bins[j] + item <= binSize> <cfset bins[j] = bins[j] + item> <cfset foundBin = true> <cfbreak> </cfif> </cfloop> <cfif not foundBin> <cfset ArrayAppend(bins, item)> </cfif> </cfloop> <cfoutput>Number of bins used: #ArrayLen(bins)#</cfoutput>
m
don't know why I am just seeing this, but... This doesn't take into account if they actually fit, this is just a count.
Even the Google Team's example only packs by weight, not by volume and dims.
e
You could take packages X, z, y and store the dimensions so you could compare volume. Think of it as an introduction to matrices and NURBS 🙂
m
Yeah, I already do something like that, but was hoping to find other examples/approaches to help fine-tune what I had or maybe rethink how I am doing it, or a suitable replacement if it was cost effective.
e
unless your products are uniformly generic, such as tiny cubes or you have a sensor package you kind of stuck doing lookups How are you warehousing your stuff, LRB or serial?
m
They are not, in any way shape or form, but we have dims for every item. I am pretty much brute forcing and it works most of the time, but when it misses, it tends to miss big. Not really doing warehouse management, it is inventory management by sku
The big miss is when smaller items are mixed with bigger items. End up with too many "packages". When something like this is manually packed, it is easy to distribute the smaller items into the packages with bigger items, not so when it is virtual; at least with what I have written so far. And since shipping costs are estimated from the virtual packaging, these big misses have the potential to lose a sale.
e
You will need to write some kind of logic for your warehousing picking, to force Items (Big) and items small (which may fit into item big) when you order item big, to shove it all into box.
m
Exactly - Which is why I was looking for other solutions to see how other folks had "solved" it.. Fresh ideas never hurt. I'm not really asking anyone to solve it for me, just some pointers to papers, blog posts or code (or a suitable replacement).