AI-ParticleSwarmOptimization
view release on metacpan or search on metacpan
1.003 Thu Oct 23 08:20:23 2008
- Changed module name from AI::PSO::OO to AI::ParticleSwarmOptimization
on suggestion of PAUSE admins
1.004
- call srand in init if -seedRand value was provided
- added plateau early exit code contributed by Kevin Balbi
1.005
- Remove POD test files from distribution
- Remove bogus print left over from dev testing
- Fix possible undef warning
1.006
- Fix Makefile.pl / Makefile.PL issue that caused *nix installs to fail!
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Program, the distribution of the whole must be on
the terms of this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to
work written entirely by you; rather, the intent is to exercise the right to control
the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the
Program (or with a work based on the Program) on a volume of a storage or
distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1 and 2
not permit royalty-free redistribution of the Program by all those who receive
copies directly or indirectly through you, then the only way you could satisfy
both it and this License would be to refrain entirely from distribution of the
Program.
If any portion of this section is held invalid or unenforceable under any particular
circumstance, the balance of the section is intended to apply and the section as
a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other
property right claims or to contest validity of any such claims; this section has
the sole purpose of protecting the integrity of the free software distribution
system, which is implemented by public license practices. Many people have
made generous contributions to the wide range of software distributed through
that system in reliance on consistent application of that system; it is up to the
author/donor to decide if he or she is willing to distribute software through any
other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
Samples/PSOPlatTest.pl view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use lib '..\lib'; # For development testing
use AI::ParticleSwarmOptimization;
use Math::Random::MT qw();
++$|;
my $pso = AI::ParticleSwarmOptimization->new (
-fitFunc => \&calcFit,
-dimensions => 3,
-iterations => 500,
-exitPlateau => 1,
-exitPlateauDP => 3,
Samples/PSOTest.pl view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use lib '..\lib'; # For development testing
use AI::ParticleSwarmOptimization;
++$|;
my $pso = AI::ParticleSwarmOptimization->new ();
$pso->setParams (
-fitFunc => \&calcFit,
-dimensions => 3,
-iterations => 100,
);
TODO list for Perl module AI::ParticleSwarmOptimization
Add more tests
Document optimization engine methods to allow customisation through derivation
Reinit particles using best position and random velocities as option
No search size limit by default
lib/AI/ParticleSwarmOptimization.pm view on Meta::CPAN
Maximum coordinate value for any dimension in the hyper space. Defaults to 100.
=item I<-posMin>: number, optional
Minimum coordinate value for any dimension in the hyper space. Defaults to
-I<-posMax> (if I<-posMax> is negative I<-posMin> should be set more negative).
=item I<-randSeed>: number, optional
Seed for the random number generator. Useful if you want to rerun an
optimization, perhaps for benchmarking or test purposes.
=item I<-randStartVelocity>: boolean, optional
Set true to initialize particles with a random velocity. Otherwise particle
velocity is set to 0 on initalization.
A range based on 1/100th of -I<-posMax> - I<-posMin> is used for the initial
speed in each dimension of the velocity vector if a random start velocity is
used.
t/01_pso_oo.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use lib '../lib'; # For development testing
use AI::ParticleSwarmOptimization;
=head1 NAME
AI::ParticleSwarmOptimization test suite
=head1 DESCRIPTION
Test AI::ParticleSwarmOptimization
=cut
plan (tests => 27);
ok (my $pso = AI::ParticleSwarmOptimization->new (), 'Constructor');
mustDie ('$pso->setParams (-fitFunc => 1)', 'Bad -fitFunc');
ok ($pso->setParams (-fitFunc => \&fitFunc,), 'Good -fitFunc (setParams)');
ok ($pso = AI::ParticleSwarmOptimization->new (-fitFunc => \&fitFunc,),
'Good -fitFunc (new)');
ok ($pso->setParams (-fitFunc => [\&fitFunc, 1]), 'Good -fitFunc (array)');
mustDie ('$pso->setParams (-dimensions => 0)', '-dimensions 0');
mustDie ('$pso->setParams (-dimensions => -1)', '-dimensions -1');
t/01_pso_oo.t view on Meta::CPAN
);
mustDie (
'$pso->setParams (-posMax => -1); $pso->setParams (-posMin => 0); $pso->init ()',
'-posMax < -posMin'
);
ok (
'$pso->setParams (-posMax => -1); $pso->setParams (-posMin => -2); $pso->init ()',
'-posMax > -posMin'
);
# Calculation tests.
$pso = AI::ParticleSwarmOptimization->new (
-randSeed => 2626813951,# Fit 0.00006 at (-1.0051, -0.0005, 1.0058) after 258 iterations
-fitFunc => \&calcFit,
-dimensions => 3,
-iterations => 500,
-exitPlateau => 1,
-exitPlateauDP => 3,
-exitPlateauBurnin => 100,
-exitPlateauWindow => 60,
);
t/01_pso_oo.t view on Meta::CPAN
my @values = @_;
my $offset = int (-@values / 2);
my $sum;
$sum += ($_ - $offset++)**2 for @values;
return $sum;
}
sub mustDie {
my ($test, $name) = @_;
eval $test;
ok (defined $@, $name);
}
( run in 0.330 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )