diff options
author | Johannes 'josch' Schauer <josch@debian.org> | 2019-01-27 13:56:24 +0100 |
---|---|---|
committer | Johannes 'josch' Schauer <josch@debian.org> | 2019-01-27 13:56:33 +0100 |
commit | 6ce553563bc795f389f639a3a8cdfe356de71441 (patch) | |
tree | da4c9ede3087ca534d93bc1ac5a14f044f036600 /fuzzylite/src/norm/s | |
parent | bbefa170378553e5a6e0d72e4d52328b61f3e8ac (diff) |
new upstream version 6.0
Diffstat (limited to 'fuzzylite/src/norm/s')
-rw-r--r-- | fuzzylite/src/norm/s/AlgebraicSum.cpp | 26 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/BoundedSum.cpp | 28 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/DrasticSum.cpp | 28 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/EinsteinSum.cpp | 26 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/HamacherSum.cpp | 29 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/Maximum.cpp | 28 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/NilpotentMaximum.cpp | 32 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/NormalizedSum.cpp | 31 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/SNormFunction.cpp | 65 | ||||
-rw-r--r-- | fuzzylite/src/norm/s/UnboundedSum.cpp | 43 |
10 files changed, 211 insertions, 125 deletions
diff --git a/fuzzylite/src/norm/s/AlgebraicSum.cpp b/fuzzylite/src/norm/s/AlgebraicSum.cpp index e96c1a7..0497f23 100644 --- a/fuzzylite/src/norm/s/AlgebraicSum.cpp +++ b/fuzzylite/src/norm/s/AlgebraicSum.cpp @@ -1,25 +1,17 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/AlgebraicSum.h" @@ -30,6 +22,10 @@ namespace fl { return "AlgebraicSum"; } + Complexity AlgebraicSum::complexity() const { + return Complexity().arithmetic(3); + } + scalar AlgebraicSum::compute(scalar a, scalar b) const { return a + b - (a * b); } diff --git a/fuzzylite/src/norm/s/BoundedSum.cpp b/fuzzylite/src/norm/s/BoundedSum.cpp index 9c050c8..b1cb42b 100644 --- a/fuzzylite/src/norm/s/BoundedSum.cpp +++ b/fuzzylite/src/norm/s/BoundedSum.cpp @@ -1,35 +1,33 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/BoundedSum.h" +#include "fl/Operation.h" + namespace fl { std::string BoundedSum::className() const { return "BoundedSum"; } + Complexity BoundedSum::complexity() const { + return Complexity().arithmetic(1).function(1); + } + scalar BoundedSum::compute(scalar a, scalar b) const { return Op::min(scalar(1.0), a + b); } diff --git a/fuzzylite/src/norm/s/DrasticSum.cpp b/fuzzylite/src/norm/s/DrasticSum.cpp index c0629db..b0d9f1e 100644 --- a/fuzzylite/src/norm/s/DrasticSum.cpp +++ b/fuzzylite/src/norm/s/DrasticSum.cpp @@ -1,35 +1,33 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/DrasticSum.h" +#include "fl/Operation.h" + namespace fl { std::string DrasticSum::className() const { return "DrasticSum"; } + Complexity DrasticSum::complexity() const { + return Complexity().comparison(1).function(2); + } + scalar DrasticSum::compute(scalar a, scalar b) const { if (Op::isEq(Op::min(a, b), 0.0)) { return Op::max(a, b); diff --git a/fuzzylite/src/norm/s/EinsteinSum.cpp b/fuzzylite/src/norm/s/EinsteinSum.cpp index ec0fbd8..a638c7b 100644 --- a/fuzzylite/src/norm/s/EinsteinSum.cpp +++ b/fuzzylite/src/norm/s/EinsteinSum.cpp @@ -1,25 +1,17 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/EinsteinSum.h" @@ -30,6 +22,10 @@ namespace fl { return "EinsteinSum"; } + Complexity EinsteinSum::complexity() const { + return Complexity().arithmetic(4); + } + scalar EinsteinSum::compute(scalar a, scalar b) const { return (a + b) / (1.0 + a * b); } diff --git a/fuzzylite/src/norm/s/HamacherSum.cpp b/fuzzylite/src/norm/s/HamacherSum.cpp index f9c0994..41242ee 100644 --- a/fuzzylite/src/norm/s/HamacherSum.cpp +++ b/fuzzylite/src/norm/s/HamacherSum.cpp @@ -1,36 +1,35 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/HamacherSum.h" +#include "fl/Operation.h" + namespace fl { std::string HamacherSum::className() const { return "HamacherSum"; } + Complexity HamacherSum::complexity() const { + return Complexity().arithmetic(7); + } + scalar HamacherSum::compute(scalar a, scalar b) const { + if (Op::isEq(a * b, 1.0)) return 1.0; return (a + b - 2.0 * a * b) / (1.0 - a * b); } diff --git a/fuzzylite/src/norm/s/Maximum.cpp b/fuzzylite/src/norm/s/Maximum.cpp index ed8a839..5277d49 100644 --- a/fuzzylite/src/norm/s/Maximum.cpp +++ b/fuzzylite/src/norm/s/Maximum.cpp @@ -1,35 +1,33 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/Maximum.h" +#include "fl/Operation.h" + namespace fl { std::string Maximum::className() const { return "Maximum"; } + Complexity Maximum::complexity() const { + return Complexity().function(1); + } + scalar Maximum::compute(scalar a, scalar b) const { return Op::max(a, b); } diff --git a/fuzzylite/src/norm/s/NilpotentMaximum.cpp b/fuzzylite/src/norm/s/NilpotentMaximum.cpp index 0a09136..7c63999 100644 --- a/fuzzylite/src/norm/s/NilpotentMaximum.cpp +++ b/fuzzylite/src/norm/s/NilpotentMaximum.cpp @@ -1,38 +1,36 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/NilpotentMaximum.h" +#include "fl/Operation.h" + namespace fl { std::string NilpotentMaximum::className() const { return "NilpotentMaximum"; } + Complexity NilpotentMaximum::complexity() const { + return Complexity().comparison(1).arithmetic(1).function(1); + } + scalar NilpotentMaximum::compute(scalar a, scalar b) const { if (Op::isLt(a + b, 1.0)) { - return std::max(a, b); + return Op::max(a, b); } return 1.0; } @@ -45,6 +43,4 @@ namespace fl { return new NilpotentMaximum; } - } - diff --git a/fuzzylite/src/norm/s/NormalizedSum.cpp b/fuzzylite/src/norm/s/NormalizedSum.cpp index 94ad5ea..c420ed1 100644 --- a/fuzzylite/src/norm/s/NormalizedSum.cpp +++ b/fuzzylite/src/norm/s/NormalizedSum.cpp @@ -1,37 +1,35 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzylite™ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #include "fl/norm/s/NormalizedSum.h" +#include "fl/Operation.h" + namespace fl { std::string NormalizedSum::className() const { return "NormalizedSum"; } + Complexity NormalizedSum::complexity() const { + return Complexity().arithmetic(3).function(1); + } + scalar NormalizedSum::compute(scalar a, scalar b) const { - return a + b / Op::max(scalar(1.0), Op::max(a, b)); + return (a + b) / Op::max(scalar(1.0), a + b); } NormalizedSum* NormalizedSum::clone() const { @@ -42,5 +40,4 @@ namespace fl { return new NormalizedSum; } - } diff --git a/fuzzylite/src/norm/s/SNormFunction.cpp b/fuzzylite/src/norm/s/SNormFunction.cpp new file mode 100644 index 0000000..f8d9e42 --- /dev/null +++ b/fuzzylite/src/norm/s/SNormFunction.cpp @@ -0,0 +1,65 @@ +/* + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> + + This file is part of fuzzylite. + + fuzzylite is free software: you can redistribute it and/or modify it under + the terms of the FuzzyLite License included with the software. + + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + + fuzzylite is a registered trademark of FuzzyLite Limited. + */ + +#include "fl/norm/s/SNormFunction.h" + +namespace fl { + + SNormFunction::SNormFunction(const std::string& formula) : SNorm() { + _function.variables["a"] = fl::nan; + _function.variables["b"] = fl::nan; + if (not formula.empty()) { + _function.load(formula); + } + } + + std::string SNormFunction::className() const { + return "SNormFunction"; + } + + Complexity SNormFunction::complexity() const { + if (_function.root()) + return _function.complexity().function(2 * std::log(scalar(_function.variables.size()))); + return _function.complexity(); + } + + scalar SNormFunction::compute(scalar a, scalar b) const { + _function.variables["a"] = a; + _function.variables["b"] = b; + return _function.evaluate(); + } + + Function& SNormFunction::function() { + return this->_function; + } + + void SNormFunction::setFormula(const std::string& formula) { + this->_function.load(formula); + } + + std::string SNormFunction::getFormula() const { + return _function.getFormula(); + } + + SNormFunction* SNormFunction::clone() const { + return new SNormFunction(*this); + } + + SNorm* SNormFunction::constructor() { + return new SNormFunction; + } + +} diff --git a/fuzzylite/src/norm/s/UnboundedSum.cpp b/fuzzylite/src/norm/s/UnboundedSum.cpp new file mode 100644 index 0000000..adee6ad --- /dev/null +++ b/fuzzylite/src/norm/s/UnboundedSum.cpp @@ -0,0 +1,43 @@ +/* + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> + + This file is part of fuzzylite. + + fuzzylite is free software: you can redistribute it and/or modify it under + the terms of the FuzzyLite License included with the software. + + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + + fuzzylite is a registered trademark of FuzzyLite Limited. + */ + +#include "fl/norm/s/UnboundedSum.h" + +#include "fl/Operation.h" + +namespace fl { + + std::string UnboundedSum::className() const { + return "UnboundedSum"; + } + + Complexity UnboundedSum::complexity() const { + return Complexity().arithmetic(1); + } + + scalar UnboundedSum::compute(scalar a, scalar b) const { + return a + b; + } + + UnboundedSum* UnboundedSum::clone() const { + return new UnboundedSum(*this); + } + + SNorm* UnboundedSum::constructor() { + return new UnboundedSum; + } + +} |