Debian Codegraph @

gram/Network_def.h

raw
1 /* Network_def.h
2 *
3 * Copyright (C) 2009-2020,2022 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20 #define ooSTRUCT NetworkNode
21 oo_DEFINE_STRUCT (NetworkNode)
22
23 oo_DOUBLE (x)
24 oo_DOUBLE (y)
25 oo_BOOLEAN (clamped)
26 oo_DOUBLE (activity)
27
28 #if ! oo_READING && ! oo_WRITING && ! oo_COMPARING
29 oo_DOUBLE (excitation)
30 #endif
31
32 oo_END_STRUCT (NetworkNode)
33 #undef ooSTRUCT
34
35
36 #define ooSTRUCT NetworkConnection
37 oo_DEFINE_STRUCT (NetworkConnection)
38
39 oo_INTEGER (nodeFrom)
40 oo_INTEGER (nodeTo)
41 oo_DOUBLE (weight)
42
43 oo_FROM (1)
44 oo_DOUBLE (plasticity)
45 oo_ENDFROM
46 #if oo_READING
47 oo_VERSION_UNTIL (1)
48 our plasticity = 1.0;
49 oo_VERSION_END
50 #endif
51
52 oo_END_STRUCT (NetworkConnection)
53 #undef ooSTRUCT
54
55
56 #define ooSTRUCT Network
57 oo_DEFINE_CLASS (Network, Daata)
58
59 oo_DOUBLE (minimumActivity)
60 oo_DOUBLE (maximumActivity)
61 oo_FROM (3)
62 oo_BYTE (dummyActivitySpreadingRule)
63 oo_ENDFROM
64 oo_FROM (4)
65 oo_DOUBLE (shunting)
66 oo_ENUM (kNetwork_activityClippingRule, activityClippingRule)
67 oo_ENDFROM
68 oo_DOUBLE (spreadingRate)
69 oo_DOUBLE (activityLeak)
70 oo_DOUBLE (minimumWeight)
71 oo_DOUBLE (maximumWeight)
72 oo_FROM (2)
73 oo_BYTE (dummyWeightUpdateRule)
74 oo_ENDFROM
75 oo_DOUBLE (learningRate)
76 oo_FROM (5)
77 oo_DOUBLE (instar)
78 oo_DOUBLE (outstar)
79 oo_ENDFROM
80 oo_DOUBLE (weightLeak)
81
82 #if oo_READING
83 oo_VERSION_UNTIL (5)
84 if (our learningRate != 0.0)
85 our weightLeak /= our learningRate;
86 if (our dummyWeightUpdateRule == 1) {
87 our instar = 1.0;
88 our outstar = 0.0;
89 }
90 if (our dummyWeightUpdateRule == 2) {
91 our instar = 0.0;
92 our outstar = 1.0;
93 }
94 if (our dummyWeightUpdateRule == 3) {
95 our instar = 0.5;
96 our outstar = 0.5;
97 }
98 oo_VERSION_END
99 oo_VERSION_UNTIL (6)
100 our activityLeak = - our activityLeak; // convert self-excitation to activity leak
101 oo_VERSION_END
102 #endif
103
104 oo_DOUBLE (xmin)
105 oo_DOUBLE (xmax)
106 oo_DOUBLE (ymin)
107 oo_DOUBLE (ymax)
108 oo_INTEGER (numberOfNodes)
109 oo_STRUCTVEC (NetworkNode, nodes, numberOfNodes)
110 oo_INTEGER (numberOfConnections)
111 oo_STRUCTVEC (NetworkConnection, connections, numberOfConnections)
112
113 #if oo_DECLARING
114 void v1_info ()
115 override;
116 void checkNodeNumber (integer nodeNumber) {
117 Melder_require (nodeNumber >= 1 && nodeNumber <= our numberOfNodes,
118 this, U": node number (", nodeNumber, U") out of the range 1..", our numberOfNodes, U".");
119 }
120 integer checkAndDefaultNodeRange (integer *p_fromNode, integer *p_toNode) {
121 if (*p_fromNode == 0)
122 *p_fromNode = 1;
123 if (*p_toNode == 0)
124 *p_toNode = our numberOfNodes;
125 Melder_require (*p_fromNode >= 1 && *p_fromNode <= our numberOfNodes,
126 this, U": from-node number (", *p_fromNode, U") out of the range 1..", our numberOfNodes, U".");
127 Melder_require (*p_toNode >= 1 && *p_toNode <= our numberOfNodes,
128 this, U": to-node number (", *p_toNode, U") out of the range 1..", our numberOfNodes, U".");
129 return *p_toNode - *p_fromNode + 1;
130 }
131 #endif
132
133 oo_END_CLASS (Network)
134 #undef ooSTRUCT
135
136
137 /* End of file Network_def.h */