**3.2.2 Inverting the problem**

From our discussion on section 2, one can see that generating a synthetic spectrum is a Pproblem, as the result is obtained from a set of parameters, and no more computing is need. The generation time is obviously finite, and there are a number of very efficient software tools that do that. The only care to be taken is to assure that the artificial spectrum has the same wavelength resolution of the observed spectrum, in order to simplify the future comparison.

The above mentioned step 4, a methodology to optimize the artificial spectrum, is the trick point. If one wants to use GA so solve the abundances problem, it is necessary to invert the P-problem, that is, it is necessary to use the artificial spectrum generation tool as an external routine of a bigger and more complex algorithm. The algorithm used to this task is presented in figure 6.

Fig. 5. FEROS spectrum for star PDS054 (Rojas et al. 2008).

Fig. 6. Main blocks of a GA code to fit multi-band spectra of T Tauri stars (adapted from Hetem & Gregorio-Hetem 2009).

Establishing the abundances of each element as the parameters to be found, one individual in the GA terminology is the set of all elemental abundances added to some atmospheric parameters. The initial parameter set is used to build the first generation with 100 individuals. The evaluator routine creates a synthetic spectrum whose entries are the genetic data in each chromosome. This task is performed by calling the elected spectral tool.

There are a number of very efficient software tools that can be chosen. In our application, the abundances of chemical species are determined by using the spectral synthesis software SPECTRUM provided by Corbally (Gray & Corbally 1994) and the atmosphere model software ATLAS9 from Kurucz (1993).
