GRALE
Public Member Functions
grale::LensFitnessObject Class Reference

This class is a base class for fitness calculation code in the GA. More...

#include <lensfitnessobject.h>

List of all members.

Public Member Functions

virtual bool init (std::list< ImagesDataExtended * > &images, std::list< ImagesDataExtended * > &massScaleImages)=0
 Initialize this object.
virtual void postInit (const std::list< ImagesDataExtended * > &images, const std::list< ImagesDataExtended * > &massScaleImages, double angularScale)
 This function is called after the LensFitnessObject::init function, before finishing the initialization of the genetic algorithm.
virtual float calculateMassScaleFitness (const ProjectedImagesInterface &interface0) const =0
 Given the situation described by the ProjectedImagesInterface instance, this function must calculate a single fitness value (lower is better) which will be used to find an appropriate scale of the basis functions in the GA.
virtual void calculateOverallFitness (const ProjectedImagesInterface &interface0, float *pFitnessValues) const =0
 This function should inspect the situation described by the ProjectedImagesInterface instance, and calculate all corresponding fitness values.
virtual int getNumberOfFitnessComponents () const =0
 The number of fitness components your lens fitness object will calculate (is 1 for a single-objective GA, 2 or more for a multi-objective GA).
virtual int getImagesGroupSize () const =0
 The length of the images data list in the LensFitnessObject::init function must be a multiple of this number.
Basic calculation flags

The following functions provide information to the BackProjectMatrixNew instances in the genetic algorithm about what information should be calculated and stored.

virtual void getTotalCalcFlags (std::vector< bool > &deflectionFlags, std::vector< bool > &derivativeFlags, std::vector< bool > &potentialFlags) const =0
 The LensFitnessObject instance should create these arrays of flags to indicate what properties should be calculated for which source in the original (possibly modified) images data list.
virtual void getTotalStoreFlags (bool *pStoreIntens, bool *pStoreTimeDelay, bool *pStoreShearInfo) const =0
 These flags indicate what information from the input images data should be stored in the ProjectedImagesInterface instance (you can save some memory this way, but if this isn't an issue just set everything to true, it doensn't have any other effect on the performance)
virtual void getShortCalcFlags (std::vector< bool > &deflectionFlags, std::vector< bool > &derivativeFlags, std::vector< bool > &potentialFlags) const =0
 Same as the LensFitnessObject::getTotalCalcFlags, but this is about the massScaleImages list from the LensFitnessObject::init function.
virtual void getShortStoreFlags (bool *pStoreIntens, bool *pStoreTimeDelay, bool *pStoreShearInfo) const =0
 Same as the LensFitnessObject::getTotalStoreFlags, but this is about the massScaleImages list from the LensFitnessObject::init function.
Derived calculation flags

The following functions provide information to the BackProjectMatrixNew instances in the genetic algorithm about what information should be calculated based on the deflection angle derivatives.

You'll need to enable calculation of the derivatives of the deflection angles for a source to be able to calculate these properties.

virtual bool totalNeedInverseMagnifications () const =0
 Should only return false if none of the sources need the inverse magnifications calculated.
virtual bool totalNeedShearComponents () const =0
 Should only return false if none of the sources need the shear components (gamma1 and gamma2) to be calculated.
virtual bool totalNeedConvergence () const =0
 Should only return false if none of the sources need the convergence to be calculated.
virtual const std::vector< bool > * getTotalInverseMagnificationFlags () const =0
 If LensFitnessObject::totalNeedInverseMagnifications returns true, this function will be called and should return a list (of equal length as images from the LensFitnessObject::init function) indicating for which sources the inverse magnification calculation should be done.
virtual const std::vector< bool > * getTotalShearComponentFlags () const =0
 If LensFitnessObject::totalNeedShearComponents returns true, this function will be called and should return a list (of equal length as images from the LensFitnessObject::init function) indicating for which sources the shear components calculation should be done.
virtual const std::vector< bool > * getTotalConvergenceFlags () const =0
 If LensFitnessObject::totalNeedConvergence returns true, this function will be called and should return a list (of equal length as images from the LensFitnessObject::init function) indicating for which sources the convergence calculation should be done.
virtual bool shortNeedInverseMagnifications () const =0
 Same as LensFitnessObject::totalNeedInverseMagnifications, but for the images data used in the mass scale fitness calculation (the massScaleImages from the LensFitnessObject::init function).
virtual bool shortNeedShearComponents () const =0
 Same as LensFitnessObject::totalNeedShearComponents, but for the images data used in the mass scale fitness calculation (the massScaleImages from the LensFitnessObject::init function).
virtual bool shortNeedConvergence () const =0
 Same as LensFitnessObject::totalNeedConvergence, but for the images data used in the mass scale fitness calculation (the massScaleImages from the LensFitnessObject::init function).
virtual const std::vector< bool > * getShortInverseMagnificationFlags () const =0
 Same as LensFitnessObject::getTotalInverseMagnificationFlags, but for the images data used in the mass scale fitness calculation (the massScaleImages from the LensFitnessObject::init function).
virtual const std::vector< bool > * getShortShearComponentFlags () const =0
 Same as LensFitnessObject::getTotalShearComponentFlags, but for the images data used in the mass scale fitness calculation (the massScaleImages from the LensFitnessObject::init function).
