libbio
Loading...
Searching...
No Matches
Neuron.h
Go to the documentation of this file.
1/*
2 * This file is a part of the Biology project by eons LLC.
3 * Biology (aka Develop Biology) is a framework for approaching software
4 * development from a natural sciences perspective.
5 *
6 * Copyright (C) 2022 Séon O'Shannon & eons LLC
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "Synapse.h"
25#include "bio/neural/Impulse.h"
27
28namespace bio {
29namespace neural {
30
45class Neuron :
46 public neural::Class< Neuron >,
47 public StemCell,
48 public Covalent< chemical::LinearMotif< Impulse > >,
49 public Covalent< chemical::LinearMotif< Dendrite > >, //Neurite
50 public Covalent< chemical::LinearMotif< Axon > > //Neurite
51{
52public:
53
59
61 neural,
62 Neuron,
63 filter::Neural()
64 )
65
66 virtual ~Neuron();
67
68 //START: Recommended overrides
69
70 /*
71 * These are the most important methods for every Neuron.
72 * However, they may not all be required for your Neuron.
73 */
74
80
86
92 {
93
94 // YOUR CODE GOES HERE
95
96 return false;
97 }
98
99 // The above can also be accessed through the Impulse methods, below.
100
104 virtual void PreCrest();
105
106 //END: Recommended overrides
107
117 virtual void Learn();
118
119 //START: Impulses
120
121 /*
122 * ______Impulse() methods are called by DetermineAndCallImpulseTriggers(). <br />
123 * It is up to children of *this to determine what these methods do. <br />
124 * NOTE: Impulses should not set the FiringCondition, which is returned by GetReasonForFiring. Only DetermineImpulseTriggers() will do that. <br />
125 * If you would like to make your own Impulses, use the CreateImpulse() method and populate a molecular::Protein of the given Name. <br />
126 */
127
128 /*
129 * The default Impulses are: "RisingEdge" Called if newly activated. <br />
130 * "Continuing" Called if active and previously active. <br />
131 * "FallingEdge" Called when *this stops being active. <br />
132 */
133
139
143 void StartAtRisingEdge();
144
145 /*
146 * What "active" means is up to each Neuron to determine for itself. For example, a sensor may be active when a significant amount of stimulus is received, whereas a behavior may be active whenever it makes a call to an actuator. <br />
147 * When a Neuron is not sending continuing impulses, it will be considered active until proven otherwise (e.g. falling edge is sent). In such a case, GetTimeLastActive() will return the current timestamp. <br />
148 * NOTE: if a Neuron is not sending continuing impulses, ActiveUntil will not trigger a falling edge at the indicated time. The methods below are for reporting only and do not affect operation. <br />
149 * For how to keep a Neuron active for a time after an initial stimulus, see PersistFor or PersistUntil (below). <br />
150 * NOTE: activity may also by checked & modified through States. For example, this->Has< State >(::bio::state::Active()). <br />
151 */
152
156 void ActiveNow();
157
162 void ActiveUntil(Timestamp time);
163
169
174 bool IsActive() const;
175
181
189 void CreateImpulse(
191 const Name& impulseName,
192 bool shouldBeActive = true
193 );
194
201
206 bool IsPersisting(const Timestamp now) const;
207
211 bool IsPersisting() const
212 {
214 }
215
216 //END: Impulses
217
218 //START: Configuration/Settings
219 /*
220 * Neurons may stay active (persist) for a given amount of time after their excite trigger. <br />
221 * Calling Persist___() will result in *this remaining active for the indicated time. <br />
222 * Once *this is no longer persisting, FallingEdge will be called. <br />
223 * NOTE: Persistence requires the continuing impulses only set Active___() if and only if ExciteTrigger() is true (as should always be the case). <br />
224
225 * FIXME: PersistUntil needs to only be applied once.
226 * FIXME: Is this even a useful feature?
227 */
228
233 void PersistFor(const Milliseconds ms);
234
239 void PersistUntil(const Timestamp time);
240
241 //END: Configuration/Settings
242
243
244 //START: Synapses
245
259 );
260
267
272 virtual void PreSend();
273
279
284 virtual void PostSend();
285
292
299
306
313
331
332 //END: Synapses
333
334 //START: These are not for you.
335
340 virtual bool CheckIn();
341
346 virtual Code Crest();
347
352 virtual Code Apoptose();
353
354 //END: These are not for you.
355
356protected:
357
358 virtual void CommonConstructor();
359
370
378 virtual bool DetermineImpulseTriggers(bool trigger);
379
385
391
397
403
404private:
405 Timestamp mLastActive;
406
407 FiringCondition mFiringReason;
408
412 bool mContinuingImpulse;
413
417 Milliseconds mPersistFor;
418};
419
420} //neural namespace
421} //bio namespace
#define BIO_DISAMBIGUATE_REQUIRED_CLASS_METHODS(ns, caller)
Definition ClassMethodMacros.h:73
#define BIO_DISAMBIGUATE_OPTIONAL_CLASS_METHODS(ns, caller)
Definition ClassMethodMacros.h:93
#define BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS_WITH_COMMON_CONSTRUCTOR(ns, class,...)
Definition chemical/macro/ConstructorMacros.h:65
Definition Covalent.h:42
Definition Pointer.h:115
Definition String.h:55
Definition neural/common/Class.h:42
Definition Neuron.h:51
Index PruneAllSynapses()
Definition Neuron.cpp:780
Index DetachAllSynapsesTopologyNoDelete()
Definition Neuron.cpp:667
Pointer< molecular::Protein > mcContinuing
Definition Neuron.h:364
virtual void PreCrest()
Definition Neuron.cpp:310
Pointer< molecular::Protein > mcFallingEdge
Definition Neuron.h:365
virtual void ProcessDendrites(Pointer< ::bio::Affinity > selection=NULL)
Definition Neuron.cpp:1143
bool IsPersisting() const
Definition Neuron.h:211
void PersistUntil(const Timestamp time)
Definition Neuron.cpp:421
void ActiveUntil(Timestamp time)
Definition Neuron.cpp:435
virtual Code Apoptose()
Definition Neuron.cpp:300
Index DetachIncomingSynapsesTopologyNoDelete()
Definition Neuron.cpp:554
virtual Code CreateDefaultProteins()
Definition Neuron.cpp:278
Pointer< molecular::Protein > mcPreSend
Definition Neuron.h:367
virtual void Learn()
Definition Neuron.cpp:454
void RequestProcessingOf(Pointer< Dendrite > dendrite)
Definition Neuron.cpp:888
virtual Code CacheProteins()
Definition Neuron.cpp:288
virtual bool CheckIn()
Definition Neuron.cpp:315
virtual bool DetermineImpulseTriggers(bool trigger)
Definition Neuron.cpp:1088
virtual Code Crest()
Definition Neuron.cpp:305
Pointer< molecular::Protein > mcRisingEdge
Definition Neuron.h:363
virtual void PotentiateDendrite(Pointer< Dendrite > dendrite)
Definition Neuron.cpp:908
virtual Code ProcessDendrite(Pointer< Dendrite > dendrite)
Definition Neuron.cpp:1119
Pointer< molecular::Protein > mcPreCrest
Definition Neuron.h:366
virtual bool ExciteTrigger() const
Definition Neuron.h:91
bool DetermineAndCallImpulseTriggers()
Definition Neuron.cpp:374
virtual Code Transmit(Pointer< ::bio::Affinity > selection=NULL)
Definition Neuron.cpp:1022
virtual void PreSend()
Definition Neuron.cpp:1017
Pointer< molecular::Protein > mcLearn
Definition Neuron.h:369
void ActiveNow()
Definition Neuron.cpp:426
virtual void PostSend()
Definition Neuron.cpp:1061
virtual void DepotentiateDendrite(Pointer< Dendrite > dendrite)
Definition Neuron.cpp:963
void UpdateImpulseCallers()
Definition Neuron.cpp:343
bool IsActive() const
Definition Neuron.cpp:449
void PersistFor(const Milliseconds ms)
Definition Neuron.cpp:416
Pointer< Synapse > ConnectTo(Pointer< Neuron > target, Pointer< const Synapse > synapseType)
Definition Neuron.cpp:459
Index DetachOutgoingSynapsesTopologyNoDelete()
Definition Neuron.cpp:601
void CreateImpulse(const FiringCondition &trigger, const Name &impulseName, bool shouldBeActive=true)
Definition Neuron.cpp:355
Pointer< molecular::Protein > mcPostSend
Definition Neuron.h:368
virtual Code DepotentiateSentData(Pointer< ::bio::Affinity > selection=NULL)
Definition Neuron.cpp:1066
FiringCondition GetReasonForFiring() const
Definition Neuron.cpp:401
Timestamp GetTimeLastActive() const
Definition Neuron.cpp:440
void StartAtRisingEdge()
Definition Neuron.cpp:406
virtual void CommonConstructor()
Definition Neuron.cpp:33
Definition StemCell.h:47
Timestamp GetCurrentTimestamp()
Definition Time.cpp:46
Definition FinalCell.h:29
uint32_t Index
Definition common/container/common/Types.h:31
uint64_t Timestamp
Definition common/Types.h:52
uint64_t Milliseconds
Definition common/Types.h:64