From 0e8c1c9d31d15034b1ff1062c9bf0bfcdc849dd9 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Date: Tue, 7 Jul 2015 10:12:00 +0100 Subject: Import fuzzylite_5.1+dfsg.orig.tar.xz [dgit import orig fuzzylite_5.1+dfsg.orig.tar.xz] --- fuzzylite/fl/term/Accumulated.h | 94 +++++++++++++++++++ fuzzylite/fl/term/Activated.h | 65 +++++++++++++ fuzzylite/fl/term/Bell.h | 68 ++++++++++++++ fuzzylite/fl/term/Concave.h | 64 +++++++++++++ fuzzylite/fl/term/Constant.h | 58 ++++++++++++ fuzzylite/fl/term/Cosine.h | 62 ++++++++++++ fuzzylite/fl/term/Discrete.h | 81 ++++++++++++++++ fuzzylite/fl/term/Function.h | 171 ++++++++++++++++++++++++++++++++++ fuzzylite/fl/term/Gaussian.h | 63 +++++++++++++ fuzzylite/fl/term/GaussianProduct.h | 73 +++++++++++++++ fuzzylite/fl/term/Linear.h | 72 ++++++++++++++ fuzzylite/fl/term/PiShape.h | 74 +++++++++++++++ fuzzylite/fl/term/Ramp.h | 68 ++++++++++++++ fuzzylite/fl/term/Rectangle.h | 62 ++++++++++++ fuzzylite/fl/term/SShape.h | 64 +++++++++++++ fuzzylite/fl/term/Sigmoid.h | 68 ++++++++++++++ fuzzylite/fl/term/SigmoidDifference.h | 73 +++++++++++++++ fuzzylite/fl/term/SigmoidProduct.h | 73 +++++++++++++++ fuzzylite/fl/term/Spike.h | 62 ++++++++++++ fuzzylite/fl/term/Term.h | 71 ++++++++++++++ fuzzylite/fl/term/Trapezoid.h | 69 ++++++++++++++ fuzzylite/fl/term/Triangle.h | 68 ++++++++++++++ fuzzylite/fl/term/ZShape.h | 63 +++++++++++++ 23 files changed, 1686 insertions(+) create mode 100644 fuzzylite/fl/term/Accumulated.h create mode 100644 fuzzylite/fl/term/Activated.h create mode 100644 fuzzylite/fl/term/Bell.h create mode 100644 fuzzylite/fl/term/Concave.h create mode 100644 fuzzylite/fl/term/Constant.h create mode 100644 fuzzylite/fl/term/Cosine.h create mode 100644 fuzzylite/fl/term/Discrete.h create mode 100644 fuzzylite/fl/term/Function.h create mode 100644 fuzzylite/fl/term/Gaussian.h create mode 100644 fuzzylite/fl/term/GaussianProduct.h create mode 100644 fuzzylite/fl/term/Linear.h create mode 100644 fuzzylite/fl/term/PiShape.h create mode 100644 fuzzylite/fl/term/Ramp.h create mode 100644 fuzzylite/fl/term/Rectangle.h create mode 100644 fuzzylite/fl/term/SShape.h create mode 100644 fuzzylite/fl/term/Sigmoid.h create mode 100644 fuzzylite/fl/term/SigmoidDifference.h create mode 100644 fuzzylite/fl/term/SigmoidProduct.h create mode 100644 fuzzylite/fl/term/Spike.h create mode 100644 fuzzylite/fl/term/Term.h create mode 100644 fuzzylite/fl/term/Trapezoid.h create mode 100644 fuzzylite/fl/term/Triangle.h create mode 100644 fuzzylite/fl/term/ZShape.h (limited to 'fuzzylite/fl/term') diff --git a/fuzzylite/fl/term/Accumulated.h b/fuzzylite/fl/term/Accumulated.h new file mode 100644 index 0000000..51625d0 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Activated.h b/fuzzylite/fl/term/Activated.h new file mode 100644 index 0000000..10c1b40 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Bell.h b/fuzzylite/fl/term/Bell.h new file mode 100644 index 0000000..115479c --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Concave.h b/fuzzylite/fl/term/Concave.h new file mode 100644 index 0000000..b3aabe6 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Constant.h b/fuzzylite/fl/term/Constant.h new file mode 100644 index 0000000..c4ed17d --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Cosine.h b/fuzzylite/fl/term/Cosine.h new file mode 100644 index 0000000..510669f --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Discrete.h b/fuzzylite/fl/term/Discrete.h new file mode 100644 index 0000000..fc554b3 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Function.h b/fuzzylite/fl/term/Function.h new file mode 100644 index 0000000..99580b7 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Gaussian.h b/fuzzylite/fl/term/Gaussian.h new file mode 100644 index 0000000..a5b8055 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/GaussianProduct.h b/fuzzylite/fl/term/GaussianProduct.h new file mode 100644 index 0000000..bd1eaaa --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Linear.h b/fuzzylite/fl/term/Linear.h new file mode 100644 index 0000000..67ede04 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/PiShape.h b/fuzzylite/fl/term/PiShape.h new file mode 100644 index 0000000..a0c2f78 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Ramp.h b/fuzzylite/fl/term/Ramp.h new file mode 100644 index 0000000..63a683c --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Rectangle.h b/fuzzylite/fl/term/Rectangle.h new file mode 100644 index 0000000..23b5eda --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/SShape.h b/fuzzylite/fl/term/SShape.h new file mode 100644 index 0000000..0891357 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Sigmoid.h b/fuzzylite/fl/term/Sigmoid.h new file mode 100644 index 0000000..b37b1be --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/SigmoidDifference.h b/fuzzylite/fl/term/SigmoidDifference.h new file mode 100644 index 0000000..020f164 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/SigmoidProduct.h b/fuzzylite/fl/term/SigmoidProduct.h new file mode 100644 index 0000000..cb83f30 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Spike.h b/fuzzylite/fl/term/Spike.h new file mode 100644 index 0000000..7e520c9 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Term.h b/fuzzylite/fl/term/Term.h new file mode 100644 index 0000000..6c2b2b1 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Trapezoid.h b/fuzzylite/fl/term/Trapezoid.h new file mode 100644 index 0000000..f896997 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/Triangle.h b/fuzzylite/fl/term/Triangle.h new file mode 100644 index 0000000..9311687 --- /dev/null +++ b/fuzzylite/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/fuzzylite/fl/term/ZShape.h b/fuzzylite/fl/term/ZShape.h new file mode 100644 index 0000000..b53906e --- /dev/null +++ b/fuzzylite/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 */ + -- cgit v1.2.3