Algorithm to pack any small boxes into a big box I have a container with a certain dimension. A number of small boxes that may be different in size is to be packed into the container. How to arrange the small boxes such that the container contains as many as possible?


No rotation is allowed.
The heavier boxes must not be on the top of the lighter ones.
Approximation is allowed.


I am looking for the algorithm so I can implement it in a software.
Your problem is called 3D Bin Packing and is indeed an NP problem. 

Looking those key words on Google will yield many articles about more or less complex approximation algorithms that can help you solve this problem.