AI-PSO

 view release on metacpan or  search on metacpan

MPL-1.1.txt  view on Meta::CPAN


     1.10. "Original Code" means Source Code of computer software code
     which is described in the Source Code notice required by Exhibit A as
     Original Code, and which, at the time of its release under this
     License is not already Covered Code governed by this License.

     1.10.1. "Patent Claims" means any patent claim(s), now owned or
     hereafter acquired, including without limitation,  method, process,
     and apparatus claims, in any patent Licensable by grantor.

     1.11. "Source Code" means the preferred form of the Covered Code for
     making modifications to it, including all modules it contains, plus
     any associated interface definition files, scripts used to control
     compilation and installation of an Executable, or source code
     differential comparisons against either the Original Code or another
     well known, available Covered Code of the Contributor's choice. The
     Source Code can be in a compressed or archival form, provided the
     appropriate decompression or de-archiving software is widely available
     for no charge.

     1.12. "You" (or "Your")  means an individual or a legal entity

MPL-1.1.txt  view on Meta::CPAN

     automatically if You fail to comply with terms herein and fail to cure
     such breach within 30 days of becoming aware of the breach. All
     sublicenses to the Covered Code which are properly granted shall
     survive any termination of this License. Provisions which, by their
     nature, must remain in effect beyond the termination of this License
     shall survive.

     8.2.  If You initiate litigation by asserting a patent infringement
     claim (excluding declatory judgment actions) against Initial Developer
     or a Contributor (the Initial Developer or Contributor against whom
     You file such action is referred to as "Participant")  alleging that:

     (a)  such Participant's Contributor Version directly or indirectly
     infringes any patent, then any and all rights granted by such
     Participant to You under Sections 2.1 and/or 2.2 of this License
     shall, upon 60 days notice from Participant terminate prospectively,
     unless if within 60 days after receipt of notice You either: (i)
     agree in writing to pay Participant a mutually agreeable reasonable
     royalty for Your past and future use of Modifications made by such
     Participant, or (ii) withdraw Your litigation claim with respect to
     the Contributor Version against such Participant.  If within 60 days

examples/NeuralNet/NeuralNet.h  view on Meta::CPAN

        double    m_value;            /// value of this Neuron
        TransferFunction *xfer;        
};




/// 
/// \class Input NeuralNet.h NeuralNet
/// \brief Simulates an input neuron in a Neural net.  This class extends Neuron
///            but allows for its value to be set directly and it also overrides 
///            the virtual value function so that it returns its value directly 
///            rather than passing though a transfer function.
///
class NEURALNET_API Input : public Neuron
{
    public:


        ///
        /// \fn Input(double value)

examples/NeuralNet/NeuralNet.h  view on Meta::CPAN

        /// \param value a double
        ///
        void setValue(double value)
        {
            m_value = value;
        }


        ///
        /// \fn double value()
        /// \brief override of virtual function.
        /// \return double
        ///
//        double value()
//        {
//            return m_value;
//        }

    protected:
};

examples/NeuralNet/main.cpp  view on Meta::CPAN

        annConfigFile = string(argv[1]);
    }
    if(argc > 2) {
        annDataFile = string(argv[2]);
    }

    int numInputs, numHidden;
    ifstream ifs;
    ifs.open(annConfigFile.data());
    if(!ifs.is_open()) {
        cerr << "Error opening neural network configuration file" << endl;
    }
    ifs  >> numInputs >> numHidden;

    string xferFunc;
    ifs >> xferFunc;

    double *dataForNet = new double[numInputs];

    ifstream ids;
    ids.open(annDataFile.data());
    if(!ids.is_open()) {
        cerr << "Error opening neural network data file" << endl;
    }
    for(int i = 0; i < numInputs; i++) {
        ids >> dataForNet[i];
    }
    ids.close();


    NeuralNet *m_ann = new NeuralNet(numInputs, numHidden, xferFunc.c_str());

    double weight;

examples/NeuralNet/main.cpp  view on Meta::CPAN

    }
    
    for(int d = 0; d < numInputs; d++) {
        m_ann->setInput(d, dataForNet[d]);
    }

    delete [] dataForNet;

    ifs.close();
    if(ifs.is_open()) {
        cerr << "Error closing neural network configuration file" << endl;
    }

    cout << m_ann->value() << endl;

    delete m_ann;
}

lib/AI/PSO.pm  view on Meta::CPAN

#       for users to implement their own cache since they are passed the same array of values.
#
sub compute_fitness(@) {
    my (@values) = @_;
    my $return_fitness = 0;

#    no strict 'refs';
#    if(defined(&{"main::$user_fitness_function"})) {
#        $return_fitness = &$user_fitness_function(@values);
#    } else {
#        warn "error running user_fitness_function\n";
#        exit 1;
#    }
#    use strict 'refs';

    $return_fitness = $user_fitness_function->call(@values);

    return $return_fitness;
}


lib/AI/PSO.pm  view on Meta::CPAN

#
# get_index_of_neighbor
#
# - returns the index of Nth neighbor of the index for particle P
# ==> A neighbor is one of the next K particles following P where K is the neighborhood size.
#    So, particle 1 has neighbors 2, 3, 4, 5 if K = 4.  particle 4 has neighbors 5, 6, 7, 8
#    ...
# 
sub get_index_of_neighbor($$) {
    my ($particleIndex, $neighborNum) = @_;
    # TODO: insert error checking code / defensive programming
    return ($particleIndex + $neighborNum) % $numParticles;
}


#
# get_index_of_best_fit_neighbor
# - returns the index of the neighbor with the best fitness (when given a particle index)...
# 
sub get_index_of_best_fit_neighbor($) {
    my ($particleIndex) = @_;
    my $bestNeighborFitness   = 0;
    my $bestNeighborIndex     = 0;
    my $particleNeighborIndex = 0;
    for(my $neighbor = 0; $neighbor < $numNeighbors; $neighbor++) {
        $particleNeighborIndex = &get_index_of_neighbor($particleIndex, $neighbor);
        if(&compute_fitness(@{$particles[$particleNeighborIndex]{bestPos}}) > $bestNeighborFitness) { 
            $bestNeighborFitness = &compute_fitness(@{$particles[$particleNeighborIndex]{bestPos}});
            $bestNeighborIndex = $particleNeighborIndex;
        }
    }
    # TODO: insert error checking code / defensive programming
    return $particleNeighborIndex;
}

#
# clamp_velocity
# - restricts the change in velocity to be within a certain range (prevents large jumps in problem hyperspace)
#
sub clamp_velocity($) {
    my ($dx) = @_;
    if($dx < $deltaMin) {



( run in 0.496 second using v1.01-cache-2.11-cpan-49f99fa48dc )