The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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

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/>.