in reply to Knapsack problem

What was wrong with the suggestions given when you asked this Nesting 2 and help with nesting? This problem is NP-complete, so you will probably not find a better solution than trying every possible combination. Is enumerating all combinations the part you're having trouble with?

Replies are listed 'Best First'.
Re: (2) Knapsack problem
by stu96art (Scribe) on Dec 08, 2003 at 20:00 UTC
    I apologize, but I thought that I was trying to simplify my problem, but all I was really doing was asking it again. I am looking to have either a vertical or horizontal line from one edge to the other, but I do not know how to create the loop(s) and how to determine which is the "best" to create the vertical or horizontal line. Could someone help me by maybe pointing me to some code that will help me set up these loops. I would like to start with the largest x or y, and then on the next iteration, use the second largest x or y. I do not know how to accomplish this.

      What's this business of a horizontal or vertical line dividing the area, by the way? That's just confusing the issue. Can I solve the problem for you by saying "put that line one millimetre from the edge and then solve the knapsack thing with your MaxX x MaxY area one millimetre smaller than before?"

      The practical side of this knapsack business, by the way, is that you can spend enormous amounts of time finding better and better solutions, but they'll only be slightly better. If you find a solution that's about 80% better than random, then stop looking and go with it. People who really understand math, please correct me if I'm wrong, but there's no point continuing trying to find a slightly-more-perfect solution, unless you're chopping up solid gold, I guess.



      ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
        I am working with glass, and so, I need to have at least one cut that goes through the entire piece. It can be either vertical or horizontal. This is an important piece and why I am having an issue with it.