void Preferences::applyDefaults() { fl::Engine* engine = Model::Default()->engine(); if (engine->numberOfRuleBlocks() == 0) { QMessageBox::critical(this, "Error", "Current engine has no rule blocks. " "At least one ruleblock was expected.", QMessageBox::Ok); return; } std::string tnorm = Minimum().className(); std::string snorm = Maximum().className(); std::string activation = Minimum().className(); RuleBlock* ruleblock = engine->getRuleBlock(0); if (ruleblock->getTnorm()) tnorm = ruleblock->getTnorm()->className(); if (ruleblock->getSnorm()) snorm = ruleblock->getSnorm()->className(); if (ruleblock->getActivation()) activation = ruleblock->getActivation()->className(); std::string defuzzifier = Centroid().className(); int divisions = fl::fuzzylite::defaultDivisions(); std::string accumulation = Maximum().className(); if (engine->numberOfOutputVariables() > 0) { OutputVariable* variable = engine->getOutputVariable(0); if (variable->getDefuzzifier()) { defuzzifier = variable->getDefuzzifier()->className(); divisions = variable->getDefuzzifier()->getDivisions(); } if (variable->output()->getAccumulation()) accumulation = variable->output()->getAccumulation()->className(); } engine->configure(tnorm, snorm, activation, accumulation, defuzzifier, divisions); }
void Preferences::onChangeAccumulation(int) { std::string accumulation = ui->cbx_accumulation->currentText().toStdString(); fl::Engine* engine = Model::Default()->engine(); for (int i = 0; i < engine->numberOfOutputVariables(); ++i) { OutputVariable* outputVariable = engine->getOutputVariable(i); outputVariable->output()->setAccumulation( Factory::instance()->snorm()->create(accumulation)); } }
void Preferences::loadFromModel() { disconnect(); fl::Engine* engine = Model::Default()->engine(); if (engine->numberOfRuleBlocks() == 0) { QMessageBox::critical(this, "Error", "Current engine has no rule blocks. " "At least one ruleblock was expected.", QMessageBox::Ok); return; } RuleBlock* ruleblock = engine->getRuleBlock(0); ui->cbx_tnorm->setCurrentIndex(indexOfTnorm(ruleblock->getTnorm()->className())); ui->cbx_snorm->setCurrentIndex(indexOfSnorm(ruleblock->getSnorm()->className())); ui->cbx_activation->setCurrentIndex(indexOfTnorm(ruleblock->getActivation()->className())); if (engine->numberOfOutputVariables() > 0) { OutputVariable* variable = engine->getOutputVariable(0); ui->cbx_defuzzifier->setCurrentIndex( indexOfDefuzzifier(variable->getDefuzzifier()->className())); ui->sbx_divisions->setValue(variable->getDefuzzifier()->getDivisions()); ui->cbx_accumulation->setCurrentIndex( indexOfSnorm(variable->output()->getAccumulation()->className())); } else { ui->cbx_defuzzifier->setCurrentIndex(0); ui->sbx_divisions->setValue(fl::fuzzylite::defaultDivisions()); ui->cbx_accumulation->setCurrentIndex(0); } ui->ckx_any->setChecked(engine->hasHedge(Any().name())); ui->ckx_extremely->setChecked(engine->hasHedge(Extremely().name())); ui->ckx_not->setChecked(engine->hasHedge(Not().name())); ui->ckx_seldom->setChecked(engine->hasHedge(Seldom().name())); ui->ckx_somewhat->setChecked(engine->hasHedge(Somewhat().name())); ui->ckx_very->setChecked(engine->hasHedge(Very().name())); connect(); }