NAME
XML - Syntax and semantics of the XML files used in OPEAL
SYNOPSIS
my $xml==<<EOC;
<?xml version="1.0"?>
<!DOCTYPE ea SYSTEM "EvoSpec.dtd">
<ea version='0.4'>
<initial>
<op name='Creator' >
<param name='number' value='20' />
<param name='class' value='Vector' />
<param name='options'>
<param name='length' value='2' />
<param name='rangestart' value='0' />
<param name='rangeend' value='1' />
</param>
</op>
<op name='Easy' type='unary'>
<param name='selrate' value='0.4' />
<param name='maxgen' value='100' />
<code type='eval' language='perl'>
<src><![CDATA[ my $indi = shift;
my ( $x, $y ) = @{$indi->{_array}};
my $sqrt = sqrt( $x*$x+$y*$y);
return sin( $sqrt )/$sqrt;
]]></src>
</code>
<op name='GaussianMutation' type='unary' rate='1'>
<param name='avg' value='0' />
<param name='stddev' value='0.1' />
</op>
<op name='VectorCrossover' type='binary' rate='1'>
<param name='numPoints' value='1' />
</op>
</op>
</initial>
</ea>
EOC
use Algorithm::Evolutionary::Experiment;
use Algorithm::Evolutionary::Op::Easy;
my $xp = Algorithm::Evolutionary::Experiment->fromXML( $xml );
my $popRef = $xp->go();
DESCRIPTION
Algorithm::Evolutionary supports XML as a language for description of the evolutionary algorithm. The language is described in the EvoSpec.dtd 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, EvoSpec. 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 initial tag, while the latter goes between a couple of pop tags, and right after the initial element.
The initial 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 pop descriptor at the beginning of the initial element, and then an operator, the operator will be applied to the population; if it is an population Algorithm::Evolutionary::Op::Creator, and then several operators, the population will be created and then each operator will be applied in turn. initial 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 Algorithm::Evolutionary::Op::Base and population elements. A population element might look like this: <pop size='20'
<section name='indi'> <param name='type' value='BitString' /> <param name='length' value='64' /> </section> </pop> > (but this section stuff is kinda ugly, and will try to get rid of it in the future). The pop element has an attribute that indicates its size, and then a section devoted to describing the kind of individuals that are going to be created (hence the name='indi'
). This section includes parameters that describe the parameter type and any other thing needed to create it; the parameters are This operator includes in itself all the parameters and operators that it needs, in such a way that it recursively creates the objects that are described in the XML fragment: the Algorithm::Evolutionary::Individual::GaussianMutation operator, and the Algorithm::Evolutionary::Individual::VectorCrossover crossover operator.
It also includes the fragments of code that are problem specific, such as, in this case, the code that evaluates the chromosome to give it a fitness; this code, within the code tag will be wrapped into a bit of more code, and converted to a pointer-so-subroutine. Any other specific code should be declared this way; it will be available within the operator via the self-
{_type}> pointer.
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/17 18:59:40 $
$Header: /cvsroot/opeal/opeal/Algorithm/Evolutionary/XML.pod,v 1.6 2003/02/17 18:59:40 jmerelo Exp $
$Author: jmerelo $
$Revision: 1.6 $