⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 population.hpp

📁 这是遗传算法的源代码
💻 HPP
字号:
// -*- 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -