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 Variable::reloadModel() { if (ui->btn_sort_centroid->isChecked()) { variable->sort(); } ui->lvw_terms->clear(); for (int i = 0; i < variable->numberOfTerms(); ++i) { fl::Term* term = variable->getTerm(i); std::string text = term->getName() + " " + term->className() + " " + term->parameters(); QListWidgetItem* item = new QListWidgetItem; item->setText(QString::fromStdString(text)); item->setToolTip(QString::fromStdString(text)); ui->lvw_terms->addItem(item); } OutputVariable* outputVariable = dynamic_cast<OutputVariable*> (variable); if (outputVariable) { ui->led_default->setText(QString::number(outputVariable->getDefaultValue())); ui->chx_lock_range->setChecked(outputVariable->isLockingOutputRange()); ui->chx_lock_valid->setChecked(outputVariable->isLockingValidOutput()); if (outputVariable->fuzzyOutput()->getAccumulation()) { ui->cbx_accumulation->setCurrentIndex( ui->cbx_accumulation->findText( QString::fromStdString( outputVariable->fuzzyOutput()->getAccumulation()->className()))); } else { ui->cbx_accumulation->setCurrentIndex(-1); } if (outputVariable->getDefuzzifier()) { ui->cbx_defuzzifier->setCurrentIndex( ui->cbx_defuzzifier->findText( QString::fromStdString( outputVariable->getDefuzzifier()->className()))); IntegralDefuzzifier* integralDefuzzifier = dynamic_cast<IntegralDefuzzifier*> (outputVariable->getDefuzzifier()); if (integralDefuzzifier) { ui->sbx_accuracy->setValue(integralDefuzzifier->getResolution()); } } else { ui->cbx_defuzzifier->setCurrentIndex(-1); } } scalar minimum = variable->getMinimum(); scalar maximum = variable->getMaximum(); ui->sbx_min->setValue(minimum); ui->sbx_max->setValue(maximum); ui->btn_term_down->setEnabled(not ui->btn_sort_centroid->isChecked() and ui->lvw_terms->selectedItems().size() > 0); ui->btn_term_up->setEnabled(not ui->btn_sort_centroid->isChecked() and ui->lvw_terms->selectedItems().size() > 0); redraw(); }
void Preferences::onChangeDivisions(int value) { fl::Engine* engine = Model::Default()->engine(); for (int i = 0; i < engine->numberOfOutputVariables(); ++i) { OutputVariable* outputVariable = engine->getOutputVariable(i); outputVariable->getDefuzzifier()->setDivisions(value); } }
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(); }