-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0676a44
commit a5c2d5f
Showing
111 changed files
with
8,292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
Author: Juan Rada-Vilela, Ph.D. | ||
Copyright (C) 2010-2014 FuzzyLite Limited | ||
All rights reserved | ||
This file is part of fuzzylite. | ||
fuzzylite is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License as published by the Free | ||
Software Foundation, either version 3 of the License, or (at your option) | ||
any later version. | ||
fuzzylite is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. | ||
fuzzylite™ is a trademark of FuzzyLite Limited. | ||
*/ | ||
|
||
#ifndef FL_CONSOLE_H | ||
#define FL_CONSOLE_H | ||
|
||
#include "fl/fuzzylite.h" | ||
|
||
#include <map> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace fl { | ||
class Engine; | ||
|
||
class FL_API Console { | ||
public: | ||
|
||
struct Option { | ||
std::string key, value, description; | ||
|
||
explicit Option(const std::string& key = "", const std::string& value = "", const std::string& description = "") : | ||
key(key), value(value), description(description) { | ||
} | ||
}; | ||
|
||
static const std::string KW_INPUT_FILE; | ||
static const std::string KW_INPUT_FORMAT; | ||
static const std::string KW_OUTPUT_FILE; | ||
static const std::string KW_OUTPUT_FORMAT; | ||
static const std::string KW_EXAMPLE; | ||
static const std::string KW_DECIMALS; | ||
static const std::string KW_DATA_INPUT; | ||
static const std::string KW_DATA_MAXIMUM; | ||
static const std::string KW_DATA_EXPORT_HEADER; | ||
static const std::string KW_DATA_EXPORT_INPUTS; | ||
|
||
static Engine* mamdani(); | ||
static Engine* takagiSugeno(); | ||
|
||
protected: | ||
static std::map<std::string, std::string> parse(int argc, char** argv); | ||
static void process(const std::map<std::string, std::string>& options); | ||
|
||
static void process(const std::string& input, std::ostream& writer, | ||
const std::string& inputFormat, const std::string& outputFormat, | ||
const std::map<std::string, std::string>& options); | ||
|
||
static int readCharacter(); | ||
static void interactive(std::ostream& writer, Engine* engine); | ||
static std::string interactiveHelp(); | ||
|
||
static void exportAllExamples(const std::string& from, const std::string& to); | ||
static void exportAllExamples(const std::string& from, const std::string& to, const std::string& path); | ||
#ifdef FL_CPP11 | ||
static void benchmarkExamples(const std::string& path, int runs); | ||
#endif | ||
|
||
public: | ||
static std::string usage(); | ||
static std::vector<Option> availableOptions(); | ||
|
||
static int main(int argc, char** argv); | ||
}; | ||
|
||
} | ||
|
||
#endif /* FL_CONSOLE_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/* | ||
Author: Juan Rada-Vilela, Ph.D. | ||
Copyright (C) 2010-2014 FuzzyLite Limited | ||
All rights reserved | ||
This file is part of fuzzylite. | ||
fuzzylite is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License as published by the Free | ||
Software Foundation, either version 3 of the License, or (at your option) | ||
any later version. | ||
fuzzylite is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. | ||
fuzzylite™ is a trademark of FuzzyLite Limited. | ||
*/ | ||
|
||
#ifndef FL_ENGINE_H | ||
#define FL_ENGINE_H | ||
|
||
#include "fl/fuzzylite.h" | ||
|
||
#include "fl/defuzzifier/IntegralDefuzzifier.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace fl { | ||
|
||
class InputVariable; | ||
class OutputVariable; | ||
class Variable; | ||
class RuleBlock; | ||
class Hedge; | ||
class TNorm; | ||
class SNorm; | ||
class Defuzzifier; | ||
|
||
class FL_API Engine { | ||
private: | ||
void copyFrom(const Engine& source); | ||
protected: | ||
std::string _name; | ||
std::vector<InputVariable*> _inputVariables; | ||
std::vector<OutputVariable*> _outputVariables; | ||
std::vector<RuleBlock*> _ruleblocks; | ||
|
||
void updateReferences() const; | ||
|
||
public: | ||
explicit Engine(const std::string& name = ""); | ||
Engine(const Engine& other); | ||
Engine& operator=(const Engine& other); | ||
virtual ~Engine(); | ||
FL_DEFAULT_MOVE(Engine) | ||
|
||
//TODO: remove int resolution in v6.0 | ||
virtual void configure(const std::string& conjunctionT, | ||
const std::string& disjunctionS, | ||
const std::string& activationT, | ||
const std::string& accumulationS, | ||
const std::string& defuzzifier, | ||
int resolution = IntegralDefuzzifier::defaultResolution()); | ||
|
||
virtual void configure(TNorm* conjunction, SNorm* disjunction, | ||
TNorm* activation, SNorm* accumulation, | ||
Defuzzifier* defuzzifier); | ||
|
||
virtual bool isReady(std::string* status = fl::null) const; | ||
|
||
virtual void process(); | ||
|
||
virtual void restart(); | ||
|
||
virtual void setName(const std::string& name); | ||
virtual std::string getName() const; | ||
|
||
virtual void setInputValue(const std::string& name, scalar value); | ||
virtual scalar getOutputValue(const std::string& name); | ||
|
||
|
||
virtual std::string toString() const; | ||
|
||
enum Type { | ||
Mamdani, Larsen, TakagiSugeno, | ||
Tsukamoto, InverseTsukamoto, Hybrid, Unknown | ||
}; | ||
virtual Type type(std::string* name = fl::null, std::string* reason = fl::null) const; | ||
|
||
virtual Engine* clone() const; | ||
|
||
virtual std::vector<Variable*> variables() const; | ||
|
||
/** | ||
* Operations for iterable datatype _inputVariables | ||
*/ | ||
virtual void addInputVariable(InputVariable* inputVariable); | ||
virtual InputVariable* setInputVariable(InputVariable* inputVariable, int index); | ||
virtual void insertInputVariable(InputVariable* inputVariable, int index); | ||
virtual InputVariable* getInputVariable(int index) const; | ||
virtual InputVariable* getInputVariable(const std::string& name) const; | ||
virtual InputVariable* removeInputVariable(int index); | ||
virtual InputVariable* removeInputVariable(const std::string& name); | ||
virtual bool hasInputVariable(const std::string& name) const; | ||
virtual int numberOfInputVariables() const; | ||
virtual const std::vector<InputVariable*>& inputVariables() const; | ||
virtual void setInputVariables(const std::vector<InputVariable*>& inputVariables); | ||
virtual std::vector<InputVariable*>& inputVariables(); | ||
|
||
/** | ||
* Operations for iterable datatype _outputVariables | ||
*/ | ||
virtual void addOutputVariable(OutputVariable* outputVariable); | ||
virtual OutputVariable* setOutputVariable(OutputVariable* outputVariable, int index); | ||
virtual void insertOutputVariable(OutputVariable* outputVariable, int index); | ||
virtual OutputVariable* getOutputVariable(int index) const; | ||
virtual OutputVariable* getOutputVariable(const std::string& name) const; | ||
virtual bool hasOutputVariable(const std::string& name) const; | ||
virtual OutputVariable* removeOutputVariable(int index); | ||
virtual OutputVariable* removeOutputVariable(const std::string& name); | ||
virtual int numberOfOutputVariables() const; | ||
virtual const std::vector<OutputVariable*>& outputVariables() const; | ||
virtual void setOutputVariables(const std::vector<OutputVariable*>& outputVariables); | ||
virtual std::vector<OutputVariable*>& outputVariables(); | ||
|
||
/** | ||
* Operations for iterable datatype _ruleblocks | ||
*/ | ||
virtual void addRuleBlock(RuleBlock* ruleblock); | ||
virtual RuleBlock* setRuleBlock(RuleBlock* ruleBlock, int index); | ||
virtual void insertRuleBlock(RuleBlock* ruleblock, int index); | ||
virtual RuleBlock* getRuleBlock(int index) const; | ||
virtual RuleBlock* getRuleBlock(const std::string& name) const; | ||
virtual bool hasRuleBlock(const std::string& name) const; | ||
virtual RuleBlock* removeRuleBlock(int index); | ||
virtual RuleBlock* removeRuleBlock(const std::string& name); | ||
virtual int numberOfRuleBlocks() const; | ||
virtual const std::vector<RuleBlock*>& ruleBlocks() const; | ||
virtual void setRuleBlocks(const std::vector<RuleBlock*>& ruleBlocks); | ||
virtual std::vector<RuleBlock*>& ruleBlocks(); | ||
|
||
}; | ||
|
||
} | ||
#endif /* FL_ENGINE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Author: Juan Rada-Vilela, Ph.D. | ||
Copyright (C) 2010-2014 FuzzyLite Limited | ||
All rights reserved | ||
This file is part of fuzzylite. | ||
fuzzylite is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License as published by the Free | ||
Software Foundation, either version 3 of the License, or (at your option) | ||
any later version. | ||
fuzzylite is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. | ||
fuzzylite™ is a trademark of FuzzyLite Limited. | ||
*/ | ||
|
||
#ifndef FL_EXCEPTION_H | ||
#define FL_EXCEPTION_H | ||
|
||
#include "fl/fuzzylite.h" | ||
|
||
#include <exception> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace fl { | ||
|
||
class FL_API Exception : public std::exception { | ||
protected: | ||
std::string _what; | ||
public: | ||
explicit Exception(const std::string& what); | ||
Exception(const std::string& what, const std::string& file, int line, | ||
const std::string& function); | ||
virtual ~Exception() FL_INOEXCEPT FL_IOVERRIDE; | ||
FL_DEFAULT_COPY_AND_MOVE(Exception) | ||
|
||
virtual void setWhat(const std::string& what); | ||
virtual std::string getWhat() const; | ||
virtual const char* what() const FL_INOEXCEPT FL_IOVERRIDE; | ||
|
||
virtual void append(const std::string& whatElse); | ||
virtual void append(const std::string& file, int line, const std::string& function); | ||
virtual void append(const std::string& whatElse, | ||
const std::string& file, int line, const std::string& function); | ||
|
||
static std::string btCallStack(); | ||
|
||
static void signalHandler(int signal); | ||
static void convertToException(int signal); | ||
static void terminate(); | ||
static void catchException(const std::exception& exception); | ||
|
||
|
||
}; | ||
|
||
} | ||
#endif /* FL_EXCEPTION_H */ |
Oops, something went wrong.