The Discrete class is a basic Term that represents a discrete membership function. More...
#include <Discrete.h>
Public Types | |
typedef std::pair< scalar, scalar > | Pair |
Public Member Functions | |
Discrete (const std::string &name="", const std::vector< Pair > &xy=std::vector< Pair >(), scalar height=1.0) | |
virtual | ~Discrete () FL_IOVERRIDE |
virtual std::string | className () const FL_IOVERRIDE |
Returns the name of the class of the term. More... | |
virtual std::string | parameters () const FL_IOVERRIDE |
Returns the parameters of the term as x1 y1 xn yn [height] More... | |
virtual void | configure (const std::string ¶meters) FL_IOVERRIDE |
Configures the term with the parameters given as x1 y1 xn yn [height] More... | |
virtual void | sort () |
Ascendantly sorts the pairs of values in this Discrete term by the \(x\)-coordinate. More... | |
virtual Complexity | complexity () const FL_IOVERRIDE |
Computes the estimated complexity of evaluating the membership function. More... | |
virtual scalar | membership (scalar x) const FL_IOVERRIDE |
Computes the membership function evaluated at \(x\) by using binary search to find the lower and upper bounds of \(x\) and then linearly interpolating the membership function between the bounds. More... | |
virtual void | setXY (const std::vector< Pair > &pairs) |
Sets the vector of pairs defining the discrete membership function. More... | |
virtual const std::vector< Pair > & | xy () const |
Gets an immutable vector of pairs defining the discrete membership function. More... | |
virtual std::vector< Pair > & | xy () |
Gets a mutable vector of pairs defining the discrete membership function. More... | |
virtual const Pair & | xy (std::size_t index) const |
Gets the immutable pair \((x_i,y_i)\) at index \(i\). More... | |
virtual Pair & | xy (std::size_t index) |
Gets the mutable pair \((x_i,y_i)\) at index \(i\). More... | |
virtual std::vector< scalar > | x () const |
Creates, fills and returns a vector containing the \(x\) values. More... | |
virtual scalar | x (std::size_t index) const |
Gets the \(x\) value at the given index. More... | |
virtual scalar & | x (std::size_t index) |
Gets the reference to the \(x\) value at the given index. More... | |
virtual std::vector< scalar > | y () const |
Creates, fills and returns a vector containing the \(y\) values. More... | |
virtual scalar | y (std::size_t index) const |
Gets the \(y\) value at the given index. More... | |
virtual scalar & | y (std::size_t index) |
Gets the reference to the \(y\) value at the given index. More... | |
virtual Discrete * | clone () const FL_IOVERRIDE |
Creates a clone of the term. More... | |
Public Member Functions inherited from fl::Term | |
Term (const std::string &name="", scalar height=1.0) | |
virtual | ~Term () |
virtual void | setName (const std::string &name) |
Sets the name of the term. More... | |
virtual std::string | getName () const |
Gets the name of the term. More... | |
virtual void | setHeight (scalar height) |
Sets the height of the term. More... | |
virtual scalar | getHeight () const |
Gets the height of the term. More... | |
virtual std::string | toString () const |
Returns the representation of the term in the FuzzyLite Language. More... | |
virtual void | updateReference (const Engine *engine) |
Updates the references (if any) to point to the current engine (useful when cloning engines or creating terms within Importer objects. More... | |
Static Public Member Functions | |
static void | sort (std::vector< Pair > &pairs) |
Ascendantly sorts the given pairs of values by the \(x\)-value, as it is required by the Discrete term. More... | |
static std::vector< scalar > | toVector (const std::vector< Pair > &xy) |
Creates a vector of fl::scalar from a vector of Pair given in the form \(\left(\{x_1,y_1\},...,\{x_n,y_n\}\right)\). More... | |
static std::vector< Pair > | toPairs (const std::vector< scalar > &xy) |
Creates a vector of Pair from a vector of fl::scalar given in the form \((x_1,y_1,...,x_n,y_n)\). More... | |
static std::vector< Pair > | toPairs (const std::vector< scalar > &xy, scalar missingValue) FL_INOEXCEPT |
Creates a vector of Pair from a vector of fl::scalar given in the form \((x_1,y_1,...,x_n,y_n)\). More... | |
static std::string | formatXY (const std::vector< Pair > &xy, const std::string &prefix="(", const std::string &innerSeparator=",", const std::string &suffix=")", const std::string &outerSeparator=" ") |
Formats a vector of Pair into a std::string in the form \((x_1,y_1) ... (x_n,y_n)\). More... | |
static Discrete * | discretize (const Term *term, scalar start, scalar end, int resolution=IntegralDefuzzifier::defaultResolution(), bool boundedMembershipFunction=true) |
Discretizes the given term. More... | |
static Term * | constructor () |
template<typename T > | |
static Discrete * | create (const std::string &name, int argc, T x1, T y1,...) |
Creates a Discrete term from a variadic set of values. More... | |
Additional Inherited Members | |
Protected Attributes inherited from fl::Term | |
scalar | _height |
The Discrete class is a basic Term that represents a discrete membership function.
The pairs of values in any Discrete term must be sorted ascendently because the membership function is computed using binary search to find the lower and upper bounds of \(x\).
Definition at line 42 of file Discrete.h.
typedef std::pair<scalar, scalar> fl::Discrete::Pair |
Definition at line 44 of file Discrete.h.
|
explicit |
|
virtual |
|
virtual |
Returns the name of the class of the term.
Implements fl::Term.
|
virtual |
|
virtual |
Computes the estimated complexity of evaluating the membership function.
Implements fl::Term.
|
virtual |
Configures the term with the parameters given as x1 y1 xn yn [height]
parameters | as x1 y1 xn yn [height] |
Implements fl::Term.
|
static |
|
inlinestatic |
Creates a Discrete term from a variadic set of values.
Beware: this method is unsafe and must be used with care by ensuring:
argc
correctly and exactly determines the number of values passed,int
and fl::scalar
. name | is the name of the resulting term |
argc | is the number of values passed |
x1 | is the \(x\) value of the first Pair |
y1 | is the \(y\) value of the first Pair |
... | are the remaining pairs of values \(x_i\) and \(y_i\) |
Definition at line 259 of file Discrete.h.
|
static |
Discretizes the given term.
term | is the term to discretize |
start | is the value from which discretization starts |
end | is the value at which discretization ends |
resolution | is the number of equally-distributed samples to perform between start and end |
boundedMembershipFunction | indicates whether to ensure that \(\mu(x)\in[0.0,1.0]\) |
|
static |
Formats a vector of Pair into a std::string in the form \((x_1,y_1) ... (x_n,y_n)\).
xy | is the vector of Pair |
prefix | indicates the prefix of a Pair, e.g., ( results in \((x_i\) |
innerSeparator | indicates the separator between \(x\) and \(y\), e.g., , results in \(x_i,y_i\) |
suffix | indicates the postfix of a Pair, e.g., ] results in \(y_i]\) |
outerSeparator | indicates the separator between Pair, e.g., ; results in \((x_i,y_i);(x_j,y_j)\) |
Computes the membership function evaluated at \(x\) by using binary search to find the lower and upper bounds of \(x\) and then linearly interpolating the membership function between the bounds.
x |
where \(h\) is the height of the Term, \(x_{\min}\) and \(x_{\max}\)is are the lower and upper limits of \(x\) in xy
(respectively), \(y_{\min}\) and \(y_{\max}\)is are the membership functions of \(\mu(x_{\min})\) and \(\mu(x_{\max})\) (respectively)
Implements fl::Term.
|
virtual |
Returns the parameters of the term as x1 y1 xn yn [height]
x1 y1 xn yn [height]
Implements fl::Term.
|
virtual |
Sets the vector of pairs defining the discrete membership function.
pairs | is the vector of pairs defining the discrete membership function |
|
static |
Ascendantly sorts the given pairs of values by the \(x\)-value, as it is required by the Discrete term.
pairs | is a vector of pairs of values in the form \((x,y)\) |
|
virtual |
Ascendantly sorts the pairs of values in this Discrete term by the \(x\)-coordinate.
Creates a vector of Pair from a vector of fl::scalar given in the form \((x_1,y_1,...,x_n,y_n)\).
xy | is a vector of fl::scalar given as \((x_1,y_1,...,x_n,y_n)\) |
fl::Exception | if a value is missing, that is, if the length of \(xy\) is odd: \(|xy|\mod 2 = 1\) |
|
static |
Creates a vector of Pair from a vector of fl::scalar given in the form \((x_1,y_1,...,x_n,y_n)\).
xy | is a vector of fl::scalar given as \((x_1,y_1,...,x_n,y_n)\) possibly missing a value |
missingValue | is the replacement in the case a value is missing from \(xy\) |
Creates a vector of fl::scalar from a vector of Pair given in the form \(\left(\{x_1,y_1\},...,\{x_n,y_n\}\right)\).
xy | is the vector of Pair |
|
virtual |
Creates, fills and returns a vector containing the \(x\) values.
|
virtual |
Gets the \(x\) value at the given index.
|
virtual |
Gets the reference to the \(x\) value at the given index.
|
virtual |
Gets an immutable vector of pairs defining the discrete membership function.
|
virtual |
Gets a mutable vector of pairs defining the discrete membership function.
|
virtual |
Gets the immutable pair \((x_i,y_i)\) at index \(i\).
index | is the index \(i\) |
|
virtual |
Gets the mutable pair \((x_i,y_i)\) at index \(i\).
index | is the index \(i\) |
|
virtual |
Creates, fills and returns a vector containing the \(y\) values.
|
virtual |
Gets the \(y\) value at the given index.
index | is the index |
|
virtual |
Gets the reference to the \(y\) value at the given index.
index | is the index |