A friend of a friend used to work at NASA on how to pack the Space Shuttle, which is essentially the same problem... except that things need to be taken out in the correct order, through a small hatch, with a robot arm and in zero gravity.
This sounds like the kind of problem were I immediately decide that using some good ol' fashioned human rationale is the best way to proceed. Too many rules and conditions. Software is sometimes more difficult than its alternative.
TL;DR: Packing candy is rocket science.