NAME

    XML - Syntax and semantics of the XML files used in OPEAL


SYNOPSIS


   my $xml==<<EOC;
   <ea xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:noNamespaceSchemaLocation='ea-alpha.xsd'
    version='0.3'>
   <!-- XML file that describes the Royal Road function -->
   <initial>
    <pop size='20'>
       <section name='indi'> 
          <param name='type' value='BitString' /> 
          <param name='length' value='64' />
       </section>
    </pop>
    <op name='Easy'  type='unary'>
        <param name='selrate' value='0.4' />
        <param name='maxgen' value='100' />
        <code type='eval' language='perl'>
          <src><![CDATA[ my $chrom = shift;
                my $str = $chrom->Chrom();
                my $fitness = 0;
                for ( my $i = 0; $i < length( $str ) / $blockSize; $i++ ) {
                      my $block = 1;
                      for ( my $j = 0; $j < $blockSize; $j++ ) {
                        $block &= substr( $str, $i*$blockSize+$j, 1 );
                      }
                      ( $fitness += $blockSize ) if $block;
                }
                return $fitness;
          ]]></src>
        </code>
        <op name='Mutation' type='unary' rate='1'>
            <param name='probability' value='0.5' />
        </op>
        <op name='Crossover' type='binary' rate='5'>
                <param name='numpoints' value='2' />
        </op>
    </op>

   </initial>
  </ea>
  EOC
  # 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 Algorithm::Evolutionary::Experiment;
  use Algorithm::Evolutionary::Op::Easy;
  my $xp = Algorithm::Evolutionary::Experiment->fromXML( $xml );


DESCRIPTION

OPEAL supports XML as a language for description of the evolutionary algorithm. The language is described in the ea-alpha.xsd 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, EvoSpec.

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 initial tag, while the latter goes between a couple of runtime tags.

The initial 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 the Algorithm::Evolutionary::Individual::Vector manpage will be created to form the population, described in the second section. All parameters have a name and a value, and you can have as many as you need. The only compulsory one is the type 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 op 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 Easy 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 the Algorithm::Evolutionary::Individual::GaussianMutation manpage operator, and the the Algorithm::Evolutionary::Individual::VectorCrossover manpage 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: 2002/07/26 07:14:56 $ 
  $Header: /cvsroot/opeal/opeal/Algorithm/Evolutionary/XML.pod,v 1.4 2002/07/26 07:14:56 jmerelo Exp $ 
  $Author: jmerelo $ 
  $Revision: 1.4 $