00001 #include <stdlib.h> 00002 #include <NLstl_utils.h> 00003 00004 #include "GLBaseOrganism.h" 00005 #include "GLConstants.h" 00006 #include "GLGaStatusStandard.h" 00007 #include "GLUtils.h" 00008 00012 GLGaStatusStandard::GLGaStatusStandard(): 00013 GLBaseGaStatus() 00014 { 00015 m_best_organisms_in_population.clear(); 00016 m_generations_since_population_changed = 0; 00017 }//constructor 00018 00023 GLGaStatusStandard::GLGaStatusStandard(const GLGaStatusStandard* source): 00024 GLBaseGaStatus(source) 00025 { 00026 //only pointers are copied here 00027 m_best_organisms_in_population = source->m_best_organisms_in_population; 00028 m_generations_since_population_changed = 00029 source->m_generations_since_population_changed; 00030 }//constructor 00031 00035 GLGaStatusStandard::~GLGaStatusStandard() 00036 { 00037 }//destructor; 00038 00043 ostream& GLGaStatusStandard::toStream(ostream& out) const 00044 { 00045 //print the parent first 00046 GLBaseGaStatus::toStream(out); 00047 out << "Generations since population changed: " 00048 << m_generations_since_population_changed << endl; 00049 if (m_current_state == GLConstants::GA_STATE_RUNNING) 00050 { 00051 out << "--------- Best organisms in current population ---------\n"; 00052 out << "Number or organisms: " 00053 << m_best_organisms_in_population.size() << endl; 00054 GLUtils::printVectorOfOrganisms(out, m_best_organisms_in_population); 00055 } 00056 return out; 00057 }//toStream