home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- **** ****
- **** atree.h ****
- **** ****
- **** Copyright (C) A. Dwelly and W.W. Armstrong, 1990. ****
- **** ****
- **** All rights reserved. ****
- **** ****
- **** This is the include file for the "research" version of the adaptive ****
- **** logic network package based on work done by Prof. W. W. Armstrong ****
- **** and others in the Department of Computing Science, University of ****
- **** Alberta, and previous work at the Universite de Montreal, and at ****
- **** AT&T Bell Laboratories, Holmdel, N. J. The software demonstrates ****
- **** that networks consisting of many layers of linear threshold ****
- **** elements can indeed be effectively trained. ****
- **** ****
- **** License: ****
- **** A royalty-free license is granted for the use of this software for ****
- **** NON-COMMERCIAL PURPOSES ONLY. The software may be copied and ****
- **** modified provided this notice appears in its entirety and unchanged ****
- **** in all copies, whether changed or not. Persons modifying the code ****
- **** are requested to state the date, the changes made and who made them ****
- **** in the modification history. ****
- **** ****
- **** Warranty: ****
- **** No warranty of any kind is provided with this software. ****
- **** This software is not supported. Neither the authors, nor the ****
- **** University of Alberta, its officers, agents, servants or employees ****
- **** shall be liable or responsible in any way for any damage to ****
- **** property or direct personal or consequential injury of any nature ****
- **** whatsoever that may be suffered or sustained by any licensee, user ****
- **** or any other party as a consequence of the use or disposition of ****
- **** this software. ****
- **** ****
- **** Patent: ****
- **** The use of a digital circuit which transmits a signal indicating ****
- **** heuristic responsibility is protected by U. S. Patent 3,934,231 ****
- **** and others assigned to Dendronic Decisions Limited of Edmonton, ****
- **** W. W. Armstrong, President. ****
- **** ****
- **** A royalty-free license is granted for the use of this patent to ****
- **** run this software for NON-COMMERCIAL PURPOSES ONLY and the ****
- **** extension of this patent license to modified versions of this ****
- **** software is granted provided the purpose is NON-COMMERCIAL ONLY. ****
- **** ****
- **** Modification history: ****
- **** ****
- **** 90.09.05 Initial implementation, A.Dwelly ****
- **** 91.04.15 Port to PC and minor bug fixes, R. Manderscheid ****
- **** 91.05.31 Port to Windows & Windows Extensions, M. Thomas ****
- **** ****
- **** ****
- **** References: ****
- **** ****
- **** For technical details see "Experiments using Parsimonious Adaptive ****
- **** Logic" W. W. Armstrong, Jiandong Liang, Dekang Lin, Scott Reynolds ****
- **** Tech. Rept. TR 90-30, Department of Computing Science, University ****
- **** of Alberta, Edmonton, Alberta, Canada T6G 2H1, September 1990. ****
- **** ****
- **** The adaptive algorithm is described in the article "Adaptation ****
- **** Algorithms for Binary Tree Networks", by W. W. Armstrong and J. ****
- **** Gecsei, IEEE Trans. on Systems, Man and Cybernetics, ****
- **** vol. SMC-9, no. 5 (1979), 276 - 285. In this C-language "research" ****
- **** version, some recently discovered improvements are used. ****
- **** This version has been written with clarity, not performance, ****
- **** in mind. ****
- **** ****
- **** Please contact W. W. Armstrong at the above address at U. of A. in ****
- **** case of questions or problems. Tel. (403) 492 2374. ****
- **** ****
- *****************************************************************************/
-
-
- /*****************************************************************************
- **** ****
- **** atree ****
- **** ****
- **** An atree is the fundamental structure used by these routines; it is ****
- **** a binary tree with nodes taking one of four logical functions, AND, ****
- **** OR, LEFT or RIGHT depending on initialization or the training it ****
- **** has undergone. The tree is randomly connected to input variables ****
- **** and their complements. ****
- **** ****
- *****************************************************************************/
-
- typedef struct atree_strc
- {
- /******************************
- * 16 byte data structure
- * allows easy alignment within
- * segments
- *******************************/
-
- char leaf_flag;
- char cmp_flag;
- char seg_flag;
- char function;
- char sig_left;
- char sig_right;
- char cnt_10;
- char cnt_01;
- union l_dec {
- struct atree_strc far *child;
- int leaf;
- } left;
- union r_dec {
- struct atree_strc far *child;
- int leaf;
- } right;
- }
- atree;
-
- typedef atree far *LPATREE;
-
- /*****************************************************************************
- **** ****
- **** bit_vec ****
- **** ****
- **** A bit_vec is a packed vector of bits, stored in an array of chars. ****
- *****************************************************************************/
-
- typedef struct bit_vec_strc
- {
- int len; /* The length of the vector in bits */
- LPSTR bv;
- }
- bit_vec;
-
- typedef bit_vec far *LPBIT_VEC;
-
- /* Import public routines */
-
- void FAR PASCAL Windows_Interrupt(DWORD);
- LPATREE FAR PASCAL atree_create(int, int);
- void FAR PASCAL atree_init(void);
- void FAR PASCAL atree_print(LPATREE, int);
- int FAR PASCAL atree_size();
- LPATREE FAR PASCAL atree_load();
- int FAR PASCAL atree_store();
- BOOL FAR PASCAL atree_eval(LPATREE, LPBIT_VEC);
- BOOL FAR PASCAL atree_train(LPATREE, LPBIT_VEC, LPBIT_VEC,int,int,int,int,int);
- LPBIT_VEC FAR PASCAL atree_rand_walk(int, int, int);
- void FAR PASCAL atree_free(LPATREE);
-
- int FAR PASCAL bv_diff(LPBIT_VEC, LPBIT_VEC);
- LPBIT_VEC FAR PASCAL bv_create(int);
- LPBIT_VEC FAR PASCAL bv_pack(LPSTR, int);
- LPBIT_VEC FAR PASCAL bv_concat(int, LPBIT_VEC FAR *);
- LPBIT_VEC FAR PASCAL bv_copy(LPBIT_VEC);
- void FAR PASCAL bv_set(int,LPBIT_VEC,BOOL);
- BOOL FAR PASCAL bv_extract(int,LPBIT_VEC);
- BOOL FAR PASCAL bv_equal(LPBIT_VEC, LPBIT_VEC);
- void FAR PASCAL bv_free(LPBIT_VEC);
- void FAR PASCAL bv_print(FILE *, LPBIT_VEC);
-
- LPSTR FAR PASCAL WinMem_Malloc(WORD, WORD);
- LPSTR FAR PASCAL WinMem_Free(LPSTR);
-
- /* some public Macros */
-
- #define MEMCHECK(p) \
- if (p == NULL){ \
- char szBuffer[50]; \
- wsprintf(szBuffer,"Could not allocate requested memory");\
- MessageBox(NULL,szBuffer,"atree",MB_OK | MB_ICONSTOP);\
- exit(0);\
- }
- #define RANDOM(b) (rand() % (b))
- #define Malloc(cb) WinMem_Malloc(LMEM_MOVEABLE, (WORD) cb)
- #define Free(p) WinMem_Free((LPSTR) p)
-