AI-ANN
    
    
  
  
  
view release on metacpan or search on metacpan
ANN_specification view on Meta::CPAN
	implements an individual neuron from the neural network
	from ann, $self->{'network'}->[$n]->{'object'} = new ANN::Neuron( $thisid, {$inputid => $weight, ...}, {$neuronid => $weight})
	from ann, $self->{'network'}->[$n]->{'object'}->ready( [$input0, $input1, ...], {$neuronid => $neuronvalue, ...} ) returns 1 if all inputs are available, 0 otherwise
	from ann, $self->{'network'}->[$n]->{'object'}->execute( [$input0, $input1, ...], {$neuronid => $neuronvalue, ...} ) returns the output value of the neuron
	in addition, get_inputs and get_neurons are available. There return the respective original hashrefs. 
ANN::Evolver
	evolves the ann
	from caller, $handofgod = new ANN::Evolver({$mutationchance, $mutationamount, $addlinkchance, $killlinkchance, $subcrossoverchance}) add should be zero if you want to preserve feed-forwardness
	from caller, $handofgod->crossover($network1, $network2) returns $network3, which inherits 50% of each parent's traits. Each neuron has $subcrossoverchance to inherit 50% of its traits from each parent.
	from caller, $handofgod->mutate($network3) introduces some random mutations into neuron weights. Has a $mutationchance to change each weight by up to $mutationamount, a $addlinkchance to change an input from zero to up to $mutationamount, and a $kil...
ANN::SimWorld
	uses an ANN object to attempt to survive in a virtual world, which must be defined by the caller
	from caller, $world = new ANN::SimWorld( //stuff here )
	from caller, $world->($network) returns a fitness variable
0.005     2011-05-31 20:18:02 UTC
          Convert to use Moose. I'm told that this is better. There are a few 
          neat things (not having to write accessors, and apparently 
          inheritance just works, I'll find out about that soon enough...) 
          but overall I really don't see the point. Default values, type 
          constraints, I had all that anyway. Meh.
          Add some words about what the point of this module is.
0.004     2011-05-31 02:35:26 UTC
          Minor calling changes that I need to commit so I can test them with 
          another module.
0.003     2011-05-31 01:09:32 UTC
          Minor. Correct the perl version requirement.
0.002     2011-05-31 01:04:53 UTC
          Make many obvious (to a computer, I hope) references to the fact 
          that this requires perl 5.14, to prevent the bloody annoying 
          CPAN Testers emails. Note that I chose to do this rather than 
          make the module compatible with earlier versions.
 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
                            Preamble
  The GNU General Public License is a free, copyleft license for
software and other kinds of works.
  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.
  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.
  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
  6. Conveying Non-Source Forms.
  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.
    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.
    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
                     END OF TERMS AND CONDITIONS
            How to Apply These Terms to Your New Programs
  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>
    This program is free software: you can redistribute it and/or modify
lib/AI/ANN.pm view on Meta::CPAN
					# Fixes warnings about uninitialized values, but we make 
					# sure $i is valid first.
					$neurons[$i] = 0;
				}
				my $potential = $net->[$i]->{'object'}->execute($inputs, \@neurons);
                $self->{'rawpotentials'}->[$i] = $potential;
				$potential = &{$self->{'afunc'}}($potential);
				$potential = $self->{'maxvalue'} if $potential > $self->{'maxvalue'};
				$potential = $self->{'minvalue'} if $potential < $self->{'minvalue'};
				$neuronstemp[$i] = $net->[$i]->{'state'} = $potential;
				# We want to know the absolute change
				if (abs($neurons[$i]-$neuronstemp[$i])>$maxerror) {
					$maxerror = abs($neurons[$i]-$neuronstemp[$i]);
				}
			}
			foreach my $i (0..$lastneuron) { 
				# Update $neurons, since that is what gets passed to execute
				$neurons[$i] = $neuronstemp[$i];
			}
			if (($maxerror < 0.0001 && $loopcounter >= 5) || $loopcounter > 250) {last}
			$loopcounter++;
lib/AI/ANN/Evolver.pm view on Meta::CPAN
AI::ANN::Evolver->new( { mutation_chance => $mutationchance, 
	mutation_amount => $mutationamount, add_link_chance => $addlinkchance, 
	kill_link_chance => $killlinkchance, sub_crossover_chance => 
	$subcrossoverchance, min_value => $minvalue, max_value => $maxvalue } )
All values have a sane default.
mutation_chance is the chance that calling mutate() will add a random value
	on a per-link basis. It only affects existing (nonzero) links. 
mutation_amount is the maximum change that any single mutation can introduce. 
	It affects the result of successful mutation_chance rolls, the maximum 
	value after an add_link_chance roll, and the maximum strength of a link 
	that can be deleted by kill_link_chance rolls. It can either add or 
	subtract.
add_link_chance is the chance that, during a mutate() call, each pair of 
	unconnected neurons or each unconnected neuron => input pair will 
	spontaneously develop a connection. This should be extremely small, as
	it is not an overall chance, put a chance for each connection that does
	not yet exist. If you wish to ensure that your neural net does not become 
	recursive, this must be zero. 
t/00_initialize.t view on Meta::CPAN
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 9;
BEGIN { use_ok('AI::ANN');
	use_ok('AI::ANN::Neuron');
	use_ok('AI::ANN::Evolver'); };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
t/01_neuron_basic.t view on Meta::CPAN
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 17;
BEGIN { use_ok('AI::ANN');
	use_ok('AI::ANN::Neuron'); };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
t/02_network_basic.t view on Meta::CPAN
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 25;
BEGIN { use_ok('AI::ANN');
	use_ok('AI::ANN::Neuron'); };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
t/03_evolver_basic.t view on Meta::CPAN
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 60;
BEGIN { use_ok('AI::ANN');
	use_ok('AI::ANN::Evolver'); };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
# This test basically works by crossing a network with itself and making sure nothing changes
$network1=new AI::ANN ('inputs'=>1, 'data'=>[{ iamanoutput => 1, inputs => {0 => 1}, neurons => {}}]);
$network2=new AI::ANN ('inputs'=>1, 'data'=>[{ iamanoutput => 1, inputs => {0 => 1}, neurons => {}}]);
ok(defined $network1, "new() works");
ok($network1->isa("AI::ANN"), "Right class");
ok(defined $network2, "new() works");
ok($network2->isa("AI::ANN"), "Right class");
ok($out=$network1->execute([1]), "executed and still alive");
t/10_network_integrity.t view on Meta::CPAN
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 10;
BEGIN { use_ok('AI::ANN');
	use_ok('AI::ANN::Neuron'); };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
( run in 0.470 second using v1.01-cache-2.11-cpan-c333fce770f )