1 /*****************************************************************************
2 FILE : $Source: /projects/higgs1/SNNS/CVS/SNNS/kernel/sources/art_ui.c,v $
3 SHORTNAME :
4 SNNS VERSION : 4.2
5
6 PURPOSE : SNNS-Kernel-User-Interface for ART Networks
7 NOTES :
8
9 AUTHOR : Kai-Uwe Herrmann
10 DATE : 17.05.92
11
12 CHANGED BY : Sven Doering
13 RCS VERSION : $Revision: 2.7 $
14 LAST CHANGE : $Date: 1998/03/03 14:08:18 $
15
16 Copyright (c) 1990-1995 SNNS Group, IPVR, Univ. Stuttgart, FRG
17 Copyright (c) 1996-1998 SNNS Group, WSI, Univ. Tuebingen, FRG
18
19 ******************************************************************************/
20 #include <config.h>
21 #include "kr_typ.h" /* Global Definitions for User Interface */
22 #include "kr_ui.h" /* User Interface - Function Prototypes */
23
24 #include "kr_const.h" /* Global constants for kernel */
25
26 #include "glob_typ.h" /* Global Definitions for User Interface */
27 #include "kernel.h"
28
29 #include "art_typ.h" /* ART Global Definitions */
30 #include "kr_art.h" /* ART Kernel Function Prototypes */
31 #include "kr_art1.h"
32 #include "kr_art2.h"
33 #include "kr_amap.h"
34 #include "krart_df.h" /* ART definitions and Macros */
35 #include "art_ui.h" /* ART User Interface Function Prototypes */
36
37
38
39 /* funcname: artui_GetClassifiedStatus ()
40 Purpose : Returns the classification status of the actual network
41 in-Par : none
42 out-Par : status : Possible results are: ART_NO_CLASSIFICATION
43 ART_CLASSIFIED
44 ART_NOT_CLASSIFIABLE
45 ART_DONT_KNOW
46 ret_val : krui_err: Returns an error if no Units defined
47 */
artui_getClassifiedStatus(art_cl_status * status)48 krui_err artui_getClassifiedStatus (art_cl_status *status)
49 {
50 krui_err ret_code = KRERR_NO_ERROR;
51
52 *status = ART_NO_CLASSIFICATION;
53
54 if (krui_getNoOfUnits() == 0) {
55 ret_code = KRERR_NO_UNITS;
56 return (ret_code);
57 } /*if*/
58
59 /* Check if network has been initialized or update- or learning function
60 has been applied to it. If not, we can not know, which type of ART
61 network this is, so we return, that there has been no classification.
62 */
63 if (NetModified) {
64 return (ret_code);
65 } /*if*/
66
67 switch (TopoSortID) {
68 case ART1_TOPO_TYPE:
69 if (ART1_CLASSIFIED) {
70 *status = ART_CLASSIFIED;
71 } else {
72 if (ART1_NOT_CLASSIFIABLE) {
73 *status = ART_NOT_CLASSIFIABLE;
74 } /*if*/
75 } /*if*/
76 break;
77 case ART2_TOPO_TYPE:
78 if (ART2_CLASSIFIED) {
79 *status = ART_CLASSIFIED;
80 } else {
81 if (ART2_NOT_CLASSIFIABLE) {
82 *status = ART_NOT_CLASSIFIABLE;
83 } /*if*/
84 } /*if*/
85 case ARTMAP_TOPO_TYPE:
86 if (ARTMAP_CLASSIFIED) {
87 if (kram_AllMapUnitsActive()) {
88 *status = ART_DONT_KNOW;
89 } else {
90 *status = ART_CLASSIFIED;
91 } /*if*/
92 } else {
93 if (ARTMAP_NOT_CLASSIFIABLE) {
94 *status = ART_NOT_CLASSIFIABLE;
95 } /*if*/
96 } /*if*/
97 default:
98 break;
99 } /* switch */
100
101 return (ret_code);
102 } /* artui_getClassifiedStatus () */
103
104
105
106
107 /* funcname: artui_getClassNo ()
108 Purpose : Returns the index of the F2-winner-unit
109 in-par : none
110 out-par : class_no : If unit_no is negative, then no winning unit exists.
111 ret-val : krui_err : Returns an error if no Units defined.
112 */
artui_getClassNo(int * class_no)113 krui_err artui_getClassNo (int *class_no)
114 {
115 krui_err ret_code = KRERR_NO_ERROR;
116
117 *class_no = -1;
118
119 if (krui_getNoOfUnits () == 0) {
120 ret_code = KRERR_NO_UNITS;
121 return (ret_code);
122 } /*if*/
123
124 /* Check if network has been initialized or update- or learning function
125 has been applied to it. If not, we can not know, which type of ART
126 network this is, so we return, that there has been no classification.
127 If there is a adequate TopoSortID, then we get the no. of the class,
128 if there has been a classification.
129 */
130
131 if (NetModified) {
132 return (ret_code);
133 } /*if*/
134
135 switch (TopoSortID) {
136 case ART1_TOPO_TYPE:
137 if (ART1_CLASSIFIED) {
138 *class_no = kra1_getClassNo ();
139 } /*if*/
140 break;
141 case ART2_TOPO_TYPE:
142 if (ART2_CLASSIFIED) {
143 *class_no = kra2_getClassNo ();
144 } /*if*/
145 case ARTMAP_TOPO_TYPE:
146 if (ARTMAP_CLASSIFIED && (!kram_AllMapUnitsActive())) {
147 *class_no = kram_getClassNo ();
148 } /*if*/
149 default:
150 break;
151 } /* switch */
152
153 return (ret_code);
154 } /* artui_getClassNo () */
155
156
157
158 /* funcname: artui_getN ()
159 Purpose : Returns the number of F1-units in an ART1 or ART2 network
160 in-par : none
161 out-par : N : number of F1-Units (-1 is returned if not topologically sorted)
162 ret-val : krui_err: Returns an error if no Units defined.
163 */
artui_getN(int * N)164 krui_err artui_getN (int *N)
165 {
166 krui_err ret_code = KRERR_NO_ERROR;
167
168 *N = -1;
169
170 if (krui_getNoOfUnits() == 0) {
171 ret_code = KRERR_NO_UNITS;
172 return (ret_code);
173 } /*if*/
174
175 if (NetModified) {
176 return (ret_code);
177 } /*if*/
178
179 if ((TopoSortID == ART1_TOPO_TYPE) || (TopoSortID == ART2_TOPO_TYPE)) {
180 *N = NoOfInputUnits;
181 } /*if*/
182
183 return (ret_code);
184 } /* artui_getN () */
185
186
187 /* funcname: artui_getM ()
188 Purpose : Returns the number of F2-units in an ART1 or ART2 network
189 in-par : none
190 out-par : M : number of F2-Units (-1 is returned if not topologically sorted)
191 ret-val : krui_err: Returns an error if no Units defined.
192 */
artui_getM(int * M)193 krui_err artui_getM (int *M)
194 {
195 krui_err ret_code = KRERR_NO_ERROR;
196
197 *M = -1;
198
199 if (krui_getNoOfUnits() == 0) {
200 ret_code = KRERR_NO_UNITS;
201 return (ret_code);
202 } /*if*/
203
204 if (NetModified) {
205 return (ret_code);
206 } /*if*/
207
208 switch (TopoSortID) {
209 case ART1_TOPO_TYPE:
210 *M = Art1_NoOfRecUnits;
211 break;
212 case ART2_TOPO_TYPE:
213 *M = Art2_NoOfRecUnits;
214 break;
215 } /*switch*/
216
217 return (ret_code);
218 } /* artui_getM () */
219
220
221
222 /* funcname: artui_getNa ()
223 Purpose : Returns the number of F1a-units in an ARTMAP network
224 in-par : none
225 out-par : Na: number of F1a-Units (-1 is returned if not topologically sorted)
226 ret-val : krui_err: Returns an error if no Units defined.
227 */
artui_getNa(int * Na)228 krui_err artui_getNa (int *Na)
229 {
230 krui_err ret_code = KRERR_NO_ERROR;
231
232 *Na = -1;
233
234 if (krui_getNoOfUnits() == 0) {
235 ret_code = KRERR_NO_UNITS;
236 return (ret_code);
237 } /*if*/
238
239 if (NetModified) {
240 return (ret_code);
241 } /*if*/
242
243 if (TopoSortID == ARTMAP_TOPO_TYPE) {
244 *Na = ArtMap_NoOfInpUnits_a;
245 } /*if*/
246
247 return (ret_code);
248 } /* artui_getNa () */
249
250
251
252
253 /* funcname: artui_getNb ()
254 Purpose : Returns the number of F1b-units in an ARTMAP network
255 in-par : none
256 out-par : Nb: number of F1b-Units (-1 is returned if not topologically sorted)
257 ret-val : krui_err: Returns an error if no Units defined.
258 */
artui_getNb(int * Nb)259 krui_err artui_getNb (int *Nb)
260 {
261 krui_err ret_code = KRERR_NO_ERROR;
262
263 *Nb = -1;
264
265 if (krui_getNoOfUnits() == 0) {
266 ret_code = KRERR_NO_UNITS;
267 return (ret_code);
268 } /*if*/
269
270 if (NetModified) {
271 return (ret_code);
272 } /*if*/
273
274 if (TopoSortID == ARTMAP_TOPO_TYPE) {
275 *Nb = ArtMap_NoOfInpUnits_b;
276 } /*if*/
277
278 return (ret_code);
279 } /* artui_getNb () */
280
281
282
283
284 /* funcname: artui_getMa ()
285 Purpose : Returns the number of F2a-units in an ARTMAP network
286 in-par : none
287 out-par : Ma: number of F2a-Units (-1 is returned if not topologically sorted)
288 ret-val : krui_err: Returns an error if no Units defined.
289 */
artui_getMa(int * Ma)290 krui_err artui_getMa (int *Ma)
291 {
292 krui_err ret_code = KRERR_NO_ERROR;
293
294 *Ma = -1;
295
296 if (krui_getNoOfUnits() == 0) {
297 ret_code = KRERR_NO_UNITS;
298 return (ret_code);
299 } /*if*/
300
301 if (NetModified) {
302 return (ret_code);
303 } /*if*/
304
305 if (TopoSortID == ARTMAP_TOPO_TYPE) {
306 *Ma = ArtMap_NoOfRecUnits_a;
307 } /*if*/
308
309 return (ret_code);
310 } /* artui_getMa () */
311
312
313
314 /* funcname: artui_getMb ()
315 Purpose : Returns the number of F2b-units in an ARTMAP network
316 in-par : none
317 out-par : Mb: number of F2b-Units (-1 is returned if not topologically sorted)
318 ret-val : krui_err: Returns an error if no Units defined.
319 */
artui_getMb(int * Mb)320 krui_err artui_getMb (int *Mb)
321 {
322 krui_err ret_code = KRERR_NO_ERROR;
323
324 *Mb = -1;
325
326 if (krui_getNoOfUnits() == 0) {
327 ret_code = KRERR_NO_UNITS;
328 return (ret_code);
329 } /*if*/
330
331 if (NetModified) {
332 return (ret_code);
333 } /*if*/
334
335 if (TopoSortID == ARTMAP_TOPO_TYPE) {
336 *Mb = ArtMap_NoOfRecUnits_b;
337 } /*if*/
338
339 return (ret_code);
340 } /* artui_getMb () */
341