GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ALGORITHM::EVOLUTIONARY::INDIVIDUAL::VECTOR (3)

.ds Aq ’

NAME

Algorithm::Evolutionary::Individual::Vector - Array as an individual for evolutionary computation

CONTENTS

SYNOPSIS



    use Algorithm::Evolutionary::Individual::Vector;
    my $indi = new Algorithm::Evolutionary::Individual::Vector 10 ; # Build random vector individual with length 10
                                   # Each element in the range 0 .. 1
    my $indi2 = new Algorithm::Evolutionary::Individual::Vector 20, -5, 5; #Same, with range between -5 and 5

    #Creating a vector step by step. In Perl, theres always more than one way of doing it
    my $indi3 = new Algorithm::Evolutionary::Individual::Vector;
    $indi3->set( {length => 20,
                  rangestart => -5,
                  rangeend => 5 } );   #Sets values, but does not build the array
   
    $indi3->randomize(); #Creates an array using above parameters

    print $indi3->Atom( 7 );       #Returns the value of the 7th character
    $indi3->Atom( 3 ) = 2.35;       #Sets the value

    $indi3->addAtom( 7.5 ); #Adds a new component to the array at the end

    my $indi4 = Algorithm::Evolutionary::Individual::Vector->fromString( 3.5,4.5, 0.1, 3.2);
       #Parses the comma-separated elements of the string and creates a Algorithm::Evolutionary::Individual::Vector from them

    my $indi5 = $indi4->clone(); #Creates a copy of the individual

    my @array = qw( 3.5 4.8 3.3 4.2 0.23); #Tie a vector individual
    tie my @vector, Algorithm::Evolutionary::Individual::Vector, @array;
    print tied( @vector )->asXML();

    print $indi3->as_string(); #Prints the individual
    print $indi3->asXML() #Prints it as XML. See L<XML> for more info on this



Base Class

Algorithm::Evolutionary::Individual::Base

DESCRIPTION

Array individual for a EA. Generally used for floating-point arrays. It can be also TIEd so that it can be handled as a normal array.

METHODS

new( [$length = 10] [, CW$start_of_range = 0] [, CW$end_of_range = 1] )

Creates a new random array individual, with fixed initial length, and uniform distribution of values within a range

size()

Returns vector size (dimension)

set( CW$ref_to_hash )

Sets values of an individual; takes a hash as input. The array is initialized to a null array, and the start and end range are initialized by default to 0 and 1

randomize()

Assigns random values to the elements

    Atom

Gets or sets the value of an atom

    addAtom

Adds an atom at the end

length()

Returns the number of atoms in the individual

fromString( CW$string )

Similar to a copy ctor; creates a vector individual from a string composed of stuff separated by a separator

clone()

Similar to a copy ctor: creates a new individual from another one

asString()

Returns a string with chromosome plus fitness. OK, this is a bit confusing

as_string()

Returns just the chromosome, not the fitness

asXML()

Prints it as XML. See the Algorithm::Evolutionary::XML OPEAL manual for details.

    Chrom( [$ref_to_array]

Sets or gets the array that holds the chromosome. Not very nice, and I would never ever do this in C++

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: 2011/11/23 10:59:47 $
  $Header: /media/Backup/Repos/opeal/opeal/Algorithm-Evolutionary/lib/Algorithm/Evolutionary/Individual/Vector.pm,v 3.2 2011/11/23 10:59:47 jmerelo Exp $
  $Author: jmerelo $
  $Revision: 3.2 $



Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 ALGORITHM::EVOLUTIONARY::INDIVIDUAL::VECTOR (3) 2014-10-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.