GeneticAlgoithm
Implementation of the genetic algorithm
include
IFigureOfMerit.h
1
#ifndef IFIGUREOFMERIT_H
2
#define IFIGUREOFMERIT_H
3
4
class
IModel
;
5
6
/**
7
* @brief Abstract class representing a figure of merit.
8
*
9
* A figure of merit should implement three functionalities:
10
* - Evaluate the fittness of a model. The details of that evaluation is kept for the derive classes.
11
* - Decide whether a model is good enough to be accepted as the final answer to a problem.
12
* The default behaviour is to apply a threshold on the score.
13
* - Compares two models and decide which is the fittest.
14
* The default behaviour is that a larger score is better.
15
*
16
* Deriving from this class:
17
* - Derived classes should at least implement the `evaluate()` method if the score handling behavior is adequate.
18
* - In addition, derived classes may reimplement `accept()` and/or `isBetterThan()` versions that take scores as input
19
* to modify the handling of the scores, e.g. a lower score is may be better.
20
* - For more complex cases where the decisions are not taken solely on the score, the derived class may
21
* reimplement the overloaded versions of `accept()` and `isBetterThan()` that take a IModel as input.
22
* In this case, the fuction `evaluate()` may simply return a dummy value.
23
*
24
*/
25
class
IFigureOfMerit
{
26
27
public
:
28
29
/** Default Constructor */
30
IFigureOfMerit
();
31
32
/** Destructor */
33
virtual
~IFigureOfMerit
();
34
35
/**
36
* @brief Evaluate the fittness of a model.
37
*
38
* Derived classes should implement this method.
39
*/
40
virtual
double
evaluate
(
IModel
*model)
const
=0;
41
42
/** Decide if a model can be accepted as a final answer. */
43
virtual
bool
accept
(
IModel
*model)
const
;
44
45
/** Compares two Models */
46
virtual
bool
isBetterThan
(
IModel
*scoreToTest,
IModel
*referenceModel)
const
;
47
48
/** Sets the score threshold to accept a model as a final answer. */
49
void
setAcceptThreshold
(
double
acceptThreshold);
50
51
/** Returns the score threshold to accept a model as a final answer. */
52
double
getAcceptThreshold
()
const
;
53
54
protected
:
55
56
/** Decide if a model's score can be accepted as a final answer. */
57
virtual
bool
accept
(
double
scrore)
const
;
58
59
/** Compares two scores */
60
virtual
bool
isBetterThan
(
double
scoreToTest,
double
referenceScore)
const
;
61
62
double
m_acceptThreshold
;
//!< Stores the score threshold to accept a model as a final answer.
63
};
64
65
#endif
IFigureOfMerit::~IFigureOfMerit
virtual ~IFigureOfMerit()
Definition:
IFigureOfMerit.cxx:10
IFigureOfMerit::evaluate
virtual double evaluate(IModel *model) const =0
Evaluate the fittness of a model.
IFigureOfMerit::IFigureOfMerit
IFigureOfMerit()
Definition:
IFigureOfMerit.cxx:5
IFigureOfMerit::accept
virtual bool accept(IModel *model) const
Definition:
IFigureOfMerit.cxx:36
IFigureOfMerit::setAcceptThreshold
void setAcceptThreshold(double acceptThreshold)
Definition:
IFigureOfMerit.cxx:73
IFigureOfMerit::isBetterThan
virtual bool isBetterThan(IModel *scoreToTest, IModel *referenceModel) const
Definition:
IFigureOfMerit.cxx:65
IFigureOfMerit::getAcceptThreshold
double getAcceptThreshold() const
Definition:
IFigureOfMerit.cxx:81
IFigureOfMerit
Abstract class representing a figure of merit.
Definition:
IFigureOfMerit.h:25
IFigureOfMerit::m_acceptThreshold
double m_acceptThreshold
Stores the score threshold to accept a model as a final answer.
Definition:
IFigureOfMerit.h:62
IModel
Abstract class describing the interface for a model.
Definition:
IModel.h:13
Generated by
1.8.13