## 5 Genetic Programming and Immune Systems  
Genetic programming (GP) is a heuristic algorithm that makes use of the chromosome evolution process to solve a problem [40]. GP is specifically designed to evolve individuals which are traditionally represented as tree structures [41]. The algorithm applies different operations to evolve the population and retrieve an optimal solution. Those operations are commonly crossover, mutation and selection. The crossover operation involves exchanging random branches of two trees to produce a new and different individual that is incorporated into the population in a future generation. Mutation involves modification of some properties in an individual. The selection consists of deciding which trees (individuals) will be preserved for the next generation. GP has been applied to many applications such as robotics engineering, circuit design, art, financial engineering and so on. The nature of this algorithm makes it ideal to generate hierarchical structures that govern the chord progressions. Consequently, we decided to apply GP to optimize \(M\) and generate music. Although the traditional GP can only obtain a quasi-optimal solution, for this particular purpose the subjective criterion of the user plays an important role and cannot be predicted by our system. Therefore, it was strongly desired that ChordAIS-Gen searches for multiple solutions simultaneously, to give the user the opportunity to choose among different options. To address this problem, we looked for similar algorithms that can be fused with GP to improve its behavior. We found that [PERSON] and [PERSON] [42] developed an artificial immune system for multi-objective optimization called opt-aiNet. In opt-aiNet, each candidate solution (called antibody) is encoded as a vector whose quality is measured with an objective function. A population of antibodies, which represents a pool of candidate solutions, evolves following the immunological principles of clonal expansion, mutation and suppression. The evolution of the antibodies results in the optimization of the objective function because the objective value (or quality) of the solutions encoded by the antibodies increases. Initially, the antibodies are randomly initialized to explore the search space. Next, some antibodies are selected and cloned based on their quality. Each clone undergoes a mutation inversely proportional to its objective value. These mutated clones are subsequently re-evaluated with the objective function to determine if mutation increased their quality. Those mutated clones with higher quality values than before are introduced in the current population, while the ones whose quality decreased are discarded. In order to maintain diversity in the pool of candidate solutions, the algorithm eliminates those antibodies that are close together in the search space. The affinity between two antibodies is measured with the Euclidean distance between them, such that smaller distances mean greater affinity. Those antibodies whose affinity is higher than a given threshold are removed from the population while keeping the ones with the highest objective value. Finally, a number of newly generated antibodies are incorporated into the network. The algorithm converges when the quality of the current solutions cannot be further improved and no new solutions are found. We developed a GP incorporating some of the operations proposed in opt-aiNet. The pseudo-code of the algorithm is shown in Figure 3 and can be explained as follows:  
1. Randomly initialize a population of tree structures and chords. 2. While the stopping criterion is not met do. 1. Determine the fitness of each antibody (chord progression) according to \(M\) and normalize the matrix of profiles for the population. 2. Generate a number \(N_{c}\) of clones for each antibody (chord progression). 3. Mutate each chord progression according to a probability \(Q_{m}\). The mutation can follow two different procedures: * Mutate a leaf node (a chord) proportionally to the fitness of its parent.