http://www.perlmonks.org?node_id=321827


in reply to Help with attempting to solve cutting stock problem (knapsack)

Although Abigail is correct (NP complete problems like this one have no efficient solutions for large sets of data), you still can create software which runs it fast.

At least there are two ways to improve it:

  1. implement and algorithm which is smarter than branch-and-bound. A lot of work, requires sufficient education in programming techniques.
  2. exchange required computation force with memory consumption. Use Memoize (by MJ Dominous) on KNAP and you'll see the the speed become linear and memory consumption grow exponentially... In some cases, you may be able to buy a sufficient amount of memory to replace unrealistic time to wait. (for instance, for stock calculations, minutes may already be too long to wait)