A fuzzy logic C++ library
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
slifis::SLIFIS Class Reference

This is the main class of the library, holds everything is required for a Fis. More...

#include <slifis.hpp>

+ Collaboration diagram for slifis::SLIFIS:

List of all members.

Public Member Functions

 SLIFIS (EN_FIS_TYPE FisType=TYPE_MAMDANI)
 Constructor, default type is "Mamdani".
 SLIFIS (std::string name, EN_FIS_TYPE Type=TYPE_MAMDANI)
 Constructor, default type is "Mamdani".
Feeding input values, and getting output
void SetInputValue (size_t idx, REALVAL value)
 Sets one input value - 3.
void SetInputValue (std::string inputvar, REALVAL value)
 Sets one input value.
void SetInputValues (const std::vector< REALVAL > &vect)
 Sets input values with the values given in vector vect.
void SetInputValues (const DATA_POINT &dpt, const DATA_DESCR &dd)
 Sets input values with the values given in data point dpt.
REALVAL GetOutputValue ()
 Computes the defuzzyfied value from the FIS (Mamdani or TS type)
MEMBFUNC GetOutputMf ()
 Return the output membership function, that is, for a given set of input values,.
FUZZYVAL GetFuzzyValue (size_t idx_input, size_t idx_mf) const
 Returns fuzzy value of input set idx_input, using membership function idx_mf.
FUZZYVAL GetFuzzyValue (std::string in_name, size_t idx_mf) const
 Returns fuzzy value of input set of name in_name, using membership function idx_mf.
const std::vector< MEMBFUNC > & GetOutMfVector () const
const std::vector< size_t > & GetOutRulesVector () const
rules : adding rules from data and reducing the rule base
bool AddRuleFromValues (const std::vector< REALVAL > &vect, const VALUE_PTR &out)
 Builds and adds a Mamdani AND rule to the FIS, and compute its degree (v1)
bool AddRuleFromValues (const std::vector< REALVAL > &vect, const VALUE &out)
 Builds and adds a Mamdani AND rule to the FIS, and compute its degree (v2)
void ReduceRuleBase (EN_REDUCE_METHOD method=REDM_HIGHEST_SUM)
 Parse the rule base, and removes rules that have the same premisses but different "consequence" part, based on degree of rule.
void FactorizeRuleBase ()
 Factorisation of rule base.
bool BuildRuleBaseFromData (const DATA_SET &dataset, RBB_PARAMS &rbb_params)
 Builds the rule base using the provided data, ok for Madamni or TS FIS type.
bool BuildTSRulesFromValues (const DATA_SET &dataset, RBB_PARAMS &rbb_params)
 Linear fitting with Eigen (least squares, no outlier detection)
Handling ouput set of membership functions
void SetOutput (const FUZZY_OUT &f)
 Assigns the set of functions of output membership functions to the given set of functions fout.
bool AddOutputMf (const MEMBFUNC &mf)
 Adds the membership function mf to the output set of functions.
void DeleteOutputMf (size_t idx)
 Delete a MF in the output set.
const FUZZY_OUTGetOutputSet () const
 Returns reference on output set of functions.
std::string GetOutputName () const
 Returns name of output set of membership functions.
Handling inputs sets of membership functions
size_t GetNbInputs () const
std::string GetInputName (size_t idx) const
 Returns name of the input membership function associated to index idx.
bool HasInput (std::string s) const
 Returns true is fis already has an input of that name.
void AddInput (const FUZZY_IN &f)
 Adds a set of input membership functions to the classifyier.
void DeleteInput (std::string in_name)
 Delete an input, identified through name.
void DeleteInput (size_t idx)
 Delete an input, identified through index.
bool AddInputMf (std::string name, const MEMBFUNC &mf)
 Adds the membership function mf to the input set of functions identified by name name. Returns false on error (unable to find set of that name, or already a function of that name in set)
bool AddInputMf (size_t idx, const MEMBFUNC &mf)
 Adds the membership function mf to the input set of functions identified by index idx. Returns false on error (already a function of that name in set, or index invalid)
void DeleteInputMf (size_t fs_idx, size_t mf_idx)
 Deletes the membership function identified by index mf_idx from the input set of functions identified by index fs_idx. Returns false on error (invalid index)
void DeleteInputMf (std::string fs_name, size_t mf_idx)
 Deletes the membership function identified by index mf_idx from the input set of functions identified by name fs_name. Returns false on error (unable to find set of that name)
void DeleteAllInputsMf ()
 Erases all membership functions of the inputs, does not delete the inputs.
void DeleteAllInputs ()
 Deletes all inputs.
const FUZZY_INGetInputSet (size_t idx) const
 Returns reference on input set of index idx.
const FUZZY_INGetInputSet (std::string inputvar) const
 Returns reference on input set of name name.
Handling contained rule base
size_t GetNbRules () const
void AddRule (const RULE &r)
 Add the rule rule to the inference system.
void AddRule (const RULE_IDX &rule)
 Experimental, returns false if rule is not valid. Makes sense only if inputs/outputs have been defined.
void DeleteAllRules ()
 Deletes all rules.
const RULE_BASEGetRuleBase () const
RULE_BASEGetRuleBase ()
Managing counting of triggered functions in all the contained sets.
void ClearCounters ()
 Clears all counters.
void GenerateHistogramFile () const
 Generates material for plotting histograms of input triggering with gnuplot.
void GetOutputTriggerValues (std::vector< size_t > &v_hits) const
 Return trigger values for the ouput set of membership functions, see Density information.
void GetInputTriggerValues (size_t input_idx, std::vector< size_t > &v_hits) const
 Return trigger values for the input input_idx set of membership functions, see Density information.
void GetInputTriggerValues (std::string fs_name, std::vector< size_t > &v_hits) const
 Return trigger values for the input named name set of membership functions, see Density information.
double GetInputCoeffVar (size_t idx)
 Returns coeff of variation for input input_idx, see Density information for more information.
double GetInputCoeffVar (std::string input_name)
 Returns coeff of variation for input input_name, see Density information for more information.
double GetOutputCoeffVar ()
 Returns coeff of variation for FIS output, see Density information for more information.
File I/O operations
void Print (FILE *f=stderr) const
 Print data in human-readable form in file f.
void Print (std::string filename) const
 Print data in human-readable form, into file filename.
void Read (std::string filename, EN_AUTO_FILE_FORMAT format_auto=AUTO_EXT_OFF, EN_FIS_CHECKING=EN_FIS_CHECKING_YES)
 Read FIS from a file.
void Write (std::string filename, EN_AUTO_FILE_FORMAT format_auto=AUTO_EXT_OFF) const
 Generic "write" function.
Misc.
void Clear ()
const std::string & GetName () const
 Returns name of Fis.
void SetName (std::string n)
void SetDefuzzMethod (EN_DEFUZZMETHOD m)
void SetOutputAggregMethod (EN_SNORM snorm)
void SetRuleInferenceMethod (EN_TNORM and_op, EN_SNORM or_op)
EN_DEFUZZMETHOD GetDefuzzMethod () const
INF_PARAMSGetInferenceParams ()
EN_FIS_TYPE GetType () const
bool IsValid () const
 Checks validity of FIS.
bool Generate3DPlot (INPUT_RANGE &r0, INPUT_RANGE &r1, std::string filename)
 Generates 2 files: a data file and a gnuplot command file to generate a 3D plot of FIS.
Defined operators
bool operator== (const SLIFIS &m) const
 Comparison operator.
bool operator!= (const SLIFIS &m) const

Static Public Member Functions

static const char * GetVersion_String ()
 Static member function.
static void SetDefaultIO (EN_FF_TYPE f)

Private Member Functions

void P_Init (EN_FIS_TYPE Type)
bool P_Evaluate_M ()
 Computes the output membership function for Mamdani FIS type.
bool P_Evaluate_TS (REALVAL &out_val)
 Evaluates the fis and produces an output value for Takagi-Sugeno FIS type.
double P_ComputeCoeffVar (const std::vector< size_t > &v_hits)
 Does the computing of coeff of variation, see http://en.wikipedia.org/wiki/Coefficient_of_variation.
bool P_Read_bin (std::string filename)
 Read binary FIS file, see SLIFIS::P_Write_bin() for details.
bool P_Write_bin (std::string filename) const
 Save all the data into a binary file.
