thetaNeuronExample.cpp

This is an example of how to use the thetaNeuron class. This example does the follows:

// Summary: Example File For Using thetaNeuron class
// Author: Sam McKennoch
// Date: 2007-2009


//standard libraries
#include "stdafx.h"
#include <string>
#include <iostream>
#include <sstream>
#include <ctime>

//custom includes
#include "thetaNeuron.h"

//use standard namespace
using namespace std;

int main()
{       

        int num_inputs=4;
        int num_outputs, num_outputs2;
        double ti[]={2, 1, 1.5, 4}; //Inputs Spike Times
        int mts=3; //Maximum Number of Output Spikes
        double mse=0; //Mean Squared Error
        double *ts, *ts2, *ts3;
        ts=new double[mts];
        ts2=new double[mts];
        ts3=new double[mts];
        double phase;

        //Construct theta neuron object with randomized weights
        thetaNeuron tn(num_inputs);

        //Display Neuron Properties
        tn.displayThetaNeuron();

        //Display Neuron Phase (State)
        phase = tn.getPhase();
        cout << "Phase: " << phase << endl << endl;

        //Simulate Theta Neuron Numerically
        tn.setMethod(thetaNeuron::Numerical);
        num_outputs=tn.runThetaNeuron(ti,ts,mts);

        //Simulate Theta Neuron with Event-Driven Methodology
        tn.setMethod(thetaNeuron::EventDriven);
        num_outputs2=tn.runThetaNeuron(ti,ts2,mts);

        //Find Mean-Squared in Spike Times Between the Different Methods
        if (num_outputs!=num_outputs2) {
                cout << "The Two Simulation Methods Produced Different Numbers of Output Spikes!" << endl << endl;
        }
        else if (num_outputs==0) {
                cout << "The Two Simulation Methods Produced No Output Spikes!" << endl << endl;
        }
        else {
                for (int j=0;j<num_outputs;j++) {
                        mse+=(ts[j]-ts2[j])*(ts[j]-ts2[j]);
                }
                mse /= num_outputs;
                cout << "Output Spike Mean-Squared Error Between Simulation Methods: " << endl << "\t" << mse << endl << endl;
        }

        //Stack two neurons sequentially
        if (num_outputs>0) {
                cout << "A second neuron is simulated in connection to the output of the previous neuron" << endl;
                thetaNeuron tn3(1);
                tn3.runThetaNeuron(ts,ts3,mts);
                tn3.~thetaNeuron();
        }

        //Destruct theta neuron object
        tn.~thetaNeuron();

        system("PAUSE");

        return EXIT_SUCCESS;
}
 All Classes Functions Enumerations Enumerator

Generated on Thu Oct 29 14:56:34 2009 for ThNNTest Project Name by  doxygen 1.6.1