=head1 NAME XML - Syntax and semantics of the XML files used in OPEAL =cut =head1 SYNOPSIS my $xml==< {_array}}; my $sqrt = sqrt( $x*$x+$y*$y); return sin( $sqrt )/$sqrt; ]]> EOC use Algorithm::Evolutionary::Experiment; use Algorithm::Evolutionary::Op::Easy; my $xp = Algorithm::Evolutionary::Experiment->fromXML( $xml ); my $popRef = $xp->go(); =head1 DESCRIPTION Algorithm::Evolutionary supports XML as a language for description of the evolutionary algorithm. The language is described in the F file, which is an DTD file, something like a dictionnary that allows to check which constructions in XML are syntactically correct and which are not. This XML dialect will be called, for lack of a better name, B. I tried to use XML Schemas instead of DTDs, but couldn't find a good tool to process them in Perl. This dialect will be used to describe the algorithm, and also its results, that is, the population of individuals the algorithms is going to be applied to. The first part is contained within the B tag, while the latter goes between a couple of B tags, and right after the B element. =head2 C The B tag contains several sections. In principle, the number of sections is not bounded, but it is usual to have only two, one related to the individuals, and another related to the population. Imagine that section as a set of transformations to be performed in turn. If you put a B descriptor at the beginning of the B element, and then an operator, the operator will be applied to the population; if it is an population L, and then several operators, the population will be created and then each operator will be applied in turn. B is like a pipeline that applies operators to a population, which is implied or not, in document order. So, basically what you will find or include in this section are L and population elements. =head3 C A population element might look like this:C< > . The pop element has an attribute that indicates its size, and then describes the kind of individuals that are going to be create. This section includes parameters that describe the individual type and any other thing needed to create it; the parameters are C, for the class in which the individuals are going to be instantiated, and other parameters such as C, that will be passed to the class constructor. =head3 C After, or instead, the declaration of the initial population, there will be declarations for one or more operators that will act on the population. If there is no population, the first operator should be a C, just like this: A C is a 0-ary population operator: takes a population, which could have no individuals, and adds individuals as specified by the XML fragment. In this case, 20 individuals, of class L, with the C as an option that will be passed to the individual constructor. Once the population has been created, be it via the C tag or a C operator, some stuff should be done on it. In this case, we apply the L operator: an easy-to-build genetic algorithm, with default mutation and crossover operator. A couple of parameters, given using the C tag, are passed to the operator: the selection rate (C) and the maximun number of generations (C). Each operator has its own parameters, which are normally (or should be) specified in its synopsis. Wrong parameters will not hurt, but if required parameters are not set, Perl will complain (as it should). There is another part a bit further on that is required: the fitness function, which falls within the C tag. The language and the type of function should be specified. Right now, only the Perl language is supported, as well as only the C or fitness function, but, in principle, any code could be passed this way; it will go to an entry in the operator under the C<_eval> name. Since this entry includes free Perl code, it must be enclosed in a CDATA tag, so it's not interpreted by the XML parser. Although this can be in any order, following the code come the operators that are going to be included in this operator. In this case, the operators are Mutation and Crossover, and they follow the same convention as its parent. Type and rate must be specified, as well as any parameters. These parameters are interpreted in the context of the operator, so they could be applied, in principle, to the population or to individuals within it; the only requisite is that the L class is able to interpret this and create an operator from it. =head2 Runtime Any Algorithm::Evolutionary program should be able to generate valid XML at any point during execution; normally, whatever is generated during runtime will go B the C tag, and will usually consist of a population section like this one. 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 0 1 0 1 0 0 This population will be read when reinstating an experiment by the L class, and taken as initial population to apply the rest of operators on it. =cut =head2 Copyright This file is released under the GPL. See the LICENSE file included in this distribution, or go to http://www.fsf.org/licenses/gpl.txt CVS Info: $Date: 2003/02/27 11:05:45 $ $Header: /cvsroot/opeal/opeal/Algorithm/Evolutionary/XML.pod,v 1.7 2003/02/27 11:05:45 jmerelo Exp $ $Author: jmerelo $ $Revision: 1.7 $ =cut