summaryrefslogtreecommitdiff
path: root/fuzzylite/src/norm/t
diff options
context:
space:
mode:
authorJohannes 'josch' Schauer <josch@debian.org>2019-01-27 13:56:24 +0100
committerJohannes 'josch' Schauer <josch@debian.org>2019-01-27 13:56:33 +0100
commit6ce553563bc795f389f639a3a8cdfe356de71441 (patch)
treeda4c9ede3087ca534d93bc1ac5a14f044f036600 /fuzzylite/src/norm/t
parentbbefa170378553e5a6e0d72e4d52328b61f3e8ac (diff)
new upstream version 6.0
Diffstat (limited to 'fuzzylite/src/norm/t')
-rw-r--r--fuzzylite/src/norm/t/AlgebraicProduct.cpp26
-rw-r--r--fuzzylite/src/norm/t/BoundedDifference.cpp27
-rw-r--r--fuzzylite/src/norm/t/DrasticProduct.cpp28
-rw-r--r--fuzzylite/src/norm/t/EinsteinProduct.cpp26
-rw-r--r--fuzzylite/src/norm/t/HamacherProduct.cpp28
-rw-r--r--fuzzylite/src/norm/t/Minimum.cpp28
-rw-r--r--fuzzylite/src/norm/t/NilpotentMinimum.cpp29
-rw-r--r--fuzzylite/src/norm/t/TNormFunction.cpp66
8 files changed, 152 insertions, 106 deletions
diff --git a/fuzzylite/src/norm/t/AlgebraicProduct.cpp b/fuzzylite/src/norm/t/AlgebraicProduct.cpp
index eee1061..eefe309 100644
--- a/fuzzylite/src/norm/t/AlgebraicProduct.cpp
+++ b/fuzzylite/src/norm/t/AlgebraicProduct.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/t/AlgebraicProduct.h"
@@ -30,6 +22,10 @@ namespace fl {
return "AlgebraicProduct";
}
+ Complexity AlgebraicProduct::complexity() const {
+ return Complexity().arithmetic(1);
+ }
+
scalar AlgebraicProduct::compute(scalar a, scalar b) const {
return a * b;
}
diff --git a/fuzzylite/src/norm/t/BoundedDifference.cpp b/fuzzylite/src/norm/t/BoundedDifference.cpp
index aa4fead..3775aa4 100644
--- a/fuzzylite/src/norm/t/BoundedDifference.cpp
+++ b/fuzzylite/src/norm/t/BoundedDifference.cpp
@@ -1,29 +1,22 @@
/*
- 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/t/BoundedDifference.h"
+#include "fl/Operation.h"
namespace fl {
@@ -31,6 +24,10 @@ namespace fl {
return "BoundedDifference";
}
+ Complexity BoundedDifference::complexity() const {
+ return Complexity().arithmetic(2).function(1);
+ }
+
scalar BoundedDifference::compute(scalar a, scalar b) const {
return Op::max(scalar(0.0), a + b - scalar(1.0));
}
diff --git a/fuzzylite/src/norm/t/DrasticProduct.cpp b/fuzzylite/src/norm/t/DrasticProduct.cpp
index 124b79d..5bfdc87 100644
--- a/fuzzylite/src/norm/t/DrasticProduct.cpp
+++ b/fuzzylite/src/norm/t/DrasticProduct.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/t/DrasticProduct.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string DrasticProduct::className() const {
return "DrasticProduct";
}
+ Complexity DrasticProduct::complexity() const {
+ return Complexity().comparison(1).function(2);
+ }
+
scalar DrasticProduct::compute(scalar a, scalar b) const {
if (Op::isEq(Op::max(a, b), 1.0)) {
return Op::min(a, b);
diff --git a/fuzzylite/src/norm/t/EinsteinProduct.cpp b/fuzzylite/src/norm/t/EinsteinProduct.cpp
index ea79188..bbb3966 100644
--- a/fuzzylite/src/norm/t/EinsteinProduct.cpp
+++ b/fuzzylite/src/norm/t/EinsteinProduct.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/t/EinsteinProduct.h"
@@ -30,6 +22,10 @@ namespace fl {
return "EinsteinProduct";
}
+ Complexity EinsteinProduct::complexity() const {
+ return Complexity().arithmetic(6);
+ }
+
scalar EinsteinProduct::compute(scalar a, scalar b) const {
return (a * b) / (2.0 - (a + b - a * b));
}
diff --git a/fuzzylite/src/norm/t/HamacherProduct.cpp b/fuzzylite/src/norm/t/HamacherProduct.cpp
index e3f093e..9416084 100644
--- a/fuzzylite/src/norm/t/HamacherProduct.cpp
+++ b/fuzzylite/src/norm/t/HamacherProduct.cpp
@@ -1,29 +1,22 @@
/*
- 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/t/HamacherProduct.h"
+#include "fl/Operation.h"
namespace fl {
@@ -31,7 +24,12 @@ namespace fl {
return "HamacherProduct";
}
+ Complexity HamacherProduct::complexity() const {
+ return Complexity().arithmetic(5);
+ }
+
scalar HamacherProduct::compute(scalar a, scalar b) const {
+ if (Op::isEq(a + b, 0.0)) return 0.0;
return (a * b) / (a + b - a * b);
}
diff --git a/fuzzylite/src/norm/t/Minimum.cpp b/fuzzylite/src/norm/t/Minimum.cpp
index 34f348f..1a63658 100644
--- a/fuzzylite/src/norm/t/Minimum.cpp
+++ b/fuzzylite/src/norm/t/Minimum.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/t/Minimum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string Minimum::className() const {
return "Minimum";
}
+ Complexity Minimum::complexity() const {
+ return Complexity().function(1);
+ }
+
scalar Minimum::compute(scalar a, scalar b) const {
return Op::min(a, b);
}
diff --git a/fuzzylite/src/norm/t/NilpotentMinimum.cpp b/fuzzylite/src/norm/t/NilpotentMinimum.cpp
index b52a2fc..7ab906b 100644
--- a/fuzzylite/src/norm/t/NilpotentMinimum.cpp
+++ b/fuzzylite/src/norm/t/NilpotentMinimum.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/t/NilpotentMinimum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string NilpotentMinimum::className() const {
return "NilpotentMinimum";
}
+ Complexity NilpotentMinimum::complexity() const {
+ return Complexity().comparison(1).arithmetic(1).function(1);
+ }
+
scalar NilpotentMinimum::compute(scalar a, scalar b) const {
if (Op::isGt(a + b, 1.0)) {
return Op::min(a, b);
@@ -47,4 +45,3 @@ namespace fl {
}
-
diff --git a/fuzzylite/src/norm/t/TNormFunction.cpp b/fuzzylite/src/norm/t/TNormFunction.cpp
new file mode 100644
index 0000000..1e0563e
--- /dev/null
+++ b/fuzzylite/src/norm/t/TNormFunction.cpp
@@ -0,0 +1,66 @@
+/*
+ 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/t/TNormFunction.h"
+
+namespace fl {
+
+ TNormFunction::TNormFunction(const std::string& formula) : TNorm() {
+ _function.variables["a"] = fl::nan;
+ _function.variables["b"] = fl::nan;
+ if (not formula.empty()) {
+ _function.load(formula);
+ }
+ }
+
+ std::string TNormFunction::className() const {
+ return "TNormFunction";
+ }
+
+ Complexity TNormFunction::complexity() const {
+ if (_function.root())
+ return _function.complexity().function(2 * std::log(scalar(_function.variables.size())));
+ return _function.complexity();
+ }
+
+ scalar TNormFunction::compute(scalar a, scalar b) const {
+ _function.variables["a"] = a;
+ _function.variables["b"] = b;
+ return _function.evaluate();
+ }
+
+ Function& TNormFunction::function() {
+ return this->_function;
+ }
+
+ void TNormFunction::setFormula(const std::string& formula) {
+ this->_function.load(formula);
+ }
+
+ std::string TNormFunction::getFormula() const {
+ return _function.getFormula();
+ }
+
+ TNormFunction* TNormFunction::clone() const {
+ return new TNormFunction(*this);
+ }
+
+ TNorm* TNormFunction::constructor() {
+ return new TNormFunction;
+ }
+
+
+}