bool P_Write_FCL (std::string filename) const
 FCL export function, argument is name WITHOUT extension (will be added automatically)
bool P_Read_XML (std::string filename)
 XML file reading, see File Storage.
bool P_Write_XML (std::string filename) const
 XML file write, see File Storage.

Private Attributes

bool _HasChanged
 Flag used to know if "something" (rule base, input sets, output set, input values...) has changed in the FIS.
RULE_BASE _rule_base
 The rule base...
INPUT_SETS _InputFuzzySets
 Input sets of membership functions.
FUZZY_OUT _OutputFuzzySet
 Output set of membership functions.
MEMBFUNC _mf_out
 Output membership function, for a given input value.
std::vector< MEMBFUNC_v_out_mf
 Used only for evaluating output (aggregation of MF produced by several rules)
std::vector< size_t > _v_RuleIndexes
 Used only for evaluating output, holds indexes of the rules used to produce the output membership function.
std::string _fis_name
EN_FIS_TYPE _FisType
 TYPE_MAMDANI or TYPE_SUGENO.
INF_PARAMS _InferParams
 Inference parameters.

Static Private Attributes

static EN_FF_TYPE _s_file_format = IO_BIN
 default file format used for Write() and Read() operations, change with SetDefaultIO()

Friends

void PrintDifferences (FILE *f, const SLIFIS &fis1, const SLIFIS &fis2)
 Prints in f the differences between the two FIS.

Detailed Description

This is the main class of the library, holds everything is required for a Fis.

Contains the following data items:


Constructor & Destructor Documentation

Constructor, default type is "Mamdani".

slifis::SLIFIS::SLIFIS ( std::string  name,
EN_FIS_TYPE  Type = TYPE_MAMDANI 
)

Constructor, default type is "Mamdani".


Member Function Documentation

void slifis::SLIFIS::SetInputValue ( size_t  idx,
REALVAL  value 
)

Sets one input value - 3.

References __IN__, __OUT__, slifis::ERR_MFSET_BAD_INDEX, and SLIFIS_ERROR_2.

Referenced by Process().

void slifis::SLIFIS::SetInputValue ( std::string  inputvar,
REALVAL  value 
)

Sets one input value.

References __IN__, __OUT__, slifis::ERR_MFSET_NONAME, and SLIFIS_ERROR_1.

void slifis::SLIFIS::SetInputValues ( const std::vector< REALVAL > &  v_in)

Sets input values with the values given in vector vect.

Warning:
Using this function is not recommended, because values are mapped on inputs depending on their index, so you need to take care of the orders of inputs in the FIS.

References __IN__, __OUT__, slifis::ERR_BAD_INPUT_SIZE, and SLIFIS_ERROR_2.

Referenced by main().

void slifis::SLIFIS::SetInputValues ( const DATA_POINT dpt,
const DATA_DESCR dd 
)

Computes the defuzzyfied value from the FIS (Mamdani or TS type)

  • Assumes the FIS has rules, input and output functions, and input values
  • Returns false if unable to defuzzify

References __IN__, __OUT__, slifis::ERR_FIS_DEFUZZ_UNABLE, slifis::ERR_FIS_EVAL_UNABLE, SLIFIS_ERROR, and slifis::TYPE_MAMDANI.

Referenced by main().

Return the output membership function, that is, for a given set of input values,.

returns the function that was built using the rule base.

References __IN__, __OUT__, slifis::ERR_FIS_BAD_TYPE, SLIFIS_ERROR, and slifis::TYPE_MAMDANI.

Referenced by Process(), and Show().

FUZZYVAL slifis::SLIFIS::GetFuzzyValue ( size_t  idx_input,
size_t  idx_mf 
) const

Returns fuzzy value of input set idx_input, using membership function idx_mf.

References __IN__, __OUT__, slifis::ERR_MFSET_BAD_INDEX, and SLIFIS_ERROR_2.

FUZZYVAL slifis::SLIFIS::GetFuzzyValue ( std::string  in_name,
size_t  idx_mf 
) const

Returns fuzzy value of input set of name in_name, using membership function idx_mf.

References __IN__, and __OUT__.

const std::vector<MEMBFUNC>& slifis::SLIFIS::GetOutMfVector ( ) const [inline]

References _v_out_mf.

