|
#pragma once
#include "LinguisticVariable.h"
#include "FuzzyInput.h"
#include <hash_map>
using namespace stdext;
/*
* Author: Sa�o Ma�ari�
*/
namespace FuzzyLogic{
//ENUM operation
enum Operation{
AND,OR,EMPTY
};
class CFuzzyRuleToken
{
//Is there operator before token
Operation operation;
//Is there negation for this token
bool b_negation;
//Pointer to linguistic variable
CLinguisticVariable* p_linguisticVariable;
//Name of Linguistic value
string linguisticValueName;
public:
//Constructor
CFuzzyRuleToken(bool nNegation,
Operation nOperation,
CLinguisticVariable* nLinguisticVariable,
string nLinguisticValueId)
{
b_negation = nNegation;
operation = nOperation;
p_linguisticVariable = nLinguisticVariable;
linguisticValueName = nLinguisticValueId;
}
~CFuzzyRuleToken(void)
{
}
//Calculate token value
double CalculateTokenOutputValue(hash_map <string, CFuzzyInput*> h_fuzzyInputHashMap)
{
hash_map <string, CFuzzyInput*> :: const_iterator iterator;
//Find linguistic variable
iterator = h_fuzzyInputHashMap.find(p_linguisticVariable->ToString());
CFuzzyInput* temp = (CFuzzyInput*)iterator->second;
double input = temp->GetInputValue();
//Calculate linguistic value
return p_linguisticVariable->CalculateLinguisticValueByName(linguisticValueName, input);
}
void UpdateTokenValue(double newVal)
{
//Just update token value
p_linguisticVariable->UpdateLinguisticValueByName(linguisticValueName, newVal);
}
//GETTERS
string GetLinguisticValueName(){return linguisticValueName;}
CLinguisticVariable* GetLinguisticVariable(){return p_linguisticVariable;}
bool IsOutput(){ return p_linguisticVariable->IsOutputVariable();}
bool IsNegated(){return b_negation;}
bool IsFirst(){
if(operation == EMPTY)
return true;
return false;
}
bool IsAndOperator(){
if(operation == AND)
return true;
return false;
}
bool IsOrOperator(){
if(operation == OR)
return true;
return false;
}
};
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Hey, if you like my content fell more than welcome to contact me on LinkedIn or send me an email to saso.madaric@gmail.com
http://www.linkedin.com/pub/saso-madaric/72/372/b1a
Passionate Team Leader with purpose to keep his team happy and Senior Java Developer who started his first professional software development job at age 20. An enthusiastic believer that technical knowledge is not enough for successfully delivered project - without understanding business domain in detail, project quickly becomes unsuccessful.