virtual const std::vector< bool > * getShortConvergenceFlags () const =0
 Same as LensFitnessObject::getTotalConvergenceFlags, but for the images data used in the mass scale fitness calculation (the massScaleImages from the LensFitnessObject::init function).

Detailed Description


Member Function Documentation

virtual float grale::LensFitnessObject::calculateMassScaleFitness ( const ProjectedImagesInterface interface0) const
pure virtual
virtual void grale::LensFitnessObject::calculateOverallFitness ( const ProjectedImagesInterface interface0,
float *  pFitnessValues 
) const
pure virtual
virtual int grale::LensFitnessObject::getImagesGroupSize ( ) const
pure virtual

For more complex optimizations, typically several images data instances correspond to a single source. For example an images data instance that corresponds to the actual image points of a source could be followed by an instance specifying the null space grid. In that case this function could return 2 and a check will be done that the list (after calling LensFitnessObject::init) is a multiple of 2. It is only used for such a check though, so you can also just return 1.

virtual int grale::LensFitnessObject::getNumberOfFitnessComponents ( ) const
pure virtual
virtual void grale::LensFitnessObject::getShortCalcFlags ( std::vector< bool > &  deflectionFlags,
std::vector< bool > &  derivativeFlags,
std::vector< bool > &  potentialFlags 
) const
pure virtual
virtual const std::vector<bool>* grale::LensFitnessObject::getShortConvergenceFlags ( ) const
pure virtual
virtual const std::vector<bool>* grale::LensFitnessObject::getShortInverseMagnificationFlags ( ) const
pure virtual
virtual const std::vector<bool>* grale::LensFitnessObject::getShortShearComponentFlags ( ) const
pure virtual
virtual void grale::LensFitnessObject::getShortStoreFlags ( bool *  pStoreIntens,
bool *  pStoreTimeDelay,
bool *  pStoreShearInfo 
) const
pure virtual
virtual void grale::LensFitnessObject::getTotalCalcFlags ( std::vector< bool > &  deflectionFlags,
std::vector< bool > &  derivativeFlags,
std::vector< bool > &  potentialFlags 
) const
pure virtual

The LensFitnessObject instance should create these arrays of flags to indicate what properties should be calculated for which source in the original (possibly modified) images data list. You should resize each vector to match the size of the images vector in the LensFitnessObject::init function, and for each source store what properties should be calculated.

Parameters:
deflectionFlagsFor which sources should the deflection be calculated (you'll need this to access the ProjectedImagesInterface::getBetas functions from within the genetic algorithm)
derivativeFlagsFlags to indicate for which sources the derivatives of the deflection angle should be calculated.
potentialFlagsThese indicate for which source indices the lens potential at the image points should be calculated.
virtual const std::vector<bool>* grale::LensFitnessObject::getTotalConvergenceFlags ( ) const
pure virtual
virtual const std::vector<bool>* grale::LensFitnessObject::getTotalInverseMagnificationFlags ( ) const
pure virtual
virtual const std::vector<bool>* grale::LensFitnessObject::getTotalShearComponentFlags ( ) const
pure virtual
virtual bool grale::LensFitnessObject::init ( std::list< ImagesDataExtended * > &  images,
std::list< ImagesDataExtended * > &  massScaleImages 
)
pure virtual

Initialize this object.

Parameters:
imagesWhen calling this function, this list of images data basically contains all the images data you specified as input, for example using the GRALESHELL command 'imgdata/list/add'. You can modify this list, and for all the images remaining in the list, the points will be projected back onto the corresponding source plane (or will be used to calculate other properties like shear or convergence). So if you need images data as input for your module, but don't actually need the points to be projected onto the source plane (or need other properties that depend on a specific lens model), you can remove these images data instances from the list.
massScaleImagesAs explained in writing inversion modules, the genetic algorithm first determines a suitable mass scale by optimizing the value returned by LensFitnessObject::calculateMassScaleFitness. When this 'init' function is called, the massScaleImages list is empty, and you can store in this list the entries from the images list which are needed in the mass scale fitness calculation. If it remains empty, the same list as images will be used in the mass scale fitness calculation.
virtual void grale::LensFitnessObject::postInit ( const std::list< ImagesDataExtended * > &  images,
const std::list< ImagesDataExtended * > &  massScaleImages,
double  angularScale 
)
inlinevirtual

This function is called after the LensFitnessObject::init function, before finishing the initialization of the genetic algorithm. Since the images data (after modification) from the LensFitnessObject::init function are used to calculate a relevant angular scale, the LensFitnessObject::init function itself cannot know this angular scale yet. This function could be used to inform your module of said angular scale for example.

Parameters:
imagesThe list you specified upon completion of the LensFitnessObject::init function
massScaleImagesThe corresponding list from the LensFitnessObject::init function
angularScaleBased on the images, the algorithm has calculated this angular scale.
virtual bool grale::LensFitnessObject::shortNeedConvergence ( ) const
pure virtual
virtual bool grale::LensFitnessObject::shortNeedInverseMagnifications ( ) const
pure virtual
virtual bool grale::LensFitnessObject::shortNeedShearComponents ( ) const
pure virtual
virtual bool grale::LensFitnessObject::totalNeedConvergence ( ) const
pure virtual
virtual bool grale::LensFitnessObject::totalNeedInverseMagnifications ( ) const
pure virtual
virtual bool grale::LensFitnessObject::totalNeedShearComponents ( ) const
pure virtual

The documentation for this class was generated from the following file: