A fuzzy logic C++ library
|
Holds all the sets of input membership functions. More...
#include <input_sets.hpp>
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_IN & | GetMfSet (size_t idx) const |
Returns const reference on set of functions identified by index idx . | |
FUZZY_IN & | GetMfSet (size_t idx) |
Returns reference on set of functions identified by index idx . | |
const FUZZY_IN & | GetMfSet (std::string inputvar) const |
Returns const reference on input set of name name . | |
FUZZY_IN & | GetMfSet (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 |
Holds all the sets of input membership functions.
Data is a vector of inputs (FUZZY_IN class)
void slifis::INPUT_SETS::Clear | ( | ) |
Referenced by slifis::SLIFIS::DeleteAllInputs().
void slifis::INPUT_SETS::ClearAllCounters | ( | ) |
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.
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 const reference on set of functions identified by index idx
.
References __IN__, __OUT__, slifis::ERR_MFSET_BAD_INDEX, and SLIFIS_ERROR.
Referenced by slifis::RULE_BASE::AddNewRule(), slifis::RULE_BASE::GetInputSet(), slifis::RULE_IDX::GetRuleFiringStrength(), slifis::DATA_SET::GetSubset(), slifis::ROOT_RULE::GetTSOutputValue(), slifis::SLIFIS::operator==(), and slifis::PrintDifferences().
FUZZY_IN & slifis::INPUT_SETS::GetMfSet | ( | size_t | idx | ) |
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.
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.
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.
fs_idx | index of the input where we want to remove a membership function |
mf_idx | index 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.
void slifis::INPUT_SETS::DeleteAllMf | ( | ) |
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 |
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 the nb of inputs.
References _v_InputFuzzySets.
Referenced by GetName(), slifis::RULE_BASE::GetNbInputs(), slifis::SLIFIS::GetNbInputs(), slifis::RULE_IDX::GetRuleFiringStrength(), slifis::DATA_SET::GetSubset(), slifis::ROOT_RULE::GetTSOutputValue(), and slifis::RULE_BASE::Sort().
bool slifis::INPUT_SETS::AreValid | ( | ) | const |
Returns true if all the sets are valid.
Just calls FUZZY_ROOT::SetIsValid() on all of them.
const std::vector<FUZZY_IN>& slifis::INPUT_SETS::GetMfSetVector | ( | ) | const [inline] |
References _v_InputFuzzySets.
size_t slifis::INPUT_SETS::GetNbCombinations | ( | ) | const |
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 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
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.
std::vector<FUZZY_IN> slifis::INPUT_SETS::_v_InputFuzzySets [private] |
Referenced by GetMfSetVector(), GetName(), and GetNb().