Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qlibs::fis::instance Class Reference

A FIS(Fuzzy Inference System) object. More...

#include <fis.hpp>

Inheritance diagram for qlibs::fis::instance:
qlibs::fis::core

Public Member Functions

 instance ()=default
 
virtual ~instance ()
 
bool setup (const type t, input *const inputs, const size_t ni, output *const outputs, const size_t no, mf *const mf_inputs, const size_t nmi, mf *const mf_outputs, const size_t nmo, const rules *const r, const size_t n, real_t *rWeights=nullptr) noexcept
 Setup and initialize the FIS instance.
 
template<size_t numberInputs, size_t numberOutputs, size_t numberMFinputs, size_t numberMFOutputs, size_t numberRules>
bool setup (const type t, input(&inputs)[numberInputs], output(&outputs)[numberOutputs], mf(&mf_inputs)[numberMFinputs], mf(&mf_outputs)[numberMFOutputs], const rules *const r, real_t(&rWeights)[numberRules]) noexcept
 Setup and initialize the FIS instance.
 
bool setupInput (const tag t, const real_t Min, const real_t Max) noexcept
 Setup the input with the specified tag and set limits for it.
 
bool setupOutput (const tag t, const real_t Min, const real_t Max) noexcept
 Setup the output with the specified tag and set limits for it.
 
bool setupInputMF (const tag io, const tag mf, const shapeMF s, const real_t *cp, const real_t h=1.0_re) noexcept
 Setup the input tag and points for the specified membership function.
 
bool setupInputMF (const tag io, const tag mf, mfFunction customMfs, const real_t *cp, const real_t h=1.0_re) noexcept
 Setup the input tag and points for the specified membership function.
 
bool setupOutputMF (const tag io, const tag mf, const shapeMF s, const real_t *cp, const real_t h=1.0_re) noexcept
 Setup the output tag and points for the specified membership function.
 
bool setupOutputMF (const tag io, const tag mf, mfFunction customMfs, const real_t *cp, const real_t h=1.0_re) noexcept
 Set the output tag and points for the specified membership function.
 
bool setInput (const tag t, const real_t value) noexcept
 Set a crisp value of the input with the specified tag.
 
bool getOutput (const tag t, real_t &value) const noexcept
 Get the de-fuzzified crisp value from the output with the specified tag.
 
bool setParameter (const parameter p, const paramValue x) noexcept
 Set parameters of the FIS instance.
 
bool setDeFuzzMethod (deFuzzMethod m) noexcept
 Change the default de-Fuzzification method of the FIS instance.
 
bool fuzzify (void) noexcept
 Perform the fuzzification operation over the crisp inputs on the requested FIS object.
 
bool deFuzzify (void) noexcept
 Perform the de-Fuzzification operation to compute the crisp outputs.
 
bool inference (void) noexcept
 Perform the inference process on the FIS object.
 
bool setRuleWeights (real_t *rWeights) noexcept
 Set weights to the rules of the inference system.
 
size_t getNumberOfPoints (void) const noexcept
 Get the number of points used on Mamdani to perform the de-fuzzification proccess.
 
real_t operator[] (tag outTag) const
 Get the de-fuzzified crisp value from the output with the specified tag.
 
instanceoperator<< (const tag &t)
 Select the input to set using with the specified tag.
 
instanceoperator<< (const int &value)
 The value to set the previously selected input.
 
instanceoperator<< (const real_t &value)
 The value to set the previously selected input.
 

Detailed Description

A FIS(Fuzzy Inference System) object.

The instance should be initialized using the instance::setup() method.

Constructor & Destructor Documentation

◆ instance()

qlibs::fis::instance::instance ( )
default

◆ ~instance()

virtual qlibs::fis::instance::~instance ( )
inlinevirtual

Member Function Documentation

◆ deFuzzify()

bool fis::instance::deFuzzify ( void )
noexcept

Perform the de-Fuzzification operation to compute the crisp outputs.

Precondition
The instance should have already invoked the inference process successfully with fis::inference()
Note
By default, this method, uses the Centroid method on Mamdani type FIS and weight-average on Sugeno type FIS. To change the default settings use the instance::setDeFuzzMethod() function.
Returns
true on success, otherwise return false.

◆ fuzzify()

bool fis::instance::fuzzify ( void )
noexcept

Perform the fuzzification operation over the crisp inputs on the requested FIS object.

Precondition
I/Os and fuzzy sets must be previously initialized by instance::setupInput(), instance::setupOutput(), instance::setupInputMF(), instance::setupOutputMF and instance::setup() respectively.
Returns
true on success, otherwise return false.

◆ getNumberOfPoints()

size_t qlibs::fis::instance::getNumberOfPoints ( void ) const
inlinenoexcept

Get the number of points used on Mamdani to perform the de-fuzzification proccess.

Returns
The number for points for de-fuzzification.

◆ getOutput()

bool fis::instance::getOutput ( const tag t,
real_t & value ) const
noexcept

Get the de-fuzzified crisp value from the output with the specified tag.

Parameters
[in]tThe output tag
[out]valueThe variable where the output will be stored
Returns
The requested de-fuzzified crisp value.

◆ inference()

bool fis::instance::inference ( void )
noexcept

Perform the inference process on the FIS object.

Precondition
The instance should have already invoked the fuzzification operation successfully with instance::fuzzify()
Returns
true on success, otherwise return false.

◆ operator<<() [1/3]

instance & qlibs::fis::instance::operator<< ( const int & value)
inline

The value to set the previously selected input.

Parameters
[in]valueThe crisp value to set
Returns
The fis object you invoked << upon.

◆ operator<<() [2/3]

instance & qlibs::fis::instance::operator<< ( const real_t & value)
inline

The value to set the previously selected input.

Parameters
[in]valueThe crisp value to set
Returns
The fis object you invoked << upon.

◆ operator<<() [3/3]

instance & qlibs::fis::instance::operator<< ( const tag & t)
inline

Select the input to set using with the specified tag.

Parameters
[in]tThe input tag
Returns
The fis object you invoked << upon.

◆ operator[]()

real_t qlibs::fis::instance::operator[] ( tag outTag) const
inline

Get the de-fuzzified crisp value from the output with the specified tag.

Parameters
[in]outTagThe output tag
Returns
The requested de-fuzzified crisp value.

◆ setDeFuzzMethod()

bool fis::instance::setDeFuzzMethod ( fis::deFuzzMethod m)
noexcept

Change the default de-Fuzzification method of the FIS instance.

Parameters
[in]mThe de-fuzzification method: use one of the following : centroid, bisector, mom, lom, som, wtaver, wtsum
Note
centroid, bisector, mom, lom and som only apply for a Mamdani FIS
wtaver and wtsum only apply for a Sugeno FIS.
wtaver only apply for a Tsukamoto FIS
Returns
true on success, otherwise return false

◆ setInput()

bool fis::instance::setInput ( const tag t,
const real_t value )
noexcept

Set a crisp value of the input with the specified tag.

Parameters
[in]tThe input tag
[in]valueThe crisp value to set
Returns
true on success, otherwise return false.

◆ setParameter()

bool fis::instance::setParameter ( const parameter p,
const paramValue x )
noexcept

Set parameters of the FIS instance.

Parameters
[in]pThe requested parameter to change/set.
[in]xThe value of the parameter to set.
Returns
true on success, otherwise return false.

◆ setRuleWeights()

bool fis::instance::setRuleWeights ( real_t * rWeights)
noexcept

Set weights to the rules of the inference system.

Precondition
I/Os and fuzzy sets must be previously initialized by instance::setupInput(), instance::setupOutput(), instance::setInputMF(), instance::setOutputMF and instance::setup() respectively.
Parameters
[in]rWeightsAn array with the values of every rule weight;
Returns
true on success, otherwise return false.

◆ setup() [1/2]

bool fis::instance::setup ( const type t,
fis::input *const inputs,
const size_t ni,
fis::output *const outputs,
const size_t no,
fis::mf *const mf_inputs,
const size_t nmi,
fis::mf *const mf_outputs,
const size_t nmo,
const rules *const r,
const size_t n,
real_t * rWeights = nullptr )
noexcept

Setup and initialize the FIS instance.

Note
Default configuration : AND = Min, OR = Max, Implication = Min Aggregation = Max, EvalPoints = 100
Parameters
[in]tType of inference Mamdani, Sugeno or Tsukamoto.
[in]inputsAn array with all the system inputs as fis::input objects.
[in]niThe number of elements in the inputs array.
[in]outputsAn array with all the system outputs as fis::output objects.
[in]noThe number of elements in the outputs array.
[in]mf_inputsAn array with all the membership functions related to the inputs. This should be an array of fis::mf objects.
[in]nmiThe number of elements in the mf_inputs array.
[in]mf_outputsAn array with all the membership functions related to the outputs. This should be an array of fis::mf objects.
[in]nmoThe number of elements in the mf_outputs array.
[in]rThe rules set.
[in]nNumber of rules
[in]rWeightsAn array of size n were the rule strengths will be stored.
Returns
true on success, otherwise return false.

◆ setup() [2/2]

template<size_t numberInputs, size_t numberOutputs, size_t numberMFinputs, size_t numberMFOutputs, size_t numberRules>
bool qlibs::fis::instance::setup ( const type t,
input(&) inputs[numberInputs],
output(&) outputs[numberOutputs],
mf(&) mf_inputs[numberMFinputs],
mf(&) mf_outputs[numberMFOutputs],
const rules *const r,
real_t(&) rWeights[numberRules] )
inlinenoexcept

Setup and initialize the FIS instance.

Note
Default configuration : AND = Min, OR = Max, Implication = Min Aggregation = Max, EvalPoints = 100
Parameters
[in]tType of inference Mamdani, Sugeno or Tsukamoto.
[in]inputsAn array with all the system inputs as fis::input objects.
[in]outputsAn array with all the system outputs as fis::output objects.
[in]mf_inputsAn array with all the membership functions related to the inputs. This should be an array of fis::mf objects.
[in]mf_outputsAn array with all the membership functions related to the outputs. This should be an array of fis::mf objects.
[in]rThe rules set.
[in]rWeightsAn array of size n were the rule strengths will be stored.
Returns
true on success, otherwise return false.

◆ setupInput()

bool fis::instance::setupInput ( const tag t,
const real_t Min,
const real_t Max )
noexcept

Setup the input with the specified tag and set limits for it.

Parameters
[in]tThe input tag
[in]MinMinimum allowed value for this input
[in]MaxMax allowed value for this input
Returns
true on success, otherwise return false.

◆ setupInputMF() [1/2]

bool qlibs::fis::instance::setupInputMF ( const tag io,
const tag mf,
const shapeMF s,
const real_t * cp,
const real_t h = 1.0_re )
inlinenoexcept

Setup the input tag and points for the specified membership function.

Parameters
[in]ioThe input tag related with this membership function
[in]mfThe user-defined tag for this membership function
[in]sThe wanted shape/form for this membership function, can be one of the following: trimf, trapmf, gbellmf, gaussmf, gauss2mf, sigmf, dsigmf, psigmf, pimf, smf, zmf, singletonmf, concavemf, spikemf, linsmf, linzmf, rectmf, cosmf.
Note
For Sugeno FIS, an output membership function should be one of the following: constantmf, linearmf.
For Tsukamoto FIS, an output membership function should be one the following monotonic functions : tlinsmf, tlinzmf, tsmf, tzmf, tconcavemf
Parameters
[in]cpPoints or coefficients of the membership function.
[in]hHeight of the membership function.
Note
Height parameter h does not apply for output membership functions on Sugeno and Tsukamoto inference systems. [ 0 <= h <= 1]
Returns
true on success, otherwise return false.

◆ setupInputMF() [2/2]

bool qlibs::fis::instance::setupInputMF ( const tag io,
const tag mf,
mfFunction customMfs,
const real_t * cp,
const real_t h = 1.0_re )
inlinenoexcept

Setup the input tag and points for the specified membership function.

Parameters
[in]ioThe input tag related with this membership function
[in]mfThe user-defined tag for this membership function
[in]customMfsCustom user-defined membership function.
[in]cpPoints or coefficients of the membership function.
[in]hHeight of the membership function.
Note
Height parameter h does not apply for output membership functions on Sugeno and Tsukamoto inference systems. [ 0 <= h <= 1]
Returns
true on success, otherwise return false.

◆ setupOutput()

bool fis::instance::setupOutput ( const tag t,
const real_t Min,
const real_t Max )
noexcept

Setup the output with the specified tag and set limits for it.

Parameters
[in]tThe output tag
[in]MinMinimum allowed value for this output
[in]MaxMax allowed value for this output
Returns
true on success, otherwise return false.

◆ setupOutputMF() [1/2]

bool qlibs::fis::instance::setupOutputMF ( const tag io,
const tag mf,
const shapeMF s,
const real_t * cp,
const real_t h = 1.0_re )
inlinenoexcept

Setup the output tag and points for the specified membership function.

Parameters
[in]ioThe output tag related with this membership function
[in]mfThe user-defined tag for this membership function
[in]sThe wanted shape/form for this membership function, can be one of the following: trimf, trapmf, gbellmf, gaussmf, gauss2mf, sigmf, dsigmf, psigmf, pimf, smf, zmf, singletonmf, concavemf, spikemf, linsmf, linzmf, rectmf, cosmf.
Note
For Sugeno FIS, an output membership function should be one of the following: constantmf, linearmf.
For Tsukamoto FIS, an output membership function should be one the following monotonic functions : tlinsmf, tlinzmf, tsmf, tzmf, tconcavemf
Parameters
[in]cpPoints or coefficients of the membership function.
[in]hHeight of the membership function.
Note
Height parameter h does not apply for output membership functions on Sugeno and Tsukamoto inference systems. [ 0 <= h <= 1]
Returns
true on success, otherwise return false.

◆ setupOutputMF() [2/2]

bool qlibs::fis::instance::setupOutputMF ( const tag io,
const tag mf,
mfFunction customMfs,
const real_t * cp,
const real_t h = 1.0_re )
inlinenoexcept

Set the output tag and points for the specified membership function.

Parameters
[in]ioThe output tag related with this membership function
[in]mfThe user-defined tag for this membership function
[in]customMfsCustom user-defined membership function.
[in]cpPoints or coefficients of the membership function.
[in]hHeight of the membership function.
Note
Height parameter h does not apply for output membership functions on Sugeno and Tsukamoto inference systems. [ 0 <= h <= 1]
Returns
true on success, otherwise return false.