home Forums # Technical Support Engine not ready error Reply To: Engine not ready error

#2637
Unknown
Member

So 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”));
}