Referenced by main(), and Process().

const std::vector<size_t>& slifis::SLIFIS::GetOutRulesVector ( ) const [inline]

References _v_RuleIndexes.

Referenced by main().

bool slifis::SLIFIS::AddRuleFromValues ( const std::vector< REALVAL > &  in,
const VALUE_PTR out 
)

Builds and adds a Mamdani AND rule to the FIS, and compute its degree (v1)

according to

  • the given input values (one per input variable)
  • the given output value (string or numerical)

Referenced by main().

bool slifis::SLIFIS::AddRuleFromValues ( const std::vector< REALVAL > &  in,
const VALUE out 
)

Builds and adds a Mamdani AND rule to the FIS, and compute its degree (v2)

according to

  • the given input values (one per input variable)
  • the given output value (string or numerical)

References __IN__, __OUT__, slifis::ERR_FIS_BAD_TYPE, SLIFIS_ERROR, and slifis::TYPE_MAMDANI.

Parse the rule base, and removes rules that have the same premisses but different "consequence" part, based on degree of rule.

See RULE_BASE::Reduce()

References __IN__, __OUT__, SLIFIS_WARNING, and slifis::TYPE_MAMDANI.

Referenced by main().

Factorisation of rule base.

References __IN__, and __OUT__.

Referenced by main().

bool slifis::SLIFIS::BuildRuleBaseFromData ( const DATA_SET dataset,
RBB_PARAMS rbb_params 
)
bool slifis::SLIFIS::BuildTSRulesFromValues ( const DATA_SET dataset,
RBB_PARAMS rbb_params 
)
void slifis::SLIFIS::SetOutput ( const FUZZY_OUT f)

Assigns the set of functions of output membership functions to the given set of functions fout.

References __IN__, __OUT__, slifis::ERR_MFSET_NOT_VALID, slifis::FUZZY_OUT::SetIsValid(), and SLIFIS_ERROR.

Referenced by main().

bool slifis::SLIFIS::AddOutputMf ( const MEMBFUNC mf)

Adds the membership function mf to the output set of functions.

References __IN__, and __OUT__.

void slifis::SLIFIS::DeleteOutputMf ( size_t  idx)

Delete a MF in the output set.

References __IN__, and __OUT__.

Returns reference on output set of functions.

Referenced by main(), Mouse_CB_rb_2D(), Mouse_CB_rb_text(), and slifis::PrintDifferences().

std::string slifis::SLIFIS::GetOutputName ( ) const [inline]

Returns name of output set of membership functions.

References _OutputFuzzySet, and slifis::FUZZY_ROOT::GetName().

size_t slifis::SLIFIS::GetNbInputs ( ) const [inline]
std::string slifis::SLIFIS::GetInputName ( size_t  idx) const

Returns name of the input membership function associated to index idx.

Referenced by main(), and Show().

bool slifis::SLIFIS::HasInput ( std::string  s) const

Returns true is fis already has an input of that name.

void slifis::SLIFIS::AddInput ( const FUZZY_IN f)

Adds a set of input membership functions to the classifyier.

Warning:
If a set of same name already exists in the FIS, then its function will be (silently) overwritten!

References __IN__, and __OUT__.

Referenced by main().

void slifis::SLIFIS::DeleteInput ( std::string  in_name)

Delete an input, identified through name.

  • Returns true on success, false if not found. Warning is issued in log file on failure (by INPUT_SETS::Delete() function)

References __IN__, __OUT__, and SLIFIS_CATCH_RETHROW.

void slifis::SLIFIS::DeleteInput ( size_t  idx)

Delete an input, identified through index.

  • Returns true on success, false if not found. Warning is issued in log file on failure (by INPUT_SETS::Delete() function)

References __IN__, __OUT__, and SLIFIS_CATCH_RETHROW.

bool slifis::SLIFIS::AddInputMf ( std::string  name,
const MEMBFUNC mf 
)

Adds the membership function mf to the input set of functions identified by name name. Returns false on error (unable to find set of that name, or already a function of that name in set)

References __IN__, and __OUT__.

bool slifis::SLIFIS::AddInputMf ( size_t  idx,
const MEMBFUNC mf 
)

Adds the membership function mf to the input set of functions identified by index idx. Returns false on error (already a function of that name in set, or index invalid)

