Oh. Btw, there is a policy that big quantities in the bundles should be used first before the small ones. Hence, in my example, I primarily used the 25 and the 20's. ;)
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alex Rufon Sent: Wednesday, April 30, 2008 12:49 PM To: Programming forum Subject: [Jprogramming] distribution problem This last few days, I've been working on a small module that calculates the distribution of bundled material to make a set of garments. The first version that I finished today is just doing a straight forward distribution and not very optimized (just trying to get a prototype out the door). To illustrate, let's say that your bundles are: bundles=. 20 20 20 25 10 10 8 15 5 5 5 If the quantity of garments that need to be made from the bundle is 60. I just do a progressive sum on the bundles and get all the values up to the first qty greater than or equal to the garment quantity like so: bundles{.~>:{.I.60<:+/\ bundles 20 20 20 Unfortunately, this would become in-efficient as values as the bundle distribution varies, like in this example, the quantity is 96 bundles{.~>:{.I.96<:+/\bundles 20 20 20 25 10 10 What I am looking for is a way to find the "optimum" distribution for a garment quantity. Like for a garment quantity of 96, a good distribution could be +/ 25 20 20 20 5 8 98 Or a good enough result can be +/ 25 20 20 20 15 100 I do have some ideas on how to optimize but all of them would require a brute force solution one way or the other. So any suggestion are highly appreciated. :) Thanks. r/Alex ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
