population.hpp

来自「这是遗传算法的源代码」· HPP 代码 · 共 74 行

HPP
74
字号
// -*- c++ -*-////  File:         population.hpp////  Description:  C++ interface for the class population.////  Author:       Fernando Lobo////  Date:         June/1999////  Extended to deal with chi-ary problems by Luis de la Ossa//  GCC 3.4 and 4 series compliance by Kumara Sastry ////  Date:         March/2006#ifndef _population_hpp#define _population_hpp#include <assert.h>#include <iostream>#include <fstream>#include "chromosome.hpp"class population{  private:    int        PopSize;             // population size    chromosome *Chromosomes;        // individuals    int        *MatingPool;         // mating pool                                    // information for statistical purposes    int        Best;                // index of best individual    double     MaxFit;              // maximum fitness    double     MinFit;              // minimum fitness    double     AvgFit;              // average fitness        int        tournament_winner( int *shufflearray, int &pick, int s );  public:        population( int popsize );    population( population &pop );    ~population();    void random();    void selection( population *newpop );    void evaluate();       void statistics();     int popsize(){ return PopSize; }    int best() { return Best; }    double maxfit() { return MaxFit; }    double minfit() { return MinFit; }    double avgfit() { return AvgFit; }    chromosome & operator[]( int index );    population & operator=( population &pop );    friend std::ostream &operator<< ( std::ostream &out, population &pop );    bool converged();       //    // selection schemes    //     friend void tselect_without_replacement( population &pop );          //    // stopping criterias    //    friend bool sc_maxgen( population &pop, int gen );    friend bool sc_allele_conv( population &pop, int gen );};#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?