blob: 743c59f6118410f079cdf6222336f2e5fe71fefe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
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/defuzzifier/WeightedDefuzzifier.h"
#include "fl/term/Activated.h"
#include "fl/term/Concave.h"
#include "fl/term/Constant.h"
#include "fl/term/Function.h"
#include "fl/term/Linear.h"
#include "fl/term/Ramp.h"
#include "fl/term/Sigmoid.h"
#include "fl/term/SShape.h"
#include "fl/term/ZShape.h"
namespace fl {
WeightedDefuzzifier::WeightedDefuzzifier(Type type) : _type(type) { }
WeightedDefuzzifier::WeightedDefuzzifier(const std::string& type) {
if (type == "Automatic") setType(Automatic);
else if (type == "TakagiSugeno") setType(TakagiSugeno);
else if (type == "Tsukamoto") setType(Tsukamoto);
else {
setType(Automatic);
FL_LOG("[warning] incorrect type <" + type + "> of WeightedDefuzzifier"
+ " has been defaulted to <Automatic>");
}
}
WeightedDefuzzifier::~WeightedDefuzzifier() { }
std::string WeightedDefuzzifier::typeName(Type type) {
switch (type) {
case Automatic: return "Automatic";
case TakagiSugeno: return "TakagiSugeno";
case Tsukamoto: return "Tsukamoto";
default: return "";
}
}
void WeightedDefuzzifier::setType(Type type) {
this->_type = type;
}
WeightedDefuzzifier::Type WeightedDefuzzifier::getType() const {
return this->_type;
}
std::string WeightedDefuzzifier::getTypeName() const {
return typeName(getType());
}
WeightedDefuzzifier::Type WeightedDefuzzifier::inferType(const Term* term) const {
if (dynamic_cast<const Constant*> (term)
or dynamic_cast<const Linear*> (term)
or dynamic_cast<const Function*> (term)) {
return TakagiSugeno;
}
return Tsukamoto;
}
}
|