A fuzzy logic C++ library
Private Attributes
slifis::INPUT_SETS Class Reference

Holds all the sets of input membership functions. More...

#include <input_sets.hpp>

+ Collaboration diagram for slifis::INPUT_SETS:

List of all members.

Public Member Functions

Constructors and related functions
 INPUT_SETS ()
 ~INPUT_SETS ()
void Clear ()
Density/triggering related
void ClearAllCounters ()
 Clears all trigger counters of all the inputs.
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.
Adding stuff to inputs
void Add (const FUZZY_IN &f)
 Add set of functions f to input set.
bool AddMf (size_t idx, const MEMBFUNC &mf)
 Add membership function mf to input set idx. Returns false in case of error, and outputs an warning in logfile.
bool AddMf (std::string name, const MEMBFUNC &mf)
 Add membership function mf to input set identified by name. Returns false in case of error, and outputs an warning in logfile.
Fetching and editing sets
const FUZZY_INGetMfSet (size_t idx) const
 Returns const reference on set of functions identified by index idx.
FUZZY_INGetMfSet (size_t idx)
 Returns reference on set of functions identified by index idx.
const FUZZY_INGetMfSet (std::string inputvar) const
 Returns const reference on input set of name name.
FUZZY_INGetMfSet (std::string inputvar)
 Returns reference on input set of name name.
void DeleteSet (size_t idx)
 Delete input set identified by index idx, return false on failure, true on success.
void DeleteSet (std::string &in_name)
 Delete input set identified by name in_name, return false on failure, true on success.
void DeleteMf (size_t fs_idx, size_t mf_idx)
 Delete a membership function in one of the inputs sets, given by index.
void DeleteMf (std::string in_name, size_t mf_idx)
 Deletes in input fs_name the membership function with index mf_idx.
void DeleteAllMf ()
 Removes all membreship functions of all input sets, but keeps those.
Information on sets
int FindInputSet (std::string name) const
 Returns the index of input set of functions identified by name. If not found, returns -1.
const std::string & GetName (size_t idx) const
 Returns the name of input of index idx.
size_t GetNb () const
 Returns the nb of inputs.
bool AreValid () const
 Returns true if all the sets are valid.
const std::vector< FUZZY_IN > & GetMfSetVector () const
size_t GetNbCombinations () const
 Returns the nb of membership combinations possible with the given input sets.
void GetIndexCombination (size_t idx, std::vector< size_t > &) const
 Returns a vector of size equal to the number of inputs, containing indexes for inputs corresponding to combination idx.
void PrintInputNames (FILE *f) const
 Prints input names, used for user help in case of trouble.

Private Attributes

std::vector< FUZZY_IN_v_InputFuzzySets

Detailed Description

Holds all the sets of input membership functions.

Data is a vector of inputs (FUZZY_IN class)


Constructor & Destructor Documentation


Member Function Documentation

Clears all trigger counters of all the inputs.

void slifis::INPUT_SETS::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 __IN__, __OUT__, slifis::ERR_MFSET_BAD_INDEX, and SLIFIS_ERROR_2.

void slifis::INPUT_SETS::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.

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

void slifis::INPUT_SETS::Add ( const FUZZY_IN f)

Add set of functions f to input set.

Warning:
If a set of same name already exists in input set, the new one will (silently) replace it!

References slifis::FUZZY_ROOT::GetName().

bool slifis::INPUT_SETS::AddMf ( size_t  idx,
const MEMBFUNC mf 
)

Add membership function mf to input set idx. Returns false in case of error, and outputs an warning in logfile.

References __IN__, __OUT__, SLIFIS_WARNING, and SLIFIS_WARNING_1.

bool slifis::INPUT_SETS::AddMf ( std::string  name,
const MEMBFUNC mf 
)

Add membership function mf to input set identified by name. Returns false in case of error, and outputs an warning in logfile.

References __IN__, __OUT__, SLIFIS_WARNING, and SLIFIS_WARNING_1.

