1 /*****************************************************************************
2   FILE           : $Source: /projects/higgs1/SNNS/CVS/SNNS/kernel/sources/glob_typ.h,v $
3   SHORTNAME      :
4   SNNS VERSION   : 4.2
5 
6   PURPOSE        : SNNS-Kernel: Global Datatypes and Constants
7   NOTES          : For User's Application Programs, User-Interface and Kernel
8 
9   AUTHOR         : Niels Mache
10   DATE           : 14.02.90
11 
12   CHANGED BY     : Michael Vogt, Guenter Mamier, Sven Doering, Christine Bagdi
13   RCS VERSION    : $Revision: 2.31 $
14   LAST CHANGE    : $Date: 1998/04/20 11:54:49 $
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 #ifndef KR_GLOBAL_TYPES
21 #define KR_GLOBAL_TYPES
22 
23 #include <stdio.h>
24 
25 #ifdef ultrix
26    /* DEC's pseudo ansi C-compiler doesn't understand const  */
27 #  define const
28 #endif
29 
30 
31 #ifndef __BORLANDC__
32 
33 
34 
35 /*  define MASPAR_KERNEL to build the parallel MasPar Kernel
36 */
37 /*
38 #define MASPAR_KERNEL
39 */
40 
41 #endif
42 
43 #ifdef MASPAR_KERNEL
44 
45 /*  define MASPAR_KERNEL_EMULATION to build a (sequentiel) kernel that simulates
46     the MasPar interface
47 */
48 /*
49 #define  MASPAR_KERNEL_EMULATION
50 */
51 
52 /*
53 #define  KERNEL_VERBOSE
54 */
55 
56 #endif
57 
58 
59 /* ******************************************   */
60 
61 #ifndef TRUE
62 #define     TRUE    1
63 #endif
64 #ifndef FALSE
65 #define     FALSE   0
66 #endif
67 
68 /*#################################################
69 
70 GROUP: Public Constants
71 
72 #################################################*/
73 
74 /*  Kernel user interface error codes
75 */
76 #define  KRERR_NO_ERROR         0
77 #define  KRERR_INSUFFICIENT_MEM -1
78 #define  KRERR_UNIT_NO          -2
79 #define  KRERR_OUTFUNC          -3
80 #define  KRERR_ACTFUNC          -4
81 #define  KRERR_SITEFUNC         -5
82 #define  KRERR_CREATE_SITE      -6
83 #define  KRERR_ALREADY_CONNECTED  -7
84 #define  KRERR_CRITICAL_MALLOC  -8
85 #define  KRERR_FTYPE_NAME       -9
86 #define  KRERR_FTYPE_ENTRY      -10
87 #define  KRERR_COPYMODE         -11
88 #define  KRERR_NO_SITES         -12
89 #define  KRERR_FROZEN           -13
90 #define  KRERR_REDEF_SITE_NAME  -14
91 #define  KRERR_UNDEF_SITE_NAME  -15
92 #define  KRERR_NOT_3D           -16
93 #define  KRERR_DUPLICATED_SITE  -17
94 #define  KRERR_INUSE_SITE       -18
95 #define  KRERR_FTYPE_SITE       -19
96 #define  KRERR_FTYPE_SYMBOL     -20
97 #define  KRERR_IO               -21
98 #define  KRERR_SAVE_LINE_LEN    -22
99 #define  KRERR_FEW_LAYERS       -23
100 #define  KRERR_NO_UNITS         -24
101 #define  KRERR_EOF              -25
102 #define  KRERR_LINE_LENGTH      -26
103 #define  KRERR_FILE_FORMAT      -27
104 #define  KRERR_FILE_OPEN        -28
105 #define  KRERR_FILE_SYNTAX      -29
106 #define  KRERR_MALLOC1          -30
107 #define  KRERR_TTYPE            -31
108 #define  KRERR_SYMBOL           -32
109 #define  KRERR_NO_SUCH_SITE     -33
110 #define  KRERR_NO_HIDDEN_UNITS  -34
111 #define  KRERR_CYCLES           -35
112 #define  KRERR_DEAD_UNITS       -36
113 #define  KRERR_INPUT_PATTERNS   -37
114 #define  KRERR_OUTPUT_PATTERNS  -38
115 #define  KRERR_CHANGED_I_UNITS  -39
116 #define  KRERR_CHANGED_O_UNITS  -40
117 #define  KRERR_NO_INPUT_UNITS   -41
118 #define  KRERR_NO_OUTPUT_UNITS  -42
119 #define  KRERR_NO_PATTERNS      -43
120 #define  KRERR_INCORE_PATTERNS  -44
121 #define  KRERR_PATTERN_NO       -45
122 #define  KRERR_LEARNING_FUNC    -46
123 #define  KRERR_PARAMETERS       -47
124 #define  KRERR_UPDATE_FUNC      -48
125 #define  KRERR_INIT_FUNC        -49
126 #define  KRERR_DERIV_FUNC       -50
127 #define  KRERR_I_UNITS_CONNECT	-51
128 #define  KRERR_O_UNITS_CONNECT	-52
129 #define  KRERR_TOPOMODE 	-53
130 #define  KRERR_LEARNING_SITES   -54
131 #define  KRERR_SITES_NO_SUPPORT -55
132 #define  KRERR_NO_MASPAR_KERNEL -56
133 #define  KRERR_NOT_NEIGHBOUR_LAYER -57
134 #define  KRERR_MUCH_LAYERS      -58
135 #define  KRERR_NOT_FULLY_CONNECTED -59
136 #define  KRERR_MODE_FF1_INVALID_OP -60
137 #define  KRERR_NET_TRANSFORM    -61
138 #define  KRERR_NO_CURRENT_LINK	-62
139 #define  KRERR_NO_CURRENT_UNIT	-63
140 #define  KRERR_UNIT_NO_INPUTS	-64
141 #define  KRERR_TOPO_DEFINITION	-65
142 #define  KRERR_BAD_CONNECTION   -66
143 #define  KRERR_MASPAR_NO_RESPOND -67
144 #define  KRERR_NOT_IMPEMENTED_YET -68
145 #define  KRERR_NOT_PARALLEL_MODE  -69
146 #define  KRERR_MASPAR_OUT_OF_PE_MEM -70
147 #define  KRERR_MASPAR_COMMUNICATE -71
148 #define  KRERR_MASPAR_OUT_OF_PE   -72
149 #define  KRERR_MISSING_DEFAULT_FUNC  -73
150 #define  KRERR_MASPAR_MULTI_OUT_FUNC -74
151 #define  KRERR_MASPAR_MULTI_ACT_FUNC -75
152 #define  KRERR_NET_DEPTH        -76
153 #define  KRERR_NO_OF_UNITS_IN_LAYER         -77
154 #define  KRERR_UNIT_MISSING                 -78
155 #define  KRERR_UNDETERMINED_UNIT            -79
156 #define  KRERR_ACT_FUNC                     -80
157 #define  KRERR_OUT_FUNC                     -81
158 #define  KRERR_SITE_FUNC                    -82
159 #define  KRERR_UNEXPECTED_SITES             -83
160 #define  KRERR_UNEXPECTED_DIRECT_INPUTS     -84
161 #define  KRERR_SITE_MISSING                 -85
162 #define  KRERR_UNEXPECTED_LINK              -86
163 #define  KRERR_LINK_MISSING                 -87
164 #define  KRERR_LINK_TO_WRONG_SITE           -88
165 #define  KRERR_TOPOLOGY                     -89
166 #define  KRERR_PARAM_BETA                   -90
167 #define  KRERR_CC_ERROR1                    -91
168 #define  KRERR_CC_ERROR2                    -92
169 #define  KRERR_CC_ERROR3                    -93
170 #define  KRERR_CC_ERROR4                    -94
171 #define  KRERR_CC_ERROR5                    -95
172 #define  KRERR_CC_ERROR6                    -96
173 #define  KRERR_CC_ERROR7                    -97
174 #define  KRERR_CC_ERROR8                    -98
175 #define  KRERR_CC_ERROR9                    -99
176 #define  KRERR_CC_ERROR10                  -100
177 #define  KRERR_CC_ERROR11                  -101
178 #define  DLVQ_ERROR1                       -102
179 #define  DLVQ_ERROR2                       -103
180 #define  DLVQ_ERROR3                       -104
181 #define  DLVQ_ERROR4                       -105
182 #define  DLVQ_ERROR5                       -106
183 #define  KRERR_NP_NO_MORE_ENTRIES          -107
184 #define  KRERR_NP_NO_SUCH_PATTERN_SET      -108
185 #define  KRERR_NP_NO_CURRENT_PATTERN       -109
186 #define  KRERR_NP_DIMENSION                -110
187 #define  KRERR_NP_NO_SUCH_PATTERN          -111
188 #define  KRERR_NP_NO_CURRENT_PATTERN_SET   -112
189 #define  KRERR_NP_DOES_NOT_FIT             -113
190 #define  KRERR_NP_NO_TRAIN_SCHEME          -114
191 #define  KRERR_NP_NO_OUTPUT_PATTERN        -115
192 #define  KRERR_NP_INCOMPATIBLE_NEW         -116
193 #define  KRERR_IP_ISNOTINITED              -117
194 #define  KRERR_IP_ISINITED                 -118
195 #define  KRERR_IP_SENDMSGFAILED            -119
196 #define  KRERR_IP_MSGSYNTAX                -120
197 #define  KRERR_IP_UNKNOWENCMD              -121
198 #define  KRERR_IP_LESSPAT                  -122
199 #define  KRERR_IP_WEIGHTUPDATE             -123
200 #define  KRERR_IP_LEARNFNOTPAR             -124
201 /* codes 125 to 129 belonged to delted rpc sources */
202 #define  KRERR_NP_WORKAROUND               -130
203 #define  DDA_PARAM_ONE                     -131
204 #define  DDA_PARAM_TWO                     -132
205 #define  DDA_PARAM_THREE                   -133
206 #define  DDA_DESIRED_CLASS                 -134
207 #define  DDA_CONN_POINTER                  -135
208 #define  DDA_SHORTCUTS                     -136
209 #define  DDA_INPUT_ACT_FUNC                -137
210 #define  DDA_HIDDEN_ACT_FUNC               -138
211 #define  DDA_OUTPUT_ACT_FUNC               -139
212 #define  KRERR_CC_INVALID_ADD_PARAMETERS   -140
213 #define  KRERR_UPS_ACT_NOT_THRESHOLD       -141
214 #define  KRERR_UPS_LEARN_NOT_BACKPROP      -142
215 #define  KRERR_SINGLE_CLASS                -143
216 #define  KRERR_REMAP_FUNC                  -144
217 #define  KRERR_NO_CLASSES                  -145
218 #define  KRERR_ILL_CLASS_DISTRIB           -146
219 #define  KRERR_CANT_NORM                   -147
220 
221 /*  Function types
222 */
223 #define  OUT_FUNC        1
224 #define  ACT_FUNC        2
225 #define  SITE_FUNC       3
226 #define  LEARN_FUNC      4
227 #define  UPDATE_FUNC     5
228 #define  INIT_FUNC       6
229 #define  ACT_DERIV_FUNC  7
230 #define  JOG_WEIGHT_FUNC 8
231 #define  ACT_2_DERIV_FUNC 9
232 #define  PRUNING_FUNC    10
233 #define  TEST_FUNC       11
234 #define  REMAP_FUNC       12
235 
236 #define  FUNC_TYPE_MASK  0x00ff
237 #define  DEFAULT_FUNC    0x0100
238 #define  BENCH_FUNC      0x0200
239 #define  FF_LEARN_FUNC   0x0400          /* used by pruning algorithms */
240 
241 
242 
243 /*   entry types for name table
244 */
245 #define  UNUSED_SYM         0
246 #define  UNIT_SYM           1
247 #define  SITE_SYM           2
248 #define  FTYPE_UNIT_SYM     3
249 
250 /* constants for the network-analyzer tool
251 */
252 
253 #define MAX_ARRAY_SIZE 5000
254 #define NA_ERROR_LIN      1
255 #define NA_ERROR_SQR      2
256 #define NA_ERROR_SU       3
257 
258 /*  Copy Modes
259 */
260 #define  INPUTS_AND_OUTPUTS     1
261 #define  ONLY_INPUTS            2
262 #define  ONLY_OUTPUTS           3
263 #define  ONLY_UNIT              4
264 
265 
266 /*  Topological Unit Types
267 */
268 #define  UNKNOWN    0
269 #define  INPUT      1
270 #define  OUTPUT     2
271 #define  HIDDEN     3
272 #define  DUAL       4
273 #define  SPECIAL    5
274 #define  SPECIAL_I  6
275 #define  SPECIAL_O  7
276 #define  SPECIAL_H  8
277 #define  SPECIAL_D     9
278 #define  SPECIAL_X    10 /* Only used for toggle special flag */
279 #define  N_SPECIAL_X  11 /* Only used for toggle special flag */
280 
281 /*  Unit Input Types
282 */
283 #define  NO_INPUTS      0
284 #define  SITES          1
285 #define  DIRECT_LINKS   2
286 
287 /*  Pattern update modes
288 */
289 #define  OUTPUT_NOTHING  1
290 #define  OUTPUT_ACT      2
291 #define  OUTPUT_OUT      3
292 
293 /*  Maximum number of pattern sets
294 */
295 #define  NO_OF_PAT_SETS 5
296 
297 /*  Maximum Dimensions of Pattern
298 */
299 #define MAX_NO_OF_VAR_I_DIM     2  /* maximum number of variable input       */
300 				   /* dimensions                             */
301 #define MAX_NO_OF_VAR_O_DIM     2  /* maximum number of variable             */
302 				   /* output dimensions                      */
303 #define MAX_NO_OF_VAR_DIM       2  /* maximum of MAX_NO_OF_VAR_I_DIM         */
304 				   /* MAX_NO_OF_VAR_O_DIM                    */
305 
306 /*  Maximum no. of learning parameters for learning functions
307 */
308 #define     NO_OF_LEARN_PARAMS	28
309 
310 /*  Maximum no. of results from the learning functions
311 */
312 #define     NO_OF_RESULTS	10
313 
314 /*  Maximum no. of stored error from the learning functions
315 */
316 #define     NO_OF_STORED_ERRORS	50
317 
318 /*  Maximum no. of init parameters for initialization functions
319 */
320 #define     NO_OF_INIT_PARAMS   10
321 
322 /*  Maximum no. of update parameters for update functions
323 */
324 #define     NO_OF_UPDATE_PARAMS   10
325 
326 /*  Maximum no. of parameters for pattern remap functions
327 */
328 #define     NO_OF_REMAP_PARAMS   5
329 
330 
331 
332 
333 /*  Translation Table op's
334 */
335 #define     OP_TRANSTABLE_GET           1
336 #define     OP_TRANSTABLE_SET           2
337 #define     OP_TRANSTABLE_CLEAR         3
338 
339 
340 
341 /*#################################################
342 
343 GROUP: Global Var's
344 
345 #################################################*/
346 
347 /*  Kernel Interface Error Code
348 */
349 #ifndef SNNS_KERNEL
350 extern int  KernelErrorCode;
351 #endif
352 
353 /*#################################################
354 
355 GROUP: Global Datatypes
356 
357 #################################################*/
358 
359 typedef int     bool;
360 typedef float   FlintType;
361 typedef int     krui_err;
362 
363 
364 typedef struct
365 {
366     double parameter[NO_OF_LEARN_PARAMS];
367     /*  UI_NO_OF_CASCADE_PARAMS is declared in ui.h the learn parameter     */
368     int noOfParameters;                      /* number of learn parameters  */
369     char **parameterDescription;             /* not supported yet           */
370     double result[NO_OF_RESULTS];            /* the result of training      */
371     int noOfResults;                         /* number of results           */
372     int firstPattern;                        /* the first pattern to train  */
373     int lastPattern;                         /* the last pattern to train   */
374     int noOfEpochs;                          /* number of epochs to learn   */
375     double learnErrors[NO_OF_STORED_ERRORS]; /* stores the Error            */
376     int atEpoch[NO_OF_STORED_ERRORS];        /* the epoch for the error     */
377     int noOfErrors;                          /* the number of stored errrors*/
378     float netError;                          /* the last net error          */
379     int   lastEpoch;                         /* the last epoch learned      */
380     bool interrupted;                        /* marks if all epochs learned */
381 } NetLearnParameters;
382 
383 typedef struct
384 {
385     int number_of_pattern;     /* the number of pattern (pairs) in           */
386                                /* this set                                   */
387     int virtual_no_of_pattern; /* the number of pattern (pairs) if           */
388                                /* class_distrib_active == TRUE               */
389     bool output_present;       /* TRUE if output pattern present             */
390     bool fixed_fixsizes;       /* the fixsizes of all pattern are equal      */
391     int in_fixsize;            /* if fixed_fixsizes TRUE, fixsize of         */
392                                /* the input pattern, else -1                 */
393     int out_fixsize;           /* if fixed_fixsizes TRUE, fixsize of         */
394                                /* the output pattern, else -1                */
395     int in_number_of_dims;     /* number of variable input dimensions        */
396     int out_number_of_dims;    /* number of variable output dimensions       */
397     int in_max_dim_sizes[MAX_NO_OF_VAR_I_DIM];  /* maximum values of         */
398                                                 /* the input dimension       */
399     int out_max_dim_sizes[MAX_NO_OF_VAR_O_DIM]; /* maximum values of the     */
400                                                 /* output dimension          */
401     int in_min_dim_sizes[MAX_NO_OF_VAR_I_DIM];  /* minimum values of the     */
402                                                 /* input dimensions          */
403     int out_min_dim_sizes[MAX_NO_OF_VAR_O_DIM]; /* minimum values of the     */
404                                                 /* output dimensions         */
405 
406     int classes;               /* number of pattern classes if > 0           */
407     char **class_names;        /* array of <classes> class names, ordered    */
408     bool class_distrib_active; /* class amount redistribution is active      */
409     int *class_redistribution; /* amounts for redistrib. <classes> entries   */
410 
411     char *remap_function;      /* name of remap function or NULL             */
412     float remap_params[NO_OF_REMAP_PARAMS];     /* remap function parameters */
413     int no_of_remap_params;    /* number of remap function parameters        */
414 } pattern_set_info;
415 
416 typedef struct
417 {
418     int input_dim;             /* number of variable input dimensions        */
419     int input_dim_sizes[MAX_NO_OF_VAR_I_DIM];  /* actual sizes of the input  */
420                                                /* dimensions                 */
421     int input_fixsize;         /* size of the fixed part of the in pattern   */
422                                /* or 0 if no input pattern present           */
423     int output_dim;            /* number of variable output dimensions       */
424     int output_dim_sizes[MAX_NO_OF_VAR_O_DIM]; /* actual sizes of the output */
425                                                /* dimensions                 */
426     int output_fixsize;        /* size of the fixed part of the out pattern  */
427                                /* or 0 if no output pattern present          */
428     int my_class;              /* class index of this pattern, if classes    */
429                                /* available, -1 otherwise                    */
430 } pattern_descriptor;
431 
432 #ifdef __STDC__
433 typedef double  FlintTypeParam;
434 #else
435 typedef float  FlintTypeParam;
436 #endif
437 
438 
439 
440 /*#################################################
441 
442 GROUP: 3D-Kernel Definitions
443 
444 #################################################*/
445 
446 #define HAVE_QSORT
447 
448 struct   PosType  {
449   short  x,
450 	 y,
451 	 z;
452 };
453 
454 
455 
456 #define  NO_OF_UNIT_CENTER_POS  1
457 
458 struct   PositionVector  {
459   float  x,
460 	 y,
461 	 z,
462 	 w;
463 };
464 
465 
466 /* List of Inversion Units */
467 struct UnitList{
468     int             no;
469     FlintType       act;
470     FlintType       i_act;
471     FlintType       im_act;
472     struct PosType  gridPos;
473     struct UnitList *next;
474     struct UnitList *prev;
475 };
476 
477 /*#################################################
478 
479 GROUP: Constants for the parallel kernel
480 
481 #################################################*/
482 
483 /*  Topologic network types
484 */
485 #define  NET_TYPE_GENERAL  0   /*  normal network presentation, no limitations  */
486 #define  NET_TYPE_FF1      1   /*  feedforward net with limitations  */
487 
488 /*  MasPar modes
489 */
490 #define  MASPAR_DISCONNECT  0
491 #define  MASPAR_CONNECT  1
492 
493 
494 #endif
495