home › Forums › # Technical Support › Problem with importing and getting results
Tagged: # Technical Support
 This topic has 2 replies, 2 voices, and was last updated 7 years, 10 months ago by Unknown.

AuthorPosts

January 26, 2015 at 11:50 #1641UnknownMember
Hi Juan,
Thanks for your great toolbox. I wanted to use your toolbox in my project. I used following codes, but every time I get “nan”as a result. Would you please help me out?
Cheers
MohammadFUNCTION_BLOCK Backoff
VAR_INPUT
NBRate: REAL;
Datarate: REAL;
END_VARVAR_OUTPUT
BE: REAL;
END_VARFUZZIFY NBRate
RANGE := (0.100 .. 6.000);
TERM low := Triangle 0.100 0.000 0.200;
TERM medium := Triangle 0.000 0.750 1.500;
TERM mediumhigh := Triangle 0.750 1.500 2.750;
TERM high := Triangle 2.000 5.000 6.000;
END_FUZZIFYFUZZIFY Datarate
RANGE := (0.000 .. 102.000);
TERM low := Triangle 0.000 1.600 3.200;
TERM medium := Triangle 1.600 24.000 50.000;
TERM mediumhigh := Triangle 24.000 50.000 80.000;
TERM high := Triangle 50.00 100.000 102.000;
END_FUZZIFYDEFUZZIFY BE
RANGE := (1.000 .. 9.000);
TERM d1 := Triangle 1.000 2.010 2.500;
TERM d2 := Triangle 2.000 2.510 3.000;
TERM d3 := Triangle 2.000 3.010 4.000;
TERM d4 := Triangle 3.000 4.010 5.000;
TERM d5 := Triangle 5.000 6.010 7.000;
TERM d6 := Triangle 6.000 7.010 8.000;
TERM d7 := Triangle 7.000 8.010 9.000;
METHOD : COG;
ACCU : MAX;
DEFAULT := nan;
END_DEFUZZIFYRULEBLOCK
AND : MIN;
OR : MAX;
ACT : MIN;
RULE 1 : is NBRate is low AND Datarate is low then BE is d2;
RULE 2 : if NBRate is low AND Datarate is medium then BE is d2;
RULE 3 : if NBRate is low AND Datarate is mediumhigh then BE is d2;
RULE 4 : if NBRate is low AND Datarate is high then BE is d2;
RULE 5 : if NBRate is medium AND Datarate is low then BE is d3;
RULE 6 : if NBRate is medium AND Datarate is medium then BE is d3;
RULE 7 : if NBRate is medium AND Datarate is mediumhigh then BE is d3;
RULE 8 : if NBRate is medium AND Datarate is high then BE is d4;
RULE 9 : if NBRate is mediumhigh AND Datarate is low then BE is d4;
RULE 10 : if NBRate is mediumhigh AND Datarate is medium then BE is d4;
RULE 11 : if NBRate is mediumhigh AND Datarate is mediumhigh then BE is d4;
RULE 12 : if NBRate is mediumhigh AND Datarate is high then BE is d5;
RULE 13 : if NBRate is high AND Datarate is low then BE is d4;
RULE 14 : if NBRate is high AND Datarate is medium then BE is d5;
RULE 15 : if NBRate is high AND Datarate is mediumhigh then BE is d5;
RULE 16 : if NBRate is high AND Datarate is high then BE is d5;
END_RULEBLOCKEND_FUNCTION_BLOCK
Engine* engine = new Engine;
FclImporter* importer = new FclImporter;
std::string inputFilename = “NBrateDatarate_BEv10.fcl”;
engine = importer>fromFile(inputFilename);
engine>setInputValue(“NBRate”, 5.5);
engine>setInputValue(“Datarate”, 50.0);
engine>process();
cout<<“This is for Backoff: “<< engine>getOutputValue(“BE”) <<endl;January 26, 2015 at 14:20 #1642Juan RadaVilela (admin)KeymasterHi Mohammad,
you should use QtFuzzyLite to help you with such kind of issues.
The problems you have are:
(1) the first rule starts withis
instead ofif
(2) the fuzzy operators (AND, OR) are case sensitive, and in fuzzylite you utilize “and” and “or” instead of their uppercase operators.Cheers,
Juan
January 26, 2015 at 16:15 #1645UnknownMemberThanks Juan.
Cheers,
Mohammad 
AuthorPosts
 You must be logged in to reply to this topic.