=head1 NAME
XML - Syntax and semantics of the XML files used in OPEAL
=cut
=head1 SYNOPSIS
my ( $x, $y ) = @{$indi->{_array}};
my $sqrt = sqrt( $x*$x+$y*$y);
return sin( $sqrt )/$sqrt;
# This XML doc will be read by a program like this one, which will
# run the EA (parse-opeal-1.pl)
#!/usr/bin/perl
use warnings;
use strict;
#New parser for the new version of the schema
use XML::Simple;
#EA-related modules
use IndiBase;
use OpBase;
#-------------------------- Program starts here --------------------------------
my $file = shift || die "Usage: $0 \n";
#Open file and parse it
open(IN, "<$file" );
my $xml=join("", );
close IN;
my $ref = XMLin($xml);
#Create population
my @pop;
for ( my $i = 0; $i < $ref->{initial}{section}{pop}{param}{value}; $i ++ ) {
my $indi = IndiBase->fromParam( $ref->{initial}{section}{indi}{param} );
push( @pop, $indi );
print $indi->asString, "\n";
}
#Create an algorithm
my $easyEA = OpBase->fromXML( $ref->{initial}{section}{pop}{op} );
for ( my $i = 0; $i < $ref->{initial}{section}{pop}{op}{param}{maxgen}{value}; $i++ ) {
print "<", "="x 20, "Generation $i", "="x 20, ">\n";
$easyEA->apply( \@pop );
for ( @pop ) {
print $_->asString, "\n";
}
}
=cut
=head1 DESCRIPTION
OPEAL supports XML as a language for description of the evolutionary algorithm.
The language is described in the F file, which is an
XSchema 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.
This dialect will be used to describe the algorithm, and also the
results of the algorithm, 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.
The B tag contains several sections. In principle, the
number of sections is not bounded, but it's usual to have only two,
one related to the individuals, and another related to the
population.
The first section describes the parameters used to create
an individual by the evolutionary algorithm, included its type. In
this case, individuals of the class L will be created to
form the population, described in the second section. All parameters
have a B and a B, and you can have as many as you
need. The only compulsory one is the B parameter, which
indicates the class in which the population members will be instantiated.
The second section describes population-related stuff; basically
population parameters and the algorithms that are going to be applied
to the population; the tag B describes the operator applied to the
population; how these operators will be applied is left to the program
that parses this file. In this case, an algorithm of the class L
will be applied.
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
L operator, and the
L crossover operator.
It also includes the fragments of code that are problem specific, such
as, in this case, the code that evaluates the I to give it
a fitness; this code, within the B 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 C{_type}> pointer.
=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: 2006/03/15 08:51:23 $
$Header: /cvsroot/opeal/opeal/Algorithm/xml/XML.pod,v 1.1 2006/03/15 08:51:23 jmerelo Exp $
$Author: jmerelo $
$Revision: 1.1 $
=cut