当前位置: 首页>>代码示例>>C++>>正文


C++ OutputVariable类代码示例

本文整理汇总了C++中OutputVariable的典型用法代码示例。如果您正苦于以下问题:C++ OutputVariable类的具体用法?C++ OutputVariable怎么用?C++ OutputVariable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OutputVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reader

 void FllImporter::processOutputVariable(const std::string& block, Engine* engine) const {
     std::istringstream reader(block);
     std::string line;
     OutputVariable* outputVariable = new OutputVariable;
     engine->addOutputVariable(outputVariable);
     while (std::getline(reader, line)) {
         std::pair<std::string, std::string> keyValue = parseKeyValue(line, ':');
         if ("OutputVariable" == keyValue.first) {
             outputVariable->setName(keyValue.second);
         } else if ("enabled" == keyValue.first) {
             outputVariable->setEnabled(parseBoolean(keyValue.second));
         } else if ("range" == keyValue.first) {
             std::pair<scalar, scalar> range = parseRange(keyValue.second);
             outputVariable->setRange(range.first, range.second);
         } else if ("default" == keyValue.first) {
             outputVariable->setDefaultValue(Op::toScalar(keyValue.second));
         } else if ("lock-valid" == keyValue.first) {
             outputVariable->setLockValidOutput(parseBoolean(keyValue.second));
         } else if ("lock-range" == keyValue.first) {
             outputVariable->setLockOutputRange(parseBoolean(keyValue.second));
         } else if ("defuzzifier" == keyValue.first) {
             outputVariable->setDefuzzifier(parseDefuzzifier(keyValue.second));
         } else if ("accumulation" == keyValue.first) {
             outputVariable->fuzzyOutput()->setAccumulation(parseSNorm(keyValue.second));
         } else if ("term" == keyValue.first) {
             outputVariable->addTerm(parseTerm(keyValue.second, engine));
         } else {
             throw fl::Exception("[import error] key <" + keyValue.first + "> not "
                     "recognized in pair <" + keyValue.first + ":" + keyValue.second + ">", FL_AT);
         }
     }
 }
开发者ID:maciek-slon,项目名称:Fuzzy,代码行数:32,代码来源:FllImporter.cpp

示例2: onChangeDivisions

 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);
     }
 }
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:7,代码来源:Preferences.cpp

示例3: onChangeAccumulation

 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));
     }
 }
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:9,代码来源:Preferences.cpp

示例4: onChangeDefuzzifier

 void Preferences::onChangeDefuzzifier(int) {
     std::string defuzzifier = ui->cbx_defuzzifier->currentText().toStdString();
     fl::Engine* engine = Model::Default()->engine();
     for (int i = 0; i < engine->numberOfOutputVariables(); ++i) {
         OutputVariable* outputVariable = engine->getOutputVariable(i);
         outputVariable->setDefuzzifier(
                 Factory::instance()->defuzzifier()->create(defuzzifier));
     }
 }
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:9,代码来源:Preferences.cpp

示例5: main

int main(int argc, char** argv){
//C++ code generated with fuzzylite 6.0.

using namespace fl;

Engine* engine = new Engine;
engine->setName("sltbu_fl");

InputVariable* distance = new InputVariable;
distance->setEnabled(true);
distance->setName("distance");
distance->setRange(0.000, 25.000);
distance->setLockValueInRange(false);
distance->addTerm(new ZShape("near", 1.000, 2.000));
distance->addTerm(new SShape("far", 1.000, 2.000));
engine->addInputVariable(distance);

InputVariable* control1 = new InputVariable;
control1->setEnabled(true);
control1->setName("control1");
control1->setRange(-0.785, 0.785);
control1->setLockValueInRange(false);
engine->addInputVariable(control1);

InputVariable* control2 = new InputVariable;
control2->setEnabled(true);
control2->setName("control2");
control2->setRange(-0.785, 0.785);
control2->setLockValueInRange(false);
engine->addInputVariable(control2);

OutputVariable* control = new OutputVariable;
control->setEnabled(true);
control->setName("control");
control->setRange(-0.785, 0.785);
control->setLockValueInRange(false);
control->fuzzyOutput()->setAggregation(fl::null);
control->setDefuzzifier(new WeightedAverage("TakagiSugeno"));
control->setDefaultValue(fl::nan);
control->setLockPreviousValue(false);
control->addTerm(Linear::create("out1mf1", engine, 0.000, 0.000, 1.000, 0.000));
control->addTerm(Linear::create("out1mf2", engine, 0.000, 1.000, 0.000, 0.000));
engine->addOutputVariable(control);

RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setEnabled(true);
ruleBlock->setName("");
ruleBlock->setConjunction(fl::null);
ruleBlock->setDisjunction(fl::null);
ruleBlock->setImplication(fl::null);
ruleBlock->setActivation(new General);
ruleBlock->addRule(Rule::parse("if distance is near then control is out1mf1", engine));
ruleBlock->addRule(Rule::parse("if distance is far then control is out1mf2", engine));
engine->addRuleBlock(ruleBlock);


}
开发者ID:NatalProductions,项目名称:fuzzylite,代码行数:57,代码来源:sltbu_fl.cpp

示例6: reloadModel

        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();

        }
开发者ID:maciek-slon,项目名称:Fuzzy,代码行数:56,代码来源:Variable.cpp

示例7: membership

 scalar Function::membership(scalar x) const {
     if (not this->_root.get()) {
         throw fl::Exception("[function error] function <" + _formula + "> not loaded.", FL_AT);
     }
     if (this->_engine) {
         for (int i = 0; i < this->_engine->numberOfInputVariables(); ++i) {
             InputVariable* input = this->_engine->getInputVariable(i);
             this->variables[input->getName()] = input->getInputValue();
         }
         for (int i = 0; i < this->_engine->numberOfOutputVariables(); ++i) {
             OutputVariable* output = this->_engine->getOutputVariable(i);
             this->variables[output->getName()] = output->getOutputValue();
         }
     }
     this->variables["x"] = x;
     return this->evaluate(&this->variables);
 }
开发者ID:Audeliano,项目名称:ros-indigo-robotino,代码行数:17,代码来源:Function.cpp

示例8: setWindowTitle

        void Variable::edit(const OutputVariable* outputVariable) {
            variable->setMinimum(outputVariable->getMinimum());
            variable->setMaximum(outputVariable->getMaximum());
            for (int i = 0; i < outputVariable->numberOfTerms(); ++i) {
                this->variable->addTerm(outputVariable->getTerm(i)->copy());
            }

            scalar singleStep = (variable->getMaximum() - variable->getMinimum()) / 100;
            ui->sbx_min->setSingleStep(std::max(scalar(0.01), singleStep));
            ui->sbx_max->setSingleStep(std::max(scalar(0.01), singleStep));

            setWindowTitle("Edit variable");
            ui->led_name->setText(QString::fromStdString(outputVariable->getName()));
            ui->cbx_enabled->setChecked(outputVariable->isEnabled());

            OutputVariable* editable = dynamic_cast<OutputVariable*> (this->variable);
            editable->setDefaultValue(outputVariable->getDefaultValue());
            editable->setLastValidOutput(fl::nan);
            editable->setLockValidOutput(outputVariable->isLockingValidOutput());
            editable->setLockOutputRange(outputVariable->isLockingOutputRange());

            editable->fuzzyOutput()->setAccumulation(outputVariable->fuzzyOutput()->getAccumulation());
            Defuzzifier* defuzzifier = outputVariable->getDefuzzifier();
            //            if (not defuzzifier) {
            //                defuzzifier = Factory::instance()->defuzzifier()->
            //                        create(Centroid().className(), fl::fuzzylite::defaultDivisions());
            //            }
            editable->setDefuzzifier(defuzzifier);

            reloadModel();
        }
开发者ID:maciek-slon,项目名称:Fuzzy,代码行数:31,代码来源:Variable.cpp

示例9: getText

    void Consequent::modify(scalar activationDegree, const TNorm* implication) {
        if (not isLoaded()) {
            throw fl::Exception("[consequent error] consequent <" + getText() + "> is not loaded", FL_AT);
        }
        for (std::size_t i = 0; i < _conclusions.size(); ++i) {
            Proposition* proposition = _conclusions.at(i);
            if (proposition->variable->isEnabled()) {
                if (not proposition->hedges.empty()) {
                    for (std::vector<Hedge*>::const_reverse_iterator rit = proposition->hedges.rbegin();
                            rit != proposition->hedges.rend(); ++rit) {
                        activationDegree = (*rit)->hedge(activationDegree);
                    }
                }

                OutputVariable * outputVariable = static_cast<OutputVariable*> (proposition->variable);
                Activated term(proposition->term, activationDegree, implication);
                outputVariable->fuzzyOutput()->addTerm(term);
                FL_DBG("Aggregating " << term.toString());
            }
        }
    }
