NAME
PDL::Opt::ParticleSwarm::Simple - An easy to use particle swarm optimizer
SYNOPSIS
use PDL::Opt::ParticleSwarm::Simple;
# Simple single-variable invocation
$simpl = PDL::Opt::ParticleSwarm::Simple->new(
vars => {
# initial guess for x
x => 1
},
f => sub {
my $vars = shift;
# Parabola with minima at x = -3
return (($vars->{x}+3)**2 - 5)
},
opts => {
# Options from PDL::Opt::ParticleSwarm
}
);
$simpl->optimize();
$result_vars = $simpl->get_result_simple();
print "x=" . $result_vars->{x} . "\n"; # x=-3
$result_vars = $simpl->optimize();
use Data::Dumper;
print Dumper($result_vars);
DESCRIPTION
This class uses PDL::Opt::ParticleSwarm to find the values for vars
that cause the f
coderef to return the minimum value. The difference between PDL::Opt::ParticleSwarm and PDL::Opt::ParticleSwarm::Simple is that PDL::Opt::ParticleSwarm expects all data to be in PDL format and it is more complicated to manage, whereas, PDL::Opt::ParticleSwarm:Simple uses all scalar Perl values. (PDL values are supported, too)
FUNCTIONS
$self->new(opts => \%args) - Instantiate class
This is a subclass implementation of Particle Swarm based on PDL::Opt::Simplex::Simple. Many other features are available, so please see the PDL::Opt::Simplex::Simple documentation for full details.
OPTIONS
See PDL::Opt::ParticleSwarm for options available above in opts
.
SEE ALSO
- PDL::Opt::ParticleSwarm - A PDL implementation of Particle Swarm
- PDL::Opt::Simplex::Simple - Use names for Simplex-optimized values
- PDL::Opt::Simplex - A PDL implementation of the Simplex optimization algorithm
AUTHOR
Originally written by Eric Wheeler, KJ7LNW for Zeke to optimize PID controller values for an antenna rotors controller to contact the International Space Station. More project information is available here: https://youtu.be/vrlw4QPKMRY
COPYRIGHT
Copyright (C) 2023 Eric Wheeler, KJ7LNW
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this module. If not, see <http://www.gnu.org/licenses/>.