summaryrefslogtreecommitdiff
path: root/fuzzylite/src/hedge
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/hedge
parentbbefa170378553e5a6e0d72e4d52328b61f3e8ac (diff)
new upstream version 6.0
Diffstat (limited to 'fuzzylite/src/hedge')
-rw-r--r--fuzzylite/src/hedge/Any.cpp35
-rw-r--r--fuzzylite/src/hedge/Extremely.cpp30
-rw-r--r--fuzzylite/src/hedge/HedgeFunction.cpp63
-rw-r--r--fuzzylite/src/hedge/Not.cpp27
-rw-r--r--fuzzylite/src/hedge/Seldom.cpp31
-rw-r--r--fuzzylite/src/hedge/Somewhat.cpp26
-rw-r--r--fuzzylite/src/hedge/Very.cpp26
7 files changed, 137 insertions, 101 deletions
diff --git a/fuzzylite/src/hedge/Any.cpp b/fuzzylite/src/hedge/Any.cpp
index 72724f1..9d04262 100644
--- a/fuzzylite/src/hedge/Any.cpp
+++ b/fuzzylite/src/hedge/Any.cpp
@@ -1,43 +1,37 @@
/*
- 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/hedge/Any.h"
namespace fl {
- Any::Any() {
- }
+ Any::Any() { }
- Any::~Any() {
- }
+ Any::~Any() { }
std::string Any::name() const {
return "any";
}
+ Complexity Any::complexity() const {
+ return Complexity();
+ }
+
scalar Any::hedge(scalar x) const {
- (void) x;
+ FL_IUNUSED(x);
return 1.0;
}
@@ -50,3 +44,4 @@ namespace fl {
}
}
+
diff --git a/fuzzylite/src/hedge/Extremely.cpp b/fuzzylite/src/hedge/Extremely.cpp
index eabbb60..60d3abd 100644
--- a/fuzzylite/src/hedge/Extremely.cpp
+++ b/fuzzylite/src/hedge/Extremely.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/hedge/Extremely.h"
@@ -32,10 +24,14 @@ namespace fl {
return "extremely";
}
+ Complexity Extremely::complexity() const {
+ return Complexity().comparison(1).arithmetic(5);
+ }
+
scalar Extremely::hedge(scalar x) const {
return Op::isLE(x, 0.5)
? 2.0 * x * x
- : 1.0 - 2.0 * (1.0 - x) * (1.0 - x);
+ : (1.0 - 2.0 * (1.0 - x) * (1.0 - x));
}
Extremely* Extremely::clone() const {
@@ -46,5 +42,5 @@ namespace fl {
return new Extremely;
}
-
}
+
diff --git a/fuzzylite/src/hedge/HedgeFunction.cpp b/fuzzylite/src/hedge/HedgeFunction.cpp
new file mode 100644
index 0000000..c31c72c
--- /dev/null
+++ b/fuzzylite/src/hedge/HedgeFunction.cpp
@@ -0,0 +1,63 @@
+/*
+ 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/hedge/HedgeFunction.h"
+
+namespace fl {
+
+ HedgeFunction::HedgeFunction(const std::string& formula) : Hedge() {
+ _function.variables["x"] = fl::nan;
+ if (not formula.empty()) {
+ _function.load(formula);
+ }
+ }
+
+ std::string HedgeFunction::name() const {
+ return "HedgeFunction";
+ }
+
+ Complexity HedgeFunction::complexity() const {
+ if (_function.root())
+ return _function.complexity().function(2 * std::log(scalar(_function.variables.size())));
+ return _function.complexity();
+ }
+
+ scalar HedgeFunction::hedge(scalar x) const {
+ _function.variables["x"] = x;
+ return _function.membership(x);
+ }
+
+ Function& HedgeFunction::function() {
+ return this->_function;
+ }
+
+ void HedgeFunction::setFormula(const std::string& formula) {
+ _function.load(formula);
+ }
+
+ std::string HedgeFunction::getFormula() const {
+ return _function.getFormula();
+ }
+
+ HedgeFunction* HedgeFunction::clone() const {
+ return new HedgeFunction(*this);
+ }
+
+ Hedge* HedgeFunction::constructor() {
+ return new HedgeFunction;
+ }
+
+}
diff --git a/fuzzylite/src/hedge/Not.cpp b/fuzzylite/src/hedge/Not.cpp
index 531213f..defbabd 100644
--- a/fuzzylite/src/hedge/Not.cpp
+++ b/fuzzylite/src/hedge/Not.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/hedge/Not.h"
@@ -30,6 +22,10 @@ namespace fl {
return "not";
}
+ Complexity Not::complexity() const {
+ return Complexity().arithmetic(1);
+ }
+
scalar Not::hedge(scalar x) const {
return 1.0 - x;
}
@@ -42,5 +38,4 @@ namespace fl {
return new Not;
}
-
}
diff --git a/fuzzylite/src/hedge/Seldom.cpp b/fuzzylite/src/hedge/Seldom.cpp
index d87b48a..092e873 100644
--- a/fuzzylite/src/hedge/Seldom.cpp
+++ b/fuzzylite/src/hedge/Seldom.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/hedge/Seldom.h"
@@ -32,10 +24,14 @@ namespace fl {
return "seldom";
}
+ Complexity Seldom::complexity() const {
+ return Complexity().comparison(1).function(1).arithmetic(3);
+ }
+
scalar Seldom::hedge(scalar x) const {
return Op::isLE(x, 0.5)
- ? std::sqrt(x / 2.0)
- : 1.0 - std::sqrt((1.0 - x) / 2.0);
+ ? std::sqrt(0.5 * x)
+ : (1.0 - std::sqrt(0.5 * (1.0 - x)));
}
Seldom* Seldom::clone() const {
@@ -46,5 +42,4 @@ namespace fl {
return new Seldom;
}
-
}
diff --git a/fuzzylite/src/hedge/Somewhat.cpp b/fuzzylite/src/hedge/Somewhat.cpp
index 16c371b..4d68c20 100644
--- a/fuzzylite/src/hedge/Somewhat.cpp
+++ b/fuzzylite/src/hedge/Somewhat.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/hedge/Somewhat.h"
@@ -30,6 +22,10 @@ namespace fl {
return "somewhat";
}
+ Complexity Somewhat::complexity() const {
+ return Complexity().function(1);
+ }
+
scalar Somewhat::hedge(scalar x) const {
return std::sqrt(x);
}
diff --git a/fuzzylite/src/hedge/Very.cpp b/fuzzylite/src/hedge/Very.cpp
index dc1fbec..5ac7a86 100644
--- a/fuzzylite/src/hedge/Very.cpp
+++ b/fuzzylite/src/hedge/Very.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/hedge/Very.h"
@@ -30,6 +22,10 @@ namespace fl {
return "very";
}
+ Complexity Very::complexity() const {
+ return Complexity().arithmetic(1);
+ }
+
scalar Very::hedge(scalar x) const {
return x * x;
}