const FUZZY_IN & slifis::INPUT_SETS::GetMfSet ( size_t  idx) const

Returns reference on set of functions identified by index idx.

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

const FUZZY_IN & slifis::INPUT_SETS::GetMfSet ( std::string  inputvar) const

Returns const reference on input set of name name.

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

FUZZY_IN & slifis::INPUT_SETS::GetMfSet ( std::string  inputvar)

Returns reference on input set of name name.

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

void slifis::INPUT_SETS::DeleteSet ( size_t  idx)

Delete input set identified by index idx, return false on failure, true on success.

  • In case of failure (invalid index), prints a warning in logfile

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

void slifis::INPUT_SETS::DeleteSet ( std::string &  in_name)

Delete input set identified by name in_name, return false on failure, true on success.

  • In case of failure (set has no input of that name), prints a warning in logfile

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

void slifis::INPUT_SETS::DeleteMf ( size_t  fs_idx,
size_t  mf_idx 
)

Delete a membership function in one of the inputs sets, given by index.

Parameters:
fs_idxindex of the input where we want to remove a membership function
mf_idxindex of the membership function we want to remove in the input fs_idx

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

void slifis::INPUT_SETS::DeleteMf ( std::string  in_name,
size_t  mf_idx 
)

Deletes in input fs_name the membership function with index mf_idx.

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

Removes all membreship functions of all input sets, but keeps those.

References __IN__, and __OUT__.

Referenced by slifis::SLIFIS::DeleteAllInputsMf().

int slifis::INPUT_SETS::FindInputSet ( std::string  name) const

Returns the index of input set of functions identified by name. If not found, returns -1.

References __IN__, and __OUT__.

const std::string & slifis::INPUT_SETS::GetName ( size_t  idx) const [inline]

Returns the name of input of index idx.

References __IN__, __OUT__, _v_InputFuzzySets, slifis::ERR_MFSET_BAD_INDEX, GetNb(), and SLIFIS_ERROR_2.

size_t slifis::INPUT_SETS::GetNb ( ) const [inline]

Returns true if all the sets are valid.

Just calls FUZZY_ROOT::SetIsValid() on all of them.

References __IN__, and __OUT__.

const std::vector<FUZZY_IN>& slifis::INPUT_SETS::GetMfSetVector ( ) const [inline]

References _v_InputFuzzySets.

Returns the nb of membership combinations possible with the given input sets.

For example, say input 1 has 3 MF, input 2 has 2 MF and input 3 has 4 MF. Then whe have $ 3 \times 2 \times 4 = 24 $ possible combinations.

References __IN__, __OUT__, slifis::ERR_NO_INPUTS, and SLIFIS_ERROR.

void slifis::INPUT_SETS::GetIndexCombination ( size_t  idx_comb,
std::vector< size_t > &  v_idx 
) const

Returns a vector of size equal to the number of inputs, containing indexes for inputs corresponding to combination idx.

For example, say input 1 has 3 MF, input 2 has 2 MF and input 3 has 4 MF. Then the number of combinations will be computed by GetNbCombinations() and will be equal to $ 3 \times 2 \times 4 = 24 $

If we ask for:

index 0, then vector will be ( 0, 0, 0 )
      1,                     ( 0, 0, 1 )
      2,                     ( 0, 0, 2 )
      3,                     ( 0, 0, 3 )
      4,                     ( 0, 1, 0 )
      5,                     ( 0, 1, 1 )
      6,                     ( 0, 1, 2 )
      7,                     ( 0, 1, 3 )
      8,                     ( 1, 0, 0 )
...
	 22,                     ( 2, 1, 2 )
	 23,                     ( 2, 1, 3 )

Needed for Takagi-Sugeno rule building.

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

void slifis::INPUT_SETS::PrintInputNames ( FILE *  f) const

Prints input names, used for user help in case of trouble.


Member Data Documentation

Referenced by GetMfSetVector(), GetName(), and GetNb().