diff --git a/dep/fl/Console.h b/dep/fl/Console.h
new file mode 100644
index 0000000..59e818d
--- /dev/null
+++ b/dep/fl/Console.h
@@ -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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CONSOLE_H
+#define FL_CONSOLE_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+#include
+
+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 parse(int argc, char** argv);
+ static void process(const std::map& options);
+
+ static void process(const std::string& input, std::ostream& writer,
+ const std::string& inputFormat, const std::string& outputFormat,
+ const std::map& 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 availableOptions();
+
+ static int main(int argc, char** argv);
+ };
+
+}
+
+#endif /* FL_CONSOLE_H */
+
diff --git a/dep/fl/Engine.h b/dep/fl/Engine.h
new file mode 100644
index 0000000..532c5e9
--- /dev/null
+++ b/dep/fl/Engine.h
@@ -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 .
+
+ 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
+#include
+
+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 _inputVariables;
+ std::vector _outputVariables;
+ std::vector _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 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& inputVariables() const;
+ virtual void setInputVariables(const std::vector& inputVariables);
+ virtual std::vector& 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& outputVariables() const;
+ virtual void setOutputVariables(const std::vector& outputVariables);
+ virtual std::vector& 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& ruleBlocks() const;
+ virtual void setRuleBlocks(const std::vector& ruleBlocks);
+ virtual std::vector& ruleBlocks();
+
+ };
+
+}
+#endif /* FL_ENGINE_H */
diff --git a/dep/fl/Exception.h b/dep/fl/Exception.h
new file mode 100644
index 0000000..f33fb13
--- /dev/null
+++ b/dep/fl/Exception.h
@@ -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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_EXCEPTION_H
+#define FL_EXCEPTION_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+#include
+
+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 */
diff --git a/dep/fl/Headers.h b/dep/fl/Headers.h
new file mode 100644
index 0000000..9c2299a
--- /dev/null
+++ b/dep/fl/Headers.h
@@ -0,0 +1,131 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_HEADERS_H
+#define FL_HEADERS_H
+
+#include "fl/fuzzylite.h"
+
+#include "fl/Console.h"
+#include "fl/Engine.h"
+#include "fl/Exception.h"
+
+#include "fl/defuzzifier/Bisector.h"
+#include "fl/defuzzifier/Centroid.h"
+#include "fl/defuzzifier/Defuzzifier.h"
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+#include "fl/defuzzifier/SmallestOfMaximum.h"
+#include "fl/defuzzifier/LargestOfMaximum.h"
+#include "fl/defuzzifier/MeanOfMaximum.h"
+#include "fl/defuzzifier/WeightedAverage.h"
+#include "fl/defuzzifier/WeightedDefuzzifier.h"
+#include "fl/defuzzifier/WeightedSum.h"
+
+#include "fl/factory/CloningFactory.h"
+#include "fl/factory/ConstructionFactory.h"
+#include "fl/factory/FactoryManager.h"
+#include "fl/factory/FunctionFactory.h"
+#include "fl/factory/DefuzzifierFactory.h"
+#include "fl/factory/HedgeFactory.h"
+#include "fl/factory/SNormFactory.h"
+#include "fl/factory/TNormFactory.h"
+#include "fl/factory/TermFactory.h"
+
+#include "fl/imex/CppExporter.h"
+#include "fl/imex/FclImporter.h"
+#include "fl/imex/FclExporter.h"
+#include "fl/imex/FisImporter.h"
+#include "fl/imex/FisExporter.h"
+#include "fl/imex/FldExporter.h"
+#include "fl/imex/FllImporter.h"
+#include "fl/imex/FllExporter.h"
+#include "fl/imex/JavaExporter.h"
+
+#include "fl/hedge/Any.h"
+#include "fl/hedge/Extremely.h"
+#include "fl/hedge/Hedge.h"
+#include "fl/hedge/Not.h"
+#include "fl/hedge/Seldom.h"
+#include "fl/hedge/Somewhat.h"
+#include "fl/hedge/Very.h"
+
+#include "fl/Operation.h"
+
+#include "fl/norm/Norm.h"
+#include "fl/norm/SNorm.h"
+#include "fl/norm/TNorm.h"
+
+#include "fl/norm/s/AlgebraicSum.h"
+#include "fl/norm/s/BoundedSum.h"
+#include "fl/norm/s/DrasticSum.h"
+#include "fl/norm/s/EinsteinSum.h"
+#include "fl/norm/s/HamacherSum.h"
+#include "fl/norm/s/Maximum.h"
+#include "fl/norm/s/NilpotentMaximum.h"
+#include "fl/norm/s/NormalizedSum.h"
+
+#include "fl/norm/t/AlgebraicProduct.h"
+#include "fl/norm/t/BoundedDifference.h"
+#include "fl/norm/t/DrasticProduct.h"
+#include "fl/norm/t/EinsteinProduct.h"
+#include "fl/norm/t/HamacherProduct.h"
+#include "fl/norm/t/Minimum.h"
+#include "fl/norm/t/NilpotentMinimum.h"
+
+#include "fl/rule/Antecedent.h"
+#include "fl/rule/Consequent.h"
+#include "fl/rule/Rule.h"
+#include "fl/rule/RuleBlock.h"
+#include "fl/rule/Expression.h"
+
+#include "fl/term/Accumulated.h"
+#include "fl/term/Bell.h"
+#include "fl/term/Concave.h"
+#include "fl/term/Constant.h"
+#include "fl/term/Cosine.h"
+#include "fl/term/Discrete.h"
+#include "fl/term/Function.h"
+#include "fl/term/Gaussian.h"
+#include "fl/term/GaussianProduct.h"
+#include "fl/term/Linear.h"
+#include "fl/term/PiShape.h"
+#include "fl/term/Ramp.h"
+#include "fl/term/Rectangle.h"
+#include "fl/term/SShape.h"
+#include "fl/term/Sigmoid.h"
+#include "fl/term/SigmoidDifference.h"
+#include "fl/term/SigmoidProduct.h"
+#include "fl/term/Spike.h"
+#include "fl/term/Term.h"
+#include "fl/term/Activated.h"
+#include "fl/term/Trapezoid.h"
+#include "fl/term/Triangle.h"
+#include "fl/term/ZShape.h"
+
+#include "fl/variable/InputVariable.h"
+#include "fl/variable/OutputVariable.h"
+#include "fl/variable/Variable.h"
+
+
+#endif /* FL_HEADERS_H */
diff --git a/dep/fl/Operation.h b/dep/fl/Operation.h
new file mode 100644
index 0000000..d92e66c
--- /dev/null
+++ b/dep/fl/Operation.h
@@ -0,0 +1,144 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_OPERATION_H
+#define FL_OPERATION_H
+
+#include "fl/fuzzylite.h"
+
+#include "fl/Exception.h"
+
+#include
+#include
+
+namespace fl {
+
+ class FL_API Operation {
+ public:
+
+ template
+ static T min(T a, T b);
+
+ template
+ static T max(T a, T b);
+
+ template
+ static T bound(T x, T min, T max);
+
+ template
+ static bool in(T x, T min, T max, bool geq = true, bool leq = true);
+
+ template
+ static bool isInf(T x);
+
+ template
+ static bool isNaN(T x);
+
+ template
+ static bool isFinite(T x);
+
+ //Is less than
+
+ static bool isLt(scalar a, scalar b, scalar macheps = fl::fuzzylite::macheps());
+ static bool isLE(scalar a, scalar b, scalar macheps = fl::fuzzylite::macheps());
+ static bool isEq(scalar a, scalar b, scalar macheps = fl::fuzzylite::macheps());
+ static bool isGt(scalar a, scalar b, scalar macheps = fl::fuzzylite::macheps());
+ static bool isGE(scalar a, scalar b, scalar macheps = fl::fuzzylite::macheps());
+
+ static scalar scale(scalar x, scalar fromMin, scalar fromMax,
+ scalar toMin, scalar toMax, bool bounded = false);
+
+ static scalar add(scalar a, scalar b);
+ static scalar subtract(scalar a, scalar b);
+ static scalar multiply(scalar a, scalar b);
+ static scalar divide(scalar a, scalar b);
+ static scalar modulo(scalar a, scalar b);
+ static scalar logicalAnd(scalar a, scalar b);
+ static scalar logicalOr(scalar a, scalar b);
+ static scalar logicalNot(scalar a);
+ static scalar negate(scalar a);
+ static scalar round(scalar x);
+
+ //greater than
+ static scalar gt(scalar a, scalar b);
+ //greater than or equal to
+ static scalar ge(scalar a, scalar b);
+ //equal to
+ static scalar eq(scalar a, scalar b);
+ //not equal to
+ static scalar neq(scalar a, scalar b);
+ //less than or equal to
+ static scalar le(scalar a, scalar b);
+ //less than
+ static scalar lt(scalar a, scalar b);
+
+ static bool increment(std::vector& x, std::vector& min, std::vector& max);
+ static bool increment(std::vector& x, int position, std::vector& min, std::vector& max);
+
+ static double mean(const std::vector& x);
+ static double variance(const std::vector& x);
+ static double variance(const std::vector& x, scalar mean);
+ static double standardDeviation(const std::vector& x);
+ static double standardDeviation(const std::vector& x, scalar mean);
+
+ static std::string validName(const std::string& name);
+
+ static int isValidForName(int character);
+
+ static std::string findReplace(const std::string& str, const std::string& find,
+ const std::string& replace, bool replaceAll = true);
+
+ static std::vector split(const std::string& str,
+ const std::string& delimiter = " ", bool ignoreEmpty = true);
+
+ static std::string trim(const std::string& text);
+
+ static std::string format(const std::string& text, int matchesChar(int),
+ const std::string& replacement = "");
+
+ //Intentionally results in a compiler error in C++11, or linker error in C++98
+ //in order to avoid the deprecated usage of this method from version 4.0
+ static scalar toScalar(const std::string& x, bool quiet,
+ scalar alternative = fl::nan) FL_IDELETE;
+
+ static scalar toScalar(const std::string& x); //throws fl::Exception
+
+ static scalar toScalar(const std::string& x, scalar alternative) FL_INOEXCEPT;
+
+ static bool isNumeric(const std::string& x);
+
+ template
+ static std::string str(T x, int decimals = fuzzylite::decimals());
+
+ template
+ static std::string join(const std::vector& x, const std::string& separator);
+
+ template
+ static std::string join(int items, const std::string& separator, T first, ...);
+ };
+
+ typedef Operation Op;
+}
+#endif /* FL_OPERATION_H */
+
diff --git a/dep/fl/defuzzifier/Bisector.h b/dep/fl/defuzzifier/Bisector.h
new file mode 100644
index 0000000..7ba8db2
--- /dev/null
+++ b/dep/fl/defuzzifier/Bisector.h
@@ -0,0 +1,49 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_BISECTOR_H
+#define FL_BISECTOR_H
+
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API Bisector : public IntegralDefuzzifier {
+ public:
+ explicit Bisector(int resolution = defaultResolution());
+ virtual ~Bisector() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Bisector)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual Bisector* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+
+}
+
+#endif /* FL_BISECTOR_H */
+
diff --git a/dep/fl/defuzzifier/Centroid.h b/dep/fl/defuzzifier/Centroid.h
new file mode 100644
index 0000000..7510673
--- /dev/null
+++ b/dep/fl/defuzzifier/Centroid.h
@@ -0,0 +1,47 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CENTROID_H
+#define FL_CENTROID_H
+
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API Centroid : public IntegralDefuzzifier {
+ public:
+ explicit Centroid(int resolution = defaultResolution());
+ virtual ~Centroid() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Centroid)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual Centroid* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+
+}
+#endif /* FL_CENTROID_H */
diff --git a/dep/fl/defuzzifier/Defuzzifier.h b/dep/fl/defuzzifier/Defuzzifier.h
new file mode 100644
index 0000000..3598113
--- /dev/null
+++ b/dep/fl/defuzzifier/Defuzzifier.h
@@ -0,0 +1,53 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+//TODO Check http://en.wikipedia.org/wiki/Defuzzification for other defuzzifiers.
+
+#ifndef FL_DEFUZZIFIER_H
+#define FL_DEFUZZIFIER_H
+
+#include "fl/fuzzylite.h"
+#include
+
+namespace fl {
+ class Term;
+
+ class FL_API Defuzzifier {
+ public:
+
+ Defuzzifier() {
+ }
+
+ virtual ~Defuzzifier() {
+ }
+ FL_DEFAULT_COPY_AND_MOVE(Defuzzifier)
+
+ virtual std::string className() const = 0;
+ virtual Defuzzifier* clone() const = 0;
+ virtual scalar defuzzify(const Term* term, scalar minimum, scalar maximum) const = 0;
+
+ };
+
+}
+#endif /* FL_DEFUZZIFIER_H */
diff --git a/dep/fl/defuzzifier/IntegralDefuzzifier.h b/dep/fl/defuzzifier/IntegralDefuzzifier.h
new file mode 100644
index 0000000..61aaf8a
--- /dev/null
+++ b/dep/fl/defuzzifier/IntegralDefuzzifier.h
@@ -0,0 +1,53 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_INTEGRALDEFUZZIFIER_H
+#define FL_INTEGRALDEFUZZIFIER_H
+
+#include "fl/defuzzifier/Defuzzifier.h"
+
+namespace fl {
+ //TODO: check http://en.wikipedia.org/wiki/Adaptive_quadrature
+
+ class FL_API IntegralDefuzzifier : public Defuzzifier {
+ protected:
+ static int _defaultResolution;
+
+ int _resolution;
+ public:
+
+ static void setDefaultResolution(int defaultResolution);
+ static int defaultResolution();
+
+ explicit IntegralDefuzzifier(int resolution = defaultResolution());
+ virtual ~IntegralDefuzzifier() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(IntegralDefuzzifier)
+
+ virtual void setResolution(int resolution);
+ virtual int getResolution() const;
+ };
+}
+
+#endif /* INTEGRALDEFUZZIFIER_H */
+
diff --git a/dep/fl/defuzzifier/LargestOfMaximum.h b/dep/fl/defuzzifier/LargestOfMaximum.h
new file mode 100644
index 0000000..8f1d3c8
--- /dev/null
+++ b/dep/fl/defuzzifier/LargestOfMaximum.h
@@ -0,0 +1,47 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_LARGESTOFMAXIMUM_H
+#define FL_LARGESTOFMAXIMUM_H
+
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API LargestOfMaximum : public IntegralDefuzzifier {
+ public:
+ explicit LargestOfMaximum(int resolution = defaultResolution());
+ virtual ~LargestOfMaximum() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(LargestOfMaximum)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual LargestOfMaximum* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+}
+#endif /* FL_LARGESTOFMAXIMUM_H */
+
diff --git a/dep/fl/defuzzifier/MeanOfMaximum.h b/dep/fl/defuzzifier/MeanOfMaximum.h
new file mode 100644
index 0000000..2c09759
--- /dev/null
+++ b/dep/fl/defuzzifier/MeanOfMaximum.h
@@ -0,0 +1,48 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_MEANOFMAXIMUM_H
+#define FL_MEANOFMAXIMUM_H
+
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API MeanOfMaximum : public IntegralDefuzzifier {
+ public:
+ explicit MeanOfMaximum(int resolution = defaultResolution());
+ virtual ~MeanOfMaximum() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(MeanOfMaximum)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual MeanOfMaximum* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+}
+
+#endif /* FL_MEANOFMAXIMUM_H */
+
diff --git a/dep/fl/defuzzifier/SmallestOfMaximum.h b/dep/fl/defuzzifier/SmallestOfMaximum.h
new file mode 100644
index 0000000..289e2a9
--- /dev/null
+++ b/dep/fl/defuzzifier/SmallestOfMaximum.h
@@ -0,0 +1,48 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SMALLESTOFMAXIMUM_H
+#define FL_SMALLESTOFMAXIMUM_H
+
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API SmallestOfMaximum : public IntegralDefuzzifier {
+ public:
+ explicit SmallestOfMaximum(int resolution = defaultResolution());
+ virtual ~SmallestOfMaximum() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(SmallestOfMaximum)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual SmallestOfMaximum* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+}
+
+#endif /* FL_SMALLESTOFMAXIMUM_H */
+
diff --git a/dep/fl/defuzzifier/WeightedAverage.h b/dep/fl/defuzzifier/WeightedAverage.h
new file mode 100644
index 0000000..3fbbd38
--- /dev/null
+++ b/dep/fl/defuzzifier/WeightedAverage.h
@@ -0,0 +1,50 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_WEIGHTEDAVERAGE_H
+#define FL_WEIGHTEDAVERAGE_H
+
+#include "fl/defuzzifier/WeightedDefuzzifier.h"
+
+namespace fl {
+ class Activated;
+
+ class FL_API WeightedAverage : public WeightedDefuzzifier {
+ public:
+ explicit WeightedAverage(Type type = Automatic);
+ explicit WeightedAverage(const std::string& type);
+ virtual ~WeightedAverage() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(WeightedAverage)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual WeightedAverage* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+}
+
+#endif /* FL_WEIGHTEDAVERAGE_H */
+
diff --git a/dep/fl/defuzzifier/WeightedDefuzzifier.h b/dep/fl/defuzzifier/WeightedDefuzzifier.h
new file mode 100644
index 0000000..2bf0495
--- /dev/null
+++ b/dep/fl/defuzzifier/WeightedDefuzzifier.h
@@ -0,0 +1,63 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_WEIGHTEDDEFUZZIFIER_H
+#define FL_WEIGHTEDDEFUZZIFIER_H
+
+#include "fl/defuzzifier/Defuzzifier.h"
+
+namespace fl {
+ class Activated;
+
+ class FL_API WeightedDefuzzifier : public Defuzzifier {
+ public:
+
+ enum Type {
+ Automatic, TakagiSugeno, Tsukamoto
+ };
+ static std::string typeName(Type);
+
+ explicit WeightedDefuzzifier(Type type = Automatic);
+ explicit WeightedDefuzzifier(const std::string& type);
+ virtual ~WeightedDefuzzifier() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(WeightedDefuzzifier)
+
+ virtual void setType(Type type);
+ virtual Type getType() const;
+ virtual std::string getTypeName() const;
+ virtual Type inferType(const Term* term) const;
+ virtual bool isMonotonic(const Term* term) const;
+
+ virtual scalar tsukamoto(const Term* monotonic, scalar activationDegree,
+ scalar minimum, scalar maximum) const;
+
+ protected:
+ Type _type;
+
+ };
+
+}
+
+#endif /* FL_WEIGHTEDDEFUZZIFIER_H */
+
diff --git a/dep/fl/defuzzifier/WeightedSum.h b/dep/fl/defuzzifier/WeightedSum.h
new file mode 100644
index 0000000..a754023
--- /dev/null
+++ b/dep/fl/defuzzifier/WeightedSum.h
@@ -0,0 +1,50 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_WEIGHTEDSUM_H
+#define FL_WEIGHTEDSUM_H
+
+
+#include "fl/defuzzifier/WeightedDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API WeightedSum : public WeightedDefuzzifier {
+ public:
+ explicit WeightedSum(Type type = Automatic);
+ explicit WeightedSum(const std::string& type);
+ virtual ~WeightedSum() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(WeightedSum)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual scalar defuzzify(const Term* term,
+ scalar minimum, scalar maximum) const FL_IOVERRIDE;
+ virtual WeightedSum* clone() const FL_IOVERRIDE;
+
+ static Defuzzifier* constructor();
+ };
+}
+
+#endif /* FL_WEIGHTEDSUM_H */
+
diff --git a/dep/fl/factory/CloningFactory.h b/dep/fl/factory/CloningFactory.h
new file mode 100644
index 0000000..3262721
--- /dev/null
+++ b/dep/fl/factory/CloningFactory.h
@@ -0,0 +1,62 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CLONINGFACTORY_H
+#define FL_CLONINGFACTORY_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+#include
+
+namespace fl {
+
+ template
+ class FL_API CloningFactory {
+ protected:
+ std::string _name;
+ std::map _objects;
+
+ public:
+ explicit CloningFactory(const std::string& name = "");
+ CloningFactory(const CloningFactory& other);
+ CloningFactory& operator=(const CloningFactory& other);
+ virtual ~CloningFactory();
+ FL_DEFAULT_MOVE(CloningFactory)
+
+ virtual std::string name() const;
+
+ virtual void registerObject(const std::string& key, T object);
+ virtual void deregisterObject(const std::string& key);
+ virtual bool hasObject(const std::string& key) const;
+ virtual T getObject(const std::string& key) const;
+ virtual T cloneObject(const std::string& key) const;
+ virtual std::vector available() const;
+
+ };
+}
+
+#endif /* FL_CLONINGFACTORY_H */
+
diff --git a/dep/fl/factory/ConstructionFactory.h b/dep/fl/factory/ConstructionFactory.h
new file mode 100644
index 0000000..d01ca7d
--- /dev/null
+++ b/dep/fl/factory/ConstructionFactory.h
@@ -0,0 +1,64 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FACTORY_H
+#define FL_FACTORY_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+#include
+
+namespace fl {
+
+ template
+ class FL_API ConstructionFactory {
+ public:
+ typedef T(*Constructor)();
+
+ protected:
+ std::string _name;
+ std::map _constructors;
+
+ public:
+ explicit ConstructionFactory(const std::string& name);
+ virtual ~ConstructionFactory();
+ FL_DEFAULT_COPY_AND_MOVE(ConstructionFactory)
+
+ virtual std::string name() const;
+
+ virtual void registerConstructor(const std::string& key, Constructor constructor);
+ virtual void deregisterConstructor(const std::string& key);
+ virtual bool hasConstructor(const std::string& key) const;
+ virtual Constructor getConstructor(const std::string& key) const;
+ virtual T constructObject(const std::string& key) const;
+ virtual std::vector available() const;
+
+ };
+
+}
+
+#endif /* FL_FACTORY_H */
+
diff --git a/dep/fl/factory/DefuzzifierFactory.h b/dep/fl/factory/DefuzzifierFactory.h
new file mode 100644
index 0000000..32d3ee7
--- /dev/null
+++ b/dep/fl/factory/DefuzzifierFactory.h
@@ -0,0 +1,51 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_DEFUZZIFIERFACTORY_H
+#define FL_DEFUZZIFIERFACTORY_H
+
+#include "fl/factory/ConstructionFactory.h"
+
+#include "fl/defuzzifier/Defuzzifier.h"
+#include "fl/defuzzifier/IntegralDefuzzifier.h"
+#include "fl/defuzzifier/WeightedDefuzzifier.h"
+
+namespace fl {
+
+ class FL_API DefuzzifierFactory : public ConstructionFactory {
+ public:
+ DefuzzifierFactory();
+ virtual ~DefuzzifierFactory() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(DefuzzifierFactory)
+
+ virtual Defuzzifier* constructDefuzzifier(const std::string& key,
+ int resolution, WeightedDefuzzifier::Type) const;
+
+ virtual Defuzzifier* constructDefuzzifier(const std::string& key, int resolution) const;
+
+ virtual Defuzzifier* constructDefuzzifier(const std::string& key, WeightedDefuzzifier::Type type);
+ };
+}
+#endif /* DEFUZZIFIERFACTORY_H */
+
diff --git a/dep/fl/factory/FactoryManager.h b/dep/fl/factory/FactoryManager.h
new file mode 100644
index 0000000..d853d93
--- /dev/null
+++ b/dep/fl/factory/FactoryManager.h
@@ -0,0 +1,81 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FACTORYMANAGER_H
+#define FL_FACTORYMANAGER_H
+
+#include "fl/fuzzylite.h"
+
+namespace fl {
+ class TNormFactory;
+ class SNormFactory;
+ class DefuzzifierFactory;
+ class TermFactory;
+ class HedgeFactory;
+ class FunctionFactory;
+
+ class FL_API FactoryManager {
+ protected:
+ static FactoryManager _instance;
+
+ FL_unique_ptr _tnorm;
+ FL_unique_ptr _snorm;
+ FL_unique_ptr _defuzzifier;
+ FL_unique_ptr _term;
+ FL_unique_ptr _hedge;
+ FL_unique_ptr _function;
+
+ FactoryManager();
+ FactoryManager(TNormFactory* tnorm, SNormFactory* snorm,
+ DefuzzifierFactory* defuzzifier, TermFactory* term,
+ HedgeFactory* hedge, FunctionFactory* function);
+ FactoryManager(const FactoryManager& other);
+ FactoryManager& operator=(const FactoryManager& other);
+ FL_DEFAULT_MOVE(FactoryManager)
+ virtual ~FactoryManager();
+
+ public:
+ static FactoryManager* instance();
+
+ virtual void setTnorm(TNormFactory* tnorm);
+ virtual TNormFactory* tnorm() const;
+
+ virtual void setSnorm(SNormFactory* snorm);
+ virtual SNormFactory* snorm() const;
+
+ virtual void setDefuzzifier(DefuzzifierFactory* defuzzifier);
+ virtual DefuzzifierFactory* defuzzifier() const;
+
+ virtual void setTerm(TermFactory* term);
+ virtual TermFactory* term() const;
+
+ virtual void setHedge(HedgeFactory* hedge);
+ virtual HedgeFactory* hedge() const;
+
+ virtual void setFunction(FunctionFactory* function);
+ virtual FunctionFactory* function() const;
+ };
+}
+#endif /* FL_FACTORYMANAGER_H */
+
diff --git a/dep/fl/factory/FunctionFactory.h b/dep/fl/factory/FunctionFactory.h
new file mode 100644
index 0000000..c1ea9f1
--- /dev/null
+++ b/dep/fl/factory/FunctionFactory.h
@@ -0,0 +1,51 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FUNCTIONFACTORY_H
+#define FL_FUNCTIONFACTORY_H
+
+#include "fl/factory/CloningFactory.h"
+
+#include "fl/term/Function.h"
+
+namespace fl {
+
+ class FunctionFactory : public CloningFactory {
+ private:
+ void registerOperators();
+ void registerFunctions();
+ public:
+ FunctionFactory();
+ virtual ~FunctionFactory() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FunctionFactory)
+
+ virtual std::vector availableOperators() const;
+ virtual std::vector availableFunctions() const;
+
+ };
+
+}
+
+#endif /* FL_FUNCTIONFACTORY_H */
+
diff --git a/dep/fl/factory/HedgeFactory.h b/dep/fl/factory/HedgeFactory.h
new file mode 100644
index 0000000..aca5d3a
--- /dev/null
+++ b/dep/fl/factory/HedgeFactory.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_HEDGEFACTORY_H
+#define FL_HEDGEFACTORY_H
+
+#include "fl/factory/ConstructionFactory.h"
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+
+ class FL_API HedgeFactory : public ConstructionFactory {
+ public:
+ HedgeFactory();
+ virtual ~HedgeFactory() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(HedgeFactory)
+ };
+}
+#endif /* FL_HEDGEFACTORY_H */
+
diff --git a/dep/fl/factory/SNormFactory.h b/dep/fl/factory/SNormFactory.h
new file mode 100644
index 0000000..ca8bf1a
--- /dev/null
+++ b/dep/fl/factory/SNormFactory.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SNORMFACTORY_H
+#define FL_SNORMFACTORY_H
+
+#include "fl/factory/ConstructionFactory.h"
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API SNormFactory : public ConstructionFactory {
+ public:
+ SNormFactory();
+ virtual ~SNormFactory() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(SNormFactory)
+ };
+}
+#endif /* FL_SNORMFACTORY_H */
+
diff --git a/dep/fl/factory/TNormFactory.h b/dep/fl/factory/TNormFactory.h
new file mode 100644
index 0000000..6af2249
--- /dev/null
+++ b/dep/fl/factory/TNormFactory.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_TNORMFACTORY_H
+#define FL_TNORMFACTORY_H
+
+#include "fl/factory/ConstructionFactory.h"
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API TNormFactory : public ConstructionFactory {
+ public:
+ TNormFactory();
+ virtual ~TNormFactory() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(TNormFactory)
+ };
+}
+#endif /* FL_TNORMFACTORY_H */
+
diff --git a/dep/fl/factory/TermFactory.h b/dep/fl/factory/TermFactory.h
new file mode 100644
index 0000000..6fd0656
--- /dev/null
+++ b/dep/fl/factory/TermFactory.h
@@ -0,0 +1,43 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_TERMFACTORY_H
+#define FL_TERMFACTORY_H
+
+
+#include "fl/factory/ConstructionFactory.h"
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API TermFactory : public ConstructionFactory {
+ public:
+ TermFactory();
+ virtual ~TermFactory() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(TermFactory)
+ };
+}
+#endif /* FL_TERMFACTORY_H */
+
diff --git a/dep/fl/fuzzylite.h b/dep/fl/fuzzylite.h
new file mode 100644
index 0000000..18c8dfa
--- /dev/null
+++ b/dep/fl/fuzzylite.h
@@ -0,0 +1,222 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FUZZYLITE_H
+#define FL_FUZZYLITE_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifndef FL_VERSION
+#define FL_VERSION "?"
+#endif
+
+#ifndef FL_DATE
+#define FL_DATE "?"
+#endif
+
+#ifndef FL_BUILD_PATH
+#define FL_BUILD_PATH ""
+#endif
+
+#if defined(_WIN32) || defined(WIN32)
+#define FL_WINDOWS
+#endif
+
+#if defined(unix) || defined(__unix__) || defined(__unix)
+#define FL_UNIX
+#endif
+
+#ifdef __APPLE__
+#define FL_APPLE
+#endif
+
+#define FL__FILE__ std::string(__FILE__).substr(std::string(FL_BUILD_PATH).size())
+
+#define FL_LOG_PREFIX FL__FILE__ << " [" << __LINE__ << "]:"
+
+#define FL_AT FL__FILE__, __LINE__, __FUNCTION__
+
+
+#define FL_LOG(message) {if (fl::fuzzylite::logging()){std::cout << FL_LOG_PREFIX << message << std::endl;}}
+#define FL_LOGP(message) {if (fl::fuzzylite::logging()){std::cout << message << std::endl;}}
+
+#define FL_DEBUG_BEGIN if (fl::fuzzylite::debug()){
+#define FL_DEBUG_END }
+
+#define FL_DBG(message) FL_DEBUG_BEGIN\
+ std::cout << FL__FILE__ << "::" << __FUNCTION__ << "[" << __LINE__ << "]:" \
+ << message << std::endl;\
+ FL_DEBUG_END
+
+
+#ifdef FL_WINDOWS
+#include //alternative operator spellings:
+//#define and &&
+//#define or ||
+//#define not !
+//#define bitand &
+//#define bitor |
+
+//TODO: Address warning 4251 by exporting members?
+//http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html
+#ifdef _MSC_VER
+#pragma warning (disable:4251)
+#endif
+
+//fuzzylite as a shared library is exported
+//Applications linking with fuzzylite as a shared library need to import
+
+//fuzzylite as a static library does not export or import
+//Applications linking with fuzzylite as a static library do not import
+
+#if defined(FL_EXPORT_LIBRARY)
+#define FL_API __declspec(dllexport)
+#elif defined(FL_IMPORT_LIBRARY)
+#define FL_API __declspec(dllimport)
+#else
+#define FL_API
+#endif
+
+#else
+#define FL_API
+#endif
+
+
+namespace fl {
+#ifdef FL_USE_FLOAT
+ typedef float scalar;
+#else
+ typedef double scalar;
+#endif
+
+ const scalar nan = std::numeric_limits::quiet_NaN();
+ const scalar inf = std::numeric_limits::infinity();
+
+#ifdef FL_CPP11
+ //C++11 defines
+
+ //Pointers
+ const std::nullptr_t null = nullptr;
+#define FL_unique_ptr std::unique_ptr
+#define FL_move_ptr(x) std::move(x)
+
+ //Identifiers
+#define FL_IOVERRIDE override
+#define FL_IFINAL final
+#define FL_IDEFAULT = default
+#define FL_IDELETE = delete
+#define FL_INOEXCEPT noexcept
+
+ //Constructors
+#define FL_DEFAULT_COPY(Class) \
+ Class(const Class&) = default; \
+ Class& operator=(const Class&) = default;
+#define FL_DEFAULT_MOVE(Class) \
+ Class(Class&&) = default; \
+ Class& operator=(Class&&) = default;
+#define FL_DEFAULT_COPY_AND_MOVE(Class) \
+ Class(const Class&) = default; \
+ Class& operator=(const Class&) = default;\
+ Class(Class&&) = default; \
+ Class& operator=(Class&&) = default;
+
+#define FL_DISABLE_COPY(Class) \
+ Class(const Class &) = delete;\
+ Class &operator=(const Class &) = delete;
+
+#else
+ //C++98 defines
+
+ //Pointers
+ const long null = 0L;
+#define FL_unique_ptr std::auto_ptr
+#define FL_move_ptr(x) x
+
+ //Identifiers
+#define FL_IOVERRIDE
+#define FL_IFINAL
+#define FL_IDEFAULT
+#define FL_IDELETE
+#define FL_INOEXCEPT throw()
+
+ //Constructors
+#define FL_DEFAULT_COPY(Class)
+#define FL_DEFAULT_MOVE(Class)
+#define FL_DEFAULT_COPY_AND_MOVE(Class)
+
+#define FL_DISABLE_COPY(Class) \
+ Class(const Class &);\
+ Class &operator=(const Class &);
+
+#endif
+}
+
+
+namespace fl {
+
+ class FL_API fuzzylite {
+ protected:
+ static int _decimals;
+ static scalar _macheps;
+ static bool _debug;
+ static bool _logging;
+
+ public:
+ static std::string name();
+ static std::string fullname();
+ static std::string version();
+ static std::string longVersion();
+ static std::string license();
+ static std::string author();
+ static std::string company();
+ static std::string website();
+
+ static std::string date();
+ static std::string platform();
+
+ static std::string floatingPoint();
+
+ static bool debug();
+ static void setDebug(bool debug);
+
+ static int decimals();
+ static void setDecimals(int decimals);
+
+ static scalar macheps();
+ static void setMachEps(scalar macheps);
+
+ static bool logging();
+ static void setLogging(bool logging);
+
+ };
+}
+
+
+#endif /* FL_FUZZYLITE_H */
+
diff --git a/dep/fl/hedge/Any.h b/dep/fl/hedge/Any.h
new file mode 100644
index 0000000..c30b4c7
--- /dev/null
+++ b/dep/fl/hedge/Any.h
@@ -0,0 +1,47 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ANY_H
+#define FL_ANY_H
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+ //Only this hedge has virtual methods due to its special case use.
+
+ class FL_API Any : public Hedge {
+ public:
+ Any();
+ virtual ~Any() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Any)
+
+ virtual std::string name() const FL_IOVERRIDE;
+ virtual scalar hedge(scalar x) const FL_IOVERRIDE;
+ virtual Any* clone() const FL_IOVERRIDE;
+
+ static Hedge* constructor();
+ };
+
+}
+#endif /* FL_ANY_H */
diff --git a/dep/fl/hedge/Extremely.h b/dep/fl/hedge/Extremely.h
new file mode 100644
index 0000000..7ecda66
--- /dev/null
+++ b/dep/fl/hedge/Extremely.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_EXTREMELY_H
+#define FL_EXTREMELY_H
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+
+ class FL_API Extremely : public Hedge {
+ public:
+ std::string name() const;
+ scalar hedge(scalar x) const;
+ Extremely* clone() const;
+
+ static Hedge* constructor();
+ };
+
+}
+#endif /* FL_EXTREMELY_H */
diff --git a/dep/fl/hedge/Hedge.h b/dep/fl/hedge/Hedge.h
new file mode 100644
index 0000000..011c745
--- /dev/null
+++ b/dep/fl/hedge/Hedge.h
@@ -0,0 +1,51 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_HEDGE_H
+#define FL_HEDGE_H
+
+#include "fl/fuzzylite.h"
+
+#include
+
+namespace fl {
+
+ class FL_API Hedge {
+ public:
+
+ Hedge() {
+ }
+
+ virtual ~Hedge() {
+ }
+ FL_DEFAULT_COPY_AND_MOVE(Hedge)
+
+ virtual std::string name() const = 0;
+ virtual scalar hedge(scalar x) const = 0;
+ virtual Hedge* clone() const = 0;
+
+ };
+}
+
+#endif /* FL_HEDGE_H */
diff --git a/dep/fl/hedge/Not.h b/dep/fl/hedge/Not.h
new file mode 100644
index 0000000..161fefd
--- /dev/null
+++ b/dep/fl/hedge/Not.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_NOT_H
+#define FL_NOT_H
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+
+ class FL_API Not : public Hedge {
+ public:
+ std::string name() const FL_IOVERRIDE;
+ scalar hedge(scalar x) const FL_IOVERRIDE;
+ Not* clone() const FL_IOVERRIDE;
+
+ static Hedge* constructor();
+ };
+
+}
+#endif /* FL_NOT_H */
diff --git a/dep/fl/hedge/Seldom.h b/dep/fl/hedge/Seldom.h
new file mode 100644
index 0000000..a2a96c2
--- /dev/null
+++ b/dep/fl/hedge/Seldom.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SELDOM_H
+#define FL_SELDOM_H
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+
+ class FL_API Seldom : public Hedge {
+ public:
+ std::string name() const FL_IOVERRIDE;
+ scalar hedge(scalar x) const FL_IOVERRIDE;
+ Seldom* clone() const FL_IOVERRIDE;
+
+ static Hedge* constructor();
+ };
+
+}
+#endif /* FL_SELDOM_H */
diff --git a/dep/fl/hedge/Somewhat.h b/dep/fl/hedge/Somewhat.h
new file mode 100644
index 0000000..89a14a6
--- /dev/null
+++ b/dep/fl/hedge/Somewhat.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SOMEWHAT_H
+#define FL_SOMEWHAT_H
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+
+ class FL_API Somewhat : public Hedge {
+ public:
+ std::string name() const FL_IOVERRIDE;
+ scalar hedge(scalar x) const FL_IOVERRIDE;
+ Somewhat* clone() const FL_IOVERRIDE;
+
+ static Hedge* constructor();
+ };
+
+}
+#endif /* FL_SOMEWHAT_H */
diff --git a/dep/fl/hedge/Very.h b/dep/fl/hedge/Very.h
new file mode 100644
index 0000000..bcfe5e4
--- /dev/null
+++ b/dep/fl/hedge/Very.h
@@ -0,0 +1,42 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_VERY_H
+#define FL_VERY_H
+
+#include "fl/hedge/Hedge.h"
+
+namespace fl {
+
+ class FL_API Very : public Hedge {
+ public:
+ std::string name() const FL_IOVERRIDE;
+ scalar hedge(scalar x) const FL_IOVERRIDE;
+ Very* clone() const FL_IOVERRIDE;
+
+ static Hedge* constructor();
+ };
+
+}
+#endif /* FL_VERY_H */
diff --git a/dep/fl/imex/CppExporter.h b/dep/fl/imex/CppExporter.h
new file mode 100644
index 0000000..e53cf15
--- /dev/null
+++ b/dep/fl/imex/CppExporter.h
@@ -0,0 +1,70 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CPPEXPORTER_H
+#define FL_CPPEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+
+namespace fl {
+ class Engine;
+ class InputVariable;
+ class OutputVariable;
+ class Term;
+ class RuleBlock;
+ class Norm;
+ class Defuzzifier;
+ class Hedge;
+
+ class FL_API CppExporter : public Exporter {
+ protected:
+ bool _prefixNamespace;
+ virtual std::string fl(const std::string& clazz) const;
+ public:
+ explicit CppExporter(bool prefixNamespace = false);
+ 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;
+
+ virtual std::string toString(const InputVariable* inputVariable, const Engine* engine) const;
+ virtual std::string toString(const OutputVariable* outputVariable, const Engine* engine) const;
+ virtual std::string toString(const RuleBlock* ruleBlock, const Engine* engine) const;
+ virtual std::string toString(scalar value) const;
+
+ virtual std::string toString(const Hedge* hedge) const;
+ virtual std::string toString(const Term* term) const;
+ virtual std::string toString(const Norm* op) const;
+ virtual std::string toString(const Defuzzifier* defuzzifier) const;
+
+ virtual CppExporter* clone() const FL_IOVERRIDE;
+
+ };
+}
+#endif /* FL_CPPEXPORTER_H */
+
diff --git a/dep/fl/imex/Exporter.h b/dep/fl/imex/Exporter.h
new file mode 100644
index 0000000..8b55c21
--- /dev/null
+++ b/dep/fl/imex/Exporter.h
@@ -0,0 +1,52 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_EXPORTER_H
+#define FL_EXPORTER_H
+
+#include "fl/fuzzylite.h"
+
+#include
+
+namespace fl {
+ class Engine;
+
+ class FL_API Exporter {
+ public:
+
+ Exporter();
+ virtual ~Exporter();
+ FL_DEFAULT_COPY_AND_MOVE(Exporter)
+
+ virtual std::string toString(const Engine* engine) const = 0;
+ virtual void toFile(const std::string& path, const Engine* engine) const;
+
+ virtual std::string name() const = 0;
+ virtual Exporter* clone() const = 0;
+ };
+
+}
+
+#endif /* FL_EXPORTER_H */
+
diff --git a/dep/fl/imex/FclExporter.h b/dep/fl/imex/FclExporter.h
new file mode 100644
index 0000000..9bfa3ed
--- /dev/null
+++ b/dep/fl/imex/FclExporter.h
@@ -0,0 +1,70 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FCLEXPORTER_H
+#define FL_FCLEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+
+namespace fl {
+ class InputVariable;
+ class OutputVariable;
+ class RuleBlock;
+ class Norm;
+ class TNorm;
+ class SNorm;
+ class Defuzzifier;
+ class Term;
+
+ class FL_API FclExporter : public Exporter {
+ protected:
+ std::string _indent;
+
+ public:
+ explicit FclExporter(const std::string& indent = " ");
+ virtual ~FclExporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FclExporter)
+
+ virtual void setIndent(const std::string& indent);
+ virtual std::string getIndent() const;
+
+ virtual std::string name() const FL_IOVERRIDE;
+ virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
+
+ virtual std::string toString(const InputVariable* variable) const;
+ virtual std::string toString(const OutputVariable* variable) const;
+ virtual std::string toString(const RuleBlock* ruleBlock) const;
+
+ 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
+ virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ virtual std::string toString(const Term* term) const;
+
+ virtual FclExporter* clone() const FL_IOVERRIDE;
+ };
+
+}
+#endif /* FL_FCLEXPORTER_H */
diff --git a/dep/fl/imex/FclImporter.h b/dep/fl/imex/FclImporter.h
new file mode 100644
index 0000000..b219717
--- /dev/null
+++ b/dep/fl/imex/FclImporter.h
@@ -0,0 +1,74 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FCLIMPORTER_H
+#define FL_FCLIMPORTER_H
+
+#include "fl/imex/Importer.h"
+
+#include
+#include
+#include
+
+
+namespace fl {
+ class Norm;
+ class TNorm;
+ class SNorm;
+ class Term;
+ class Defuzzifier;
+
+ class FL_API FclImporter : public Importer {
+ public:
+ FclImporter();
+ virtual ~FclImporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FclImporter)
+
+ virtual std::string name() const FL_IOVERRIDE;
+
+ virtual Engine* fromString(const std::string& fcl) const FL_IOVERRIDE;
+
+ virtual FclImporter* clone() const FL_IOVERRIDE;
+
+ protected:
+ virtual void processBlock(const std::string& tag, const std::string& block, Engine* engine) const;
+ virtual void processVar(const std::string& var, const std::string& block, Engine* engine)const;
+ virtual void processFuzzify(const std::string& block, Engine* engine)const;
+ virtual void processDefuzzify(const std::string& block, Engine* engine)const;
+ virtual void processRuleBlock(const std::string& block, Engine* engine)const;
+
+ virtual TNorm* parseTNorm(const std::string& line) const;
+ virtual SNorm* parseSNorm(const std::string& line) const;
+ virtual Term* parseTerm(const std::string& line, const Engine* engine) const;
+
+ virtual Defuzzifier* parseDefuzzifier(const std::string& line) const;
+ virtual std::pair parseDefaultValue(const std::string& line) const;
+ virtual std::pair parseRange(const std::string& line) const;
+ virtual std::pair parseLocks(const std::string& line) const;
+ virtual bool parseEnabled(const std::string& line) const;
+
+ };
+
+}
+#endif /* FL_FCLIMPORTER_H */
diff --git a/dep/fl/imex/FisExporter.h b/dep/fl/imex/FisExporter.h
new file mode 100644
index 0000000..05d6a22
--- /dev/null
+++ b/dep/fl/imex/FisExporter.h
@@ -0,0 +1,74 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FISEXPORTER_H
+#define FL_FISEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+
+#include
+
+namespace fl {
+ class Norm;
+ class TNorm;
+ class SNorm;
+ class Defuzzifier;
+ class Term;
+ class Rule;
+ class Proposition;
+ class Variable;
+
+ class FL_API FisExporter : public Exporter {
+ protected:
+
+ virtual std::string translate(const std::vector& propositions,
+ const std::vector variables) const;
+
+ public:
+ FisExporter();
+ virtual ~FisExporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FisExporter)
+
+ 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
+ virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ virtual std::string toString(const Term* term) const;
+
+ virtual std::string exportSystem(const Engine* engine) const;
+ virtual std::string exportInputs(const Engine* engine) const;
+ virtual std::string exportOutputs(const Engine* engine) const;
+ virtual std::string exportRules(const Engine* engine) const;
+ virtual std::string exportRule(const Rule* rule, const Engine* engine) const;
+
+ virtual FisExporter* clone() const FL_IOVERRIDE;
+ };
+
+}
+
+#endif /* FL_FISEXPORTER_H */
+
diff --git a/dep/fl/imex/FisImporter.h b/dep/fl/imex/FisImporter.h
new file mode 100644
index 0000000..b631a48
--- /dev/null
+++ b/dep/fl/imex/FisImporter.h
@@ -0,0 +1,79 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FISIMPORTER_H
+#define FL_FISIMPORTER_H
+
+#include "fl/imex/Importer.h"
+
+#include
+#include
+
+
+namespace fl {
+ class Norm;
+ class TNorm;
+ class SNorm;
+ class Term;
+ class Defuzzifier;
+ class Variable;
+
+ class FL_API FisImporter : public Importer {
+ public:
+ FisImporter();
+ virtual ~FisImporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FisImporter)
+
+ virtual std::string name() const FL_IOVERRIDE;
+
+ virtual Engine* fromString(const std::string& fcl) const FL_IOVERRIDE;
+
+ virtual FisImporter* clone() const FL_IOVERRIDE;
+
+ protected:
+ virtual void importSystem(const std::string& section, Engine* engine,
+ std::string& andMethod, std::string& orMethod,
+ std::string& impMethod, std::string& aggMethod,
+ std::string& defuzzMethod) const;
+ virtual void importInput(const std::string& section, Engine* engine) const;
+ 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 Term* parseTerm(const std::string& line, const Engine* engine) const;
+ virtual Term* createInstance(const std::string& termClass, const std::string& name,
+ const std::vector& params, const Engine* engine) const;
+ //TODO: rename to parseRange in v6.0
+ virtual std::pair range(const std::string& range) const;
+
+ };
+
+}
+#endif /* FL_FISIMPORTER_H */
+
diff --git a/dep/fl/imex/FldExporter.h b/dep/fl/imex/FldExporter.h
new file mode 100644
index 0000000..71679a6
--- /dev/null
+++ b/dep/fl/imex/FldExporter.h
@@ -0,0 +1,84 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FLDEXPORTER_H
+#define FL_FLDEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+
+#include
+
+namespace fl {
+ class Engine;
+ class InputVariable;
+ class OutputVariable;
+
+ class FL_API FldExporter : public Exporter {
+ protected:
+ std::string _separator;
+ bool _exportHeaders;
+ bool _exportInputValues;
+ bool _exportOutputValues;
+ public:
+ explicit FldExporter(const std::string& separator = " ");
+ virtual ~FldExporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FldExporter)
+
+ virtual std::string name() const FL_IOVERRIDE;
+
+ virtual void setSeparator(const std::string& separator);
+ virtual std::string getSeparator() const;
+
+ virtual void setExportHeader(bool exportHeaders);
+ virtual bool exportsHeader() const;
+
+ virtual void setExportInputValues(bool exportInputValues);
+ virtual bool exportsInputValues() const;
+
+ virtual void setExportOutputValues(bool exportOutputValues);
+ virtual bool exportsOutputValues() const;
+
+ virtual std::string header(const Engine* engine) const;
+
+ //WARNING: The engine will be const_casted in order to be processed!
+ 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;
+
+ 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 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& inputValues) const;
+
+ virtual FldExporter* clone() const FL_IOVERRIDE;
+ };
+}
+
+#endif /* FL_FLDEXPORTER_H */
+
diff --git a/dep/fl/imex/FllExporter.h b/dep/fl/imex/FllExporter.h
new file mode 100644
index 0000000..e6a89f5
--- /dev/null
+++ b/dep/fl/imex/FllExporter.h
@@ -0,0 +1,83 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FLLEXPORTER_H
+#define FL_FLLEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+
+#include
+
+namespace fl {
+ class Variable;
+ class InputVariable;
+ class OutputVariable;
+ class RuleBlock;
+ class Rule;
+ class Norm;
+ class Defuzzifier;
+ class Term;
+
+ class FL_API FllExporter : public Exporter {
+ protected:
+ std::string _indent;
+ std::string _separator;
+ public:
+ explicit FllExporter(const std::string& indent = " ", const std::string& separator = "\n");
+ virtual ~FllExporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FllExporter)
+
+ virtual std::string name() const FL_IOVERRIDE;
+
+ virtual void setIndent(const std::string& indent);
+ virtual std::string getIndent() const;
+
+ virtual void setSeparator(const std::string& separator);
+ virtual std::string getSeparator() const;
+
+ virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
+
+ virtual std::string toString(const std::vector& variables) const;
+ virtual std::string toString(const std::vector& inputVariables) const;
+ virtual std::string toString(const std::vector& outputVariables) const;
+ virtual std::string toString(const std::vector& ruleBlocks) const;
+
+ virtual std::string toString(const Variable* variable) const;
+ virtual std::string toString(const InputVariable* inputVariable) const;
+ virtual std::string toString(const OutputVariable* outputVariable) const;
+
+ virtual std::string toString(const RuleBlock* ruleBlock) const;
+ virtual std::string toString(const Rule* rule) const;
+
+ virtual std::string toString(const Norm* norm) const;
+ virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ virtual std::string toString(const Term* term) const;
+
+ virtual FllExporter* clone() const FL_IOVERRIDE;
+ };
+
+}
+
+#endif /* FL_FLLEXPORTER_H */
+
diff --git a/dep/fl/imex/FllImporter.h b/dep/fl/imex/FllImporter.h
new file mode 100644
index 0000000..5be41c7
--- /dev/null
+++ b/dep/fl/imex/FllImporter.h
@@ -0,0 +1,77 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FLLIMPORTER_H
+#define FL_FLLIMPORTER_H
+
+#include "fl/imex/Importer.h"
+
+#include
+
+namespace fl {
+ class TNorm;
+ class SNorm;
+ class Term;
+ class Defuzzifier;
+
+ class FL_API FllImporter : public Importer {
+ protected:
+ std::string _separator;
+ public:
+ explicit FllImporter(const std::string& separator = "\n");
+ virtual ~FllImporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(FllImporter)
+
+ virtual void setSeparator(const std::string& separator);
+ virtual std::string getSeparator() const;
+
+ virtual std::string name() const FL_IOVERRIDE;
+ virtual Engine* fromString(const std::string& fll) const FL_IOVERRIDE;
+
+ 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;
+ virtual void processRuleBlock(const std::string& block, Engine* engine) const;
+
+ virtual TNorm* parseTNorm(const std::string& name) const;
+ virtual SNorm* parseSNorm(const std::string& name) const;
+
+ virtual Term* parseTerm(const std::string& text, Engine* engine) const;
+
+ virtual Defuzzifier* parseDefuzzifier(const std::string& line) const;
+ virtual std::pair parseRange(const std::string& line) const;
+ virtual bool parseBoolean(const std::string& boolean) const;
+
+ virtual std::pair parseKeyValue(const std::string& text,
+ char separator = ':') const;
+ virtual std::string clean(const std::string& line) const;
+
+ };
+}
+
+#endif /* FL_FLLIMPORTER_H */
+
diff --git a/dep/fl/imex/Importer.h b/dep/fl/imex/Importer.h
new file mode 100644
index 0000000..28d2b36
--- /dev/null
+++ b/dep/fl/imex/Importer.h
@@ -0,0 +1,52 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_IMPORTER_H
+#define FL_IMPORTER_H
+
+#include "fl/fuzzylite.h"
+
+#include
+
+namespace fl {
+ class Engine;
+
+ class FL_API Importer {
+ public:
+
+ Importer();
+ virtual ~Importer();
+ FL_DEFAULT_COPY_AND_MOVE(Importer)
+
+ virtual Engine* fromString(const std::string& s) const = 0;
+ virtual Engine* fromFile(const std::string& path) const;
+
+ virtual std::string name() const = 0;
+ virtual Importer* clone() const = 0;
+ };
+
+}
+
+#endif /* IMPORTER_H */
+
diff --git a/dep/fl/imex/JavaExporter.h b/dep/fl/imex/JavaExporter.h
new file mode 100644
index 0000000..e882d4a
--- /dev/null
+++ b/dep/fl/imex/JavaExporter.h
@@ -0,0 +1,68 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_JAVAEXPORTER_H
+#define FL_JAVAEXPORTER_H
+
+#include "fl/imex/Exporter.h"
+
+namespace fl {
+
+ class Engine;
+ class InputVariable;
+ class OutputVariable;
+ class RuleBlock;
+ class Term;
+ class Defuzzifier;
+ class Norm;
+ class SNorm;
+ class TNorm;
+
+ class FL_API JavaExporter : public Exporter {
+ public:
+ JavaExporter();
+ virtual ~JavaExporter() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(JavaExporter)
+
+ virtual std::string name() const FL_IOVERRIDE;
+
+ virtual std::string toString(const Engine* engine) const FL_IOVERRIDE;
+ virtual std::string toString(const InputVariable* inputVariable, const Engine* engine) const;
+ virtual std::string toString(const OutputVariable* outputVariable, const Engine* engine) const;
+ virtual std::string toString(const RuleBlock* ruleBlock, const Engine* engine) const;
+ virtual std::string toString(const Term* term) const;
+ virtual std::string toString(const Defuzzifier* defuzzifier) const;
+ 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
+ virtual std::string toString(scalar value) const;
+
+ virtual JavaExporter* clone() const FL_IOVERRIDE;
+
+ };
+
+}
+
+#endif /* FL_JAVAEXPORTER_H */
+
diff --git a/dep/fl/norm/Norm.h b/dep/fl/norm/Norm.h
new file mode 100644
index 0000000..5f1b578
--- /dev/null
+++ b/dep/fl/norm/Norm.h
@@ -0,0 +1,55 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_NORM_H
+#define FL_NORM_H
+
+#include "fl/fuzzylite.h"
+
+#include "fl/Operation.h"
+
+#include
+
+namespace fl {
+
+ class FL_API Norm {
+ public:
+
+ Norm() {
+ }
+
+ virtual ~Norm() {
+ }
+
+ FL_DEFAULT_COPY_AND_MOVE(Norm)
+
+ virtual std::string className() const = 0;
+ virtual scalar compute(scalar a, scalar b) const = 0;
+
+ virtual Norm* clone() const = 0;
+
+ };
+}
+#endif /* FL_NORM_H */
+
diff --git a/dep/fl/norm/SNorm.h b/dep/fl/norm/SNorm.h
new file mode 100644
index 0000000..a281f52
--- /dev/null
+++ b/dep/fl/norm/SNorm.h
@@ -0,0 +1,47 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SNORM_H
+#define FL_SNORM_H
+
+#include "fl/norm/Norm.h"
+
+namespace fl {
+
+ class FL_API SNorm : public Norm {
+ public:
+
+ SNorm() {
+ }
+
+ virtual ~SNorm() FL_IOVERRIDE {
+ }
+
+ FL_DEFAULT_COPY_AND_MOVE(SNorm)
+
+ virtual SNorm* clone() const FL_IOVERRIDE = 0;
+ };
+}
+#endif /* FL_SNORM_H */
+
diff --git a/dep/fl/norm/TNorm.h b/dep/fl/norm/TNorm.h
new file mode 100644
index 0000000..8ba8538
--- /dev/null
+++ b/dep/fl/norm/TNorm.h
@@ -0,0 +1,47 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_TNORM_H
+#define FL_TNORM_H
+
+#include "fl/norm/Norm.h"
+
+namespace fl {
+
+ class FL_API TNorm : public Norm {
+ public:
+
+ TNorm() {
+ }
+
+ virtual ~TNorm() FL_IOVERRIDE {
+ }
+
+ FL_DEFAULT_COPY_AND_MOVE(TNorm)
+
+ virtual TNorm* clone() const FL_IOVERRIDE = 0;
+ };
+}
+#endif /* TNORM_H */
+
diff --git a/dep/fl/norm/s/AlgebraicSum.h b/dep/fl/norm/s/AlgebraicSum.h
new file mode 100644
index 0000000..786bcbd
--- /dev/null
+++ b/dep/fl/norm/s/AlgebraicSum.h
@@ -0,0 +1,46 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ALGEBRAICSUM_H
+#define FL_ALGEBRAICSUM_H
+
+#include "fl/norm/SNorm.h"
+
+
+namespace fl {
+
+ class FL_API AlgebraicSum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ AlgebraicSum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+
+
+}
+
+#endif /* FL_ALGEBRAICSUM_H */
+
diff --git a/dep/fl/norm/s/BoundedSum.h b/dep/fl/norm/s/BoundedSum.h
new file mode 100644
index 0000000..5231856
--- /dev/null
+++ b/dep/fl/norm/s/BoundedSum.h
@@ -0,0 +1,43 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_BOUNDEDSUM_H
+#define FL_BOUNDEDSUM_H
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API BoundedSum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ BoundedSum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+}
+
+#endif /* FL_BOUNDEDSUM_H */
+
diff --git a/dep/fl/norm/s/DrasticSum.h b/dep/fl/norm/s/DrasticSum.h
new file mode 100644
index 0000000..65d4d4c
--- /dev/null
+++ b/dep/fl/norm/s/DrasticSum.h
@@ -0,0 +1,43 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_DRASTICSUM_H
+#define FL_DRASTICSUM_H
+
+#include "fl/norm/SNorm.h"
+namespace fl {
+
+ class FL_API DrasticSum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ DrasticSum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+
+}
+
+#endif /* FL_DRASTICSUM_H */
+
diff --git a/dep/fl/norm/s/EinsteinSum.h b/dep/fl/norm/s/EinsteinSum.h
new file mode 100644
index 0000000..8114c68
--- /dev/null
+++ b/dep/fl/norm/s/EinsteinSum.h
@@ -0,0 +1,44 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_EINSTEINSUM_H
+#define FL_EINSTEINSUM_H
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API EinsteinSum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ EinsteinSum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+
+}
+
+#endif /* FL_EINSTEINSUM_H */
+
diff --git a/dep/fl/norm/s/HamacherSum.h b/dep/fl/norm/s/HamacherSum.h
new file mode 100644
index 0000000..3daf852
--- /dev/null
+++ b/dep/fl/norm/s/HamacherSum.h
@@ -0,0 +1,44 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_HAMACHERSUM_H
+#define FL_HAMACHERSUM_H
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API HamacherSum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ HamacherSum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+
+}
+
+#endif /* FL_HAMACHERSUM_H */
+
diff --git a/dep/fl/norm/s/Maximum.h b/dep/fl/norm/s/Maximum.h
new file mode 100644
index 0000000..28a3b6d
--- /dev/null
+++ b/dep/fl/norm/s/Maximum.h
@@ -0,0 +1,45 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_MAXIMUM_H
+#define FL_MAXIMUM_H
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API Maximum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ Maximum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+
+
+}
+
+#endif /* FL_MAXIMUM_H */
+
diff --git a/dep/fl/norm/s/NilpotentMaximum.h b/dep/fl/norm/s/NilpotentMaximum.h
new file mode 100644
index 0000000..151d92d
--- /dev/null
+++ b/dep/fl/norm/s/NilpotentMaximum.h
@@ -0,0 +1,43 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_NILPOTENTMAXIMUM_H
+#define FL_NILPOTENTMAXIMUM_H
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API NilpotentMaximum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ NilpotentMaximum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+}
+
+#endif /* FL_NILPOTENTMAXIMUM_H */
+
diff --git a/dep/fl/norm/s/NormalizedSum.h b/dep/fl/norm/s/NormalizedSum.h
new file mode 100644
index 0000000..59063a6
--- /dev/null
+++ b/dep/fl/norm/s/NormalizedSum.h
@@ -0,0 +1,44 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_NORMALIZEDSUM_H
+#define FL_NORMALIZEDSUM_H
+
+#include "fl/norm/SNorm.h"
+
+namespace fl {
+
+ class FL_API NormalizedSum : public SNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ NormalizedSum* clone() const FL_IOVERRIDE;
+
+ static SNorm* constructor();
+ };
+
+}
+
+#endif /* FL_NORMALIZEDSUM_H */
+
diff --git a/dep/fl/norm/t/AlgebraicProduct.h b/dep/fl/norm/t/AlgebraicProduct.h
new file mode 100644
index 0000000..e4b0865
--- /dev/null
+++ b/dep/fl/norm/t/AlgebraicProduct.h
@@ -0,0 +1,45 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ALGEBRAICPRODUCT_H
+#define FL_ALGEBRAICPRODUCT_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API AlgebraicProduct : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ AlgebraicProduct* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+
+
+}
+
+#endif /* FL_ALGEBRAICPRODUCT_H */
+
diff --git a/dep/fl/norm/t/BoundedDifference.h b/dep/fl/norm/t/BoundedDifference.h
new file mode 100644
index 0000000..3dc9d3a
--- /dev/null
+++ b/dep/fl/norm/t/BoundedDifference.h
@@ -0,0 +1,44 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_BOUNDEDDIFFERENCE_H
+#define FL_BOUNDEDDIFFERENCE_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API BoundedDifference : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ BoundedDifference* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+
+}
+
+#endif /* FL_BOUNDEDDIFFERENCE_H */
+
diff --git a/dep/fl/norm/t/DrasticProduct.h b/dep/fl/norm/t/DrasticProduct.h
new file mode 100644
index 0000000..efd589d
--- /dev/null
+++ b/dep/fl/norm/t/DrasticProduct.h
@@ -0,0 +1,45 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_DRASTICPRODUCT_H
+#define FL_DRASTICPRODUCT_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API DrasticProduct : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ DrasticProduct* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+
+
+}
+
+#endif /* FL_DRASTICPRODUCT_H */
+
diff --git a/dep/fl/norm/t/EinsteinProduct.h b/dep/fl/norm/t/EinsteinProduct.h
new file mode 100644
index 0000000..a4c1141
--- /dev/null
+++ b/dep/fl/norm/t/EinsteinProduct.h
@@ -0,0 +1,45 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_EINSTEINPRODUCT_H
+#define FL_EINSTEINPRODUCT_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API EinsteinProduct : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ EinsteinProduct* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+
+
+}
+
+#endif /* FL_EINSTEINPRODUCT_H */
+
diff --git a/dep/fl/norm/t/HamacherProduct.h b/dep/fl/norm/t/HamacherProduct.h
new file mode 100644
index 0000000..9bc6b40
--- /dev/null
+++ b/dep/fl/norm/t/HamacherProduct.h
@@ -0,0 +1,44 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_HAMACHERPRODUCT_H
+#define FL_HAMACHERPRODUCT_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API HamacherProduct : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ HamacherProduct* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+
+}
+
+#endif /* FL_HAMACHERPRODUCT_H */
+
diff --git a/dep/fl/norm/t/Minimum.h b/dep/fl/norm/t/Minimum.h
new file mode 100644
index 0000000..3590e42
--- /dev/null
+++ b/dep/fl/norm/t/Minimum.h
@@ -0,0 +1,44 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_MINIMUM_H
+#define FL_MINIMUM_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API Minimum : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ Minimum* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+
+}
+
+#endif /* FL_MINIMUM_H */
+
diff --git a/dep/fl/norm/t/NilpotentMinimum.h b/dep/fl/norm/t/NilpotentMinimum.h
new file mode 100644
index 0000000..b3c11e0
--- /dev/null
+++ b/dep/fl/norm/t/NilpotentMinimum.h
@@ -0,0 +1,43 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_NILPOTENTMINIMUM_H
+#define FL_NILPOTENTMINIMUM_H
+
+#include "fl/norm/TNorm.h"
+
+namespace fl {
+
+ class FL_API NilpotentMinimum : public TNorm {
+ public:
+ std::string className() const FL_IOVERRIDE;
+ scalar compute(scalar a, scalar b) const FL_IOVERRIDE;
+ NilpotentMinimum* clone() const FL_IOVERRIDE;
+
+ static TNorm* constructor();
+ };
+}
+
+#endif /* FL_NILPOTENTMINIMUM_H */
+
diff --git a/dep/fl/rule/Antecedent.h b/dep/fl/rule/Antecedent.h
new file mode 100644
index 0000000..02724e5
--- /dev/null
+++ b/dep/fl/rule/Antecedent.h
@@ -0,0 +1,77 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ANTECEDENT_H
+#define FL_ANTECEDENT_H
+
+#include "fl/fuzzylite.h"
+
+#include
+
+namespace fl {
+ class Engine;
+ class Rule;
+ class TNorm;
+ class SNorm;
+ class Expression;
+
+ class FL_API Antecedent {
+ protected:
+ std::string _text;
+ Expression* _expression;
+
+ public:
+ Antecedent();
+ virtual ~Antecedent();
+
+ virtual void setText(const std::string& text);
+ virtual std::string getText() const;
+
+ virtual Expression* getExpression() const;
+
+ virtual bool isLoaded() const;
+
+ virtual void unload();
+ virtual void load(Rule* rule, const Engine* engine);
+ virtual void load(const std::string& antecedent, Rule* rule, const Engine* engine);
+
+ virtual scalar activationDegree(const TNorm* conjunction, const SNorm* disjunction,
+ const Expression* node) const;
+
+ virtual scalar activationDegree(const TNorm* conjunction, const SNorm* disjunction) const;
+
+ virtual std::string toString() const;
+
+ virtual std::string toPrefix(const Expression* node = fl::null) const;
+ virtual std::string toInfix(const Expression* node = fl::null) const;
+ virtual std::string toPostfix(const Expression* node = fl::null) const;
+
+
+ private:
+ FL_DISABLE_COPY(Antecedent)
+ };
+
+}
+
+#endif /* FL_ANTECEDENT_H */
diff --git a/dep/fl/rule/Consequent.h b/dep/fl/rule/Consequent.h
new file mode 100644
index 0000000..5394dc0
--- /dev/null
+++ b/dep/fl/rule/Consequent.h
@@ -0,0 +1,68 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CONSEQUENT_H
+#define FL_CONSEQUENT_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+
+namespace fl {
+ class Engine;
+ class Rule;
+ class Proposition;
+ class TNorm;
+
+ class FL_API Consequent {
+ protected:
+ std::string _text;
+ std::vector _conclusions;
+
+ public:
+ Consequent();
+ virtual ~Consequent();
+
+ virtual void setText(const std::string& text);
+ virtual std::string getText() const;
+
+ virtual const std::vector& conclusions() const;
+
+ virtual bool isLoaded();
+ virtual void unload();
+ virtual void load(Rule* rule, const Engine* engine);
+ virtual void load(const std::string& consequent, Rule* rule, const Engine* engine);
+
+ virtual void modify(scalar activationDegree, const TNorm* activation);
+
+ virtual std::string toString() const;
+
+ private:
+ FL_DISABLE_COPY(Consequent)
+ };
+
+}
+
+#endif /* FL_CONSEQUENT_H */
diff --git a/dep/fl/rule/Expression.h b/dep/fl/rule/Expression.h
new file mode 100644
index 0000000..cb48355
--- /dev/null
+++ b/dep/fl/rule/Expression.h
@@ -0,0 +1,84 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_EXPRESSION_H
+#define FL_EXPRESSION_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+
+
+
+namespace fl {
+ class Variable;
+ class Hedge;
+ class Term;
+
+ class FL_API Expression {
+ public:
+
+ Expression();
+ virtual ~Expression();
+
+ virtual std::string toString() const = 0;
+
+ private:
+ FL_DISABLE_COPY(Expression)
+ };
+
+ class FL_API Proposition : public Expression {
+ public:
+ Variable* variable;
+ std::vector hedges;
+ Term* term;
+
+ Proposition();
+ virtual ~Proposition() FL_IOVERRIDE;
+
+ virtual std::string toString() const FL_IOVERRIDE;
+
+ private:
+ FL_DISABLE_COPY(Proposition)
+ };
+
+ class FL_API Operator : public Expression {
+ public:
+ std::string name;
+ Expression* left;
+ Expression* right;
+
+ Operator();
+ virtual ~Operator() FL_IOVERRIDE;
+
+ virtual std::string toString() const FL_IOVERRIDE;
+
+ private:
+ FL_DISABLE_COPY(Operator)
+
+ };
+
+}
+#endif /* FL_FUZZYEXPRESSION_H */
diff --git a/dep/fl/rule/Rule.h b/dep/fl/rule/Rule.h
new file mode 100644
index 0000000..20d39fb
--- /dev/null
+++ b/dep/fl/rule/Rule.h
@@ -0,0 +1,121 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_RULE_H
+#define FL_RULE_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+
+
+namespace fl {
+ class Engine;
+ class Antecedent;
+ class Consequent;
+ class Hedge;
+ class TNorm;
+ class SNorm;
+
+ class FL_API Rule {
+ protected:
+ std::string _text;
+ scalar _weight;
+ FL_unique_ptr _antecedent;
+ FL_unique_ptr _consequent;
+ std::map _hedges;
+
+ public:
+ explicit Rule(const std::string& text = "", scalar weight = 1.0);
+ Rule(const Rule& other);
+ Rule& operator=(const Rule& other);
+ virtual ~Rule();
+ FL_DEFAULT_MOVE(Rule)
+
+ virtual void setText(const std::string& text);
+ virtual std::string getText() const;
+
+ virtual void setWeight(scalar weight);
+ virtual scalar getWeight() const;
+
+ virtual void setAntecedent(Antecedent* antecedent);
+ virtual Antecedent* getAntecedent() const;
+
+ virtual void setConsequent(Consequent* consequent);
+ virtual Consequent* getConsequent() const;
+
+ virtual void addHedge(Hedge* hedge);
+ virtual Hedge* getHedge(const std::string& name) const;
+ virtual Hedge* removeHedge(const std::string& hedge);
+ virtual bool hasHedge(const std::string& name) const;
+ virtual int numberOfHedges() const;
+ virtual void setHedges(const std::map& hedges);
+ virtual const std::map& hedges() const;
+ virtual std::map& hedges();
+
+ virtual scalar activationDegree(const TNorm* conjunction, const SNorm* disjunction) const;
+ virtual void activate(scalar degree, const TNorm* activation) const;
+
+ virtual std::string toString() const;
+
+ virtual bool isLoaded() const;
+ virtual void unload();
+ virtual void load(const Engine* engine);
+ virtual void load(const std::string& rule, const Engine* engine);
+
+ virtual Rule* clone() const;
+
+ static Rule* parse(const std::string& rule, const Engine* engine);
+
+ static std::string ifKeyword() {
+ return "if";
+ }
+
+ static std::string isKeyword() {
+ return "is";
+ }
+
+ static std::string thenKeyword() {
+ return "then";
+ }
+
+ static std::string andKeyword() {
+ return "and";
+ }
+
+ static std::string orKeyword() {
+ return "or";
+ }
+
+ static std::string withKeyword() {
+ return "with";
+ }
+
+ };
+
+}
+
+
+#endif /* FL_RULE_H */
diff --git a/dep/fl/rule/RuleBlock.h b/dep/fl/rule/RuleBlock.h
new file mode 100644
index 0000000..35fe62e
--- /dev/null
+++ b/dep/fl/rule/RuleBlock.h
@@ -0,0 +1,97 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_RULEBLOCK_H
+#define FL_RULEBLOCK_H
+
+#include "fl/fuzzylite.h"
+
+#include
+#include
+
+
+namespace fl {
+
+ class Engine;
+ class Rule;
+ class TNorm;
+ class SNorm;
+
+ class FL_API RuleBlock {
+ private:
+ void copyFrom(const RuleBlock& source);
+ protected:
+ std::string _name;
+ std::vector _rules;
+ FL_unique_ptr _conjunction;
+ FL_unique_ptr _disjunction;
+ FL_unique_ptr _activation;
+ bool _enabled;
+
+ public:
+ explicit RuleBlock(const std::string& name = "");
+ RuleBlock(const RuleBlock& other);
+ RuleBlock& operator=(const RuleBlock& other);
+ virtual ~RuleBlock();
+ FL_DEFAULT_MOVE(RuleBlock)
+
+ virtual void activate();
+
+ virtual void setName(std::string name);
+ virtual std::string getName() const;
+
+ virtual void setConjunction(TNorm* conjunction);
+ virtual TNorm* getConjunction() const;
+
+ virtual void setDisjunction(SNorm* disjunction);
+ virtual SNorm* getDisjunction() const;
+
+ virtual void setActivation(TNorm* activation);
+ virtual TNorm* getActivation() const;
+
+ virtual void setEnabled(bool enabled);
+ virtual bool isEnabled() const;
+
+ virtual void unloadRules() const;
+ virtual void loadRules(const Engine* engine);
+ virtual void reloadRules(const Engine* engine);
+
+ virtual std::string toString() const;
+
+ /**
+ * Operations for iterable datatype _rules
+ */
+ virtual void addRule(Rule* rule);
+ virtual void insertRule(Rule* rule, int index);
+ virtual Rule* getRule(int index) const;
+ virtual Rule* removeRule(int index);
+ virtual int numberOfRules() const;
+ virtual void setRules(const std::vector& rules);
+ virtual const std::vector& rules() const;
+ virtual std::vector& rules();
+
+ };
+
+}
+#endif /* RULEBLOCK_H */
diff --git a/dep/fl/term/Accumulated.h b/dep/fl/term/Accumulated.h
new file mode 100644
index 0000000..51625d0
--- /dev/null
+++ b/dep/fl/term/Accumulated.h
@@ -0,0 +1,94 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ACCUMULATED_H
+#define FL_ACCUMULATED_H
+
+#include "fl/term/Term.h"
+
+#include
+
+namespace fl {
+
+ class Activated;
+ class SNorm;
+ class TNorm;
+
+ class FL_API Accumulated : public Term {
+ private:
+ void copyFrom(const Accumulated& source);
+ protected:
+ std::vector _terms;
+ scalar _minimum, _maximum;
+ FL_unique_ptr _accumulation;
+ public:
+ explicit Accumulated(const std::string& name = "",
+ scalar minimum = fl::nan,
+ scalar maximum = fl::nan,
+ SNorm* accumulation = fl::null);
+ Accumulated(const Accumulated& other);
+ Accumulated& operator=(const Accumulated& other);
+ virtual ~Accumulated() FL_IOVERRIDE;
+ FL_DEFAULT_MOVE(Accumulated)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual Accumulated* clone() const FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+ virtual scalar activationDegree(const Term* forTerm) const;
+
+ virtual std::string toString() const FL_IOVERRIDE;
+
+
+ virtual void setMinimum(scalar minimum);
+ virtual scalar getMinimum() const;
+
+ virtual void setMaximum(scalar maximum);
+ virtual scalar getMaximum() const;
+
+ virtual void setRange(scalar minimum, scalar maximum);
+ virtual scalar range() const;
+
+ virtual void setAccumulation(SNorm* accumulation);
+ virtual SNorm* getAccumulation() const;
+
+ /**
+ * Operations for std::vector _terms
+ */
+ virtual void addTerm(const Term* term, scalar degree, const TNorm* activation);
+ virtual void addTerm(Activated* term);
+ virtual Activated* getTerm(int index) const;
+ virtual Activated* removeTerm(int index);
+ virtual int numberOfTerms() const;
+ virtual const std::vector& terms() const;
+ virtual std::vector& terms();
+ virtual bool isEmpty() const;
+ virtual void clear();
+ };
+
+}
+#endif /* FL_ACCUMULATED_H */
diff --git a/dep/fl/term/Activated.h b/dep/fl/term/Activated.h
new file mode 100644
index 0000000..10c1b40
--- /dev/null
+++ b/dep/fl/term/Activated.h
@@ -0,0 +1,65 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ACTIVATED_H
+#define FL_ACTIVATED_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+ class TNorm;
+
+ class FL_API Activated : public Term {
+ protected:
+ const Term* _term;
+ scalar _degree;
+ const TNorm* _activation;
+
+ public:
+ explicit Activated(const Term* term = fl::null, scalar degree = 1.0,
+ const TNorm* activationOperator = fl::null);
+ virtual ~Activated() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Activated)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+ virtual std::string toString() const FL_IOVERRIDE;
+
+ virtual void setTerm(const Term* term);
+ virtual const Term* getTerm() const;
+
+ virtual void setDegree(scalar degree);
+ virtual scalar getDegree() const;
+
+ virtual void setActivation(const TNorm* activation);
+ virtual const TNorm* getActivation() const;
+
+ virtual Activated* clone() const FL_IOVERRIDE;
+ };
+
+}
+#endif /* FL_ACTIVATED_H */
diff --git a/dep/fl/term/Bell.h b/dep/fl/term/Bell.h
new file mode 100644
index 0000000..115479c
--- /dev/null
+++ b/dep/fl/term/Bell.h
@@ -0,0 +1,68 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_BELL_H
+#define FL_BELL_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Bell : public Term {
+ protected:
+ scalar _center;
+ scalar _width;
+ scalar _slope;
+ public:
+ explicit Bell(const std::string& name = "",
+ scalar center = fl::nan,
+ scalar width = fl::nan,
+ scalar slope = fl::nan,
+ scalar height = 1.0);
+ virtual ~Bell() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Bell)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setCenter(scalar center);
+ virtual scalar getCenter() const;
+
+ virtual void setWidth(scalar width);
+ virtual scalar getWidth() const;
+
+ virtual void setSlope(scalar slope);
+ virtual scalar getSlope() const;
+
+ virtual Bell* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+
+ };
+
+}
+#endif /* FL_BELL_H */
diff --git a/dep/fl/term/Concave.h b/dep/fl/term/Concave.h
new file mode 100644
index 0000000..b3aabe6
--- /dev/null
+++ b/dep/fl/term/Concave.h
@@ -0,0 +1,64 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CONCAVE_H
+#define FL_CONCAVE_H
+
+#include "fl/term/Term.h"
+
+
+namespace fl {
+
+ class FL_API Concave : public Term {
+ protected:
+ scalar _inflection, _end;
+ public:
+ explicit Concave(const std::string& name = "",
+ scalar inflection = fl::nan,
+ scalar end = fl::nan,
+ scalar height = 1.0);
+ virtual ~Concave() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Concave)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setInflection(scalar inflection);
+ virtual scalar getInflection() const;
+
+ virtual void setEnd(scalar end);
+ virtual scalar getEnd() const;
+
+ virtual Concave* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+
+
+#endif /* FL_CONCAVE_H */
+
diff --git a/dep/fl/term/Constant.h b/dep/fl/term/Constant.h
new file mode 100644
index 0000000..c4ed17d
--- /dev/null
+++ b/dep/fl/term/Constant.h
@@ -0,0 +1,58 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_CONSTANT_H
+#define FL_CONSTANT_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Constant : public Term {
+ protected:
+ scalar _value;
+
+ public:
+ explicit Constant(const std::string& name = "",
+ scalar value = fl::nan);
+ virtual ~Constant() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Constant)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setValue(scalar value);
+ virtual scalar getValue() const;
+
+ virtual Constant* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+
+#endif /* FL_CONSTANT_H */
+
diff --git a/dep/fl/term/Cosine.h b/dep/fl/term/Cosine.h
new file mode 100644
index 0000000..510669f
--- /dev/null
+++ b/dep/fl/term/Cosine.h
@@ -0,0 +1,62 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_COSINE_H
+#define FL_COSINE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Cosine : public Term {
+ protected:
+ scalar _center, _width;
+ public:
+ explicit Cosine(const std::string& name = "",
+ scalar center = fl::nan,
+ scalar width = fl::nan,
+ scalar height = 1.0);
+ virtual ~Cosine() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Cosine)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setCenter(scalar center);
+ virtual scalar getCenter() const;
+
+ virtual void setWidth(scalar width);
+ virtual scalar getWidth() const;
+
+ virtual Cosine* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+
+#endif /* FL_COSINE_H */
+
diff --git a/dep/fl/term/Discrete.h b/dep/fl/term/Discrete.h
new file mode 100644
index 0000000..fc554b3
--- /dev/null
+++ b/dep/fl/term/Discrete.h
@@ -0,0 +1,81 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_DISCRETE_H
+#define FL_DISCRETE_H
+
+#include "fl/term/Term.h"
+
+#include
+#include
+
+namespace fl {
+
+ class FL_API Discrete : public Term {
+ public:
+ typedef std::pair Pair;
+ protected:
+ std::vector _xy;
+ public:
+ explicit Discrete(const std::string& name = "",
+ const std::vector& xy = std::vector(),
+ scalar height = 1.0);
+ virtual ~Discrete() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Discrete)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ //Warning: this method is unsafe. Make sure you use it correctly.
+ template
+ static Discrete* create(const std::string& name, int argc,
+ T x1, T y1, ...); // throw (fl::Exception);
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setXY(const std::vector& pairs);
+ virtual const std::vector& xy() const;
+ virtual std::vector& xy();
+ virtual const Pair& xy(int index) const;
+ virtual Pair& xy(int index);
+
+
+ static std::vector toVector(const std::vector& xy);
+ static std::vector toPairs(const std::vector& xy);
+ static std::vector toPairs(const std::vector& xy,
+ scalar missingValue) FL_INOEXCEPT;
+
+ static std::string formatXY(const std::vector& xy,
+ const std::string& prefix = "(", const std::string& innerSeparator = ",",
+ const std::string& postfix = ")", const std::string& outerSeparator = " ");
+
+ virtual Discrete* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+
+ };
+
+}
+#endif /* FL_DISCRETE_H */
diff --git a/dep/fl/term/Function.h b/dep/fl/term/Function.h
new file mode 100644
index 0000000..99580b7
--- /dev/null
+++ b/dep/fl/term/Function.h
@@ -0,0 +1,171 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_FUNCTION_H
+#define FL_FUNCTION_H
+
+#include "fl/term/Term.h"
+
+#include
+#include
+
+namespace fl {
+
+ class Engine;
+
+ class FL_API Function : public Term {
+ /****************************
+ * Parsing Elements
+ ****************************/
+
+ public:
+ typedef scalar(*Unary)(scalar);
+ typedef scalar(*Binary)(scalar, scalar);
+
+ struct FL_API Element {
+
+ enum Type {
+ OPERATOR, FUNCTION
+ };
+ std::string name;
+ std::string description;
+ Type type;
+ Unary unary;
+ Binary binary;
+ int arity;
+ int precedence; //Operator
+ int associativity;
+ Element(const std::string& name, const std::string& description, Type type);
+ Element(const std::string& name, const std::string& description,
+ Type type, Unary unary, int precedence = 0, int associativity = -1);
+ Element(const std::string& name, const std::string& description,
+ Type type, Binary binary, int precedence = 0, int associativity = -1);
+ virtual ~Element();
+ FL_DEFAULT_COPY_AND_MOVE(Element)
+
+ virtual bool isOperator() const;
+ virtual bool isFunction() const;
+
+ virtual Element* clone() const;
+
+ virtual std::string toString() const;
+
+ };
+
+ /**************************
+ * Tree elements, wrap Elements into Nodes.
+ **************************/
+
+ struct FL_API Node {
+ FL_unique_ptr element;
+ FL_unique_ptr left;
+ FL_unique_ptr right;
+ std::string variable;
+ scalar value;
+
+ explicit Node(Element* element, Node* left = fl::null, Node* right = fl::null);
+ explicit Node(const std::string& variable);
+ explicit Node(scalar value);
+ Node(const Node& source);
+ Node& operator=(const Node& rhs);
+ virtual ~Node();
+ FL_DEFAULT_MOVE(Node)
+
+ virtual scalar evaluate(const std::map*
+ variables = fl::null) const;
+
+ virtual Node* clone() const;
+
+ virtual std::string toString() const;
+ virtual std::string toPrefix(const Node* node = fl::null) const;
+ virtual std::string toInfix(const Node* node = fl::null) const;
+ virtual std::string toPostfix(const Node* node = fl::null) const;
+ private:
+ void copyFrom(const Node& source);
+ };
+
+
+
+
+ /******************************
+ * Term
+ ******************************/
+
+ protected:
+ FL_unique_ptr _root;
+ std::string _formula;
+ const Engine* _engine;
+ public:
+ mutable std::map variables;
+ explicit Function(const std::string& name = "",
+ const std::string& formula = "", const Engine* engine = fl::null);
+ Function(const Function& other);
+ Function& operator=(const Function& other);
+ virtual ~Function() FL_IOVERRIDE;
+ FL_DEFAULT_MOVE(Function)
+
+ static Function* create(const std::string& name,
+ const std::string& formula,
+ const Engine* engine = fl::null); // throw (fl::Exception);
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual scalar evaluate(const std::map* variables) const;
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual void setFormula(const std::string& formula);
+ virtual std::string getFormula() const;
+
+ virtual void setEngine(const Engine* engine);
+ virtual const Engine* getEngine() const;
+
+ virtual Node* root() const;
+
+ virtual bool isLoaded() const;
+ virtual void unload();
+ virtual void load(); // throw (fl::Exception);
+ virtual void load(const std::string& formula); // throw (fl::Exception);
+ virtual void load(const std::string& formula, const Engine* engine); // throw (fl::Exception);
+
+ virtual Node* parse(const std::string& formula); // throw (fl::Exception);
+
+ virtual std::string toPostfix(const std::string& formula) const; //throw (fl::Exception);
+
+ virtual std::string space(const std::string& formula) const;
+
+ virtual Function* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+
+ static void main();
+
+ };
+
+}
+
+#endif /* FL_FUNCTION_H */
+
diff --git a/dep/fl/term/Gaussian.h b/dep/fl/term/Gaussian.h
new file mode 100644
index 0000000..a5b8055
--- /dev/null
+++ b/dep/fl/term/Gaussian.h
@@ -0,0 +1,63 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_GAUSSIAN_H
+#define FL_GAUSSIAN_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Gaussian : public Term {
+ protected:
+ scalar _mean;
+ scalar _standardDeviation;
+
+ public:
+ explicit Gaussian(const std::string& name = "",
+ scalar mean = fl::nan,
+ scalar standardDeviation = fl::nan,
+ scalar height = 1.0);
+ virtual ~Gaussian() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Gaussian)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setMean(scalar c);
+ virtual scalar getMean() const;
+
+ virtual void setStandardDeviation(scalar sigma);
+ virtual scalar getStandardDeviation() const;
+
+ virtual Gaussian* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+
+}
+#endif /* FL_GAUSSIAN_H */
diff --git a/dep/fl/term/GaussianProduct.h b/dep/fl/term/GaussianProduct.h
new file mode 100644
index 0000000..bd1eaaa
--- /dev/null
+++ b/dep/fl/term/GaussianProduct.h
@@ -0,0 +1,73 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_GAUSSIANPRODUCT_H
+#define FL_GAUSSIANPRODUCT_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API GaussianProduct : public Term {
+ protected:
+ scalar _meanA;
+ scalar _standardDeviationA;
+ scalar _meanB;
+ scalar _standardDeviationB;
+
+ public:
+ explicit GaussianProduct(const std::string& name = "",
+ scalar meanA = fl::nan,
+ scalar standardDeviationA = fl::nan,
+ scalar meanB = fl::nan,
+ scalar standardDeviationB = fl::nan,
+ scalar height = 1.0);
+ virtual ~GaussianProduct() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(GaussianProduct)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setMeanA(scalar meanA);
+ virtual scalar getMeanA() const;
+
+ virtual void setStandardDeviationA(scalar sigmaA);
+ virtual scalar getStandardDeviationA() const;
+
+ virtual void setMeanB(scalar meanB);
+ virtual scalar getMeanB() const;
+
+ virtual void setStandardDeviationB(scalar sigmaB);
+ virtual scalar getStandardDeviationB() const;
+
+ virtual GaussianProduct* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+#endif /* FL_GAUSSIANPRODUCT_H */
+
diff --git a/dep/fl/term/Linear.h b/dep/fl/term/Linear.h
new file mode 100644
index 0000000..67ede04
--- /dev/null
+++ b/dep/fl/term/Linear.h
@@ -0,0 +1,72 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_LINEAR_H
+#define FL_LINEAR_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+ class Engine;
+
+ class FL_API Linear : public Term {
+ protected:
+ std::vector _coefficients;
+ const Engine* _engine;
+ public:
+ explicit Linear(const std::string& name = "",
+ const std::vector& coefficients = std::vector(),
+ const Engine* engine = fl::null);
+ virtual ~Linear() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Linear)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void set(const std::vector& coeffs, const Engine* engine);
+
+ virtual void setCoefficients(const std::vector& coeffs);
+ virtual const std::vector& coefficients() const;
+ virtual std::vector& coefficients();
+
+ virtual void setEngine(const Engine* engine);
+ virtual const Engine* getEngine() const;
+
+ virtual Linear* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+
+ //Warning: this method is unsafe, make sure you use it correctly.
+ template
+ static Linear* create(const std::string& name, const Engine* engine,
+ T firstCoefficient, ...); // throw (fl::Exception);
+ };
+
+}
+
+#endif /* FL_LINEAR_H */
+
diff --git a/dep/fl/term/PiShape.h b/dep/fl/term/PiShape.h
new file mode 100644
index 0000000..a0c2f78
--- /dev/null
+++ b/dep/fl/term/PiShape.h
@@ -0,0 +1,74 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_PISHAPE_H
+#define FL_PISHAPE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API PiShape : public Term {
+ protected:
+ scalar _bottomLeft;
+ scalar _topLeft;
+ scalar _topRight;
+ scalar _bottomRight;
+
+ public:
+ explicit PiShape(const std::string& name = "",
+ scalar bottomLeft = fl::nan,
+ scalar topLeft = fl::nan,
+ scalar topRight = fl::nan,
+ scalar bottomRight = fl::nan,
+ scalar height = 1.0);
+ virtual ~PiShape() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(PiShape)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setBottomLeft(scalar a);
+ virtual scalar getBottomLeft() const;
+
+ virtual void setTopLeft(scalar b);
+ virtual scalar getTopLeft() const;
+
+ virtual void setTopRight(scalar d);
+ virtual scalar getTopRight() const;
+
+ virtual void setBottomRight(scalar c);
+ virtual scalar getBottomRight() const;
+
+ virtual PiShape* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+
+#endif /* FL_PISHAPE_H */
+
diff --git a/dep/fl/term/Ramp.h b/dep/fl/term/Ramp.h
new file mode 100644
index 0000000..63a683c
--- /dev/null
+++ b/dep/fl/term/Ramp.h
@@ -0,0 +1,68 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_RAMP_H
+#define FL_RAMP_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Ramp : public Term {
+ protected:
+ scalar _start, _end;
+
+ public:
+
+ enum Direction {
+ POSITIVE, ZERO, NEGATIVE
+ };
+ explicit Ramp(const std::string& name = "",
+ scalar start = fl::nan,
+ scalar end = fl::nan,
+ scalar height = 1.0);
+ virtual ~Ramp() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Ramp)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setStart(scalar start);
+ virtual scalar getStart() const;
+
+ virtual void setEnd(scalar end);
+ virtual scalar getEnd() const;
+
+ virtual Direction direction() const;
+
+ virtual Ramp* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+#endif /* FL_RAMP_H */
+
diff --git a/dep/fl/term/Rectangle.h b/dep/fl/term/Rectangle.h
new file mode 100644
index 0000000..23b5eda
--- /dev/null
+++ b/dep/fl/term/Rectangle.h
@@ -0,0 +1,62 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_RECTANGLE_H
+#define FL_RECTANGLE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Rectangle : public Term {
+ protected:
+ scalar _start, _end;
+
+ public:
+ explicit Rectangle(const std::string& name = "",
+ scalar start = fl::nan,
+ scalar end = fl::nan,
+ scalar height = 1.0);
+ virtual ~Rectangle() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Rectangle)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setStart(scalar start);
+ virtual scalar getStart() const;
+
+ virtual void setEnd(scalar end);
+ virtual scalar getEnd() const;
+
+ virtual Rectangle* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+
+}
+#endif /* FL_RECTANGLE_H */
diff --git a/dep/fl/term/SShape.h b/dep/fl/term/SShape.h
new file mode 100644
index 0000000..0891357
--- /dev/null
+++ b/dep/fl/term/SShape.h
@@ -0,0 +1,64 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+
+#ifndef FL_SSHAPE_H
+#define FL_SSHAPE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API SShape : public Term {
+ protected:
+ scalar _start, _end;
+
+ public:
+ explicit SShape(const std::string& name = "",
+ scalar start = fl::nan,
+ scalar end = fl::nan,
+ scalar height = 1.0);
+ virtual ~SShape() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(SShape)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setStart(scalar start);
+ virtual scalar getStart() const;
+
+ virtual void setEnd(scalar end);
+ virtual scalar getEnd() const;
+
+ virtual SShape* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+
+#endif /* FL_SSHAPE_H */
+
diff --git a/dep/fl/term/Sigmoid.h b/dep/fl/term/Sigmoid.h
new file mode 100644
index 0000000..b37b1be
--- /dev/null
+++ b/dep/fl/term/Sigmoid.h
@@ -0,0 +1,68 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SIGMOID_H
+#define FL_SIGMOID_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Sigmoid : public Term {
+ protected:
+ scalar _inflection;
+ scalar _slope;
+ public:
+
+ enum Direction {
+ POSITIVE, ZERO, NEGATIVE
+ };
+ explicit Sigmoid(const std::string& name = "",
+ scalar inflection = fl::nan,
+ scalar slope = fl::nan,
+ scalar height = 1.0);
+ virtual ~Sigmoid() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Sigmoid)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setInflection(scalar inflection);
+ virtual scalar getInflection() const;
+
+ virtual void setSlope(scalar slope);
+ virtual scalar getSlope() const;
+
+ virtual Direction direction() const;
+
+ virtual Sigmoid* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+
+}
+#endif /* FL_SIGMOID_H */
diff --git a/dep/fl/term/SigmoidDifference.h b/dep/fl/term/SigmoidDifference.h
new file mode 100644
index 0000000..020f164
--- /dev/null
+++ b/dep/fl/term/SigmoidDifference.h
@@ -0,0 +1,73 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SIGMOIDDIFFERENCE_H
+#define FL_SIGMOIDDIFFERENCE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API SigmoidDifference : public Term {
+ protected:
+ scalar _left;
+ scalar _rising;
+ scalar _falling;
+ scalar _right;
+
+ public:
+ explicit SigmoidDifference(const std::string& name = "",
+ scalar left = fl::nan,
+ scalar rising = fl::nan,
+ scalar falling = fl::nan,
+ scalar right = fl::nan,
+ scalar height = 1.0);
+ virtual ~SigmoidDifference() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(SigmoidDifference)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setLeft(scalar leftInflection);
+ virtual scalar getLeft() const;
+
+ virtual void setRising(scalar risingSlope);
+ virtual scalar getRising() const;
+
+ virtual void setFalling(scalar fallingSlope);
+ virtual scalar getFalling() const;
+
+ virtual void setRight(scalar rightInflection);
+ virtual scalar getRight() const;
+
+ virtual SigmoidDifference* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+#endif /* FL_SIGMOIDDIFFERENCE_H */
+
diff --git a/dep/fl/term/SigmoidProduct.h b/dep/fl/term/SigmoidProduct.h
new file mode 100644
index 0000000..cb83f30
--- /dev/null
+++ b/dep/fl/term/SigmoidProduct.h
@@ -0,0 +1,73 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SIGMOIDPRODUCT_H
+#define FL_SIGMOIDPRODUCT_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API SigmoidProduct : public Term {
+ protected:
+ scalar _left;
+ scalar _rising;
+ scalar _falling;
+ scalar _right;
+
+ public:
+ explicit SigmoidProduct(const std::string& name = "",
+ scalar left = fl::nan,
+ scalar rising = fl::nan,
+ scalar falling = fl::nan,
+ scalar right = fl::nan,
+ scalar height = 1.0);
+ virtual ~SigmoidProduct() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(SigmoidProduct)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setLeft(scalar leftInflection);
+ virtual scalar getLeft() const;
+
+ virtual void setRising(scalar risingSlope);
+ virtual scalar getRising() const;
+
+ virtual void setFalling(scalar fallingSlope);
+ virtual scalar getFalling() const;
+
+ virtual void setRight(scalar rightInflection);
+ virtual scalar getRight() const;
+
+ virtual SigmoidProduct* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+#endif /* FL_SIGMOIDPRODUCT_H */
+
diff --git a/dep/fl/term/Spike.h b/dep/fl/term/Spike.h
new file mode 100644
index 0000000..7e520c9
--- /dev/null
+++ b/dep/fl/term/Spike.h
@@ -0,0 +1,62 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_SPIKE_H
+#define FL_SPIKE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Spike : public Term {
+ protected:
+ scalar _center, _width;
+ public:
+ explicit Spike(const std::string& name = "",
+ scalar center = fl::nan,
+ scalar width = fl::nan,
+ scalar height = 1.0);
+ virtual ~Spike() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Spike)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setCenter(scalar center);
+ virtual scalar getCenter() const;
+
+ virtual void setWidth(scalar width);
+ virtual scalar getWidth() const;
+
+ virtual Spike* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+}
+
+#endif /* FL_SPIKE_H */
+
diff --git a/dep/fl/term/Term.h b/dep/fl/term/Term.h
new file mode 100644
index 0000000..6c2b2b1
--- /dev/null
+++ b/dep/fl/term/Term.h
@@ -0,0 +1,71 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+
+#ifndef FL_TERM_H
+#define FL_TERM_H
+
+#include "fl/fuzzylite.h"
+
+#include "fl/Operation.h"
+
+#include
+#include
+#include
+
+namespace fl {
+ class Engine;
+
+ class FL_API Term {
+ protected:
+ std::string _name;
+ scalar _height;
+ public:
+
+ explicit Term(const std::string& name = "", scalar height = 1.0);
+ virtual ~Term();
+ FL_DEFAULT_COPY_AND_MOVE(Term)
+
+ virtual void setName(const std::string& name);
+ virtual std::string getName() const;
+
+ virtual void setHeight(scalar height);
+ virtual scalar getHeight() const;
+
+ virtual std::string toString() const;
+
+ virtual std::string className() const = 0;
+ virtual std::string parameters() const = 0;
+ virtual void configure(const std::string& parameters) = 0;
+
+ virtual scalar membership(scalar x) const = 0;
+
+ virtual Term* clone() const = 0;
+
+ //FIXME: This should not be static, and may not be here either.
+ static void updateReference(Term* term, const Engine* engine);
+ };
+
+}
+#endif /* FL_TERM_H */
diff --git a/dep/fl/term/Trapezoid.h b/dep/fl/term/Trapezoid.h
new file mode 100644
index 0000000..f896997
--- /dev/null
+++ b/dep/fl/term/Trapezoid.h
@@ -0,0 +1,69 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_TRAPEZOID_H
+#define FL_TRAPEZOID_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Trapezoid : public Term {
+ protected:
+ scalar _vertexA, _vertexB, _vertexC, _vertexD;
+ public:
+ explicit Trapezoid(const std::string& name = "",
+ scalar vertexA = fl::nan,
+ scalar vertexB = fl::nan,
+ scalar vertexC = fl::nan,
+ scalar vertexD = fl::nan,
+ scalar height = 1.0);
+ virtual ~Trapezoid() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Trapezoid)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setVertexA(scalar a);
+ virtual scalar getVertexA() const;
+
+ virtual void setVertexB(scalar b);
+ virtual scalar getVertexB() const;
+
+ virtual void setVertexC(scalar c);
+ virtual scalar getVertexC() const;
+
+ virtual void setVertexD(scalar d);
+ virtual scalar getVertexD() const;
+
+ virtual Trapezoid* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+ };
+
+}
+#endif /* FL_TRAPEZOID_H */
diff --git a/dep/fl/term/Triangle.h b/dep/fl/term/Triangle.h
new file mode 100644
index 0000000..9311687
--- /dev/null
+++ b/dep/fl/term/Triangle.h
@@ -0,0 +1,68 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_TRIANGLE_H
+#define FL_TRIANGLE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API Triangle : public Term {
+ protected:
+ scalar _vertexA;
+ scalar _vertexB;
+ scalar _vertexC;
+ public:
+ explicit Triangle(const std::string& name = "",
+ scalar vertexA = fl::nan,
+ scalar vertexB = fl::nan,
+ scalar vertexC = fl::nan,
+ scalar height = 1.0);
+ virtual ~Triangle() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(Triangle)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setVertexA(scalar a);
+ virtual scalar getVertexA() const;
+
+ virtual void setVertexB(scalar b);
+ virtual scalar getVertexB() const;
+
+ virtual void setVertexC(scalar c);
+ virtual scalar getVertexC() const;
+
+ virtual Triangle* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+
+ };
+
+}
+#endif /* FL_TRIANGLE_H */
diff --git a/dep/fl/term/ZShape.h b/dep/fl/term/ZShape.h
new file mode 100644
index 0000000..b53906e
--- /dev/null
+++ b/dep/fl/term/ZShape.h
@@ -0,0 +1,63 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_ZSHAPE_H
+#define FL_ZSHAPE_H
+
+#include "fl/term/Term.h"
+
+namespace fl {
+
+ class FL_API ZShape : public Term {
+ protected:
+ scalar _start, _end;
+
+ public:
+ explicit ZShape(const std::string& name = "",
+ scalar _start = fl::nan,
+ scalar _end = fl::nan,
+ scalar _height = 1.0);
+ virtual ~ZShape() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(ZShape)
+
+ virtual std::string className() const FL_IOVERRIDE;
+ virtual std::string parameters() const FL_IOVERRIDE;
+ virtual void configure(const std::string& parameters) FL_IOVERRIDE;
+
+ virtual scalar membership(scalar x) const FL_IOVERRIDE;
+
+ virtual void setStart(scalar start);
+ virtual scalar getStart() const;
+
+ virtual void setEnd(scalar end);
+ virtual scalar getEnd() const;
+
+ virtual ZShape* clone() const FL_IOVERRIDE;
+
+ static Term* constructor();
+
+ };
+}
+#endif /* ZSHAPE_H */
+
diff --git a/dep/fl/variable/InputVariable.h b/dep/fl/variable/InputVariable.h
new file mode 100644
index 0000000..bba3c7d
--- /dev/null
+++ b/dep/fl/variable/InputVariable.h
@@ -0,0 +1,52 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_INPUTVARIABLE_H
+#define FL_INPUTVARIABLE_H
+
+#include "fl/variable/Variable.h"
+
+namespace fl {
+
+ class FL_API InputVariable : public Variable {
+ protected:
+ scalar _inputValue;
+ public:
+ explicit InputVariable(const std::string& name = "",
+ scalar minimum = -fl::inf,
+ scalar maximum = fl::inf);
+ virtual ~InputVariable() FL_IOVERRIDE;
+ FL_DEFAULT_COPY_AND_MOVE(InputVariable)
+
+ virtual void setInputValue(scalar inputValue);
+ virtual scalar getInputValue() const;
+
+ virtual std::string fuzzyInputValue() const;
+
+ virtual std::string toString() const FL_IOVERRIDE;
+
+ };
+
+}
+#endif /* FL_INPUTVARIABLE_H */
diff --git a/dep/fl/variable/OutputVariable.h b/dep/fl/variable/OutputVariable.h
new file mode 100644
index 0000000..9d00aaf
--- /dev/null
+++ b/dep/fl/variable/OutputVariable.h
@@ -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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_OUTPUTVARIABLE_H
+#define FL_OUTPUTVARIABLE_H
+
+#include "fl/variable/Variable.h"
+
+namespace fl {
+ class Accumulated;
+ class Defuzzifier;
+
+ class FL_API OutputVariable : public Variable {
+ private:
+ void copyFrom(const OutputVariable& other);
+ protected:
+ FL_unique_ptr _fuzzyOutput;
+ FL_unique_ptr _defuzzifier;
+ scalar _outputValue;
+ scalar _previousOutputValue;
+ scalar _defaultValue;
+ bool _lockOutputValueInRange;
+ bool _lockPreviousOutputValue;
+
+ public:
+ explicit OutputVariable(const std::string& name = "",
+ scalar minimum = -fl::inf, scalar maximum = fl::inf);
+ OutputVariable(const OutputVariable& other);
+ OutputVariable& operator=(const OutputVariable& other);
+ virtual ~OutputVariable() FL_IOVERRIDE;
+ FL_DEFAULT_MOVE(OutputVariable)
+
+ virtual Accumulated* fuzzyOutput() const;
+
+ virtual void setName(const std::string& name) FL_IOVERRIDE;
+
+ virtual void setMinimum(scalar minimum) FL_IOVERRIDE;
+ virtual void setMaximum(scalar maximum) FL_IOVERRIDE;
+
+ virtual void setDefuzzifier(Defuzzifier* defuzzifier);
+ virtual Defuzzifier* getDefuzzifier() const;
+
+ virtual void setOutputValue(scalar outputValue);
+ virtual scalar getOutputValue() const;
+
+ virtual void setPreviousOutputValue(scalar defuzzifiedValue);
+ virtual scalar getPreviousOutputValue() const;
+
+ virtual void setDefaultValue(scalar defaultValue);
+ virtual scalar getDefaultValue() const;
+
+ virtual void setLockOutputValueInRange(bool lockOutputValueInRange);
+ virtual bool isLockedOutputValueInRange() const;
+
+ virtual void setLockPreviousOutputValue(bool lockPreviousOutputValue);
+ virtual bool isLockedPreviousOutputValue() const;
+
+ virtual void defuzzify();
+
+ virtual std::string fuzzyOutputValue() const;
+
+ virtual void clear();
+
+ virtual std::string toString() const FL_IOVERRIDE;
+
+ };
+
+}
+#endif /* FL_OUTPUTVARIABLE_H */
diff --git a/dep/fl/variable/Variable.h b/dep/fl/variable/Variable.h
new file mode 100644
index 0000000..61870af
--- /dev/null
+++ b/dep/fl/variable/Variable.h
@@ -0,0 +1,96 @@
+/*
+ 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 .
+
+ fuzzylite™ is a trademark of FuzzyLite Limited.
+
+ */
+
+#ifndef FL_VARIABLE_H
+#define FL_VARIABLE_H
+
+#include "fl/fuzzylite.h"
+#include "fl/defuzzifier/Centroid.h"
+
+#include
+#include
+
+namespace fl {
+
+ class Term;
+
+ class FL_API Variable {
+ private:
+ void copyFrom(const Variable& source);
+
+ protected:
+ std::string _name;
+ std::vector _terms;
+ scalar _minimum, _maximum;
+ bool _enabled;
+
+ public:
+ explicit Variable(const std::string& name = "",
+ scalar minimum = -fl::inf,
+ scalar maximum = fl::inf);
+ Variable(const Variable& other);
+ Variable& operator=(const Variable& other);
+ virtual ~Variable();
+ FL_DEFAULT_MOVE(Variable)
+
+ virtual void setName(const std::string& name);
+ virtual std::string getName() const;
+
+ virtual void setRange(scalar minimum, scalar maximum);
+ virtual scalar range() const;
+
+ virtual void setMinimum(scalar minimum);
+ virtual scalar getMinimum() const;
+
+ virtual void setMaximum(scalar maximum);
+ virtual scalar getMaximum() const;
+
+ virtual void setEnabled(bool enabled);
+ virtual bool isEnabled() const;
+
+ virtual std::string fuzzify(scalar x) const;
+ virtual Term* highestMembership(scalar x, scalar* yhighest = fl::null) const;
+
+ virtual std::string toString() const;
+
+ /**
+ * Operations for iterable datatype _terms
+ */
+ virtual void sort();
+ virtual void addTerm(Term* term);
+ virtual void insertTerm(Term* term, int index);
+ virtual Term* getTerm(int index) const;
+ virtual Term* getTerm(const std::string& name) const;
+ virtual bool hasTerm(const std::string& name) const;
+ virtual Term* removeTerm(int index);
+ virtual int numberOfTerms() const;
+ virtual void setTerms(const std::vector& terms);
+ virtual const std::vector& terms() const;
+ virtual std::vector& terms();
+
+ };
+
+}
+
+#endif /* FL_VARIABLE_H */
diff --git a/driver.fcl b/driver.fcl
new file mode 100644
index 0000000..91ccda7
--- /dev/null
+++ b/driver.fcl
@@ -0,0 +1,91 @@
+FUNCTION_BLOCK driver
+
+VAR_INPUT
+ trackPos: REAL;
+ angle: REAL;
+ track9: REAL;
+ speedX: REAL;
+END_VAR
+
+VAR_OUTPUT
+ steer: REAL;
+ accel: REAL;
+ brake: REAL;
+END_VAR
+
+FUZZIFY trackPos
+ RANGE := (-9.000 .. 9.000);
+ TERM left := Trapezoid 0.300 0.600 9.000 9.000;
+ TERM center := Trapezoid -0.600 -0.300 0.300 0.600;
+ TERM right := Trapezoid -9.000 -9.000 -0.600 -0.300;
+END_FUZZIFY
+
+FUZZIFY angle
+ RANGE := (-3.150 .. 3.150);
+ TERM left := Trapezoid -3.150 -3.150 -0.900 -0.000;
+ TERM center := Trapezoid -0.900 -0.000 0.000 0.900;
+ TERM right := Trapezoid 0.000 0.900 3.150 3.150;
+END_FUZZIFY
+
+FUZZIFY track9
+ RANGE := (-1.000 .. 200.000);
+ TERM outside := Trapezoid -1.000 -1.000 0.000 0.000;
+ TERM near := Trapezoid 0.000 0.000 30.000 60.000;
+ TERM far := Trapezoid 30.000 60.000 200.00 200.000;
+END_FUZZIFY
+
+FUZZIFY speedX
+ RANGE := (0.000 .. 300.000);
+ TERM f_slow := Trapezoid 0.000 0.000 15.000 30.000;
+ TERM f_fast := Trapezoid 15.000 30.000 100.00 130.000;
+ TERM f_very_fast := Trapezoid 100.000 130.000 300.00 300.000;
+END_FUZZIFY
+
+DEFUZZIFY steer
+ RANGE := (-1.000 .. 1.000);
+ TERM turn_left := Trapezoid 0.000 0.100 1.000 1.000;
+ TERM stay_center := Triangle -0.100 0.000 0.100;
+ TERM turn_right := Trapezoid -1.000 -1.000 -0.100 0.000;
+ METHOD : COG;
+ ACCU : MAX;
+ DEFAULT := 0.000;
+END_DEFUZZIFY
+
+DEFUZZIFY accel
+ RANGE := (0.000 .. 1.000);
+ TERM nogas := Trapezoid 0.000 0.000 0.300 0.500;
+ TERM medgas := Triangle 0.100 0.200 0.300;
+ TERM fullgas := Trapezoid 0.300 0.400 1.000 1.000;
+ METHOD : COG;
+ ACCU : MAX;
+ DEFAULT := 1.000;
+END_DEFUZZIFY
+
+DEFUZZIFY brake
+ RANGE := (0.000 .. 1.000);
+ TERM nobrake := Triangle 0.000 0.000 0.035;
+ TERM fullbrake := Trapezoid 0.035 0.100 1.000 1.000;
+ METHOD : COG;
+ ACCU : MAX;
+ DEFAULT := 0.000;
+END_DEFUZZIFY
+
+RULEBLOCK
+ AND : MIN;
+ OR : MAX;
+ ACT : MIN;
+ RULE 1 : if trackPos is left then steer is turn_right;
+ RULE 2 : if trackPos is center then steer is stay_center;
+ RULE 3 : if trackPos is right then steer is turn_left;
+ RULE 4 : if angle is left then steer is turn_right;
+ RULE 5 : if angle is center then steer is stay_center;
+ RULE 6 : if angle is right then steer is turn_left;
+
+ RULE 7 : if track9 is near and speedX is f_fast then accel is nogas;
+ RULE 8 : if track9 is far and speedX is f_slow then accel is fullgas and brake is nobrake;
+ RULE 9 : if track9 is outside then accel is medgas and brake is nobrake;
+
+ RULE 10 : if track9 is near and speedX is f_very_fast then accel is nogas and brake is fullbrake;
+END_RULEBLOCK
+
+END_FUNCTION_BLOCK
\ No newline at end of file
diff --git a/src/BaseDriver.cpp b/src/BaseDriver.cpp
new file mode 100644
index 0000000..c4d8148
--- /dev/null
+++ b/src/BaseDriver.cpp
@@ -0,0 +1,24 @@
+#include "BaseDriver.h"
+
+BaseDriver::BaseDriver()
+{
+}
+
+BaseDriver::~BaseDriver()
+{
+}
+
+// Initialization of the desired angles for the rangefinders
+void BaseDriver::init(float *angles)
+{
+ for (int i = 0; i < 19; ++i)
+ angles[i] = (float)(-90 + i * 10);
+}
+
+void BaseDriver::onShutdown()
+{
+}
+
+void BaseDriver::onRestart()
+{
+}
\ No newline at end of file
diff --git a/src/BaseDriver.h b/src/BaseDriver.h
new file mode 100644
index 0000000..ef8cc56
--- /dev/null
+++ b/src/BaseDriver.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+
+ file : BaseDriver.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef BASEDRIVER_H_
+#define BASEDRIVER_H_
+
+#include
+
+class BaseDriver
+{
+public:
+
+ typedef enum { WARMUP = 0, QUALIFYING = 1, RACE = 2, UNKNOWN = 3 } tstage;
+
+ tstage stage;
+ std::string trackName;
+
+ // Default Constructor
+ BaseDriver();
+
+ // Default Destructor;
+ virtual ~BaseDriver();
+
+ // Initialization of the desired angles for the rangefinders
+ virtual void init(float *angles);
+
+ // The main function:
+ // - the input variable sensors represents the current world sate
+ // - it returns a string representing the controlling action to perform
+ virtual std::string drive(std::string sensors) = 0;
+
+ // Callback function called at shutdown
+ virtual void onShutdown();
+
+ // Callback function called at server restart
+ virtual void onRestart();
+
+};
+#endif /*BASEDRIVER_H_*/
diff --git a/src/CarControl.cpp b/src/CarControl.cpp
new file mode 100644
index 0000000..21188d4
--- /dev/null
+++ b/src/CarControl.cpp
@@ -0,0 +1,156 @@
+/***************************************************************************
+
+ file : CarControl.cpp
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "CarControl.h"
+
+#include "SimpleParser.h"
+
+int CarControl::META_RESTART = 1;
+
+CarControl::CarControl()
+{
+}
+
+CarControl::CarControl(float accel, float brake, int gear, float steer, float clutch, int focus, int meta)
+{
+ this->accel = accel;
+ this->brake = brake;
+ this->gear = gear;
+ this->steer = steer;
+ this->clutch = clutch;
+ this->focus = focus;
+ this->meta = meta;
+}
+
+CarControl::CarControl(float accel, float brake, int gear, float steer, float clutch, int focus)
+{
+ this->accel = accel;
+ this->brake = brake;
+ this->gear = gear;
+ this->steer = steer;
+ this->clutch = clutch;
+ this->focus = focus;
+ this->meta = 0;
+}
+
+CarControl::CarControl(std::string sensors)
+{
+ fromString(sensors);
+}
+
+std::string CarControl::toString()
+{
+ std::string str;
+
+ str = SimpleParser::stringify("accel", accel);
+ str += SimpleParser::stringify("brake", brake);
+ str += SimpleParser::stringify("gear", gear);
+ str += SimpleParser::stringify("steer", steer);
+ str += SimpleParser::stringify("clutch", clutch);
+ str += SimpleParser::stringify("focus", focus);
+ str += SimpleParser::stringify("meta", meta);
+
+ return str;
+}
+
+void CarControl::fromString(std::string sensors)
+{
+ if (SimpleParser::parse(sensors, "accel", accel) == false)
+ accel = 0.0;
+ if (SimpleParser::parse(sensors, "brake", brake) == false)
+ brake = 0.0;
+ if (SimpleParser::parse(sensors, "gear", gear) == false)
+ gear = 1;
+ if (SimpleParser::parse(sensors, "steer", steer) == false)
+ steer = 0.0;
+ if (SimpleParser::parse(sensors, "clutch", clutch) == false)
+ clutch = 0.0;
+ if (SimpleParser::parse(sensors, "meta", meta) == false)
+ meta = 0;
+ if (SimpleParser::parse(sensors, "focus", focus) == false) //ML
+ focus = 0; //ML
+ if (focus < -90 || focus > 90)//ML What to do with focus requests out of allowed range?
+ focus = 360;//ML A value of 360 is used for not requesting focus readings; -1 is returned as focus reading to the client
+}
+
+float CarControl::getAccel() const
+{
+ return this->accel;
+}
+
+void CarControl::setAccel(float accel)
+{
+ this->accel = accel;
+}
+
+float CarControl::getBrake() const
+{
+ return this->brake;
+}
+
+void CarControl::setBrake(float brake)
+{
+ this->brake = brake;
+}
+
+int CarControl::getGear() const
+{
+ return this->gear;
+}
+
+void CarControl::setGear(int gear)
+{
+ this->gear = gear;
+}
+
+float CarControl::getSteer() const
+{
+ return this->steer;
+}
+
+void CarControl::setSteer(float steer)
+{
+ this->steer = steer;
+}
+
+int CarControl::getMeta() const
+{
+ return this->meta;
+}
+
+void CarControl::setMeta(int meta)
+{
+ this->meta = meta;
+}
+
+float CarControl::getClutch() const
+{
+ return clutch;
+}
+
+void CarControl::setClutch(float clutch)
+{
+ this->clutch = clutch;
+}
+
+int CarControl::getFocus()
+{
+ return this->focus;
+}
+
+void CarControl::setFocus(int focus)
+{
+ this->focus = focus;
+}
diff --git a/src/CarControl.h b/src/CarControl.h
new file mode 100644
index 0000000..3a19010
--- /dev/null
+++ b/src/CarControl.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+
+ file : CarControl.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef CARCONTROL_H_
+#define CARCONTROL_H_
+
+#include
+
+class CarControl
+{
+private:
+
+ // Accelerate command [0,1]
+ float accel;
+
+ // Brake command [0,1]
+ float brake;
+
+ // Gear command {-1,0,1,...,6}
+ int gear;
+
+ // Steering command [-1,1]
+ float steer;
+
+ // Clutch command [0,1]
+ float clutch;
+
+ // meta-command {0 do nothing, 1 ask competition server to restart the race}
+ int meta;
+
+ // focus command [-90,90], i.e. angle of track sensor focus desired by client
+ int focus;
+
+public:
+
+ CarControl();
+ CarControl(std::string sensors);
+ CarControl(float accel, float brake, int gear, float steer, float clutch, int focus, int meta = 0);
+ CarControl(float accel, float brake, int gear, float steer, float clutch, int focus = 0);
+
+ std::string toString();
+ void fromString(std::string sensors);
+
+ /* Getter and setter methods */
+
+ float getAccel() const;
+ void setAccel(float accel);
+ float getBrake() const;
+ void setBrake(float brake);
+ int getGear() const;
+ void setGear(int gear);
+ float getSteer() const;
+ void setSteer(float steer);
+ int getMeta() const;
+ void setMeta(int gear);
+ float getClutch() const;
+ void setClutch(float clutch);
+ int getFocus();
+ void setFocus(int focus);
+
+ // meta-command value for race restart
+ static int META_RESTART;
+
+};
+
+#endif /*CARCONTROL_H_*/
diff --git a/src/CarState.cpp b/src/CarState.cpp
new file mode 100644
index 0000000..f84c16c
--- /dev/null
+++ b/src/CarState.cpp
@@ -0,0 +1,274 @@
+/***************************************************************************
+
+ file : CarState.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "CarState.h"
+
+#include "SimpleParser.h"
+
+#include
+
+CarState::CarState()
+{
+}
+
+CarState::CarState(std::string sensors)
+{
+ SimpleParser::parse(sensors, "angle", this->angle);
+ SimpleParser::parse(sensors, "curLapTime", this->curLapTime);
+ SimpleParser::parse(sensors, "damage", this->damage);
+ SimpleParser::parse(sensors, "distFromStart", this->distFromStart);
+ SimpleParser::parse(sensors, "distRaced", this->distRaced);
+ SimpleParser::parse(sensors, "focus", this->focus, FOCUS_SENSORS_NUM);
+ SimpleParser::parse(sensors, "fuel", this->fuel);
+ SimpleParser::parse(sensors, "gear", this->gear);
+ SimpleParser::parse(sensors, "lastLapTime", this->lastLapTime);
+ SimpleParser::parse(sensors, "opponents", this->opponents, OPPONENTS_SENSORS_NUM);
+ SimpleParser::parse(sensors, "racePos", this->racePos);
+ SimpleParser::parse(sensors, "rpm", this->rpm);
+ SimpleParser::parse(sensors, "speedX", this->speedX);
+ SimpleParser::parse(sensors, "speedY", this->speedY);
+ SimpleParser::parse(sensors, "speedZ", this->speedZ);
+ SimpleParser::parse(sensors, "track", this->track, TRACK_SENSORS_NUM);
+ SimpleParser::parse(sensors, "trackPos", this->trackPos);
+ SimpleParser::parse(sensors, "wheelSpinVel", this->wheelSpinVel, 4);
+ SimpleParser::parse(sensors, "z", this->z);
+}
+
+std::string CarState::toString()
+{
+ std::string str;
+ str = SimpleParser::stringify("angle", this->angle);
+ str += SimpleParser::stringify("curLapTime", this->curLapTime);
+ str += SimpleParser::stringify("damage", this->damage);
+ str += SimpleParser::stringify("distFromStart", this->distFromStart);
+ str += SimpleParser::stringify("distRaced", this->distRaced);
+ str += SimpleParser::stringify("focus", this->focus, FOCUS_SENSORS_NUM);
+ str += SimpleParser::stringify("fuel", this->fuel);
+ str += SimpleParser::stringify("gear", this->gear);
+ str += SimpleParser::stringify("lastLapTime", this->lastLapTime);
+ str += SimpleParser::stringify("opponents", this->opponents, OPPONENTS_SENSORS_NUM);
+ str += SimpleParser::stringify("racePos", this->racePos);
+ str += SimpleParser::stringify("rpm", this->rpm);
+ str += SimpleParser::stringify("speedX", this->speedX);
+ str += SimpleParser::stringify("speedY", this->speedY);
+ str += SimpleParser::stringify("speedZ", this->speedZ);
+ str += SimpleParser::stringify("track", this->track, TRACK_SENSORS_NUM);
+ str += SimpleParser::stringify("trackPos", this->trackPos);
+ str += SimpleParser::stringify("wheelSpinVel", this->wheelSpinVel, 4);
+ str += SimpleParser::stringify("z", this->z);
+
+ return str;
+
+}
+
+float CarState::getAngle()
+{
+ return angle;
+}
+
+void CarState::setAngle(float angle)
+{
+ this->angle = angle;
+}
+
+float CarState::getCurLapTime()
+{
+ return curLapTime;
+}
+
+void CarState::setCurLapTime(float curLapTime)
+{
+ this->curLapTime = curLapTime;
+}
+
+float CarState::getDamage()
+{
+ return damage;
+}
+
+void CarState::setDamage(float damage)
+{
+ this->damage = damage;
+}
+
+float CarState::getDistFromStart()
+{
+ return distFromStart;
+}
+
+void CarState::setDistFromStart(float distFromStart)
+{
+ this->distFromStart = distFromStart;
+}
+
+float CarState::getDistRaced()
+{
+ return distRaced;
+}
+
+void CarState::setDistRaced(float distRaced)
+{
+ this->distRaced = distRaced;
+}
+
+float CarState::getFocus(int i)
+{
+ assert(i >= 0 && i < FOCUS_SENSORS_NUM);
+ return focus[i];
+}
+
+void CarState::setFocus(int i, float value)
+{
+ assert(i >= 0 && i < FOCUS_SENSORS_NUM);
+ this->focus[i] = value;
+}
+
+float CarState::getFuel()
+{
+ return fuel;
+}
+
+void CarState::setFuel(float fuel)
+{
+ this->fuel = fuel;
+}
+
+int CarState::getGear()
+{
+ return gear;
+}
+
+void CarState::setGear(int gear)
+{
+ this->gear = gear;
+}
+
+float CarState::getLastLapTime()
+{
+ return lastLapTime;
+}
+
+void CarState::setLastLapTime(float lastLapTime)
+{
+ this->lastLapTime = lastLapTime;
+}
+
+float CarState::getOpponents(int i)
+{
+ assert(i >= 0 && i < OPPONENTS_SENSORS_NUM);
+ return opponents[i];
+}
+
+void CarState::setOpponents(int i, float value)
+{
+ assert(i >= 0 && i < OPPONENTS_SENSORS_NUM);
+ this->opponents[i] = value;
+}
+
+int CarState::getRacePos()
+{
+ return racePos;
+}
+
+void CarState::setRacePos(int racePos)
+{
+ this->racePos = racePos;
+}
+
+int CarState::getRpm()
+{
+ return rpm;
+}
+
+void CarState::setRpm(int rpm)
+{
+ this->rpm = rpm;
+}
+
+float CarState::getSpeedX()
+{
+ return speedX;
+}
+
+void CarState::setSpeedX(float speedX)
+{
+ this->speedX = speedX;
+}
+
+float CarState::getSpeedY()
+{
+ return speedY;
+}
+
+void CarState::setSpeedY(float speedY)
+{
+ this->speedY = speedY;
+}
+
+float CarState::getSpeedZ()
+{
+ return speedZ;
+}
+
+
+void CarState::setSpeedZ(float speedZ)
+{
+ this->speedZ = speedZ;
+}
+
+float CarState::getTrack(int i)
+{
+ assert(i >= 0 && i < TRACK_SENSORS_NUM);
+ return track[i];
+}
+
+
+void CarState::setTrack(int i, float value)
+{
+ assert(i >= 0 && i < TRACK_SENSORS_NUM);
+ this->track[i] = value;
+}
+
+float CarState::getTrackPos()
+{
+ return trackPos;
+}
+
+void CarState::setTrackPos(float prackPos)
+{
+ this->trackPos = trackPos;
+}
+
+float CarState::getWheelSpinVel(int i)
+{
+ assert(i >= 0 && i < 4);
+ return wheelSpinVel[i];
+}
+
+void CarState::setWheelSpinVel(int i, float value)
+{
+ assert(i >= 0 && i < 4);
+ wheelSpinVel[i] = value;
+}
+
+float CarState::getZ()
+{
+ return z;
+}
+
+void CarState::setZ(float z)
+{
+ this->z = z;
+}
diff --git a/src/CarState.h b/src/CarState.h
new file mode 100644
index 0000000..8cd94bf
--- /dev/null
+++ b/src/CarState.h
@@ -0,0 +1,99 @@
+/***************************************************************************
+
+ file : CarState.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef CARSTATE_H_
+#define CARSTATE_H_
+
+#define FOCUS_SENSORS_NUM 5
+#define TRACK_SENSORS_NUM 19
+#define OPPONENTS_SENSORS_NUM 36
+
+#include
+
+class CarState
+{
+private:
+
+ float angle;
+ float curLapTime;
+ float damage;
+ float distFromStart;
+ float distRaced;
+ float focus[FOCUS_SENSORS_NUM];
+ float fuel;
+ int gear;
+ float lastLapTime;
+ float opponents[OPPONENTS_SENSORS_NUM];
+ int racePos;
+ int rpm;
+ float speedX;
+ float speedY;
+ float speedZ;
+ float track[TRACK_SENSORS_NUM];
+ float trackPos;
+ float wheelSpinVel[4];
+ float z;
+
+public:
+
+ CarState();
+ CarState(std::string sensors);
+
+ std::string toString();
+
+ /* Getter and setter methods */
+
+ float getAngle();
+ void setAngle(float angle);
+ float getCurLapTime();
+ void setCurLapTime(float curLapTime);
+ float getDamage();
+ void setDamage(float damage);
+ float getDistFromStart();
+ void setDistFromStart(float distFromStart);
+ float getDistRaced();
+ void setDistRaced(float distRaced);
+ float getFocus(int i);
+ void setFocus(int i, float value);
+ float getFuel();
+ void setFuel(float fuel);
+ int getGear();
+ void setGear(int gear);
+ float getLastLapTime();
+ void setLastLapTime(float lastLapTime);
+ float getOpponents(int i);
+ void setOpponents(int i, float value);
+ int getRacePos();
+ void setRacePos(int racePos);
+ int getRpm();
+ void setRpm(int rpm);
+ float getSpeedX();
+ void setSpeedX(float speedX);
+ float getSpeedY();
+ void setSpeedY(float speedY);
+ float getSpeedZ();
+ void setSpeedZ(float speedZ);
+ float getTrack(int i);
+ void setTrack(int i, float value);
+ float getTrackPos();
+ void setTrackPos(float trackPos);
+ float getWheelSpinVel(int i);
+ void setWheelSpinVel(int i, float value);
+ float getZ();
+ void setZ(float z);
+
+};
+
+#endif /*CARSTATE_H_*/
diff --git a/src/FuzzyDriver.cpp b/src/FuzzyDriver.cpp
new file mode 100644
index 0000000..4e2b5e7
--- /dev/null
+++ b/src/FuzzyDriver.cpp
@@ -0,0 +1,128 @@
+#include "FuzzyDriver.h"
+
+#include
+#include
+
+FuzzyDriver::FuzzyDriver(std::string trackName, BaseDriver::tstage, std::string fclFile)
+{
+ this->trackName = trackName;
+ this->stage = stage;
+ this->fclFile = fclFile;
+}
+
+FuzzyDriver::~FuzzyDriver()
+{
+ delete flEngine;
+}
+
+bool FuzzyDriver::loadFCLfile()
+{
+ bool fileLoaded = false;
+
+ try
+ {
+ flEngine = fl::FclImporter().fromFile(fclFile);
+ fileLoaded = true;
+ }
+ catch (fl::Exception &e)
+ {
+ std::cerr << "FuzzyLite: " << e.getWhat() << std::endl;
+ }
+
+ return fileLoaded;
+}
+
+void FuzzyDriver::init(float *angles)
+{
+
+ // set angles as {-90,-75,-60,-45,-30,20,15,10,5,0,5,10,15,20,30,45,60,75,90}
+
+ for (int i = 0; i < 5; i++)
+ {
+ angles[i] = (float)(-90 + i * 15);
+ angles[18 - i] = (float)(90 - i * 15);
+ }
+
+ for (int i = 5; i < 9; i++)
+ {
+ angles[i] = (float)(-20 + (i - 5) * 5);
+ angles[18 - i] = (float)(20 - (i - 5) * 5);
+ }
+ angles[9] = 0;
+}
+
+void FuzzyDriver::onShutdown()
+{
+ std::cout << "Bye bye!" << std::endl;
+}
+
+void FuzzyDriver::onRestart()
+{
+ std::cout << "Restarting the race!" << std::endl;
+}
+
+/* Gear Changing Constants*/
+const int FuzzyDriver::gearUp[6] =
+{
+ 5000,6000,6000,6500,7000,0
+};
+const int FuzzyDriver::gearDown[6] =
+{
+ 0,2500,3000,3000,3500,3500
+};
+
+CarControl FuzzyDriver::wDrive(CarState cs)
+{
+ float accel = 0; // [0,1]
+ float brake = 0; // [0,1]
+ int gear = 0; // {-1,..,6}
+ float steer = 0; // [-1,1]
+ float clutch = 0; // [0,1]
+ int meta = 0; // {0,1}
+ int focus = 0; // [-90,90]
+
+ float trackPos = cs.getTrackPos();
+ float angle = cs.getAngle();
+ float track9 = cs.getTrack(9);
+ float speedX = cs.getSpeedX();
+
+ flEngine->setInputValue("trackPos", trackPos);
+ flEngine->setInputValue("angle", angle);
+ flEngine->setInputValue("track9", track9);
+ flEngine->setInputValue("speedX", speedX);
+
+ flEngine->process();
+
+ steer = (float)flEngine->getOutputVariable("steer")->getOutputValue();
+ accel = (float)flEngine->getOutputVariable("accel")->getOutputValue();
+ brake = (float)flEngine->getOutputVariable("brake")->getOutputValue();
+ gear = getGear(cs);
+
+ std::cout << '\r' << std::fixed << std::setw(7) << std::setprecision(3) << std::setfill('0') <<
+ "trackPos: " << trackPos << ", angle: " << angle << ", speedX: " << speedX << ", track9: " << track9 << ", steer: " << steer << ", accel: " << accel <<
+ ", brake: " << brake << std::flush;
+
+ CarControl cc(accel, brake, gear, steer, clutch, focus, meta);
+ return cc;
+}
+
+int FuzzyDriver::getGear(CarState &cs)
+{
+ int gear = cs.getGear();
+ int rpm = cs.getRpm();
+
+ // if gear is 0 (N) or -1 (R) just return 1
+ if (gear < 1)
+ return 1;
+ // check if the RPM value of car is greater than the one suggested
+ // to shift up the gear from the current one
+ if (gear < 6 && rpm >= gearUp[gear - 1])
+ return gear + 1;
+ else
+ // check if the RPM value of car is lower than the one suggested
+ // to shift down the gear from the current one
+ if (gear > 1 && rpm <= gearDown[gear - 1])
+ return gear - 1;
+ else // otherwhise keep current gear
+ return gear;
+}
diff --git a/src/FuzzyDriver.h b/src/FuzzyDriver.h
new file mode 100644
index 0000000..b16d5df
--- /dev/null
+++ b/src/FuzzyDriver.h
@@ -0,0 +1,46 @@
+#ifndef FUZZYRIVER_H_
+#define FUZZYRIVER_H_
+
+#include "WrapperBaseDriver.h"
+
+#include
+
+class FuzzyDriver : public WrapperBaseDriver
+{
+public:
+
+ // Constructor
+ FuzzyDriver(std::string trackName, BaseDriver::tstage stage, std::string fclFile);
+
+ // Destructor
+ ~FuzzyDriver();
+
+ // Load FCL file
+ bool loadFCLfile();
+
+ // FuzzyDriver implements a simple and heuristic controller for driving
+ virtual CarControl wDrive(CarState cs);
+
+ // Print a shutdown message
+ virtual void onShutdown();
+
+ // Print a restart message
+ virtual void onRestart();
+
+ // Initialization of the desired angles for the rangefinders
+ virtual void init(float *angles);
+
+ static const int gearUp[6];
+ static const int gearDown[6];
+
+ // Solves the gear changing subproblems
+ int getGear(CarState &cs);
+
+private:
+
+ std::string fclFile;
+
+ fl::Engine *flEngine;
+};
+
+#endif /*FUZZYRIVER_H_*/
diff --git a/src/SimpleDriver.cpp b/src/SimpleDriver.cpp
new file mode 100644
index 0000000..e8c407e
--- /dev/null
+++ b/src/SimpleDriver.cpp
@@ -0,0 +1,323 @@
+/***************************************************************************
+
+ file : SimpleDriver.cpp
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "SimpleDriver.h"
+
+#include
+#include
+
+SimpleDriver::SimpleDriver()
+{
+ stuck = 0;
+ clutch = 0.0;
+}
+
+
+/* Gear Changing Constants*/
+const int SimpleDriver::gearUp[6] =
+{
+ 5000,6000,6000,6500,7000,0
+};
+const int SimpleDriver::gearDown[6] =
+{
+ 0,2500,3000,3000,3500,3500
+};
+
+/* Stuck constants*/
+const int SimpleDriver::stuckTime = 25;
+const float SimpleDriver::stuckAngle = .523598775f; //PI/6
+
+/* Accel and Brake Constants*/
+const float SimpleDriver::maxSpeedDist = 70;
+const float SimpleDriver::maxSpeed = 150;
+const float SimpleDriver::sin5 = 0.08716f;
+const float SimpleDriver::cos5 = 0.99619f;
+
+/* Steering constants*/
+const float SimpleDriver::steerLock = 0.366519f;
+const float SimpleDriver::steerSensitivityOffset = 80.0;
+const float SimpleDriver::wheelSensitivityCoeff = 1;
+
+/* ABS Filter Constants */
+const float SimpleDriver::wheelRadius[4] = { 0.3306f,0.3306f,0.3276f,0.3276f };
+const float SimpleDriver::absSlip = 2.0;
+const float SimpleDriver::absRange = 3.0;
+const float SimpleDriver::absMinSpeed = 3.0;
+
+/* Clutch constants */
+const float SimpleDriver::clutchMax = 0.5;
+const float SimpleDriver::clutchDelta = 0.05f;
+const float SimpleDriver::clutchRange = 0.82f;
+const float SimpleDriver::clutchDeltaTime = 0.02f;
+const float SimpleDriver::clutchDeltaRaced = 10;
+const float SimpleDriver::clutchDec = 0.01f;
+const float SimpleDriver::clutchMaxModifier = 1.3f;
+const float SimpleDriver::clutchMaxTime = 1.5;
+
+
+int SimpleDriver::getGear(CarState &cs)
+{
+ int gear = cs.getGear();
+ int rpm = cs.getRpm();
+
+ // if gear is 0 (N) or -1 (R) just return 1
+ if (gear < 1)
+ return 1;
+ // check if the RPM value of car is greater than the one suggested
+ // to shift up the gear from the current one
+ if (gear < 6 && rpm >= gearUp[gear - 1])
+ return gear + 1;
+ else
+ // check if the RPM value of car is lower than the one suggested
+ // to shift down the gear from the current one
+ if (gear > 1 && rpm <= gearDown[gear - 1])
+ return gear - 1;
+ else // otherwhise keep current gear
+ return gear;
+}
+
+float SimpleDriver::getSteer(CarState &cs)
+{
+ // steering angle is compute by correcting the actual car angle w.r.t. to track
+ // axis [cs.getAngle()] and to adjust car position w.r.t to middle of track [cs.getTrackPos()*0.5]
+ float targetAngle = (float)(cs.getAngle() - cs.getTrackPos()*0.5);
+ // at high speed reduce the steering command to avoid loosing the control
+ if (cs.getSpeedX() > steerSensitivityOffset)
+ return targetAngle / (steerLock*(cs.getSpeedX() - steerSensitivityOffset)*wheelSensitivityCoeff);
+ else
+ return (targetAngle) / steerLock;
+
+}
+float SimpleDriver::getAccel(CarState &cs)
+{
+ // checks if car is out of track
+ if (cs.getTrackPos() < 1 && cs.getTrackPos() > -1)
+ {
+ // reading of sensor at +5 degree w.r.t. car axis
+ float rxSensor = cs.getTrack(10);
+ // reading of sensor parallel to car axis
+ float cSensor = cs.getTrack(9);
+ // reading of sensor at -5 degree w.r.t. car axis
+ float sxSensor = cs.getTrack(8);
+
+ float targetSpeed;
+
+ // track is straight and enough far from a turn so goes to max speed
+ if (cSensor > maxSpeedDist || (cSensor >= rxSensor && cSensor >= sxSensor))
+ targetSpeed = maxSpeed;
+ else
+ {
+ // approaching a turn on right
+ if (rxSensor > sxSensor)
+ {
+ // computing approximately the "angle" of turn
+ float h = cSensor*sin5;
+ float b = rxSensor - cSensor*cos5;
+ float sinAngle = b*b / (h*h + b*b);
+ // estimate the target speed depending on turn and on how close it is
+ targetSpeed = maxSpeed*(cSensor*sinAngle / maxSpeedDist);
+ }
+ // approaching a turn on left
+ else
+ {
+ // computing approximately the "angle" of turn
+ float h = cSensor*sin5;
+ float b = sxSensor - cSensor*cos5;
+ float sinAngle = b*b / (h*h + b*b);
+ // estimate the target speed depending on turn and on how close it is
+ targetSpeed = maxSpeed*(cSensor*sinAngle / maxSpeedDist);
+ }
+
+ }
+
+ // accel/brake command is expontially scaled w.r.t. the difference between target speed and current one
+ return 2 / (1 + exp(cs.getSpeedX() - targetSpeed)) - 1;
+ }
+ else
+ return 0.3f; // when out of track returns a moderate acceleration command
+
+}
+
+CarControl SimpleDriver::wDrive(CarState cs)
+{
+ // check if car is currently stuck
+ if (fabs(cs.getAngle()) > stuckAngle)
+ {
+ // update stuck counter
+ stuck++;
+ }
+ else
+ {
+ // if not stuck reset stuck counter
+ stuck = 0;
+ }
+
+ // after car is stuck for a while apply recovering policy
+ if (stuck > stuckTime)
+ {
+ /* set gear and sterring command assuming car is
+ * pointing in a direction out of track */
+
+ // to bring car parallel to track axis
+ float steer = -cs.getAngle() / steerLock;
+ int gear = -1; // gear R
+
+ // if car is pointing in the correct direction revert gear and steer
+ if (cs.getAngle()*cs.getTrackPos() > 0)
+ {
+ gear = 1;
+ steer = -steer;
+ }
+
+ // Calculate clutching
+ clutching(cs, clutch);
+
+ // build a CarControl variable and return it
+ CarControl cc(1.0, 0.0, gear, steer, clutch);
+ return cc;
+ }
+
+ else // car is not stuck
+ {
+ // compute accel/brake command
+ float accel_and_brake = getAccel(cs);
+ // compute gear
+ int gear = getGear(cs);
+ // compute steering
+ float steer = getSteer(cs);
+
+
+ // normalize steering
+ if (steer < -1)
+ steer = -1;
+ if (steer > 1)
+ steer = 1;
+
+ // set accel and brake from the joint accel/brake command
+ float accel, brake;
+ if (accel_and_brake > 0)
+ {
+ accel = accel_and_brake;
+ brake = 0;
+ }
+ else
+ {
+ accel = 0;
+ // apply ABS to brake
+ brake = filterABS(cs, -accel_and_brake);
+ }
+
+ // Calculate clutching
+ clutching(cs, clutch);
+
+ // build a CarControl variable and return it
+ CarControl cc(accel, brake, gear, steer, clutch);
+ return cc;
+ }
+}
+
+float SimpleDriver::filterABS(CarState &cs, float brake)
+{
+ // convert speed to m/s
+ float speed = (float)(cs.getSpeedX() / 3.6);
+ // when spedd lower than min speed for abs do nothing
+ if (speed < absMinSpeed)
+ return brake;
+
+ // compute the speed of wheels in m/s
+ float slip = 0.0f;
+ for (int i = 0; i < 4; i++)
+ {
+ slip += cs.getWheelSpinVel(i) * wheelRadius[i];
+ }
+ // slip is the difference between actual speed of car and average speed of wheels
+ slip = speed - slip / 4.0f;
+ // when slip too high applu ABS
+ if (slip > absSlip)
+ {
+ brake = brake - (slip - absSlip) / absRange;
+ }
+
+ // check brake is not negative, otherwise set it to zero
+ if (brake < 0)
+ return 0;
+ else
+ return brake;
+}
+
+void SimpleDriver::onShutdown()
+{
+ std::cout << "Bye bye!" << std::endl;
+}
+
+void SimpleDriver::onRestart()
+{
+ std::cout << "Restarting the race!" << std::endl;
+}
+
+void SimpleDriver::clutching(CarState &cs, float &clutch)
+{
+ double maxClutch = clutchMax;
+
+ // Check if the current situation is the race start
+ if (cs.getCurLapTime() < clutchDeltaTime && stage == RACE && cs.getDistRaced() < clutchDeltaRaced)
+ clutch = (float)maxClutch;
+
+ // Adjust the current value of the clutch
+ if (clutch > 0)
+ {
+ double delta = clutchDelta;
+ if (cs.getGear() < 2)
+ {
+ // Apply a stronger clutch output when the gear is one and the race is just started
+ delta /= 2;
+ maxClutch *= clutchMaxModifier;
+ if (cs.getCurLapTime() < clutchMaxTime)
+ clutch = (float)maxClutch;
+ }
+
+ // check clutch is not bigger than maximum values
+ clutch = (float)std::min(maxClutch, double(clutch));
+
+ // if clutch is not at max value decrease it quite quickly
+ if (clutch != maxClutch)
+ {
+ clutch -= (float)delta;
+ clutch = (float)std::max(0.0, double(clutch));
+ }
+ // if clutch is at max value decrease it very slowly
+ else
+ clutch -= clutchDec;
+ }
+}
+
+void SimpleDriver::init(float *angles)
+{
+
+ // set angles as {-90,-75,-60,-45,-30,20,15,10,5,0,5,10,15,20,30,45,60,75,90}
+
+ for (int i = 0; i < 5; i++)
+ {
+ angles[i] = (float)(-90 + i * 15);
+ angles[18 - i] = (float)(90 - i * 15);
+ }
+
+ for (int i = 5; i < 9; i++)
+ {
+ angles[i] = (float)(-20 + (i - 5) * 5);
+ angles[18 - i] = (float)(20 - (i - 5) * 5);
+ }
+ angles[9] = 0;
+}
diff --git a/src/SimpleDriver.h b/src/SimpleDriver.h
new file mode 100644
index 0000000..18df1f7
--- /dev/null
+++ b/src/SimpleDriver.h
@@ -0,0 +1,118 @@
+/***************************************************************************
+
+ file : SimpleDriver.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef SIMPLEDRIVER_H_
+#define SIMPLEDRIVER_H_
+
+#include "WrapperBaseDriver.h"
+
+class SimpleDriver : public WrapperBaseDriver
+{
+public:
+
+ // Constructor
+ SimpleDriver();
+
+ // SimpleDriver implements a simple and heuristic controller for driving
+ virtual CarControl wDrive(CarState cs);
+
+ // Print a shutdown message
+ virtual void onShutdown();
+
+ // Print a restart message
+ virtual void onRestart();
+
+ // Initialization of the desired angles for the rangefinders
+ virtual void init(float *angles);
+
+private:
+
+ /* Gear Changing Constants*/
+
+ // RPM values to change gear
+ static const int gearUp[6];
+ static const int gearDown[6];
+
+ /* Stuck constants*/
+
+ // How many time steps the controller wait before recovering from a stuck position
+ static const int stuckTime;
+ // When car angle w.r.t. track axis is grather tan stuckAngle, the car is probably stuck
+ static const float stuckAngle;
+
+ /* Steering constants*/
+
+ // Angle associated to a full steer command
+ static const float steerLock;
+ // Min speed to reduce steering command
+ static const float steerSensitivityOffset;
+ // Coefficient to reduce steering command at high speed (to avoid loosing the control)
+ static const float wheelSensitivityCoeff;
+
+ /* Accel and Brake Constants*/
+
+ // max speed allowed
+ static const float maxSpeed;
+ // Min distance from track border to drive at max speed
+ static const float maxSpeedDist;
+ // pre-computed sin5
+ static const float sin5;
+ // pre-computed cos5
+ static const float cos5;
+
+ /* ABS Filter Constants */
+
+ // Radius of the 4 wheels of the car
+ static const float wheelRadius[4];
+ // min slip to prevent ABS
+ static const float absSlip;
+ // range to normalize the ABS effect on the brake
+ static const float absRange;
+ // min speed to activate ABS
+ static const float absMinSpeed;
+
+ /* Clutch constants */
+ static const float clutchMax;
+ static const float clutchDelta;
+ static const float clutchRange;
+ static const float clutchDeltaTime;
+ static const float clutchDeltaRaced;
+ static const float clutchDec;
+ static const float clutchMaxModifier;
+ static const float clutchMaxTime;
+
+ // counter of stuck steps
+ int stuck;
+
+ // current clutch
+ float clutch;
+
+ // Solves the gear changing subproblems
+ int getGear(CarState &cs);
+
+ // Solves the steering subproblems
+ float getSteer(CarState &cs);
+
+ // Solves the gear changing subproblems
+ float getAccel(CarState &cs);
+
+ // Apply an ABS filter to brake command
+ float filterABS(CarState &cs, float brake);
+
+ // Solves the clucthing subproblems
+ void clutching(CarState &cs, float &clutch);
+};
+
+#endif /*SIMPLEDRIVER_H_*/
diff --git a/src/SimpleParser.cpp b/src/SimpleParser.cpp
new file mode 100644
index 0000000..a3ac5cf
--- /dev/null
+++ b/src/SimpleParser.cpp
@@ -0,0 +1,124 @@
+/***************************************************************************
+
+ file : SimpleParser.cpp
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "SimpleParser.h"
+
+#include
+
+bool SimpleParser::parse(std::string sensors, std::string tag, float &value)
+{
+ size_t open, close;
+ open = sensors.find_first_of('(');
+ while (open != std::string::npos)
+ {
+ close = sensors.find_first_of(')', open);
+ if (close != std::string::npos)
+ {
+ std::istringstream IN(sensors.substr(open + 1, close - open - 1));
+ std::string currTag;
+ IN >> currTag;
+ if (currTag.compare(tag) == 0)
+ {
+ IN >> value;
+ return true;
+ }
+ open = sensors.find_first_of('(', close + 1);
+ }
+ else
+ return false;
+
+ }
+ return false;
+}
+
+bool SimpleParser::parse(std::string sensors, std::string tag, int &value)
+{
+ size_t open, close;
+ open = sensors.find_first_of('(');;
+ while (open != std::string::npos)
+ {
+ close = sensors.find_first_of(')', open);
+ if (close != std::string::npos)
+ {
+ std::istringstream IN(sensors.substr(open + 1, close - open - 1));
+ std::string currTag;
+ IN >> currTag;
+ if (currTag.compare(tag) == 0)
+ {
+ IN >> value;
+ return true;
+ }
+ open = sensors.find_first_of('(', close + 1);
+ }
+ else
+ return false;
+ }
+ return false;
+}
+
+bool SimpleParser::parse(std::string sensors, std::string tag, float *value, int size)
+{
+ size_t open, close;
+ open = sensors.find_first_of('(');
+ while (open != std::string::npos)
+ {
+ close = sensors.find_first_of(')', open);
+ if (close != std::string::npos)
+ {
+ std::istringstream IN(sensors.substr(open + 1, close - open - 1));
+ std::string currTag;
+ IN >> currTag;
+ if (currTag.compare(tag) == 0)
+ {
+ for (int i = 0; i < size; ++i)
+ {
+ if (!(IN >> value[i]))
+ return false;
+ }
+ return true;
+ }
+ open = sensors.find_first_of('(', close + 1);
+ }
+ else
+ return false;
+ }
+ return false;
+}
+
+std::string SimpleParser::stringify(std::string tag, float value)
+{
+ std::ostringstream STR;
+ STR << "(" << tag << " " << value << ")";
+ return STR.str();
+}
+
+std::string SimpleParser::stringify(std::string tag, int value)
+{
+ std::ostringstream STR;
+ STR << "(" << tag << " " << value << ")";
+ return STR.str();
+}
+
+std::string SimpleParser::stringify(std::string tag, float *value, int size)
+{
+ std::ostringstream STR;
+ STR << "(" << tag;
+ for (int i = 0; i < size; ++i)
+ {
+ STR << " " << value[i];
+ }
+ STR << ")";
+ return STR.str();
+}
diff --git a/src/SimpleParser.h b/src/SimpleParser.h
new file mode 100644
index 0000000..49b3a13
--- /dev/null
+++ b/src/SimpleParser.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+
+ file : SimpleParser.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef SIMPLEPARSER_H_
+#define SIMPLEPARSER_H_
+
+#include
+
+class SimpleParser
+{
+public:
+
+ static bool parse(std::string sensors, std::string tag, float &value);
+ static bool parse(std::string sensors, std::string tag, int &value);
+ static bool parse(std::string sensors, std::string tag, float *value, int size);
+ static std::string stringify(std::string tag, float value);
+ static std::string stringify(std::string tag, int value);
+ static std::string stringify(std::string tag, float *value, int size);
+
+};
+
+#endif /*SIMPLEPARSER_H_*/
diff --git a/src/WrapperBaseDriver.cpp b/src/WrapperBaseDriver.cpp
new file mode 100644
index 0000000..3915442
--- /dev/null
+++ b/src/WrapperBaseDriver.cpp
@@ -0,0 +1,24 @@
+/***************************************************************************
+
+ file : WrapperBaseDriver.cpp
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "WrapperBaseDriver.h"
+
+std::string WrapperBaseDriver::drive(std::string sensors)
+{
+ CarState cs(sensors);
+ CarControl cc = wDrive(cs);
+
+ return cc.toString();
+}
diff --git a/src/WrapperBaseDriver.h b/src/WrapperBaseDriver.h
new file mode 100644
index 0000000..b030f3c
--- /dev/null
+++ b/src/WrapperBaseDriver.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+
+ file : WrapperBaseDriver.h
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef WRAPPERBASEDRIVER_H_
+#define WRAPPERBASEDRIVER_H_
+
+#include "BaseDriver.h"
+#include "CarState.h"
+#include "CarControl.h"
+
+class WrapperBaseDriver : public BaseDriver
+{
+public:
+
+ // the drive function with string input and output
+ virtual std::string drive(std::string sensors);
+
+ // drive function that exploits the CarState and CarControl wrappers as input and output.
+ virtual CarControl wDrive(CarState cs) = 0;
+};
+
+#endif /*WRAPPERBASEDRIVER_H_*/
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..d49ad3a
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,351 @@
+/***************************************************************************
+
+ file : main.cpp
+ copyright : (C) 2007 Daniele Loiacono
+
+ ***************************************************************************/
+
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#define __DRIVER_INCLUDE__ "FuzzyDriver.h" // put here the filename of your driver header
+#define __DRIVER_CLASS__ FuzzyDriver // put here the name of your driver class
+
+#include __DRIVER_INCLUDE__
+#include "SimpleParser.h"
+
+#ifdef _WIN32
+#define WINDOWS
+#endif
+
+#ifdef WINDOWS
+#include
+#else
+#include
+#include
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+
+/*** defines for UDP *****/
+#define UDP_MSGLEN 1000
+#define UDP_CLIENT_TIMEUOT 1000000
+//#define __UDP_CLIENT_VERBOSE__
+
+#ifdef WINDOWS
+typedef sockaddr_in tSockAddrIn;
+#define CLOSE(x) closesocket(x)
+#define INVALID(x) x == INVALID_SOCKET
+#else
+typedef int SOCKET;
+typedef struct sockaddr_in tSockAddrIn;
+#define CLOSE(x) close(x)
+#define INVALID(x) x < 0
+#endif
+
+class __DRIVER_CLASS__;
+typedef __DRIVER_CLASS__ tDriver;
+
+void parse_args(int argc, char *argv[], std::string &hostName, unsigned int &serverPort, std::string &id, unsigned int &maxEpisodes,
+ unsigned int &maxSteps, std::string &trackName, BaseDriver::tstage &stage, std::string &fclFile)
+{
+ // Set default values
+ hostName = "localhost";
+ serverPort = 3001;
+ id = "SCR_Fuzzy";
+ trackName = "unknown";
+ maxEpisodes = 0;
+ maxSteps = 0;
+ stage = BaseDriver::UNKNOWN;
+ fclFile = "driver.fcl";
+
+ std::vector args(argv, argv + argc);
+
+ int i = 1;
+ while (i < argc)
+ {
+ if (args[i].find("host:") == 0)
+ hostName = args[i].substr(5);
+
+ else if (args[i].find("port:") == 0)
+ serverPort = std::stoi(args[i].substr(5));
+
+ else if (args[i].find("id:") == 0)
+ id = args[i].substr(3);
+
+ else if (args[i].find("maxEpisodes:") == 0)
+ maxEpisodes = std::stoi(args[i].substr(12));
+
+ else if (args[i].find("maxSteps:") == 0)
+ maxSteps = std::stoi(args[i].substr(9));
+
+ else if (args[i].find("track:") == 0)
+ trackName = args[i].substr(6);
+
+ else if (args[i].find("stage:") == 0)
+ {
+ stage = static_cast(std::stoi(args[i].substr(6)));
+
+ if (stage BaseDriver::RACE)
+ stage = BaseDriver::UNKNOWN;
+ }
+
+ else if (args[i].find("fcl:") == 0)
+ fclFile = args[i].substr(4);
+
+ i++;
+ }
+}
+
+
+int main(int argc, char *argv[])
+{
+ // ---------------------------- config init ----------------------------
+
+ std::string hostName;
+ unsigned int serverPort;
+ std::string id;
+ unsigned int maxEpisodes;
+ unsigned int maxSteps;
+ std::string trackName;
+ BaseDriver::tstage stage;
+ std::string fclFile;
+
+ parse_args(argc, argv, hostName, serverPort, id, maxEpisodes, maxSteps, trackName, stage, fclFile);
+
+ std::cout << "Config:" << std::endl;
+
+ std::cout << "\thost: " << hostName << std::endl;
+ std::cout << "\tport: " << serverPort << std::endl;
+ std::cout << "\tid: " << id << std::endl;
+ std::cout << "\tmax steps: " << maxSteps << std::endl;
+ std::cout << "\tmax episodes: " << maxEpisodes << std::endl;
+ std::cout << "\ttrack name: " << trackName << std::endl;
+ std::cout << "\tstage: ";
+
+ if (stage == BaseDriver::WARMUP)
+ std::cout << "warm-up" << std::endl;
+ else if (stage == BaseDriver::QUALIFYING)
+ std::cout << "qualifying" << std::endl;
+ else if (stage == BaseDriver::RACE)
+ std::cout << "race" << std::endl;
+ else
+ std::cout << "unknown" << std::endl;
+
+ std::cout << "\tfcl file: " << fclFile << std::endl << std::endl;
+
+ // ---------------------------- socket init ----------------------------
+
+ SOCKET socketDescriptor;
+ int numRead;
+
+ tSockAddrIn serverAddress;
+ struct hostent *hostInfo;
+ struct timeval timeVal;
+ fd_set readSet;
+ char buf[UDP_MSGLEN];
+
+
+#ifdef WINDOWS
+ /* WinSock startup */
+
+ WSADATA wsaData = { 0 };
+ WORD wVer = MAKEWORD(2, 2);
+ int nRet = WSAStartup(wVer, &wsaData);
+
+ if (nRet == SOCKET_ERROR)
+ {
+ std::cerr << "Failed to init WinSock library" << std::endl;
+ exit(1);
+ }
+#endif
+
+ hostInfo = gethostbyname(hostName.c_str());
+ if (hostInfo == NULL)
+ {
+ std::cerr << "Problem interpreting host: " << hostName << std::endl;
+ exit(1);
+ }
+
+ // Create a socket (UDP on IPv4 protocol)
+ socketDescriptor = socket(AF_INET, SOCK_DGRAM, 0);
+ if (INVALID(socketDescriptor))
+ {
+ std::cerr << "Cannot create socket" << std::endl;
+ exit(1);
+ }
+
+ // Set some fields in the serverAddress structure.
+ serverAddress.sin_family = hostInfo->h_addrtype;
+ memcpy((char *)&serverAddress.sin_addr.s_addr,
+ hostInfo->h_addr_list[0], hostInfo->h_length);
+ serverAddress.sin_port = htons(serverPort);
+
+ // ---------------------------- driver init ----------------------------
+
+ tDriver d(trackName, stage, fclFile);
+
+ if (!d.loadFCLfile())
+ {
+ std::cerr << "Cannot load FCL file" << std::endl;
+ exit(1);
+ }
+
+ bool shutdownClient = false;
+ unsigned long curEpisode = 0;
+
+ // -------------------------- UDP client loop --------------------------
+
+ do
+ {
+ // Initialising driver on the server
+
+ do
+ {
+ // Set angles of rangefinders
+ float angles[19];
+ d.init(angles);
+ std::string initString = SimpleParser::stringify(std::string("init"), angles, 19);
+ initString.insert(0, id);
+
+ std::cout << "Sending init: " << initString << std::endl;
+
+ if (sendto(socketDescriptor, initString.c_str(), (int)initString.length(), 0,
+ (struct sockaddr *) &serverAddress,
+ sizeof(serverAddress)) < 0)
+ {
+ std::cerr << "Cannot send data" << std::endl;
+ CLOSE(socketDescriptor);
+ exit(1);
+ }
+
+ // Wait until answer comes back, for up to UDP_CLIENT_TIMEUOT micro sec
+ FD_ZERO(&readSet);
+ FD_SET(socketDescriptor, &readSet);
+ timeVal.tv_sec = 0;
+ timeVal.tv_usec = UDP_CLIENT_TIMEUOT;
+
+ if (select((int)(socketDescriptor + 1), &readSet, NULL, NULL, &timeVal))
+ {
+ // Read data sent by the solorace server
+ memset(buf, 0x0, UDP_MSGLEN); // Zero out the buffer.
+ numRead = recv(socketDescriptor, buf, UDP_MSGLEN, 0);
+ if (numRead < 0)
+ {
+ std::cerr << "Didn't get response from server. Reconnecting..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+ else
+ {
+ if (std::string(buf) == "***identified***")
+ {
+ std::cout << "Driver identified" << std::endl;
+ break;
+ }
+ else
+ std::cout << "Received: " << buf << std::endl;
+ }
+ }
+
+ } while (true);
+
+ unsigned long currentStep = 0;
+
+ // Controlling the driver
+
+ while (true)
+ {
+ // Wait until answer comes back, for up to UDP_CLIENT_TIMEUOT micro sec
+ FD_ZERO(&readSet);
+ FD_SET(socketDescriptor, &readSet);
+ timeVal.tv_sec = 0;
+ timeVal.tv_usec = UDP_CLIENT_TIMEUOT;
+
+ if (select((int)(socketDescriptor + 1), &readSet, NULL, NULL, &timeVal))
+ {
+ // Read data sent by the solorace server
+ memset(buf, 0x0, UDP_MSGLEN);
+ numRead = recv(socketDescriptor, buf, UDP_MSGLEN, 0);
+ if (numRead < 0)
+ {
+ std::cerr << "Didn't get response from server?" << std::endl;
+ CLOSE(socketDescriptor);
+ exit(1);
+ }
+
+#ifdef __UDP_CLIENT_VERBOSE__
+ std::cout << "Received: " << buf << std::endl;
+#endif
+
+ if (std::string(buf) == "***shutdown***")
+ {
+ std::cout << std::endl << "Client shutdown" << std::endl;
+
+ d.onShutdown();
+ shutdownClient = true;
+ break;
+ }
+
+ if (std::string(buf) == "***restart***")
+ {
+ std::cout << std::endl << "Client restart" << std::endl;
+
+ d.onRestart();
+ break;
+ }
+
+ // Compute The Action to send to the solorace sever
+
+ if ((++currentStep) != maxSteps)
+ {
+ std::string action = d.drive(std::string(buf));
+ memset(buf, 0x0, UDP_MSGLEN);
+ snprintf(buf, UDP_MSGLEN, "%s", action.c_str());
+ }
+ else
+ {
+ memset(buf, 0x0, UDP_MSGLEN);
+ snprintf(buf, UDP_MSGLEN, "(meta 1)");
+ }
+
+ if (sendto(socketDescriptor, buf, (int)(strlen(buf) + 1), 0,
+ (struct sockaddr *) &serverAddress,
+ sizeof(serverAddress)) < 0)
+ {
+ std::cerr << "Cannot send data" << std::endl;
+ CLOSE(socketDescriptor);
+ exit(1);
+ }
+#ifdef __UDP_CLIENT_VERBOSE__
+ else
+ std::cout << "Sending " << buf << std::endl;
+#endif
+ }
+ else
+ {
+ //std::cout << "* Server did not respond in 1 second" << std::endl;
+ }
+ }
+ } while (shutdownClient == false && ((++curEpisode) != maxEpisodes));
+
+ if (shutdownClient == false)
+ d.onShutdown();
+
+ CLOSE(socketDescriptor);
+#ifdef WINDOWS
+ WSACleanup();
+#endif
+
+ return 0;
+}
diff --git a/torcs-client-fuzzy-cpp.sln b/torcs-client-fuzzy-cpp.sln
new file mode 100644
index 0000000..adae92d
--- /dev/null
+++ b/torcs-client-fuzzy-cpp.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.24720.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torcs-client-fuzzy-cpp", "torcs-client-fuzzy-cpp.vcxproj", "{69B2FF12-E604-4018-8390-3DB2C5B360CD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Debug|x64.ActiveCfg = Debug|x64
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Debug|x64.Build.0 = Debug|x64
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Debug|x86.ActiveCfg = Debug|Win32
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Debug|x86.Build.0 = Debug|Win32
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Release|x64.ActiveCfg = Release|x64
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Release|x64.Build.0 = Release|x64
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Release|x86.ActiveCfg = Release|Win32
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/torcs-client-fuzzy-cpp.vcxproj b/torcs-client-fuzzy-cpp.vcxproj
new file mode 100644
index 0000000..81ebd4a
--- /dev/null
+++ b/torcs-client-fuzzy-cpp.vcxproj
@@ -0,0 +1,185 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {69B2FF12-E604-4018-8390-3DB2C5B360CD}
+ Win32Proj
+ TorcsClientFuzzy
+ 8.1
+ torcs-client-fuzzy-cpp
+
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ torcs-client-fuzzy
+ $(Platform)\$(Configuration)\
+ $(SolutionDir)$(Platform)\$(Configuration)\
+
+
+ true
+ torcs-client-fuzzy
+
+
+ false
+ torcs-client-fuzzy
+ $(SolutionDir)$(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+
+
+ false
+ torcs-client-fuzzy
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)dep\;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ WS2_32.lib;Dbghelp.lib;fuzzylite-51-x86-staticd.lib;%(AdditionalDependencies)
+ $(SolutionDir)dep\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)dep\;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ WS2_32.lib;Dbghelp.lib;fuzzylite-51-x64-staticd.lib;%(AdditionalDependencies)
+ $(SolutionDir)dep\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)dep\;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)dep\lib;%(AdditionalLibraryDirectories)
+ WS2_32.lib;fuzzylite-51-x86-static.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)dep\;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+ WS2_32.lib;fuzzylite-51-x64-static.lib;%(AdditionalDependencies)
+ $(SolutionDir)dep\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/torcs-client-fuzzy-cpp.vcxproj.filters b/torcs-client-fuzzy-cpp.vcxproj.filters
new file mode 100644
index 0000000..0af0caf
--- /dev/null
+++ b/torcs-client-fuzzy-cpp.vcxproj.filters
@@ -0,0 +1,60 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
\ No newline at end of file