This is an instance of the bin packing problem, an NP-hard problem.
You have a collection of boxes numbers 0, 1, 2, ..., n-1. Each box has an associated weight. You have a collection of containers, each of which has a maximum weight of W. The idea is to place boxes into a container, never exceeding its capacity but filling it as closely as possible to its capacity. For example, suppose b1=10, b2=15, and b3=20 and W=30. If you place b1 and b2 into the container, you have 5 pounds of unused capacity. However, if you place b1 and b3 in the container, you have achieved an optimal packing. This is the kind of optimization problem that genetic algorithms can be handle.
Develop a binary representation -- i.e., one involving 0s and 1s -- that can be used by the chromosomes for this problem. Illustrate its use with an example involving a small number of boxes. Show that your representation would allow both crossover and mutation.
Develop and describe an evaluation function that can be used to determine the fitness of the different chromosomes. In other words, given your binary representation, describe a way to distinguish a good fit from a bad fit. Obviously, a chromosome in which the total weight of the container exceeds its capacity is a bad fit. One that perfectly fills the container is a perfect fit. (You can assume that the program has a separate data structure to store the weights of the individual boxes so that b1's weight can be looked up in a table, and so on.
Develop an implementation of a GA that uses your chromosome design and fitness function to solve this problem. Test your solution on randomly generated distributions of boxes and containers. Include in your implementation a way to visualize the GAs progress during execution including a visualization that makes it clear when the problem is solved.
Provide an analysis of your results, describing in the overall success of your GA. In how many cases was it able to find an optimal solution?