Storage-location assignment in warehouses is an important task as it impacts productivity of other warehouse processes. The class-based storage policy distributes the products, among a number of classes, and for each class it reserves a region within the storage area. We propose a nonlinear integer-programming model to the problem of formation of classes and allocation of storage space, considering savings in required storage space, due to random allocation of products within a class. We develop a branch and bound algorithm (BBA) to solve the model and compare it with a benchmark dynamic programming algorithm (DPA). These algorithms are applied to randomly generated data sets and to an industrial case. Computational experience shows that class-based policy can result in shorter pick-travel distances than the dedicated policy. The proposed BBA is found to be computationally much more efficient than DPA.