The clonal selection algorithm is used by the natural immune system to define the basic features of an immune response to an antigenic stimulus. It establishes the idea that only those cells that recognize the antigens are selected to proliferate. The selected cells are subject to an affinity maturation process, which improves their affinity to the selective antigens. In this paper, we propose a powerful computational implementation of the clonal selection principle that explicitly takes into account the affinity maturation of the immune response. The algorithm is shown to be an evolutionary strategy capable of solving complex machine-learning tasks, like pattern recognition and multi-modal optimization.