home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / APR94_1.ZIP / GA.ZIP / SOURCE.ZIP / GRAPHIND.CPP < prev    next >
C/C++ Source or Header  |  1994-01-10  |  2KB  |  82 lines

  1. //Copyright (C) Man Machine Interfaces 1994. All rights reserved.
  2.  
  3. #include "stdafx.h"
  4.  
  5. //Headers needed for EOS programs
  6. //You need EOS v1.1 to compile this code
  7. #include "eos.h"
  8.  
  9. //headers specific to graph GA
  10. #include "graphind.h"
  11.  
  12. //This file implements an "auto decoding" binary individual
  13. //used for performance reasons. The phenotype will decoded
  14. //only when necessary.
  15.  
  16. CGraphDrawingInd::CGraphDrawingInd()
  17.     : TBinaryIndividual()
  18. {                  
  19.     m_Decoded = 0 ;
  20. }
  21.  
  22. CGraphDrawingInd::CGraphDrawingInd(PTBinaryGenotype geno, PTPhenotype pheno)
  23.     : TBinaryIndividual(geno, pheno)
  24. {
  25.     m_Decoded = 0 ;
  26. }
  27.  
  28. CGraphDrawingInd::CGraphDrawingInd(const CGraphDrawingInd & individ)
  29.     : TBinaryIndividual(individ)
  30. {
  31.     m_Decoded = 0 ;
  32. }
  33.  
  34. const CGraphDrawingInd & CGraphDrawingInd::operator =(const CGraphDrawingInd & individ)
  35. {
  36.     if (this != &individ) {
  37.         this->TBinaryIndividual::operator =(individ) ;
  38.         m_Decoded = 0 ;
  39.         }
  40.     return *this ;
  41. }
  42.  
  43.  
  44. void CGraphDrawingInd::CalcFitness()
  45. {
  46.     if (!m_Decoded) 
  47.         Decode() ;
  48.     TBinaryIndividual::CalcFitness() ;            
  49. }
  50.  
  51. void CGraphDrawingInd::Decode()
  52. {
  53.     TBinaryIndividual::Decode() ;    
  54.     m_Decoded = 1 ;
  55. }
  56.  
  57. void CGraphDrawingInd::CopyFrom(CGraphDrawingInd * source)
  58. {
  59.     TBinaryIndividual::CopyFrom(source) ;
  60.     m_Decoded = 0 ;
  61. }
  62.     
  63. PTIndividual CGraphDrawingInd::Copy()
  64. {
  65.     return new  CGraphDrawingInd(*this) ;
  66. }
  67.     
  68. void CGraphDrawingInd::GetPhenoInfo(void *pInfoStruct)
  69. {
  70.     if (!m_Decoded) 
  71.         Decode() ;
  72.     TBinaryIndividual::GetPhenoInfo(pInfoStruct) ;
  73. }
  74.  
  75. const void * CGraphDrawingInd::GetPhenoInfo(int key)
  76. {
  77.     if (!m_Decoded) 
  78.         Decode() ;
  79.     return     TBinaryIndividual::GetPhenoInfo(key) ;
  80. }
  81.  
  82.