home › Forums › # Technical Support › Engine not ready error
- This topic has 4 replies, 2 voices, and was last updated 5 years, 10 months ago by
Juan Rada-Vilela (admin).
-
AuthorPosts
-
November 14, 2017 at 14:14 #2634
Unknown
MemberIm trying to create a fuzzy logic with boiling an egg and
I’m getting these errors:what(): [engine error] engine is not ready:
– Output variable <boiledEgg> has no aggregation operator
– Rule block 1 <ruleBlock> has no implication operator
– Rule block 1 <ruleBlock> has 3 rules that require implication operator#include “fl/Headers.h”
int main(int argc, char* argv[]){
using namespace fl;
//Code automatically generated with fuzzylite 6.0.
using namespace fl;Engine* engine = new Engine;
engine->setName(“BoilingAnEgg”);
engine->setDescription(“”);InputVariable* eggSize = new InputVariable;
eggSize->setName(“eggSize”);
eggSize->setDescription(“size of egg”);
eggSize->setEnabled(true);
eggSize->setRange(40.000, 70.000);
eggSize->setLockValueInRange(false);
eggSize->addTerm(new Trapezoid(“small”, 0.000, 0.0000, 30.000, 40.000));
eggSize->addTerm(new Triangle(“medium”, 30.000, 40.000, 50.000));
eggSize->addTerm(new Trapezoid(“large”, 0.0000, 50.000, 60.000, 70.000));
engine->addInputVariable(eggSize);InputVariable* time = new InputVariable;
time->setName(“time”);
time->setDescription(“time it takes to boil”);
time->setEnabled(true);
time->setRange(3.000, 6.000);
time->setLockValueInRange(false);
time->addTerm(new Trapezoid(“less”, 0.000, 0.000, 2.000, 3.000));
time->addTerm(new Triangle(“medium”, 0.000, 3.000, 4.000));
time->addTerm(new Trapezoid(“more”, 0.000, 5.000, 6.000, 6.000));
engine->addInputVariable(time);OutputVariable* boiledEgg = new OutputVariable;
boiledEgg->setName(“boiledEgg”);
boiledEgg->setDescription(“”);
boiledEgg->setEnabled(true);
boiledEgg->setRange(0.000, 3.000);
boiledEgg->setLockValueInRange(false);
// boiledEgg->setAggregation(new Maximum);
boiledEgg->setDefuzzifier(new Centroid(100));
boiledEgg->setDefaultValue(fl::nan);
boiledEgg->setLockPreviousValue(false);
boiledEgg->addTerm(new Triangle(“soft”, 0.000, 0.000, 1.000));
boiledEgg->addTerm(new Triangle(“medium”, 1.000, 1.000, 2.000));
boiledEgg->addTerm(new Triangle(“hard”, 2.000, 2.000, 3.000));
engine->addOutputVariable(boiledEgg);RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setName(“ruleBlock”);
ruleBlock->setDescription(“”);
ruleBlock->setEnabled(true);
ruleBlock->setConjunction(new Minimum());
ruleBlock->setDisjunction(new Maximum());
// ruleBlock->setActivation(new Minimum());
ruleBlock->addRule(Rule::parse(“if eggSize is small and time is less then boiledEgg is soft”, engine));
ruleBlock->addRule(Rule::parse(“if eggSize is medium and time is medium then boiledEgg is medium”, engine));
ruleBlock->addRule(Rule::parse(“if eggSize is large and time is more then boiledEgg is hard”, engine));
engine->addRuleBlock(ruleBlock);std::string status;
if (not engine->isReady(&status))
throw Exception(“[engine error] engine is not ready:\n” + status, FL_AT);engine->setInputValue(“eggSize”, 50.0);
engine->setInputValue(“time”, 5.0);
engine->process();
engine->getOutputValue(“boiledEgg”);
FL_LOG(engine->getOutputValue(“boiledEgg”));
}November 14, 2017 at 14:29 #2635Juan Rada-Vilela (admin)
KeymasterHi,
Thanks for your post.
You have two lines commented out in output variables. setAggregation and setActivation. You should uncomment them.
Cheers
November 15, 2017 at 02:21 #2636Unknown
MemberWhen i uncomment them i get these errors:
gurrea_activity3.cpp:55:43: error: no matching function for call to ‘fl::RuleBlock::setActivation(fl::Minimum*)’
ruleBlock->setActivation(new Minimum());
^
In file included from /home/bane/Downloads/fuzzylite-6.0/fuzzylite/fl/Headers.h:115:0,
from gurrea_activity3.cpp:2:
/home/bane/Downloads/fuzzylite-6.0/fuzzylite/fl/rule/RuleBlock.h:142:22: note: candidate: virtual void fl::RuleBlock::setActivation(fl::Activation*)
virtual void setActivation(Activation* activation);
^
/home/bane/Downloads/fuzzylite-6.0/fuzzylite/fl/rule/RuleBlock.h:142:22: note: no known conversion for argument 1 from ‘fl::Minimum*’ to ‘fl::Activation*’November 15, 2017 at 02:29 #2637Unknown
MemberSo i uncommented those lines as uve said and fixed the errors.
No problem compiling the file but when i try to run it im getting these errors”terminate called after throwing an instance of ‘fl::Exception’
what(): [engine error] engine is not ready:
– Rule block 1 <ruleBlock> has no implication operator
– Rule block 1 <ruleBlock> has 3 rules that require implication operator{at gurrea_activity3.cpp::main() [line:63]}
Aborted (core dumped)Below is the fixed code:
//File: BoilingAnEgg.cpp
#include “fl/Headers.h”
int main(int argc, char* argv[]){
using namespace fl;
//Code automatically generated with fuzzylite 6.0.
using namespace fl;Engine* engine = new Engine;
engine->setName(“BoilingAnEgg”);
engine->setDescription(“”);InputVariable* eggSize = new InputVariable;
eggSize->setName(“eggSize”);
eggSize->setDescription(“size of egg”);
eggSize->setEnabled(true);
eggSize->setRange(40.000, 70.000);
eggSize->setLockValueInRange(false);
eggSize->addTerm(new Trapezoid(“small”, 0.000, 0.0000, 30.000, 40.000));
eggSize->addTerm(new Triangle(“medium”, 30.000, 40.000, 50.000));
eggSize->addTerm(new Trapezoid(“large”, 0.0000, 50.000, 60.000, 70.000));
engine->addInputVariable(eggSize);InputVariable* time = new InputVariable;
time->setName(“time”);
time->setDescription(“time it takes to boil”);
time->setEnabled(true);
time->setRange(3.000, 6.000);
time->setLockValueInRange(false);
time->addTerm(new Trapezoid(“less”, 0.000, 0.000, 2.000, 3.000));
time->addTerm(new Triangle(“medium”, 0.000, 3.000, 4.000));
time->addTerm(new Trapezoid(“more”, 0.000, 5.000, 6.000, 6.000));
engine->addInputVariable(time);OutputVariable* boiledEgg = new OutputVariable;
boiledEgg->setName(“boiledEgg”);
boiledEgg->setDescription(“”);
boiledEgg->setEnabled(true);
boiledEgg->setRange(0.000, 3.000);
boiledEgg->setLockValueInRange(false);
boiledEgg->setAggregation(new Maximum);
boiledEgg->setDefuzzifier(new Centroid(100));
boiledEgg->setDefaultValue(fl::nan);
boiledEgg->setLockPreviousValue(false);
boiledEgg->addTerm(new Triangle(“soft”, 0.000, 0.000, 1.000));
boiledEgg->addTerm(new Triangle(“medium”, 1.000, 1.000, 2.000));
boiledEgg->addTerm(new Triangle(“hard”, 2.000, 2.000, 3.000));
engine->addOutputVariable(boiledEgg);RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setName(“ruleBlock”);
ruleBlock->setDescription(“”);
ruleBlock->setEnabled(true);
ruleBlock->setConjunction(new Minimum);
ruleBlock->setDisjunction(new Maximum);
ruleBlock->setActivation(new General);
ruleBlock->addRule(Rule::parse(“if eggSize is small and time is less then boiledEgg is soft”, engine));
ruleBlock->addRule(Rule::parse(“if eggSize is medium and time is medium then boiledEgg is medium”, engine));
ruleBlock->addRule(Rule::parse(“if eggSize is large and time is more then boiledEgg is hard”, engine));
engine->addRuleBlock(ruleBlock);std::string status;
if (not engine->isReady(&status))
throw Exception(“[engine error] engine is not ready:\n” + status, FL_AT);engine->setInputValue(“eggSize”, 50.0);
engine->setInputValue(“time”, 5.0);
engine->process();
engine->getOutputValue(“boiledEgg”);
FL_LOG(engine->getOutputValue(“boiledEgg”));
}November 21, 2017 at 13:51 #2639Juan Rada-Vilela (admin)
KeymasterHi,
You are missing ‘ruleBlock->setImplication(new Minimum);’.
When in doubt, take a look at the documentation, or even better: export the code to FLL and check it in QtFuzzyLite.
Cheers,
Juan
-
AuthorPosts
- You must be logged in to reply to this topic.