开发者ID:Sukmaragil,项目名称:fuzzylite,代码行数:21,代码来源:Consequent.cpp

示例10: Minimum

        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);
        }
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:34,代码来源:Preferences.cpp

示例11: disconnect

        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();
        }
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:38,代码来源:Preferences.cpp

示例12: idfObject

boost::optional<IdfObject> ForwardTranslator::translateOutputVariable( OutputVariable & modelObject )
{
  IdfObject idfObject( openstudio::IddObjectType::Output_Variable);
  m_idfObjects.push_back(idfObject);

  if (!modelObject.isKeyValueDefaulted()){
    idfObject.setString(Output_VariableFields::KeyValue, modelObject.keyValue());
  }

  idfObject.setString(Output_VariableFields::VariableName, modelObject.variableName());

  if (!modelObject.isReportingFrequencyDefaulted()){
    idfObject.setString(Output_VariableFields::ReportingFrequency, modelObject.reportingFrequency());
  }
 
  if (modelObject.schedule()){
    idfObject.setString(Output_VariableFields::ScheduleName, modelObject.schedule()->name().get());
  }

  return idfObject;
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:21,代码来源:ForwardTranslateOutputVariable.cpp

示例13: accept

        void Variable::accept() {
            OutputVariable* outputVariable = dynamic_cast<OutputVariable*> (variable);
            if (outputVariable) {
                try {
                    outputVariable->setDefaultValue(
                            fl::Op::toScalar(ui->led_default->text().toStdString()));
                } catch (fl::Exception& ex) {
                    std::ostringstream message;
                    message << ex.what() << std::endl <<
                            "Expected numeric values (including nan or inf)" << std::endl;
                    QMessageBox::critical(this, tr("Error"),
                            fl::qt::Window::toHtmlEscaped(
                            QString::fromStdString(message.str())),
                            QMessageBox::Ok);
                    return;
                }
                outputVariable->setLockValidOutput(ui->chx_lock_valid->isChecked());
                outputVariable->setLockOutputRange(ui->chx_lock_range->isChecked());

                SNorm* accumulation = FactoryManager::instance()->snorm()->createInstance(
                        ui->cbx_accumulation->currentText().toStdString());
                outputVariable->fuzzyOutput()->setAccumulation(accumulation);
                Defuzzifier* defuzzifier = NULL;
                if (ui->cbx_defuzzifier->currentIndex() >= 0) {
                    defuzzifier = FactoryManager::instance()->defuzzifier()->createInstance(
                            ui->cbx_defuzzifier->currentText().toStdString());
                    IntegralDefuzzifier* integralDefuzzifier =
                            dynamic_cast<IntegralDefuzzifier*> (defuzzifier);
                    if (integralDefuzzifier) {
                        integralDefuzzifier->setResolution(ui->sbx_accuracy->value());
                    }
                }
                outputVariable->setDefuzzifier(defuzzifier);

            }
            variable->setName(fl::Op::makeValidId(ui->led_name->text().toStdString()));
            variable->setEnabled(ui->cbx_enabled->isChecked());
            QDialog::accept();
        }
开发者ID:maciek-slon,项目名称:Fuzzy,代码行数:39,代码来源:Variable.cpp

示例14: main

int main(int argc, char** argv){
using namespace fl;

Engine* engine = new Engine;
engine->setName("qtfuzzylite");

InputVariable* inputVariable = new InputVariable;
inputVariable->setEnabled(true);
inputVariable->setName("AllInputTerms");
inputVariable->setRange(0.000, 6.500);
inputVariable->setLockValueInRange(false);
inputVariable->addTerm(new Sigmoid("A", 0.500, -20.000));
inputVariable->addTerm(new ZShape("B", 0.000, 1.000));
inputVariable->addTerm(new Ramp("C", 1.000, 0.000));
inputVariable->addTerm(new Triangle("D", 0.500, 1.000, 1.500));
inputVariable->addTerm(new Trapezoid("E", 1.000, 1.250, 1.750, 2.000));
inputVariable->addTerm(new Concave("F", 0.850, 0.250));
inputVariable->addTerm(new Rectangle("G", 1.750, 2.250));
inputVariable->addTerm(Discrete::create("H", 10, 2.000, 0.000, 2.250, 1.000, 2.500, 0.500, 2.750, 1.000, 3.000, 0.000));
inputVariable->addTerm(new Gaussian("I", 3.000, 0.200));
inputVariable->addTerm(new Cosine("J", 3.250, 0.650));
inputVariable->addTerm(new GaussianProduct("K", 3.500, 0.100, 3.300, 0.300));
inputVariable->addTerm(new Spike("L", 3.640, 1.040));
inputVariable->addTerm(new Bell("M", 4.000, 0.250, 3.000));
inputVariable->addTerm(new PiShape("N", 4.000, 4.500, 4.500, 5.000));
inputVariable->addTerm(new Concave("O", 5.650, 6.250));
inputVariable->addTerm(new SigmoidDifference("P", 4.750, 10.000, 30.000, 5.250));
inputVariable->addTerm(new SigmoidProduct("Q", 5.250, 20.000, -10.000, 5.750));
inputVariable->addTerm(new Ramp("R", 5.500, 6.500));
inputVariable->addTerm(new SShape("S", 5.500, 6.500));
inputVariable->addTerm(new Sigmoid("T", 6.000, 20.000));
engine->addInputVariable(inputVariable);

OutputVariable* outputVariable = new OutputVariable;
outputVariable->setEnabled(true);
outputVariable->setName("AllOutputTerms");
outputVariable->setRange(0.000, 6.500);
outputVariable->setLockValueInRange(false);
outputVariable->fuzzyOutput()->setAccumulation(new Maximum);
outputVariable->setDefuzzifier(new Centroid(200));
outputVariable->setDefaultValue(fl::nan);
outputVariable->setLockPreviousValue(false);
outputVariable->addTerm(new Sigmoid("A", 0.500, -20.000));
outputVariable->addTerm(new ZShape("B", 0.000, 1.000));
outputVariable->addTerm(new Ramp("C", 1.000, 0.000));
outputVariable->addTerm(new Triangle("D", 0.500, 1.000, 1.500));
outputVariable->addTerm(new Trapezoid("E", 1.000, 1.250, 1.750, 2.000));
outputVariable->addTerm(new Concave("F", 0.850, 0.250));
outputVariable->addTerm(new Rectangle("G", 1.750, 2.250));
outputVariable->addTerm(Discrete::create("H", 10, 2.000, 0.000, 2.250, 1.000, 2.500, 0.500, 2.750, 1.000, 3.000, 0.000));
outputVariable->addTerm(new Gaussian("I", 3.000, 0.200));
outputVariable->addTerm(new Cosine("J", 3.250, 0.650));
outputVariable->addTerm(new GaussianProduct("K", 3.500, 0.100, 3.300, 0.300));
outputVariable->addTerm(new Spike("L", 3.640, 1.040));
outputVariable->addTerm(new Bell("M", 4.000, 0.250, 3.000));
outputVariable->addTerm(new PiShape("N", 4.000, 4.500, 4.500, 5.000));
outputVariable->addTerm(new Concave("O", 5.650, 6.250));
outputVariable->addTerm(new SigmoidDifference("P", 4.750, 10.000, 30.000, 5.250));
outputVariable->addTerm(new SigmoidProduct("Q", 5.250, 20.000, -10.000, 5.750));
outputVariable->addTerm(new Ramp("R", 5.500, 6.500));
outputVariable->addTerm(new SShape("S", 5.500, 6.500));
outputVariable->addTerm(new Sigmoid("T", 6.000, 20.000));
engine->addOutputVariable(outputVariable);

RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setEnabled(true);
ruleBlock->setName("");
ruleBlock->setConjunction(new Minimum);
ruleBlock->setDisjunction(new Maximum);
ruleBlock->setImplication(new Minimum);
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is A then AllOutputTerms is T", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is B then AllOutputTerms is S", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is C then AllOutputTerms is R", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is D then AllOutputTerms is Q", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is E then AllOutputTerms is P", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is F then AllOutputTerms is O", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is G then AllOutputTerms is N", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is H then AllOutputTerms is M", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is I then AllOutputTerms is L", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is J then AllOutputTerms is K", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is K then AllOutputTerms is J", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is L then AllOutputTerms is I", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is M then AllOutputTerms is H", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is N then AllOutputTerms is G", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is O then AllOutputTerms is F", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is P then AllOutputTerms is E", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is Q then AllOutputTerms is D", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is R then AllOutputTerms is C", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is S then AllOutputTerms is B", engine));
ruleBlock->addRule(fl::Rule::parse("if AllInputTerms is T then AllOutputTerms is A", engine));
engine->addRuleBlock(ruleBlock);


}
开发者ID:ecksun,项目名称:fuzzylite,代码行数:94,代码来源:AllTerms.cpp

示例15: main

int main(int argc, char** argv) {
    using namespace fl;

    Engine* engine = new Engine;
    engine->setName("Cubic-Approximator");

    InputVariable* inputVariable = new InputVariable;
    inputVariable->setEnabled(true);
    inputVariable->setName("X");
    inputVariable->setRange(-5.000, 5.000);
    inputVariable->addTerm(new Triangle("AboutNegFive", -6.000, -5.000, -4.000));
    inputVariable->addTerm(new Triangle("AboutNegFour", -5.000, -4.000, -3.000));
    inputVariable->addTerm(new Triangle("AboutNegThree", -4.000, -3.000, -2.000));
    inputVariable->addTerm(new Triangle("AboutNegTwo", -3.000, -2.000, -1.000));
    inputVariable->addTerm(new Triangle("AboutNegOne", -2.000, -1.000, 0.000));
    inputVariable->addTerm(new Triangle("AboutZero", -1.000, 0.000, 1.000));
    inputVariable->addTerm(new Triangle("AboutOne", 0.000, 1.000, 2.000));
    inputVariable->addTerm(new Triangle("AboutTwo", 1.000, 2.000, 3.000));
    inputVariable->addTerm(new Triangle("AboutThree", 2.000, 3.000, 4.000));
    inputVariable->addTerm(new Triangle("AboutFour", 3.000, 4.000, 5.000));
    inputVariable->addTerm(new Triangle("AboutFive", 4.000, 5.000, 6.000));
    engine->addInputVariable(inputVariable);

    OutputVariable* outputVariable = new OutputVariable;
    outputVariable->setEnabled(true);
    outputVariable->setName("ApproxXCubed");
    outputVariable->setRange(-5.000, 5.000);
    outputVariable->fuzzyOutput()->setAccumulation(fl::null);
    outputVariable->setDefuzzifier(new WeightedAverage("TakagiSugeno"));
    outputVariable->setDefaultValue(fl::nan);
    outputVariable->setLockPreviousOutputValue(false);
    outputVariable->setLockOutputValueInRange(false);
    outputVariable->addTerm(Linear::create("TangentatNegFive", engine, 75.000, 250.000));
    outputVariable->addTerm(Linear::create("TangentatNegFour", engine, 48.000, 128.000));
    outputVariable->addTerm(Linear::create("TangentatNegThree", engine, 27.000, 54.000));
    outputVariable->addTerm(Linear::create("TangentatNegTwo", engine, 12.000, 16.000));
    outputVariable->addTerm(Linear::create("TangentatNegOne", engine, 3.000, 2.000));
    outputVariable->addTerm(Linear::create("TangentatZero", engine, 0.000, 0.000));
    outputVariable->addTerm(Linear::create("TangentatOne", engine, 3.000, -2.000));
    outputVariable->addTerm(Linear::create("TangentatTwo", engine, 12.000, -16.000));
    outputVariable->addTerm(Linear::create("TangentatThree", engine, 27.000, -54.000));
    outputVariable->addTerm(Linear::create("TangentatFour", engine, 48.000, -128.000));
    outputVariable->addTerm(Linear::create("TangentatFive", engine, 75.000, -250.000));
    engine->addOutputVariable(outputVariable);

    RuleBlock* ruleBlock = new RuleBlock;
    ruleBlock->setEnabled(true);
    ruleBlock->setName("");
    ruleBlock->setConjunction(fl::null);
    ruleBlock->setDisjunction(fl::null);
    ruleBlock->setActivation(fl::null);
    ruleBlock->addRule(fl::Rule::parse("if X is AboutNegFive then ApproxXCubed is TangentatNegFive", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutNegFour then ApproxXCubed is TangentatNegFour", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutNegThree then ApproxXCubed is TangentatNegThree", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutNegTwo then ApproxXCubed is TangentatNegTwo", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutNegOne then ApproxXCubed is TangentatNegOne", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutZero then ApproxXCubed is TangentatZero", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutOne then ApproxXCubed is TangentatOne", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutTwo then ApproxXCubed is TangentatTwo", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutThree then ApproxXCubed is TangentatThree", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutFour then ApproxXCubed is TangentatFour", engine));
    ruleBlock->addRule(fl::Rule::parse("if X is AboutFive then ApproxXCubed is TangentatFive", engine));
    engine->addRuleBlock(ruleBlock);


}
开发者ID:9468305,项目名称:fuzzylite,代码行数:66,代码来源:cubic_approximator.cpp


注:本文中的OutputVariable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。