summaryrefslogtreecommitdiff
path: root/fuzzylite/fl/imex
diff options
context:
space:
mode:
authorJohannes 'josch' Schauer <josch@debian.org>2019-01-27 13:56:24 +0100
committerJohannes 'josch' Schauer <josch@debian.org>2019-01-27 13:56:33 +0100
commit6ce553563bc795f389f639a3a8cdfe356de71441 (patch)
treeda4c9ede3087ca534d93bc1ac5a14f044f036600 /fuzzylite/fl/imex
parentbbefa170378553e5a6e0d72e4d52328b61f3e8ac (diff)
new upstream version 6.0
Diffstat (limited to 'fuzzylite/fl/imex')
-rw-r--r--fuzzylite/fl/imex/CppExporter.h139
-rw-r--r--fuzzylite/fl/imex/Exporter.h52
-rw-r--r--fuzzylite/fl/imex/FclExporter.h79
-rw-r--r--fuzzylite/fl/imex/FclImporter.h32
-rw-r--r--fuzzylite/fl/imex/FisExporter.h87
-rw-r--r--fuzzylite/fl/imex/FisImporter.h47
-rw-r--r--fuzzylite/fl/imex/FldExporter.h218
-rw-r--r--fuzzylite/fl/imex/FllExporter.h119
-rw-r--r--fuzzylite/fl/imex/FllImporter.h48
-rw-r--r--fuzzylite/fl/imex/Importer.h53
-rw-r--r--fuzzylite/fl/imex/JavaExporter.h124
-rw-r--r--fuzzylite/fl/imex/RScriptExporter.h246
12 files changed, 1026 insertions, 218 deletions
diff --git a/fuzzylite/fl/imex/CppExporter.h b/fuzzylite/fl/imex/CppExporter.h
index e53cf15..1c48225 100644
--- a/fuzzylite/fl/imex/CppExporter.h
+++ b/fuzzylite/fl/imex/CppExporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_CPPEXPORTER_H
@@ -36,30 +28,129 @@ namespace fl {
class Norm;
class Defuzzifier;
class Hedge;
-
+ class Activation;
+
+ /**
+ The CppExporter class is an Exporter that translates an Engine and its
+ components to the `C++` programming language using the `fuzzylite`
+ library.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see JavaExporter
+ @see Exporter
+ @since 4.0
+ */
class FL_API CppExporter : public Exporter {
- protected:
- bool _prefixNamespace;
- virtual std::string fl(const std::string& clazz) const;
+ private:
+ bool _usingNamespace;
+ bool _usingVariableNames;
public:
- explicit CppExporter(bool prefixNamespace = false);
+ explicit CppExporter(bool usingNamespace = false, bool usingVariableNames = true);
virtual ~CppExporter() FL_IOVERRIDE;
FL_DEFAULT_COPY_AND_MOVE(CppExporter)
virtual std::string name() const FL_IOVERRIDE;
virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
- virtual void setPrefixNamespace(bool prefixNamespace);
- virtual bool isPrefixNamespace() const;
-
+ /**
+ Sets whether the fl namespace of the library is prepended to types
+ (e.g., fl::Engine)
+
+ @param usingNamespace whether the fl namespace of the library is
+ prepended to types (e.g., fl::Engine)
+ */
+ virtual void setUsingNamespace(bool usingNamespace);
+ /**
+ Gets whether the fl namespace of the library is prepended to types
+ (e.g., fl::Engine)
+ @return whether the fl namespace of the library is prepended to types
+ */
+ virtual bool isUsingNamespace() const;
+
+ /**
+ Returns the given text prepended with the `fl` namespace if
+ CppExporter::isUsingNamespace is `true`, or the text otherwise
+
+ @param clazz is the text to be prepended the `fl::`.
+ @return the given text prepended with the `fl` namespace if
+ CppExporter::isUsingNamespace is `true`, or the text otherwise
+ */
+ virtual std::string fl(const std::string& clazz) const;
+ /**
+ Sets whether variables are exported using their names
+ (e.g., `power->setValue(fl::nan)`) instead of numbered identifiers
+ (e.g., `inputVariable1->setValue(fl::nan)`)
+ @param usingVariableNames indicates whether variables are exported using
+ their names
+ */
+ virtual void setUsingVariableNames(bool usingVariableNames);
+ /**
+ Gets whether variables are exported using their names
+ (e.g., `power->setValue(fl::nan)`) instead of numbered identifiers
+ (e.g., `inputVariable1->setValue(fl::nan)`)
+ @return whether variables are exported using their names
+ */
+ virtual bool isUsingVariableNames() const;
+
+ /**
+ Returns a string representation of InputVariable in the `C++` programming language
+ @param inputVariable is the input variable
+ @param engine is the engine in which the input variable is registered
+ @return a string representation of the input variable in the `C++` programming language
+ */
virtual std::string toString(const InputVariable* inputVariable, const Engine* engine) const;
+ /**
+ Returns a string representation of the OutputVariable in the `C++` programming language
+ @param outputVariable is the output variable
+ @param engine is the engine in which the output variable is registered
+ @return a string representation of the output variable in the `C++` programming language
+ */
virtual std::string toString(const OutputVariable* outputVariable, const Engine* engine) const;
+ /**
+ Returns a string representation of the RuleBlock in the `C++` programming language
+ @param ruleBlock is the rule block
+ @param engine is the engine in which the rule block is registered
+ @return a string representation of the rule block in the `C++` programming language
+ */
virtual std::string toString(const RuleBlock* ruleBlock, const Engine* engine) const;
+
+ /**
+ Returns a string representation of the Activation method in the `C++` programming language
+ @param activation is the activation method
+ @return a string representation of the activation method in the `C++` programming language
+ */
+ virtual std::string toString(const Activation* activation) const;
+
+ /**
+ Returns a string representation of the scalar value in the `C++` programming language
+ @param value is the scalar value
+ @return a string representation of the scalar value in the `C++` programming language
+ */
virtual std::string toString(scalar value) const;
+ /**
+ Returns a string representation of the Hedge in the `C++` programming language
+ @param hedge is the hedge
+ @return a string representation of the hedge in the `C++` programming language
+ */
virtual std::string toString(const Hedge* hedge) const;
+ /**
+ Returns a string representation of the Term in the `C++` programming language
+ @param term is the term
+ @return a string representation of the term in the `C++` programming language
+ */
virtual std::string toString(const Term* term) const;
- virtual std::string toString(const Norm* op) const;
+ /**
+ Returns a string representation of the Norm in the `C++` programming language
+ @param norm is the norm
+ @return a string representation of the norm in the `C++` programming language
+ */
+ virtual std::string toString(const Norm* norm) const;
+ /**
+ Returns a string representation of the Defuzzifier in the `C++` programming language
+ @param defuzzifier is the defuzzifier
+ @return a string representation of the defuzzifier in the `C++` programming language
+ */
virtual std::string toString(const Defuzzifier* defuzzifier) const;
virtual CppExporter* clone() const FL_IOVERRIDE;
diff --git a/fuzzylite/fl/imex/Exporter.h b/fuzzylite/fl/imex/Exporter.h
index 8b55c21..b883edf 100644
--- a/fuzzylite/fl/imex/Exporter.h
+++ b/fuzzylite/fl/imex/Exporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_EXPORTER_H
@@ -32,6 +24,16 @@
namespace fl {
class Engine;
+ /**
+ The Exporter class is the abstract class for exporters to translate an
+ Engine into different formats.
+
+ @todo declare methods for exporting other components (e.g., Variable)
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see Importer
+ @since 4.0
+ */
class FL_API Exporter {
public:
@@ -39,10 +41,30 @@ namespace fl {
virtual ~Exporter();
FL_DEFAULT_COPY_AND_MOVE(Exporter)
+ /**
+ Returns a string representation of the engine
+ @param engine is the engine to export
+ @return a string representation of the engine
+ */
virtual std::string toString(const Engine* engine) const = 0;
+ /**
+ Stores the string representation of the engine into the specified file
+ @param path is the full path of the file to export the engine to
+ @param engine is the engine to export
+ @throws fl::Exception if the file cannot be created
+ */
virtual void toFile(const std::string& path, const Engine* engine) const;
+ /**
+ Returns the name of the exporter
+ @return the name of the exporter
+ */
virtual std::string name() const = 0;
+
+ /**
+ Creates a clone of the exporter
+ @return a clone of the exporter
+ */
virtual Exporter* clone() const = 0;
};
diff --git a/fuzzylite/fl/imex/FclExporter.h b/fuzzylite/fl/imex/FclExporter.h
index 9bfa3ed..efec3c4 100644
--- a/fuzzylite/fl/imex/FclExporter.h
+++ b/fuzzylite/fl/imex/FclExporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FCLEXPORTER_H
@@ -37,8 +29,17 @@ namespace fl {
class Defuzzifier;
class Term;
+ /**
+ The FclExporter class is an Exporter that translates an Engine and its
+ components to the Fuzzy Control Language specification.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FclImporter
+ @see Exporter
+ @since 4.0
+ */
class FL_API FclExporter : public Exporter {
- protected:
+ private:
std::string _indent;
public:
@@ -46,25 +47,59 @@ namespace fl {
virtual ~FclExporter() FL_IOVERRIDE;
FL_DEFAULT_COPY_AND_MOVE(FclExporter)
+ /**
+ Sets the indentation string within blocks
+ @param indent is the indentation string within blocks
+ */
virtual void setIndent(const std::string& indent);
+ /**
+ Gets the indentation string within blocks
+ @return the indentation string within blocks
+ */
virtual std::string getIndent() const;
virtual std::string name() const FL_IOVERRIDE;
virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
-
+
+ /**
+ Returns a string representation of the InputVariable according to the Fuzzy Control Language specification
+ @param variable is the input variable
+ @return a string representation of the input variable according to the Fuzzy Control Language specification
+ */
virtual std::string toString(const InputVariable* variable) const;
+ /**
+ Returns a string representation of the OutputVariable according to the Fuzzy Control Language specification
+ @param variable is the output variable
+ @return a string representation of the output variable according to the Fuzzy Control Language specification
+ */
virtual std::string toString(const OutputVariable* variable) const;
+ /**
+ Returns a string representation of the RuleBlock according to the Fuzzy Control Language specification
+ @param ruleBlock is the rule block
+ @return a string representation of the rule block according to the Fuzzy Control Language specification
+ */
virtual std::string toString(const RuleBlock* ruleBlock) const;
-
+ /**
+ Returns a string representation of the Norm according to the Fuzzy Control Language specification
+ @param norm is the norm
+ @return a string representation of the norm according to the Fuzzy Control Language specification
+ */
virtual std::string toString(const Norm* norm) const;
-
- virtual std::string toString(const TNorm* tnorm) const; //TODO: Delete in v6.0
- virtual std::string toString(const SNorm* snorm) const; //TODO: Delete in v6.0
+ /**
+ Returns a string representation of the Defuzzifier according to the Fuzzy Control Language specification
+ @param defuzzifier is the defuzzifier
+ @return a string representation of the defuzzifier according to the Fuzzy Control Language specification
+ */
virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ /**
+ Returns a string representation of the Term according to the Fuzzy Control Language specification
+ @param term is the term
+ @return a string representation of the term according to the Fuzzy Control Language specification
+ */
virtual std::string toString(const Term* term) const;
virtual FclExporter* clone() const FL_IOVERRIDE;
};
-
}
+
#endif /* FL_FCLEXPORTER_H */
diff --git a/fuzzylite/fl/imex/FclImporter.h b/fuzzylite/fl/imex/FclImporter.h
index b219717..2e75432 100644
--- a/fuzzylite/fl/imex/FclImporter.h
+++ b/fuzzylite/fl/imex/FclImporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FCLIMPORTER_H
@@ -39,6 +31,15 @@ namespace fl {
class Term;
class Defuzzifier;
+ /**
+ The FclImporter class is an Importer that configures an Engine and its
+ components utilizing the Fuzzy Control Language specification.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FclExporter
+ @see Importer
+ @since 4.0
+ */
class FL_API FclImporter : public Importer {
public:
FclImporter();
@@ -69,6 +70,5 @@ namespace fl {
virtual bool parseEnabled(const std::string& line) const;
};
-
}
#endif /* FL_FCLIMPORTER_H */
diff --git a/fuzzylite/fl/imex/FisExporter.h b/fuzzylite/fl/imex/FisExporter.h
index 05d6a22..a7f5d8c 100644
--- a/fuzzylite/fl/imex/FisExporter.h
+++ b/fuzzylite/fl/imex/FisExporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FISEXPORTER_H
@@ -39,6 +31,15 @@ namespace fl {
class Proposition;
class Variable;
+ /**
+ The FisExporter class is an Exporter that translates an Engine and its
+ components into the Fuzzy Inference System format for Matlab or Octave.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FisImporter
+ @see Exporter
+ @since 4.0
+ */
class FL_API FisExporter : public Exporter {
protected:
@@ -52,22 +53,68 @@ namespace fl {
virtual std::string name() const FL_IOVERRIDE;
virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
-
- virtual std::string toString(const Norm* norm) const;
- virtual std::string toString(const TNorm* tnorm) const; //TODO: delete in v6.0
- virtual std::string toString(const SNorm* snorm) const; //TODO: delete in v6.0
+
+ /**
+ Returns a string representation of the TNorm in the Fuzzy Inference System format
+ @param tnorm is the TNorm
+ @return a string representation of the TNorm in the Fuzzy Inference System format
+ */
+ virtual std::string toString(const TNorm* tnorm) const;
+
+ /**
+ Returns a string representation of the SNorm in the Fuzzy Inference System format
+ @param snorm is the SNorm
+ @return a string representation of the SNorm in the Fuzzy Inference System format
+ */
+ virtual std::string toString(const SNorm* snorm) const;
+
+ /**
+ Returns a string representation of the Defuzzifier in the Fuzzy Inference System format
+ @param defuzzifier is the defuzzifier
+ @return a string representation of the Defuzzifier in the Fuzzy Inference System format
+ */
virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ /**
+ Returns a string representation of the Term in the Fuzzy Inference System format
+ @param term is the term
+ @return a string representation of the term in the Fuzzy Inference System format
+ */
virtual std::string toString(const Term* term) const;
+ /**
+ Returns a string representation of the `[System]` configuration
+ @param engine is the engine
+ @return a string representation of the `[System]` configuration
+ */
virtual std::string exportSystem(const Engine* engine) const;
+ /**
+ Returns a string representation of the `[Input]` configuration
+ @param engine is the engine
+ @return a string representation of the `[Input]` configuration
+ */
virtual std::string exportInputs(const Engine* engine) const;
+ /**
+ Returns a string representation of the `[Output]` configuration
+ @param engine is the engine
+ @return a string representation of the `[Output]` configuration
+ */
virtual std::string exportOutputs(const Engine* engine) const;
+ /**
+ Returns a string representation of the `[Rules]` configuration
+ @param engine is the engine
+ @return a string representation of the `[Rules]` configuration
+ */
virtual std::string exportRules(const Engine* engine) const;
+ /**
+ Returns a string representation for the Rule in the Fuzzy Inference System format
+ @param rule is the rule
+ @param engine is the engine in which the rule is registered
+ @return a string representation for the rule in the Fuzzy Inference System format
+ */
virtual std::string exportRule(const Rule* rule, const Engine* engine) const;
virtual FisExporter* clone() const FL_IOVERRIDE;
};
-
}
#endif /* FL_FISEXPORTER_H */
diff --git a/fuzzylite/fl/imex/FisImporter.h b/fuzzylite/fl/imex/FisImporter.h
index b631a48..2c9ce36 100644
--- a/fuzzylite/fl/imex/FisImporter.h
+++ b/fuzzylite/fl/imex/FisImporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FISIMPORTER_H
@@ -39,6 +31,16 @@ namespace fl {
class Defuzzifier;
class Variable;
+ /**
+ The FisImporter class is an Importer that configures an Engine and its
+ components from utilizing the Fuzzy Inference System format for Matlab or
+ Octave.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FisExporter
+ @see Importer
+ @since 4.0
+ */
class FL_API FisImporter : public Importer {
public:
FisImporter();
@@ -60,20 +62,19 @@ namespace fl {
virtual void importOutput(const std::string& section, Engine* engine) const;
virtual void importRules(const std::string& section, Engine* engine) const;
virtual std::string translateProposition(scalar code, Variable* variable) const;
-
- //TODO: rename extract to translate in v6.0
- virtual std::string extractTNorm(const std::string& tnorm) const;
- virtual std::string extractSNorm(const std::string& tnorm) const;
- virtual std::string extractDefuzzifier(const std::string& defuzzifier) const;
+
+ virtual std::string translateTNorm(const std::string& tnorm) const;
+ virtual std::string translateSNorm(const std::string& tnorm) const;
+ virtual std::string translateDefuzzifier(const std::string& defuzzifier) const;
virtual Term* parseTerm(const std::string& line, const Engine* engine) const;
virtual Term* createInstance(const std::string& termClass, const std::string& name,
const std::vector<std::string>& params, const Engine* engine) const;
- //TODO: rename to parseRange in v6.0
- virtual std::pair<scalar, scalar> range(const std::string& range) const;
- };
+ virtual std::pair<scalar, scalar> parseRange(const std::string& range) const;
+ };
}
+
#endif /* FL_FISIMPORTER_H */
diff --git a/fuzzylite/fl/imex/FldExporter.h b/fuzzylite/fl/imex/FldExporter.h
index 71679a6..98a14c9 100644
--- a/fuzzylite/fl/imex/FldExporter.h
+++ b/fuzzylite/fl/imex/FldExporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FLDEXPORTER_H
@@ -34,47 +26,219 @@ namespace fl {
class InputVariable;
class OutputVariable;
+ /**
+ The FldExporter class is an Exporter that evaluates an Engine and exports
+ its input values and output values to the FuzzyLite Dataset (FLD) format,
+ see [http://www.fuzzylite.com/fll-fld](http://www.fuzzylite.com/fll-fld)
+ for more information.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FllExporter
+ @see Exporter
+ @since 4.0
+ */
class FL_API FldExporter : public Exporter {
- protected:
+ private:
std::string _separator;
bool _exportHeaders;
bool _exportInputValues;
bool _exportOutputValues;
public:
+
+ /**
+ The ScopeOfValues refers to the scope of the equally-distributed values
+ to generate.
+ */
+ enum ScopeOfValues {
+ /**Generates @f$n@f$ values for each variable*/
+ EachVariable,
+ /**Generates @f$n@f$ values for all variables*/
+ AllVariables
+ };
explicit FldExporter(const std::string& separator = " ");
virtual ~FldExporter() FL_IOVERRIDE;
FL_DEFAULT_COPY_AND_MOVE(FldExporter)
virtual std::string name() const FL_IOVERRIDE;
+ /**
+ Sets the separator of the dataset columns
+ @param separator is the separator of the dataset columns
+ */
virtual void setSeparator(const std::string& separator);
+ /**
+ Gets the separator of the dataset columns
+ @return the separator of the dataset columns
+ */
virtual std::string getSeparator() const;
+ /**
+ Sets whether the header of the dataset is to be exported
+ @param exportHeaders indicates whether the header of the dataset is
+ to be exported
+ */
virtual void setExportHeader(bool exportHeaders);
+ /**
+ Gets whether the header of the dataset is to be exported
+ @return whether the header of the dataset is to be exported
+ */
virtual bool exportsHeader() const;
+ /**
+ Sets whether the values of the input variables are to be exported
+ @param exportInputValues indicates whether the values of the input
+ variables are to be exported
+ */
virtual void setExportInputValues(bool exportInputValues);
+ /**
+ Gets whether the values of the input variables are to be exported
+ @return whether the values of the input variables are to be exported
+ */
virtual bool exportsInputValues() const;
+ /**
+ Sets whether the values of the output variables are to be exported
+ @param exportOutputValues indicates whether the values of the output
+ variables are to be exported
+ */
virtual void setExportOutputValues(bool exportOutputValues);
+ /**
+ Gets whether the values of the output variables are to be exported
+ @return whether the values of the output variables are to be exported
+ */
virtual bool exportsOutputValues() const;
+ /**
+ Gets the header of the dataset for the given engine
+ @param engine is the engine to be exported
+ @return the header of the dataset for the given engine
+ */
virtual std::string header(const Engine* engine) const;
- //WARNING: The engine will be const_casted in order to be processed!
+ /**
+ Returns a FuzzyLite Dataset from the engine. Please consider that the
+ engine will be `const_cast`ed to achieve so; that is, despite being
+ marked as `const`, the engine will be modified in order to compute
+ the output values based on the input values.
+ @param engine is the engine to export
+ @return a FuzzyLite Dataset from the engine
+ */
virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
- virtual std::string toString(Engine* engine, int maximumNumberOfResults) const;
- virtual std::string toString(Engine* engine, const std::string& inputData) const;
+ /**
+ Returns a FuzzyLite Dataset from the engine.
+ @param engine is the engine to export
+ @param values is the number of values to export
+ @param scope indicates the scope of the values
+ @return a FuzzyLite Dataset from the engine
+ */
+ virtual std::string toString(Engine* engine, int values, ScopeOfValues scope = AllVariables) const;
+
+ /**
+ Returns a FuzzyLite Dataset from the engine.
+ @param engine is the engine to export
+ @param values is the number of values to export
+ @param scope indicates the scope of the values
+ @param activeVariables contains the input variables to generate values for.
+ The input variables must be in the same order as in the engine. A value of
+ fl::null indicates the variable is not active.
+ @return a FuzzyLite Dataset from the engine
+ */
+ virtual std::string toString(Engine* engine, int values, ScopeOfValues scope,
+ const std::vector<InputVariable*>& activeVariables) const;
+ /**
+ Returns a FuzzyLite Dataset from the engine.
+ @param engine is the engine to export
+ @param reader is the reader of a set of lines containing space-separated
+ input values
+ @return a FuzzyLite Dataset from the engine
+ */
+ virtual std::string toString(Engine* engine, std::istream& reader) const;
- using Exporter::toFile;
- virtual void toFile(const std::string& path, Engine* engine, int maximumNumberOfResults) const;
- virtual void toFile(const std::string& path, Engine* engine, const std::string& inputData) const;
-
- virtual std::vector<scalar> parse(const std::string& x) const;
- void write(Engine* engine, std::ostream& writer, int maximumNumberOfResults) const;
- void write(Engine* engine, std::ostream& writer, std::istream& reader) const;
- void write(Engine* engine, std::ostream& writer, const std::vector<scalar>& inputValues) const;
+ using Exporter::toFile;
+ /**
+ Saves the engine as a FuzzyLite Dataset into the specified file
+ @param path is the full path of the file
+ @param engine is the engine to export
+ @param values is the number of values to export
+ @param scope indicates the scope of the values
+ */
+ virtual void toFile(const std::string& path, Engine* engine,
+ int values, ScopeOfValues scope = AllVariables) const;
+ /**
+ Saves the engine as a FuzzyLite Dataset into the specified file
+ @param path is the full path of the file
+ @param engine is the engine to export
+ @param values is the number of values to export
+ @param scope indicates the scope of the values
+ @param activeVariables contains the input variables to generate values for.
+ The input variables must be in the same order as in the engine. A value of
+ fl::null indicates the variable is not active.
+ */
+ virtual void toFile(const std::string& path, Engine* engine,
+ int values, ScopeOfValues scope,
+ const std::vector<InputVariable*>& activeVariables) const;
+ /**
+ Saves the engine as a FuzzyLite Dataset into the specified file
+ @param path is the full path of the file
+ @param engine is the engine to export
+ @param reader is the reader of a set of lines containing space-separated input values
+ */
+ virtual void toFile(const std::string& path, Engine* engine, std::istream& reader) const;
+
+ /**
+ Parses the string into a vector of values unless the string starts with `#`
+ @param values is a space-separated set of values
+ @return a vector of values
+ */
+ virtual std::vector<scalar> parse(const std::string& values) const;
+
+ /**
+ Writes the engine into the given writer
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param values is the number of values to export
+ @param scope indicates the scope of the values
+ */
+ virtual void write(Engine* engine, std::ostream& writer, int values,
+ ScopeOfValues scope = AllVariables) const;
+ /**
+ Writes the engine into the given writer
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param values is the number of values to export
+ @param scope indicates the scope of the values
+ @param activeVariables contains the input variables to generate values for.
+ The input variables must be in the same order as in the engine. A value of
+ fl::null indicates the variable is not active.
+ */
+ virtual void write(Engine* engine, std::ostream& writer, int values, ScopeOfValues scope,
+ const std::vector<InputVariable*>& activeVariables) const;
+ /**
+ Writes the engine into the given writer
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param reader is the reader of a set of lines containing space-separated input values
+ */
+ virtual void write(Engine* engine, std::ostream& writer, std::istream& reader) const;
+ /**
+ Writes the engine into the given writer
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param inputValues is the vector of input values
+ */
+ virtual void write(Engine* engine, std::ostream& writer, const std::vector<scalar>& inputValues) const;
+ /**
+ Writes the engine into the given writer
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param inputValues is the vector of input values
+ @param activeVariables contains the input variables to generate values for.
+ The input variables must be in the same order as in the engine. A value of
+ fl::null indicates the variable is not active.
+ */
+ virtual void write(Engine* engine, std::ostream& writer, const std::vector<scalar>& inputValues,
+ const std::vector<InputVariable*>& activeVariables) const;
virtual FldExporter* clone() const FL_IOVERRIDE;
};
diff --git a/fuzzylite/fl/imex/FllExporter.h b/fuzzylite/fl/imex/FllExporter.h
index e6a89f5..5a222e4 100644
--- a/fuzzylite/fl/imex/FllExporter.h
+++ b/fuzzylite/fl/imex/FllExporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FLLEXPORTER_H
@@ -36,11 +28,23 @@ namespace fl {
class RuleBlock;
class Rule;
class Norm;
+ class Activation;
class Defuzzifier;
class Term;
+ /**
+ The FllExporter class is an Exporter that translates an Engine and its
+ components to the FuzzyLite Language (FLL), see
+ [http://www.fuzzylite.com/fll-fld](http://www.fuzzylite.com/fll-fld) for
+ more information.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FllImporter
+ @see Exporter
+ @since 4.0
+ */
class FL_API FllExporter : public Exporter {
- protected:
+ private:
std::string _indent;
std::string _separator;
public:
@@ -50,33 +54,114 @@ namespace fl {
virtual std::string name() const FL_IOVERRIDE;
+ /**
+ Sets the indent string of the FuzzyLite Language
+ @param indent is the indent string of the FuzzyLite Language
+ */
virtual void setIndent(const std::string& indent);
+ /**
+ Gets the indent string of the FuzzyLite Language
+ @return the indent string of the FuzzyLite Language
+ */
virtual std::string getIndent() const;
+ /**
+ Gets the separator of the FuzzyLite Language
+ @param separator of the FuzzyLite Language
+ */
virtual void setSeparator(const std::string& separator);
+ /**
+ Gets the separator of the FuzzyLite Language
+ @return the separator of the FuzzyLite Language
+ */
virtual std::string getSeparator() const;
virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
+ /**
+ Returns a string representation of the vector of variables in the FuzzyLite Language
+ @param variables is the vector of variables
+ @return a string representation of the vector of variables in the FuzzyLite Language
+ */
virtual std::string toString(const std::vector<Variable*>& variables) const;
+ /**
+ Returns a string representation of the vector of input variables in the FuzzyLite Language
+ @param inputVariables is the vector of input variables
+ @return a string representation of the vector of input variables in the FuzzyLite Language
+ */
virtual std::string toString(const std::vector<InputVariable*>& inputVariables) const;
+ /**
+ Returns a string representation of the vector of output variables in the FuzzyLite Language
+ @param outputVariables is a vector of output variables
+ @return a string representation of the vector of output variables in the FuzzyLite Language
+ */
virtual std::string toString(const std::vector<OutputVariable*>& outputVariables) const;
+ /**
+ Returns a string representation of the vector of rule blocks in the FuzzyLite Language
+ @param ruleBlocks is the vector of rule blocks
+ @return a string representation of the vector of rule blocks in the FuzzyLite Language
+ */
virtual std::string toString(const std::vector<RuleBlock*>& ruleBlocks) const;
+ /**
+ Returns a string representation of the Variable in the FuzzyLite Language
+ @param variable is the variable
+ @return a string representation of the variable in the FuzzyLite Language
+ */
virtual std::string toString(const Variable* variable) const;
+ /**
+ Returns a string representation of the InputVariable in the FuzzyLite Language
+ @param inputVariable is the input variable to export
+ @return a string representation of the input variable in the FuzzyLite Language
+ */
virtual std::string toString(const InputVariable* inputVariable) const;
+ /**
+ Returns a string representation of the OutputVariable in the FuzzyLite Language
+ @param outputVariable is the output variable
+ @return a string representation of the output variable in the FuzzyLite Language
+ */
virtual std::string toString(const OutputVariable* outputVariable) const;
+ /**
+ Returns a string representation of the RuleBlock in the FuzzyLite Language
+ @param ruleBlock is the rule block
+ @return a string representation of the rule block in the FuzzyLite Language
+ */
virtual std::string toString(const RuleBlock* ruleBlock) const;
+ /**
+ Returns a string representation of the Rule in the FuzzyLite Language
+ @param rule is the rule
+ @return a string representation of the rule in the FuzzyLite Language
+ */
virtual std::string toString(const Rule* rule) const;
+ /**
+ Returns a string representation of the Norm in the FuzzyLite Language
+ @param norm is the norm
+ @return a string representation of the norm in the FuzzyLite Language
+ */
virtual std::string toString(const Norm* norm) const;
+ /**
+ Returns a string representation of the Activation method in the FuzzyLite Language
+ @param activation is the activation method
+ @return a string representation of the activation method in the FuzzyLite Language
+ */
+ virtual std::string toString(const Activation* activation) const;
+ /**
+ Returns a string representation of the Defuzzifier in the FuzzyLite Language
+ @param defuzzifier is the defuzzifier
+ @return a string representation of the defuzzifier in the FuzzyLite Language
+ */
virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ /**
+ Returns a string representation of the Term in the FuzzyLite Language
+ @param term is the term
+ @return a string representation of the term in the FuzzyLite Language
+ */
virtual std::string toString(const Term* term) const;
virtual FllExporter* clone() const FL_IOVERRIDE;
};
-
}
#endif /* FL_FLLEXPORTER_H */
diff --git a/fuzzylite/fl/imex/FllImporter.h b/fuzzylite/fl/imex/FllImporter.h
index 5be41c7..055bb88 100644
--- a/fuzzylite/fl/imex/FllImporter.h
+++ b/fuzzylite/fl/imex/FllImporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_FLLIMPORTER_H
@@ -32,18 +24,39 @@
namespace fl {
class TNorm;
class SNorm;
+ class Activation;
class Term;
class Defuzzifier;
+ /**
+ The FllImporter class is an Importer that configures an Engine and its
+ components utilizing the FuzzyLite Language (FLL), see
+ [http://www.fuzzylite.com/fll-fld](http://www.fuzzylite.com/fll-fld) for
+ more information.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FllExporter
+ @see Importer
+ @since 4.0
+ @todo parse methods returning respective instances from blocks of text
+ */
class FL_API FllImporter : public Importer {
- protected:
+ private:
std::string _separator;
public:
explicit FllImporter(const std::string& separator = "\n");
virtual ~FllImporter() FL_IOVERRIDE;
FL_DEFAULT_COPY_AND_MOVE(FllImporter)
+ /**
+ Sets the separator of the language (default separator is a new line '\n')
+ @param separator is the separator of the language
+ */
virtual void setSeparator(const std::string& separator);
+ /**
+ Gets the separator of the language (default separator is a new line '\n')
+ @return the separator of the language
+ */
virtual std::string getSeparator() const;
virtual std::string name() const FL_IOVERRIDE;
@@ -52,6 +65,7 @@ namespace fl {
virtual FllImporter* clone() const FL_IOVERRIDE;
protected:
+
virtual void process(const std::string& tag, const std::string& block, Engine* engine) const;
virtual void processInputVariable(const std::string& block, Engine* engine) const;
virtual void processOutputVariable(const std::string& block, Engine* engine) const;
@@ -59,6 +73,7 @@ namespace fl {
virtual TNorm* parseTNorm(const std::string& name) const;
virtual SNorm* parseSNorm(const std::string& name) const;
+ virtual Activation* parseActivation(const std::string& name) const;
virtual Term* parseTerm(const std::string& text, Engine* engine) const;
@@ -68,7 +83,6 @@ namespace fl {
virtual std::pair<std::string, std::string> parseKeyValue(const std::string& text,
char separator = ':') const;
- virtual std::string clean(const std::string& line) const;
};
}
diff --git a/fuzzylite/fl/imex/Importer.h b/fuzzylite/fl/imex/Importer.h
index 28d2b36..1250e66 100644
--- a/fuzzylite/fl/imex/Importer.h
+++ b/fuzzylite/fl/imex/Importer.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_IMPORTER_H
@@ -32,6 +24,16 @@
namespace fl {
class Engine;
+ /**
+ The Importer class is the abstract class for importers to configure an
+ Engine and its components from different text formats.
+
+ @todo declare methods to import specific components
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see Exporter
+ @since 4.0
+ */
class FL_API Importer {
public:
@@ -39,13 +41,30 @@ namespace fl {
virtual ~Importer();
FL_DEFAULT_COPY_AND_MOVE(Importer)
- virtual Engine* fromString(const std::string& s) const = 0;
+ /**
+ Imports the engine from the given text
+ @param text is the string representation of the engine to import from
+ @return the engine represented by the text
+ */
+ virtual Engine* fromString(const std::string& text) const = 0;
+ /**
+ Imports the engine from the given file
+ @param path is the full path of the file containing the engine to import from
+ @return the engine represented by the file
+ */
virtual Engine* fromFile(const std::string& path) const;
+ /**
+ Returns the name of the importer
+ @return the name of the importer
+ */
virtual std::string name() const = 0;
+ /**
+ Creates a clone of the importer
+ @return a clone of the importer
+ */
virtual Importer* clone() const = 0;
};
-
}
#endif /* IMPORTER_H */
diff --git a/fuzzylite/fl/imex/JavaExporter.h b/fuzzylite/fl/imex/JavaExporter.h
index e882d4a..a1817f6 100644
--- a/fuzzylite/fl/imex/JavaExporter.h
+++ b/fuzzylite/fl/imex/JavaExporter.h
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
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.
+ the terms of the FuzzyLite License included with the software.
- 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.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#ifndef FL_JAVAEXPORTER_H
@@ -38,30 +30,122 @@ namespace fl {
class Norm;
class SNorm;
class TNorm;
-
+ class Activation;
+
+ /**
+ The JavaExporter class is an Exporter that translates an Engine and its
+ components to the `Java` programming language using the `jfuzzylite`
+ library.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see CppExporter
+ @see Exporter
+ @since 4.0
+ */
class FL_API JavaExporter : public Exporter {
+ private:
+ bool _usingVariableNames;
public:
- JavaExporter();
+ explicit JavaExporter(bool usingVariableNames = true);
virtual ~JavaExporter() FL_IOVERRIDE;
FL_DEFAULT_COPY_AND_MOVE(JavaExporter)
virtual std::string name() const FL_IOVERRIDE;
+ /**
+ Sets whether variables are exported using their names
+ (e.g., `power.setValue(Double.NaN)`) instead of numbered identifiers
+ (e.g., `inputVariable1.setValue(Double.NaN)`)
+ @param usingVariableNames indicates whether variables are exported using
+ their names
+ */
+ virtual void setUsingVariableNames(bool usingVariableNames);
+
+ /**
+ Gets whether variables are exported using their names
+ (e.g., `power.setValue(Double.NaN)`) instead of numbered identifiers
+ (e.g., `inputVariable1.setValue(Double.NaN)`)
+ @return whether variables are exported using their names
+ */
+ virtual bool isUsingVariableNames() const;
+
virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
+ /**
+ Returns a string representation of the InputVariable in the Java
+ programming language
+ @param inputVariable is the input variable
+ @param engine is the engine in which the input variable is registered
+ @return a string representation of the input variable in the Java
+ programming language
+ */
virtual std::string toString(const InputVariable* inputVariable, const Engine* engine) const;
+ /**
+ Returns a string representation of the OutputVariable in the Java
+ programming language
+ @param outputVariable is the output variable
+ @param engine is the engine in which the output variable is registered
+ @return a string representation of the output variable in the Java
+ programming language
+ */
virtual std::string toString(const OutputVariable* outputVariable, const Engine* engine) const;
+ /**
+ Returns a string representation of the RuleBlock in the Java
+ programming language
+ @param ruleBlock is the rule block
+ @param engine is the engine in which the rule block is registered
+ @return a string representation of the rule block in the Java
+ programming language
+ */
virtual std::string toString(const RuleBlock* ruleBlock, const Engine* engine) const;
+
+ /**
+ Returns a string representation of the Term in the Java programming
+ language
+ @param term is the term
+ @return a string representation of the term in the Java programming
+ language
+ */
virtual std::string toString(const Term* term) const;
+
+ /**
+ Returns a string representation of the Activation method in the Java
+ programming language
+ @param activation is the activation method
+ @return a string representation of the activation method in the Java
+ programming language
+ */
+ virtual std::string toString(const Activation* activation) const;
+
+ /**
+ Returns a string representation of the Defuzzifier in the Java
+ programming language
+ @param defuzzifier is the defuzzifier
+ @return a string representation of the defuzzifier in the Java
+ programming language
+ */
virtual std::string toString(const Defuzzifier* defuzzifier) const;
+
+ /**
+ Returns a string representation of the Norm in the Java programming
+ language
+ @param norm is the norm
+ @return a string representation of the norm in the Java programming
+ language
+ */
virtual std::string toString(const Norm* norm) const;
- virtual std::string toString(const SNorm* norm) const;//TODO: delete in v6.0
- virtual std::string toString(const TNorm* norm) const;//TODO: delete in v6.0
+
+ /**
+ Returns a string representation of the scalar value in the Java
+ programming language
+ @param value is the scalar value
+ @return a string representation of the scalar value in the Java
+ programming language
+ */
virtual std::string toString(scalar value) const;
virtual JavaExporter* clone() const FL_IOVERRIDE;
};
-
}
#endif /* FL_JAVAEXPORTER_H */
diff --git a/fuzzylite/fl/imex/RScriptExporter.h b/fuzzylite/fl/imex/RScriptExporter.h
new file mode 100644
index 0000000..c53c751
--- /dev/null
+++ b/fuzzylite/fl/imex/RScriptExporter.h
@@ -0,0 +1,246 @@
+/*
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
+
+ This file is part of fuzzylite.
+
+ fuzzylite is free software: you can redistribute it and/or modify it under
+ the terms of the FuzzyLite License included with the software.
+
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+
+ fuzzylite is a registered trademark of FuzzyLite Limited.
+ */
+
+#ifndef FL_RSCRIPTEXPORTER_H
+#define FL_RSCRIPTEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+#include "fl/imex/FldExporter.h"
+
+#include <vector>
+
+namespace fl {
+ class Engine;
+ class InputVariable;
+ class OutputVariable;
+
+ /**
+ The RScriptExporter class is an Exporter that creates an R script to plot one or
+ more surfaces of an engine for two input variables and any number of output
+ variables.
+
+ @author Juan Rada-Vilela, Ph.D.
+ @see FldExporter
+ @see Exporter
+ @since 6.0
+ */
+ class FL_API RScriptExporter : public Exporter {
+ private:
+ std::string _minimumColor;
+ std::string _maximumColor;
+ std::string _contourColor;
+
+ public:
+ RScriptExporter();
+ virtual ~RScriptExporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(RScriptExporter)
+
+ virtual std::string name() const FL_IOVERRIDE;
+
+ /**
+ Sets the color to represent the minimum values.
+ @param minimumColor is the color to represent the minimum values
+ */
+ void setMinimumColor(const std::string& minimumColor);
+ /**
+ Gets the color to represent the minimum values.
+ @return the color to represent the minimum values
+ */
+ std::string getMinimumColor() const;
+
+ /**
+ Sets the color to represent the maximum values.
+ @param maximumColor is the color to represent the maximum values
+ */
+ void setMaximumColor(const std::string& maximumColor);
+ /**
+ Gets the color to represent the maximum values.
+ @return maximumColor is the color to represent the maximum values
+ */
+ std::string getMaximumColor() const;
+
+ /**
+ Sets the color to draw the contour lines
+ @param contourColor is the color to draw the contour lines
+ */
+ void setContourColor(const std::string& contourColor);
+ /**
+ Gets the color to draw the contour lines
+ @return the color to draw the contour lines
+ */
+ std::string getContourColor() const;
+
+ /**
+ Returns an R script plotting multiple surfaces based on a data frame
+ generated with 1024 values in the scope of FldExporter::AllVariables
+ for the first two input variables.
+ @param engine is the engine to export
+ @return an R script plotting multiple surfaces for the first two input
+ variables in the engine.
+ */
+ virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
+
+ /**
+ Returns an R script plotting multiple surfaces based on a data frame
+ generated with the given number of values and scope for the two input
+ variables.
+ @param engine is the engine to export
+ @param a is the first input variable
+ @param b is the second input variable
+ @param values is the number of values to evaluate the engine
+ @param scope is the scope of the number of values to evaluate the engine
+ @param outputVariables are the output variables to create the surface for
+ @return an R script plotting multiple surfaces for the two input
+ variables on the output variables.
+ */
+ virtual std::string toString(Engine* engine, InputVariable* a, InputVariable* b,
+ int values, FldExporter::ScopeOfValues scope,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+ /**
+ Returns an R script plotting multiple surfaces based on the input stream
+ of values for the two input variables.
+ @param engine is the engine to export
+ @param a is the first input variable
+ @param b is the second input variable
+ @param reader is an input stream of data whose lines contain space-separated
+ input values
+ @param outputVariables are the output variables to create the surface for
+ @return an R script plotting multiple surfaces for the two input
+ variables on the output variables
+ */
+ virtual std::string toString(Engine* engine, InputVariable* a, InputVariable* b,
+ std::istream& reader, const std::vector<OutputVariable*>& outputVariables) const;
+
+ /**
+ Creates an R script file plotting multiple surfaces based on a data frame
+ generated with 1024 values in the scope of FldExporter::AllVariables
+ for the two input variables
+ @param filePath is the full path of the R script file
+ @param engine is the engine to export
+ */
+ virtual void toFile(const std::string& filePath, const Engine* engine) const FL_IOVERRIDE;
+
+ /**
+ Creates an R script file plotting multiple surfaces based on a data frame
+ generated with the given number of values and scope for the two input
+ variables
+ @param filePath is the full path of the R script file
+ @param engine is the engine to export
+ @param a is the first input variable
+ @param b is the second input variable
+ @param values is the number of values to evaluate the engine
+ @param scope is the scope of the number of values to evaluate the engine
+ @param outputVariables are the output variables to create the surface for
+ */
+ virtual void toFile(const std::string& filePath, Engine* engine,
+ InputVariable* a, InputVariable* b,
+ int values, FldExporter::ScopeOfValues scope,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+ /**
+ Creates an R script file plotting multiple surfaces based on the input stream
+ of values for the two input variables.
+ @param filePath is the full path of the R script file
+ @param engine is the engine to export
+ @param a is the first input variable
+ @param b is the second input variable
+ @param reader is an input stream of data whose lines contain space-separated
+ input values
+ @param outputVariables are the output variables to create the surface for
+ */
+ virtual void toFile(const std::string& filePath, Engine* engine,
+ InputVariable* a, InputVariable* b, std::istream& reader,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+
+ /**
+ Writes an R script plotting multiple surfaces based on a manually
+ imported data frame containing the data for the two input variables
+ on the output variables.
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param a is the first input variable
+ @param b is the second input variable
+ @param dataFramePath is the path where the data frame should be located
+ (the path will not be accessed, it will only be written to script)
+ @param outputVariables are the output variables to create the surface for
+ */
+ virtual void writeScriptImportingDataFrame(const Engine* engine, std::ostream& writer,
+ InputVariable* a, InputVariable* b, const std::string& dataFramePath,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+ /**
+ Writes an R script plotting multiple surfaces based on a data frame
+ generated with the given number of values and scope for the two input
+ variables on the output variables.
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param a is the first input variable
+ @param b is the second input variable
+ @param values is the number of values to evaluate the engine
+ @param scope is the scope of the number of values to evaluate the engine
+ @param outputVariables are the output variables to create the surface for
+ */
+ virtual void writeScriptExportingDataFrame(Engine* engine, std::ostream& writer,
+ InputVariable* a, InputVariable* b, int values, FldExporter::ScopeOfValues scope,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+ /**
+ Writes an R script plotting multiple surfaces based on a data frame
+ generated with the given number of values and scope for the two input
+ variables on the output variables.
+ @param engine is the engine to export
+ @param writer is the output where the engine will be written to
+ @param a is the first input variable
+ @param b is the second input variable
+ @param reader is an input stream of data whose lines contain space-separated
+ input values
+ @param outputVariables are the output variables to create the surface for
+ */
+ virtual void writeScriptExportingDataFrame(Engine* engine, std::ostream& writer,
+ InputVariable* a, InputVariable* b, std::istream& reader,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+ protected:
+ /**
+ Writes the header of the R script (e.g., import libraries)
+ @param writer is the output where the header will be written to
+ @param engine is the engine to export
+ */
+ virtual void writeScriptHeader(std::ostream& writer, const Engine* engine) const;
+
+ /**
+ Writes the code to generate the surface plots for the input variables
+ on the output variables.
+ @param writer is the output where the engine will be written to
+ @param a is the first input variable
+ @param b is the second input variable
+ @param outputVariables are the output variables to create the surface for
+ */
+ virtual void writeScriptPlots(std::ostream& writer,
+ InputVariable* a, InputVariable* b,
+ const std::vector<OutputVariable*>& outputVariables) const;
+
+
+ virtual RScriptExporter* clone() const FL_IOVERRIDE;
+
+ };
+
+}
+
+#endif /* FL_RSCRIPTEXPORTER_H */
+