📄 gainfo.h
字号:
#ifndef _GAINFO_
#define _GAINFO_
#include <vector>
using namespace std;
#include "UOFInfo.h"
#include "UOFSolver.h"
class PopSolution;
//! GA Info class
/*! This class is used for GA solver to display optimization information. */
class GAInfo : public UOFInfo
{
public:
UOFIdentity("GAInfo class",1);
//! A constructor that generates a object with initialization.
/*!
\param freq sets the m_updateFreq.
\param filename sets the m_fn.
*/
GAInfo(size_t freq=1, string filename="Log.txt");
public:
//! This function updates the recorded data and show current status
/*!
\param src the pointer of the solver.
*/
virtual void Update(UOFSolver *src);
//! This function display the summary of the optimization result
/*! This function shows the population size, number of iteration, best, worst, and mean score, the time cost
, and the optimized parameters.
*/
virtual void PrintInfo();
//! Get the mean of current scores
/*! This function returns the mean of current scores of the last updated generation
*/
virtual double GetMean(){return (m_itr==0)?1.0:m_ScoreMean[m_itr-1];}
//! Get the worst score among the entire optimization process
/*! This function returns the worst score among the entire optimization process
*/
double HistoryWorst();
//! Get the best score among the entire optimization process
/*! This function returns the best score among the entire optimization process
*/
double HistoryBest();
//! Tests if the a is better than b
/*! This function returns true if a is better than b; false if a is not better than b.s
*/
bool Better(double a, double b);
//! Get the last generation that has improvement
/*! This function returns the last generation that has improvement.
*/
virtual double GetLastImprovement(int gen);
public:
void* m_CS; /**< the point of the solver */
vector<size_t> m_popSize; /**< the vector recorded the population size of each generation */
vector<double> m_ScoreBest; /**< the vector recorded the best score of each generation */
vector<double> m_ScoreWorst; /**< the vector recorded the worst score of each generation */
vector<double> m_ScoreMean; /**< the vector recorded the mean of scores of each generation */
vector<double> m_ScoreDiversity; /**< the vector recorded the deviersity of scores of each generation */
vector<PopSolution*> m_bestChro; /**< the vector recorded the best parameter set of each generation */
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -