TDProjection.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002 * Verve                                                                 *
00003 * Copyright (C) 2004-2006                                               *
00004 * Tyler Streeter  tylerstreeter@gmail.com                               *
00005 * All rights reserved.                                                  *
00006 * Web: http://verve-agents.sourceforge.net                              *
00007 *                                                                       *
00008 * This library is free software; you can redistribute it and/or         *
00009 * modify it under the terms of EITHER:                                  *
00010 *   (1) The GNU Lesser General Public License as published by the Free  *
00011 *       Software Foundation; either version 2.1 of the License, or (at  *
00012 *       your option) any later version. The text of the GNU Lesser      *
00013 *       General Public License is included with this library in the     *
00014 *       file license-LGPL.txt.                                          *
00015 *   (2) The BSD-style license that is included with this library in     *
00016 *       the file license-BSD.txt.                                       *
00017 *                                                                       *
00018 * This library is distributed in the hope that it will be useful,       *
00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00021 * license-LGPL.txt and license-BSD.txt for more details.                *
00022 ************************************************************************/
00023 
00024 #include "TDProjection.h"
00025 #include "Neuron.h"
00026 
00027 namespace verve
00028 {
00029         TDProjection::TDProjection(TDConnectionType type)
00030         : Projection()
00031         {
00032                 mTDConnectionType = type;
00033                 mETraceDecayFactor = 0;
00034                 mTDDiscountFactor = 0;
00035         }
00036 
00037         TDProjection::~TDProjection()
00038         {
00039         }
00040 
00041         void TDProjection::setETraceDecayFactor(real value)
00042         {
00043                 // Store this value for new Connections later.
00044                 mETraceDecayFactor = value;
00045 
00046                 // Update all existing Connections.
00047                 unsigned int size = (unsigned int)mConnections.size();
00048                 for (unsigned int i = 0; i < size; ++i)
00049                 {
00050                         static_cast<TDConnection*>(mConnections[i])->
00051                                 setETraceDecayFactor(value);
00052                 }
00053         }
00054 
00055         void TDProjection::setTDDiscountFactor(real value)
00056         {
00057                 // Store this value for new Connections later.
00058                 mTDDiscountFactor = value;
00059 
00060                 // Update all existing Connections.
00061                 unsigned int size = (unsigned int)mConnections.size();
00062                 for (unsigned int i = 0; i < size; ++i)
00063                 {
00064                         static_cast<TDConnection*>(mConnections[i])->
00065                                 setTDDiscountFactor(value);
00066                 }
00067         }
00068 
00069         void TDProjection::connectNeurons(Neuron* neuron1, Neuron* neuron2)
00070         {
00071                 TDConnection* c = new TDConnection(neuron1, neuron2, 
00072                         mTDConnectionType);
00073 
00074                 c->setETraceDecayFactor(mETraceDecayFactor);
00075                 c->setTDDiscountFactor(mTDDiscountFactor);
00076 
00077                 // Tell the pre-synaptic Neuron that this connection is one of its 
00078                 // axons.
00079                 neuron1->addAxon(c);
00080 
00081                 // Tell the post-synaptic Neuron that this connection is one of its 
00082                 // dendrites.
00083                 neuron2->addDendrite(c);
00084 
00085                 mConnections.push_back(c);
00086         }
00087 }

Generated on Tue Jan 24 21:46:37 2006 for Verve by  doxygen 1.4.6-NO