26 #ifndef GRALE_TREELENSINVERSIONGAFACTORYBASE_H
28 #define GRALE_TREELENSINVERSIONGAFACTORYBASE_H
30 #include "graleconfig.h"
31 #include "randomnumbergenerator.h"
32 #include <mogal/gafactory.h>
38 class TreeLensInversionGAFactoryParams;
39 class TreeLensInversionGenomeBase;
41 class BackProjectTreeBase;
42 class ImagesDataExtended;
45 class GRALE_IMPORTEXPORT TreeLensInversionGAFactoryBase :
public virtual mogal::GAFactory
48 TreeLensInversionGAFactoryBase();
49 ~TreeLensInversionGAFactoryBase();
51 mogal::GAFactoryParams *createParamsInstance()
const;
52 const mogal::GAFactoryParams *getCurrentParameters()
const;
54 bool init(
const mogal::GAFactoryParams *p);
56 mogal::Genome *createNewGenome()
const;
58 size_t getMaximalFitnessSize()
const {
return sizeof(float)*(1+getNumberOfFitnessComponents()); }
59 size_t getMaximalGenomeSize()
const {
return m_maxGenomeSize; }
61 bool writeGenome(serut::SerializationInterface &si,
const mogal::Genome *g)
const;
62 bool readGenome(serut::SerializationInterface &si, mogal::Genome **g)
const;
63 bool writeGenomeFitness(serut::SerializationInterface &si,
const mogal::Genome *g)
const;
64 bool readGenomeFitness(serut::SerializationInterface &si, mogal::Genome *g)
const;
65 bool writeCommonGenerationInfo(serut::SerializationInterface &si)
const;
66 bool readCommonGenerationInfo(serut::SerializationInterface &si);
68 const RandomNumberGenerator *getRandomNumberGenerator()
const {
return &m_rndGen; }
70 int getMaximumNumberOfBasisFunctions()
const {
return m_maxBasisFunctions; }
71 int getMaximumDepth()
const {
return m_maxDepth; }
72 bool useWeights()
const {
return m_useWeights; }
74 virtual float getChanceMultiplier() = 0;
75 virtual bool useAbsoluteMutation() = 0;
76 virtual float getMutationAmplitude() = 0;
79 virtual TreeLensInversionGenomeBase *allocateNewGenome(TreeLensInversionGAFactoryBase *pFactory,
80 BackProjectTreeBase *pBackProjectTree,
81 GridNodeBase *pRootNode,
82 int firstLevelSubdiv)
const = 0;
84 int getMaximumNumberOfGenerations()
const {
return m_maxGenerations; }
85 virtual bool subInit(std::list<ImagesDataExtended *> &images) {
return true; }
88 void onSortedPopulation(
const std::vector<mogal::GenomeWrapper> &population);
89 #endif // SHOWEVOLUTION
91 bool writeNode(serut::SerializationInterface &si,
const GridNodeBase *pNode)
const;
92 bool readNode(serut::SerializationInterface &si, GridNodeBase **pNode,
int level)
const;
94 BackProjectTreeBase *m_pBackProjectTree;
95 RandomNumberGenerator m_rndGen;
96 TreeLensInversionGAFactoryParams *m_pCurrentParams;
99 int m_maxBasisFunctions;
101 int m_firstLevelSubdiv;
107 #endif // GRALE_TREELENSINVERSIONGAFACTORYBASE_H