home › Forums › # Technical Support › nan output problem
- This topic has 1 reply, 2 voices, and was last updated 6 years, 7 months ago by
Juan Rada-Vilela (admin).
-
AuthorPosts
-
February 1, 2017 at 05:29 #2296
Unknown
Memberthis is my fis code::-
[System]
Name=’Scheduling_fuzzy’
Type=’mamdani’
Version=2.0
NumInputs=3
NumOutputs=1
NumRules=27
AndMethod=’min’
OrMethod=’max’
ImpMethod=’min’
AggMethod=’max’
DefuzzMethod=’centroid’[Input1]
Name=’Rarity’
Range=[0 100]
NumMFs=3
MF1=’LessRare’:’trapmf’,[-45 -5 5 25]
MF2=’AverageRare’:’trapmf’,[25 45.3 55.3 75]
MF3=’VeryRare’:’trapmf’,[75 95.5 106 146][Input2]
Name=’Layer’
Range=[0 6]
NumMFs=3
MF1=’LowerLayer’:’trapmf’,[-2.7 -0.3 0.3 1]
MF2=’MediumLayer’:’trapmf’,[1 2.5 3.41 5]
MF3=’HigherLayer’:’trapmf’,[5 5.7 6.3 8.7][Input3]
Name=’Deadline’
Range=[0 200]
NumMFs=3
MF1=’VeryVeryUrgent’:’trapmf’,[-89.4708994708995 -9.47089947089948 10.5291005291005 51.058201058201]
MF2=’VeryUrgent’:’trapmf’,[51.5582010582011 91.0582010582011 111.058201058201 151.058201058201]
MF3=’Urgent’:’trapmf’,[150.529100529101 190.529100529101 210.529100529101 290.529100529101][Output1]
Name=’Priority’
Range=[0 100]
NumMFs=6
MF1=’VeryVeryHigh’:’trapmf’,[-18 -2 2 10]
MF2=’VeryHigh’:’trapmf’,[10 18 22 30]
MF3=’High’:’trapmf’,[30 38.53 42.53 50]
MF4=’Low’:’trapmf’,[50 58 62 70]
MF5=’VeryLow’:’trapmf’,[70 78 82 90]
MF6=’VeryVeryLow’:’trapmf’,[90 98 102 118][Rules]
3 3 3, 6 (1) : 1
3 2 3, 5 (1) : 1
3 1 3, 2 (1) : 1
2 3 3, 6 (1) : 1
2 2 3, 4 (1) : 1
1 3 3, 6 (1) : 1
1 1 3, 3 (1) : 1
3 3 2, 5 (1) : 1
3 2 2, 3 (1) : 1
3 1 2, 2 (1) : 1
2 3 2, 5 (1) : 1
2 2 2, 4 (1) : 1
2 1 2, 2 (1) : 1
1 3 2, 5 (1) : 1
1 2 2, 3 (1) : 1
1 1 2, 2 (1) : 1
3 2 1, 3 (1) : 1
3 1 1, 1 (1) : 1
2 3 1, 5 (1) : 1
2 2 1, 3 (1) : 1
2 1 1, 1 (1) : 1
1 3 1, 4 (1) : 1
1 2 1, 3 (1) : 1
1 1 1, 2 (1) : 1
2 1 3, 3 (1) : 1
1 2 3, 5 (1) : 1
3 3 1, 4 (1) : 1and this is fuzzylite code ::-
int main(int argc, char* argv[]){
using namespace fl;
Engine* engine = new Engine;
engine->setName(“Scheduling_fuzzy”);InputVariable* inputVariable1 = new InputVariable;
inputVariable1->setEnabled(true);
inputVariable1->setName(“Rarity”);
inputVariable1->setRange(0.000, 100.000);
inputVariable1->addTerm(new Trapezoid(“LessRare”, -45.000, -5.000, 5.000, 25.000));
inputVariable1->addTerm(new Trapezoid(“AverageRare”, 25.000, 45.300, 55.300, 75.000));
inputVariable1->addTerm(new Trapezoid(“VeryRare”, 75.000, 95.500, 106.000, 146.000));
engine->addInputVariable(inputVariable1);InputVariable* inputVariable2 = new InputVariable;
inputVariable2->setEnabled(true);
inputVariable2->setName(“Layer”);
inputVariable2->setRange(0.000, 6.000);
inputVariable2->addTerm(new Trapezoid(“LowerLayer”, -2.700, -0.300, 0.300, 1.000));
inputVariable2->addTerm(new Trapezoid(“MediumLayer”, 1.000, 2.500, 3.410, 5.000));
inputVariable2->addTerm(new Trapezoid(“HigherLayer”, 5.000, 5.700, 6.300, 8.700));
engine->addInputVariable(inputVariable2);InputVariable* inputVariable3 = new InputVariable;
inputVariable3->setEnabled(true);
inputVariable3->setName(“Deadline”);
inputVariable3->setRange(0.000, 200.000);
inputVariable3->addTerm(new Trapezoid(“VeryVeryUrgent”, -89.471, -9.471, 10.529, 51.058));
inputVariable3->addTerm(new Trapezoid(“VeryUrgent”, 51.558, 91.058, 111.058, 151.058));
inputVariable3->addTerm(new Trapezoid(“Urgent”, 150.529, 190.529, 210.529, 290.529));
engine->addInputVariable(inputVariable3);OutputVariable* outputVariable = new OutputVariable;
outputVariable->setEnabled(true);
outputVariable->setName(“Priority”);
outputVariable->setRange(0.000, 100.000);
outputVariable->fuzzyOutput()->setAccumulation(new Maximum);
outputVariable->setDefuzzifier(new Centroid(200));
outputVariable->setDefaultValue(fl::nan);
outputVariable->setLockPreviousOutputValue(false);
outputVariable->setLockOutputValueInRange(false);
outputVariable->addTerm(new Trapezoid(“VeryVeryHigh”, -18.000, -2.000, 2.000, 10.000));
outputVariable->addTerm(new Trapezoid(“VeryHigh”, 10.000, 18.000, 22.000, 30.000));
outputVariable->addTerm(new Trapezoid(“High”, 30.000, 38.530, 42.530, 50.000));
outputVariable->addTerm(new Trapezoid(“Low”, 50.000, 58.000, 62.000, 70.000));
outputVariable->addTerm(new Trapezoid(“VeryLow”, 70.000, 78.000, 82.000, 90.000));
outputVariable->addTerm(new Trapezoid(“VeryVeryLow”, 90.000, 98.000, 102.000, 118.000));
engine->addOutputVariable(outputVariable);RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setEnabled(true);
ruleBlock->setName(“”);
ruleBlock->setConjunction(new Minimum);
ruleBlock->setDisjunction(new Maximum);
ruleBlock->setActivation(new Minimum);
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is HigherLayer and Deadline is Urgent then Priority is VeryVeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is MediumLayer and Deadline is Urgent then Priority is VeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is LowerLayer and Deadline is Urgent then Priority is VeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is HigherLayer and Deadline is Urgent then Priority is VeryVeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is MediumLayer and Deadline is Urgent then Priority is Low”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is HigherLayer and Deadline is Urgent then Priority is VeryVeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is LowerLayer and Deadline is Urgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is HigherLayer and Deadline is VeryUrgent then Priority is VeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is MediumLayer and Deadline is VeryUrgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is LowerLayer and Deadline is VeryUrgent then Priority is VeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is HigherLayer and Deadline is VeryUrgent then Priority is VeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is MediumLayer and Deadline is VeryUrgent then Priority is Low”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is LowerLayer and Deadline is VeryUrgent then Priority is VeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is HigherLayer and Deadline is VeryUrgent then Priority is VeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is MediumLayer and Deadline is VeryUrgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is LowerLayer and Deadline is VeryUrgent then Priority is VeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is MediumLayer and Deadline is VeryVeryUrgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is LowerLayer and Deadline is VeryVeryUrgent then Priority is VeryVeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is HigherLayer and Deadline is VeryVeryUrgent then Priority is VeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is MediumLayer and Deadline is VeryVeryUrgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is LowerLayer and Deadline is VeryVeryUrgent then Priority is VeryVeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is HigherLayer and Deadline is VeryVeryUrgent then Priority is Low”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is MediumLayer and Deadline is VeryVeryUrgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is LowerLayer and Deadline is VeryVeryUrgent then Priority is VeryHigh”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is AverageRare and Layer is LowerLayer and Deadline is Urgent then Priority is High”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is LessRare and Layer is MediumLayer and Deadline is Urgent then Priority is VeryLow”, engine));
ruleBlock->addRule(fl::Rule::parse(“if Rarity is VeryRare and Layer is HigherLayer and Deadline is VeryVeryUrgent then Priority is Low”, engine));
engine->addRuleBlock(ruleBlock);engine->getInputVariable(0)->setInputValue(5);
engine->getInputVariable(1)->setInputValue(5);
engine->getInputVariable(2)->setInputValue(5);
engine->process();
fl::OutputVariable* output = engine->getOutputVariable(“Priority”);
cout << output->getOutputValue() << “\n”;}
but i am getting the output nan but matlab showing it 50
please help me correct my code if i am wrong.February 1, 2017 at 07:45 #2297Juan Rada-Vilela (admin)
KeymasterHi,
please use QtFuzzyLite to figure this out. You can use the commercial or community edition.
If no rules activate, Matlab shows the average of the range of the output variable, like your case: (100-0)/2. In fuzzylite, when no rules activate, the default value is
NaN
, but you can set it to any value. Using the FuzzyLite Language,default: 50
.Cheers.
-
AuthorPosts
- You must be logged in to reply to this topic.