home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / virus / ddj0491.zip / MORROW.ZIP / GA.H < prev    next >
C/C++ Source or Header  |  1989-09-03  |  2KB  |  84 lines

  1. /***
  2. *       GASystem
  3. *       Mike Morrow
  4. *       September 1989
  5. ***/
  6.  
  7.  
  8.  
  9. /**
  10. *    Header file for GA stuff
  11. **/
  12.  
  13.  
  14. #ifndef GA_H
  15.  
  16. #if __STDC__
  17. # define CONST const
  18. #else
  19. # define CONST
  20. #endif
  21.  
  22.  
  23.     /**
  24.     *    We assume that "long ints" can hold at least 32 bits of precision,
  25.     *    "ints" can hold at least 16 bits.
  26.     **/
  27.  
  28.  
  29.  
  30.  
  31.  
  32.     /**
  33.     *    Objective functions return this type of value.  A GENE's fitness
  34.     *    is of this type.
  35.     **/
  36. typedef unsigned long int    FIT_TYPE;
  37.  
  38.  
  39.     /**
  40.     *    A GENE's genetic pattern is contained in a SEQ (sequence).
  41.     **/
  42. typedef char SEQ_COMPONENT;
  43. typedef SEQ_COMPONENT *SEQ;
  44.  
  45.     /**
  46.     *    Here's how we represent genes
  47.     **/
  48. typedef struct
  49. {
  50.     FIT_TYPE    gene_fit;            /* current fitness value    */
  51.     int            gene_tag;            /* misc.                    */
  52.     SEQ            gene_seq;            /* the acutal genetic sequence */
  53. }GENE;
  54.  
  55.  
  56.  
  57. /***
  58. *    These are the routines that the user must supply.
  59. *        objinit() is called once at program start up.
  60. *        objective() will be called often to get a fitness value
  61. *            for SEQ s.
  62. *        objshow() is called when the user requests to see a gene SEQ.
  63. *        objdumpdone() is called at the end of a group of objshow()s.
  64. *            It allows the display formatter to segregate logical
  65. *            blocks of display.
  66. ***/
  67.  
  68. #if __STDC__
  69. extern void objinit();
  70. extern FIT_TYPE objective(SEQ s, int len);
  71. extern void objshow(SEQ s, int len, FIT_TYPE fitness);
  72. extern void objdumpdone();
  73. #else
  74. extern void objinit();
  75. extern FIT_TYPE objective();
  76. extern void objshow();
  77. extern void objdumpdone();
  78. #endif
  79.  
  80.  
  81. #define GA_H
  82.  
  83. #endif /* ifndef GA_H */
  84.