References __IN__, and __OUT__.

void slifis::SLIFIS::DeleteInputMf ( size_t  fs_idx,
size_t  mf_idx 
)

Deletes the membership function identified by index mf_idx from the input set of functions identified by index fs_idx. Returns false on error (invalid index)

References __IN__, and __OUT__.

void slifis::SLIFIS::DeleteInputMf ( std::string  fs_name,
size_t  mf_idx 
)

Deletes the membership function identified by index mf_idx from the input set of functions identified by name fs_name. Returns false on error (unable to find set of that name)

References __IN__, and __OUT__.

Erases all membership functions of the inputs, does not delete the inputs.

References _InputFuzzySets, and slifis::INPUT_SETS::DeleteAllMf().

Deletes all inputs.

References _HasChanged, _InputFuzzySets, and slifis::INPUT_SETS::Clear().

Referenced by main().

const FUZZY_IN & slifis::SLIFIS::GetInputSet ( size_t  idx) const

Returns reference on input set of index idx.

Referenced by main(), and Mouse_CB_rb_text().

const FUZZY_IN & slifis::SLIFIS::GetInputSet ( std::string  inputvar) const

Returns reference on input set of name name.

size_t slifis::SLIFIS::GetNbRules ( ) const [inline]

References _rule_base, and slifis::RULE_BASE::GetNbRules().

Referenced by main().

void slifis::SLIFIS::AddRule ( const RULE rule)

Add the rule rule to the inference system.

This functions converts the rule expressed in linguistic terms (RULE) into a rule expressed using indexes of corresponding input and output fuzzyfication (RULE_IDX) Throws an error if:

  • rule is not of same inference type as the Fis,
  • the Fis has no inputs defined,
  • the rule has no terms,
  • no inputs are assigned, in case of a Madani rule.

References __IN__, __OUT__, slifis::RULE_IDX::AddTerm(), slifis::ERR_MF_NAME_NOT_FOUND, slifis::ERR_MFSET_EMPTY, slifis::ERR_NO_INPUTS, slifis::ERR_RULE_BAD_TYPE, slifis::ERR_RULE_NAME_NOT_FOUND, slifis::ERR_RULE_NO_OUTPUT_VAL, slifis::ERR_RULE_NO_TERMS, slifis::ROOT_RULE::GetFisType(), slifis::FUZZY_ROOT::GetMfName(), slifis::FUZZY_ROOT::GetName(), slifis::FUZZY_ROOT::GetNbMf(), slifis::RULE::GetNbTerms(), slifis::RULE::GetOutputValue(), slifis::RULE::GetVarName(), slifis::RULE::GetVarValue(), slifis::RULE_IDX::SetOutMfIndex(), SLIFIS_DEBUG_LOG, SLIFIS_ERROR, SLIFIS_ERROR_2, and slifis::TYPE_MAMDANI.

Referenced by main().

void slifis::SLIFIS::AddRule ( const RULE_IDX rule)
void slifis::SLIFIS::DeleteAllRules ( ) [inline]

Deletes all rules.

References _HasChanged, _rule_base, slifis::RULE_BASE::Clear(), and ClearCounters().

Referenced by main().

const RULE_BASE& slifis::SLIFIS::GetRuleBase ( ) const [inline]

References _rule_base.

Clears all counters.

This function is called on each modification of FIS (adding or deleting inputs, adding or deleting Mf from inputs, adding or deleting output Mf,...

See Density information.

References slifis::FUZZY_ROOT::ClearCounters().

Referenced by DeleteAllRules().

Generates material for plotting histograms of input triggering with gnuplot.

The goal is that the user can appreciate how the choosen sets of functions 'fit' the real data, in a visual way.

See Density information.

With a fis having 'n' input, this function will generate n+2 files:

  • 1 main plotting file (SLIFIS_histo.plt), that is the "command" file for gnuplot
  • 1 data file (.dat) for the output function set triggering
  • n data files (.dat) for the input function sets triggering

At present, all files are written in the current directory

Of course, this must be done when some data has been fed to the fis. This can be done in learning stage, or in production stage.

The tool used is gnuplot (http://www.gnuplot.info), a well-known plotting app, freely available for all platforms.

At present, histogram plotting style parameters (gnuplot related) are hard-coded, but you can of course edit this file afterwards.

Low Priority Todo:
Replace hard-coded gnuplot commands by a text file included from here. This will enable easier customization without rebuilding library.

References __IN__, __OUT__, slifis::ERR_IO_ERROR, SLIFIS_ERROR_1, SLIFIS_STAMP_S, and SLIFIS_WARNING.

Referenced by main().

void slifis::SLIFIS::GetOutputTriggerValues ( std::vector< size_t > &  v_hits) const

Return trigger values for the ouput set of membership functions, see Density information.

void slifis::SLIFIS::GetInputTriggerValues ( size_t  input_idx,
std::vector< size_t > &  v_hits 
) const

Return trigger values for the input input_idx set of membership functions, see Density information.

References SLIFIS_CATCH_RETHROW.

void slifis::SLIFIS::GetInputTriggerValues ( std::string  fs_name,
std::vector< size_t > &  v_hits 
) const

Return trigger values for the input named name set of membership functions, see Density information.

double slifis::SLIFIS::GetInputCoeffVar ( size_t  idx)

Returns coeff of variation for input input_idx, see Density information for more information.

References SLIFIS_WARNING_2.

Referenced by main().

double slifis::SLIFIS::GetInputCoeffVar ( std::string  input_name)

Returns coeff of variation for input input_name, see Density information for more information.

References SLIFIS_WARNING_1.

Returns coeff of variation for FIS output, see Density information for more information.

Referenced by main().

void slifis::SLIFIS::Print ( FILE *  f = stderr) const

Print data in human-readable form in file f.

This can be any opened file, or stdout, stderr, ...

References __IN__, __OUT__, slifis::GetString(), and SLIFIS_STAMP_F.

Referenced by main().

void slifis::SLIFIS::Print ( std::string  filename) const

Print data in human-readable form, into file filename.

References __IN__, __OUT__, and SLIFIS_WARNING_1.

void slifis::SLIFIS::Read ( std::string  filename,
EN_AUTO_FILE_FORMAT  format_auto = AUTO_EXT_OFF,
EN_FIS_CHECKING  do_checking = EN_FIS_CHECKING_YES 
)

Read FIS from a file.

In case of error, throws an error, and writes error message to cerr

Warning:
Default defuzzyfication method IS NOT read from file !

References __IN__, __OUT__, slifis::AUTO_EXT_ON, slifis::EN_FIS_CHECKING_YES, slifis::ERR_FIS_NOTVALID, slifis::ERR_IO_ERROR, slifis::GetTypeFromFilename(), slifis::IO_BIN, slifis::IO_FCL, slifis::IO_UNKNOWN, slifis::IO_XML, SLIFIS_ERROR_1, SLIFIS_ERROR_LOG, and SWITCH_ERROR.

Referenced by main().

void slifis::SLIFIS::Write ( std::string  filename,
EN_AUTO_FILE_FORMAT  format_auto = AUTO_EXT_OFF 
) const
const std::string & slifis::SLIFIS::GetName ( ) const [inline]

Returns name of Fis.

References _fis_name.

Referenced by main().

void slifis::SLIFIS::SetName ( std::string  n) [inline]

References _fis_name.

References _InferParams, and slifis::INF_PARAMS::DefuzzMethod.

Referenced by main().

void slifis::SLIFIS::SetRuleInferenceMethod ( EN_TNORM  and_op,
EN_SNORM  or_op 
) [inline]

References _InferParams.

References _FisType.

Referenced by main(), operator==(), and slifis::PrintDifferences().

bool slifis::SLIFIS::IsValid ( ) const

Checks validity of FIS.

A FIS must have:

References __IN__, __OUT__, and SLIFIS_ERROR_LOG.

bool slifis::SLIFIS::Generate3DPlot ( INPUT_RANGE rx,
INPUT_RANGE ry,
std::string  filename 
)

Generates 2 files: a data file and a gnuplot command file to generate a 3D plot of FIS.

Low Priority Todo:
Move all the static gnuplot commands to a template file, for easier customisation

References __IN__, __OUT__, slifis::INPUT_RANGE::GetCurrentValue(), slifis::INPUT_RANGE::GetName(), slifis::INPUT_RANGE::GetNbSteps(), slifis::INPUT_RANGE::Init(), SLIFIS_ERROR_LOG, and SLIFIS_STAMP_S.

Referenced by main().

const char * slifis::SLIFIS::GetVersion_String ( ) [static]

Static member function.

References STR.

Referenced by main().

static void slifis::SLIFIS::SetDefaultIO ( EN_FF_TYPE  f) [inline, static]

References _s_file_format.

Referenced by main().

bool slifis::SLIFIS::operator== ( const SLIFIS m) const
bool slifis::SLIFIS::operator!= ( const SLIFIS m) const [inline]
void slifis::SLIFIS::P_Init ( EN_FIS_TYPE  Type) [private]
bool slifis::SLIFIS::P_Evaluate_M ( ) [private]
bool slifis::SLIFIS::P_Evaluate_TS ( REALVAL out_val) [private]

Evaluates the fis and produces an output value for Takagi-Sugeno FIS type.

Inference method: for each rule, we compute its firing strength (see Firing strength of a rule), the corresponding value computed from the coefficients, and the global output value is the weighted means of all the values.

See FIS usage and Defuzzification.

References __IN__, __OUT__, slifis::RULE_IDX::GetRuleFiringStrength(), slifis::ROOT_RULE::GetTSOutputValue(), slifis::FUZZYVAL::IsZero(), SLIFIS_DEBUG_LOG, and SLIFIS_WARNING.

double slifis::SLIFIS::P_ComputeCoeffVar ( const std::vector< size_t > &  v_hits) [private]

Does the computing of coeff of variation, see http://en.wikipedia.org/wiki/Coefficient_of_variation.

bool slifis::SLIFIS::P_Read_bin ( std::string  filename) [private]
bool slifis::SLIFIS::P_Write_bin ( std::string  filename) const [private]

Save all the data into a binary file.

In case of error, returns false, and writes error message to cerr.

The ordering of data inside file is:

  1. string : version string of library used to save the file
  2. string : name and/or description
  3. Rule base
  4. int : Nb of input sets of membership functions
  5. Input sets of membership functions
  6. Output set of membership functions
  7. Inference parameters

See SLIFIS::P_Read_bin() for reading

References __IN__, __OUT__, slifis::g_current_bin_file_format(), SLIFIS_WARNING, SLIFIS_WARNING_1, STREAM_OK_TEST, STREAM_WRITE_STRING, and STREAMCHECK_INIT.

bool slifis::SLIFIS::P_Write_FCL ( std::string  filename) const [private]
bool slifis::SLIFIS::P_Read_XML ( std::string  filename) [private]
bool slifis::SLIFIS::P_Write_XML ( std::string  filename) const [private]

Friends And Related Function Documentation

void PrintDifferences ( FILE *  f,
const SLIFIS fis1,
const SLIFIS fis2 
) [friend]

Prints in f the differences between the two FIS.


Member Data Documentation

default file format used for Write() and Read() operations, change with SetDefaultIO()

Referenced by SetDefaultIO().

Flag used to know if "something" (rule base, input sets, output set, input values...) has changed in the FIS.

The ONLY time it is set to 'false' is when output membership function is evaluated (see P_Evaluate_M() )

Referenced by DeleteAllInputs(), and DeleteAllRules().

The rule base...

Referenced by DeleteAllRules(), GetNbRules(), GetRuleBase(), and operator==().

Input sets of membership functions.

Referenced by DeleteAllInputs(), DeleteAllInputsMf(), GetNbInputs(), operator==(), and slifis::PrintDifferences().

Output set of membership functions.

Referenced by GetOutputName(), and operator==().

Output membership function, for a given input value.

std::vector<MEMBFUNC> slifis::SLIFIS::_v_out_mf [private]

Used only for evaluating output (aggregation of MF produced by several rules)

Referenced by GetOutMfVector().

std::vector<size_t> slifis::SLIFIS::_v_RuleIndexes [private]

Used only for evaluating output, holds indexes of the rules used to produce the output membership function.

Referenced by GetOutRulesVector().

std::string slifis::SLIFIS::_fis_name [private]

Referenced by GetName(), and SetName().

TYPE_MAMDANI or TYPE_SUGENO.

Referenced by GetType().