1 /* 2 fuzzylite (R), a fuzzy logic control library in C++. 3 Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. 4 Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> 5 6 This file is part of fuzzylite. 7 8 fuzzylite is free software: you can redistribute it and/or modify it under 9 the terms of the FuzzyLite License included with the software. 10 11 You should have received a copy of the FuzzyLite License along with 12 fuzzylite. If not, see <http://www.fuzzylite.com/license/>. 13 14 fuzzylite is a registered trademark of FuzzyLite Limited. 15 */ 16 17 #ifndef FL_BELL_H 18 #define FL_BELL_H 19 20 #include "fl/term/Term.h" 21 22 namespace fl { 23 24 /** 25 The Bell class is an extended Term that represents the generalized bell 26 curve membership function. 27 28 @image html bell.svg 29 30 @author Juan Rada-Vilela, Ph.D. 31 @see Term 32 @see Variable 33 @since 4.0 34 */ 35 class FL_API Bell : public Term { 36 private: 37 scalar _center; 38 scalar _width; 39 scalar _slope; 40 public: 41 explicit Bell(const std::string& name = "", 42 scalar center = fl::nan, 43 scalar width = fl::nan, 44 scalar slope = fl::nan, 45 scalar height = 1.0); 46 virtual ~Bell() FL_IOVERRIDE; 47 FL_DEFAULT_COPY_AND_MOVE(Bell) 48 49 virtual std::string className() const FL_IOVERRIDE; 50 /** 51 Returns the parameters of the term 52 @return `"center width slope [height]"` 53 */ 54 virtual std::string parameters() const FL_IOVERRIDE; 55 /** 56 Configures the term with the parameters 57 @param parameters as `"center width slope [height]"` 58 */ 59 virtual void configure(const std::string& parameters) FL_IOVERRIDE; 60 61 virtual Complexity complexity() const FL_IOVERRIDE; 62 63 /** 64 Computes the membership function evaluated at @f$x@f$ 65 @param x 66 @return @f$h / (1 + \left(|x-c|/w\right)^{2s}@f$ 67 68 where @f$h@f$ is the height of the Term, 69 @f$c@f$ is the center of the Bell, 70 @f$w@f$ is the width of the Bell, 71 @f$s@f$ is the slope of the Bell 72 */ 73 virtual scalar membership(scalar x) const FL_IOVERRIDE; 74 75 /** 76 Sets the center of the bell curve 77 @param center is the center of the bell curve 78 */ 79 virtual void setCenter(scalar center); 80 /** 81 Gets the center of the bell curve 82 @return the center of the bell curve 83 */ 84 virtual scalar getCenter() const; 85 86 /** 87 Sets the width of the bell curve 88 @param width is the width of the bell curve 89 */ 90 virtual void setWidth(scalar width); 91 /** 92 Gets the width of the bell curve 93 @return the width of the bell curve 94 */ 95 virtual scalar getWidth() const; 96 97 /** 98 Sets the slope of the bell curve 99 @param slope is the slope of the bell curve 100 */ 101 virtual void setSlope(scalar slope); 102 /** 103 Gets the slope of the bell curve 104 @return the slope of the bell curve 105 */ 106 virtual scalar getSlope() const; 107 108 virtual Bell* clone() const FL_IOVERRIDE; 109 110 static Term* constructor(); 111 112 }; 113 } 114 #endif /* FL_BELL_H */ 115