📄 ggreedysearch.h
字号:
/* Copyright (C) 2006, Mike Gashler This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. see http://www.gnu.org/copyleft/lesser.html*/#ifndef __GGREEDYSEARCH_H__#define __GGREEDYSEARCH_H__#include "GSearch.h"// At each iteration this algorithm moves in only one// dimension. If the situation doesn't improve it tries// the opposite direction. If both directions are worse,// it decreases the step size for that dimension, otherwise// it increases the step size for that dimension.class GMomentumGreedySearch : public GRealVectorSearch{protected: int m_nDimensions; int m_nCurrentDim; double* m_pStepSizes; double* m_pVector; double m_dError; double m_dChangeFactor;public: GMomentumGreedySearch(GRealVectorCritic* pCritic); virtual ~GMomentumGreedySearch(); virtual void Iterate(); // d should be a value between 0 and 1 void SetChangeFactor(double d) { m_dChangeFactor = d; }};// At each iteration this algorithm moves in a random direction// from the best point ever found. The size of the step is a// random number raised to a constant power (called the// conservativeness).class GStochasticGreedySearch : public GRealVectorSearch{protected: double m_dRange; double m_dConservativeness; int m_nDimensions; double* m_pVector; double* m_pTest; double m_dError;public: GStochasticGreedySearch(GRealVectorCritic* pCritic, double dMin, double dRange); virtual ~GStochasticGreedySearch(); virtual void Iterate(); // d should be greater than 1. A bigger value will cause it to usually // take small steps and only rarely take big steps. A smaller value // will cause it to take big steps more frequently. void SetConservativeness(double d) { m_dConservativeness = d; }};class GActionGreedySearch : public GActionPathSearch{protected: double* m_pTmpState;public: GActionGreedySearch(GActionPathCritic* pCritic); virtual ~GActionGreedySearch(); virtual bool Iterate();};#endif // __GGREEDYSEARCH_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -