Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
fis.hpp
1
8
9#ifndef QLIBS_FIS
10#define QLIBS_FIS
11
12#include <include/qlibs_types.hpp>
13
17namespace qlibs {
18
22 namespace fis {
23
28
66
79 FIS_NUM_DEFUZZ
81 };
82
93
104
113
115 enum deFuzzState {
116 FIS_DEFUZZ_INIT,
117 FIS_DEFUZZ_COMPUTE,
118 FIS_DEFUZZ_END
119 };
121
123 class core;
124 class instance;
125 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
126 class system;
128
129 class ioBase {
130 protected:
132 real_t min{ -1.0_re };
133 real_t max{ 1.0_re };
134 real_t value{ 0.0_re };
136 public:
137 virtual ~ioBase() {};
138 ioBase() = default;
139 friend class instance;
140 friend class core;
141 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
142 friend class system;
143 };
144
149 class input : public ioBase {
150 public:
151 input() = default;
152 virtual ~input() {};
153 friend class instance;
154 friend class core;
155 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
156 friend class system;
157 };
158
163 class output : public ioBase {
164 private:
165 instance *owner{ nullptr };
166 real_t *xag{ nullptr };
167 real_t *yag{ nullptr };
168 real_t res{ 0.01_re };
169 real_t x{ 0.0_re };
170 real_t y{ 0.0_re };
171 real_t v[ 4 ] = { 0.0_re, 0.0_re, 0.0_re, 0.0_re };
172 inline void getNextX( const size_t i ) noexcept
173 {
174 x = min + ( ( static_cast<real_t>( i ) + 0.5_re )*res );
175 }
176 public:
177 output() = default;
178 virtual ~output() {};
179 bool storeAggregatedRegion( real_t *xData,
180 real_t *yData,
181 const size_t n ) noexcept;
182 template <size_t numberOfPoints>
183 bool storeAggregatedRegion( real_t (&xData)[ numberOfPoints ],
184 real_t (&yData)[ numberOfPoints ] ) noexcept
185 {
186 return storeAggregatedRegion( xData, yData, numberOfPoints );
187 }
188 friend class instance;
189 friend class core;
190 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
191 friend class system;
192 };
193
195 using mfFunction = real_t (*)( const ioBase * const in,
196 const real_t *p,
197 const size_t n );
199
200 class core {
201 protected:
203 enum defuzzMembers {
204 yMax = 0,
205 xSmallest = 1,
206 xLargest = 2 ,
207 sp = 3,
208 sum_xy = 0,
209 sum_y = 1,
210 halfArea = 2,
211 currentArea = 3,
212 sum_wz = 0,
213 sum_w = 1,
214 };
215 virtual ~core() {}
216 core() = default;
217 static real_t bound( real_t y,
218 const real_t minValue = 0.0_re,
219 const real_t maxValue= 1.0_re );
220 static real_t Min( const real_t a,
221 const real_t b );
222 static real_t Prod( const real_t a,
223 const real_t b );
224 static real_t Max( const real_t a,
225 const real_t b );
226 static real_t ProbOr( const real_t a,
227 const real_t b );
228 static real_t Sum( const real_t a,
229 const real_t b );
230
231 static real_t TriMF( const ioBase * const in,
232 const real_t *p,
233 const size_t n );
234 static real_t TrapMF( const ioBase * const in,
235 const real_t *p,
236 const size_t n );
237 static real_t GBellMF( const ioBase * const in,
238 const real_t *p,
239 const size_t n );
240 static real_t GaussMF( const ioBase * const in,
241 const real_t *p,
242 const size_t n );
243 static real_t Gauss2MF( const ioBase * const in,
244 const real_t *p,
245 const size_t n );
246 static real_t SigMF( const ioBase * const in,
247 const real_t *p,
248 const size_t n );
249 static real_t TSigMF( const ioBase * const in,
250 const real_t *p,
251 const size_t n );
252 static real_t DSigMF( const ioBase * const in,
253 const real_t *p,
254 const size_t n );
255 static real_t PSigMF( const ioBase * const in,
256 const real_t *p,
257 const size_t n );
258 static real_t SMF( const ioBase * const in,
259 const real_t *p,
260 const size_t n );
261 static real_t TSMF( const ioBase * const in,
262 const real_t *p,
263 const size_t n );
264 static real_t ZMF( const ioBase * const in,
265 const real_t *p,
266 const size_t n );
267 static real_t LinSMF( const ioBase * const in,
268 const real_t *p,
269 const size_t n );
270 static real_t LinZMF( const ioBase * const in,
271 const real_t *p,
272 const size_t n );
273 static real_t TZMF( const ioBase * const in,
274 const real_t *p,
275 const size_t n );
276 static real_t PiMF( const ioBase * const in,
277 const real_t *p,
278 const size_t n );
279 static real_t SingletonMF( const ioBase * const in,
280 const real_t *p,
281 const size_t n );
282 static real_t ConcaveMF( const ioBase * const in,
283 const real_t *p,
284 const size_t n );
285 static real_t TConcaveMF( const ioBase * const in,
286 const real_t *p,
287 const size_t n );
288 static real_t SpikeMF( const ioBase * const in,
289 const real_t *p,
290 const size_t n );
291 static real_t TLinSMF( const ioBase * const in,
292 const real_t *p,
293 const size_t n );
294 static real_t TLinZMF( const ioBase * const in,
295 const real_t *p,
296 const size_t n );
297 static real_t TRampMF( const ioBase * const in,
298 const real_t *p,
299 const size_t n );
300 static real_t RectangleMF( const ioBase * const in,
301 const real_t *p,
302 const size_t n );
303 static real_t CosineMF( const ioBase * const in,
304 const real_t *p,
305 const size_t n );
306 static real_t ConstantMF( const ioBase * const in,
307 const real_t *p,
308 const size_t n );
309 static real_t LinearMF( const ioBase * const in,
310 const real_t *p,
311 const size_t n );
312
313 static real_t deFuzzCentroid( output * const o,
314 const deFuzzState stage );
315 static real_t deFuzzBisector( output * const o,
316 const deFuzzState stage );
317 static real_t deFuzzLOM( output * const o,
318 const deFuzzState stage );
319 static real_t deFuzzSOM( output * const o,
320 const deFuzzState stage );
321 static real_t deFuzzMOM( output * const o,
322 const deFuzzState stage );
323 static real_t deFuzzWtAverage( output * const o,
324 const deFuzzState stage );
325 static real_t deFuzzWtSum( output * const o,
326 const deFuzzState stage );
328 };
329
335 class mf {
336 private:
337 mfFunction shape{ nullptr };
338 const real_t *points{ nullptr };
339 real_t fx{ 0.0_re };
340 real_t h{ 0.0_re };
341 size_t index{ 0U };
342 inline size_t getIndex( void ) const
343 {
344 return index;
345 }
346 inline real_t membership( const ioBase * const io,
347 size_t n = 1U )
348 {
349 fx = ( nullptr != shape ) ? h*shape( io, points, n ) : 0.0_re;
350 return fx;
351 }
352 public:
353 virtual ~mf() {};
354 mf() = default;
355 friend class instance;
356 };
357
359 #define FIS_RULE_ITEM_SIZE 1
361
362 #if ( FIS_RULE_ITEM_SIZE == 1 )
382 using rules = int8_t;
384 constexpr fis::rules FIS_RULES_MIN_VALUE = INT8_MIN;
386 #else
406 using rules = int16_t;
408 constexpr fis::rules FIS_RULES_MIN_VALUE = INT16_MIN;
410 #endif
411
421 using tag = rules;
422 /*cstat -MISRAC++2008-0-1-4_b*/
424 constexpr fis::rules Q_FIS_RULES_BEGIN = FIS_RULES_MIN_VALUE;
425 constexpr fis::rules Q_FIS_RULES_END = FIS_RULES_MIN_VALUE + 1;
426 constexpr fis::rules Q_FIS_AND = FIS_RULES_MIN_VALUE + 2;
427 constexpr fis::rules Q_FIS_OR = FIS_RULES_MIN_VALUE + 3;
428 constexpr fis::rules Q_FIS_THEN = FIS_RULES_MIN_VALUE + 4;
429 /*cstat +MISRAC++2008-0-1-4_b*/
430 #define Q_FIS_IF_STATEMENT ,
431 #define Q_FIS_AND_STATEMENT +1),fis::Q_FIS_AND,
432 #define Q_FIS_OR_STATEMENT +1),fis::Q_FIS_OR,
433 #define Q_FIS_THEN_STATEMENT +1),fis::Q_FIS_THEN,
434 #define Q_FIS_IS_STATEMENT ,(
435 #define Q_FIS_IS_NOT_STATEMENT ,-(
436 #define Q_FIS_END_STATEMENT +1)
438
457 #define FIS_RULES_BEGIN fis::Q_FIS_RULES_BEGIN
476 #define FIS_RULES_END ,fis::Q_FIS_RULES_END
478 #define IF Q_FIS_IF_STATEMENT
480 #define AND Q_FIS_AND_STATEMENT
482 #define OR Q_FIS_OR_STATEMENT
484 #define THEN Q_FIS_THEN_STATEMENT
486 #define IS Q_FIS_IS_STATEMENT
488 #define IS_NOT Q_FIS_IS_NOT_STATEMENT
490 #define END Q_FIS_END_STATEMENT
491
492
493 using deFuzzFunction = real_t (*)( output * const o, const deFuzzState stage );
494 using fuzzyOperator = real_t (*)( const real_t a, const real_t b );
495
500 class instance: public core, private nonCopyable {
501 using methods_fcn = real_t (*)( const real_t a, const real_t b );
502
503 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
504 friend class system;
505
506 private:
507 input *xInput{ nullptr };
508 output *xOutput{ nullptr };
509 mf *inMF{ nullptr };
510 mf *outMF{ nullptr };
511 methods_fcn andOp{ &Min };
512 methods_fcn orOp{ &Max };
513 methods_fcn implicate{ &Min };
514 methods_fcn aggregate{ &Max };
515 size_t (instance::*inferenceState)( size_t i );
516 size_t (instance::*aggregationState)( size_t i );
517 deFuzzFunction deFuzz{ &deFuzzCentroid };
518 real_t *ruleWeight{ nullptr };
519 real_t *wi{ nullptr };
520 const rules *xRules{ nullptr };
521 size_t rules_cols{ 0U};
522 size_t nInputs{ 0 };
523 size_t nOutputs{ 0 };
524 size_t nMFInputs{ 0U };
525 size_t nMFOutputs{ 0U };
526 size_t nPoints{ 100 };
527 size_t nRules{ 0U };
528 size_t ruleCount{ 0U };
529 real_t rStrength{ 0.0_re };
530 rules lastConnector;
531 type xType{ Mamdani };
532 bool setMF( mf *m,
533 const tag io,
534 const tag mf,
535 const shapeMF s,
536 mfFunction customMf,
537 const real_t *cp,
538 const real_t h ) noexcept;
539 static real_t parseFuzzValue( mf * const mfIO,
540 rules index ) noexcept;
541 fuzzyOperator getFuzzOperator( void ) noexcept;
542 size_t inferenceAntecedent( size_t i ) noexcept;
543 size_t inferenceReachEnd( size_t i ) noexcept;
544 size_t aggregationFindConsequent( size_t i ) noexcept;
545 size_t inferenceConsequent( size_t i ) noexcept;
546 void fuzzyAggregate( void ) noexcept;
547 static const size_t INFERENCE_ERROR;
548 tag lastTag{ -1 };
549 public:
550 instance() = default;
551 virtual ~instance() {}
552
575 bool setup( const type t,
576 input * const inputs,
577 const size_t ni,
578 output * const outputs,
579 const size_t no,
580 mf * const mf_inputs,
581 const size_t nmi,
582 mf * const mf_outputs,
583 const size_t nmo,
584 const rules * const r,
585 const size_t n,
586 real_t *rWeights = nullptr ) noexcept;
587
605 template <size_t numberInputs, size_t numberOutputs, size_t numberMFinputs, size_t numberMFOutputs, size_t numberRules>
606 bool setup( const type t,
607 input (&inputs)[ numberInputs ],
608 output (&outputs)[ numberOutputs ],
609 mf (&mf_inputs)[ numberMFinputs ],
610 mf (&mf_outputs)[ numberMFOutputs ],
611 const rules * const r,
612 real_t (&rWeights)[ numberRules ] ) noexcept
613 {
614 return setup( t, inputs, numberInputs, outputs, numberOutputs, mf_inputs, numberMFinputs, mf_outputs, numberMFOutputs, r, numberRules, rWeights );
615 }
616
624 bool setupInput( const tag t,
625 const real_t Min,
626 const real_t Max ) noexcept;
634 bool setupOutput( const tag t,
635 const real_t Min,
636 const real_t Max ) noexcept;
637
659 bool setupInputMF( const tag io,
660 const tag mf,
661 const shapeMF s,
662 const real_t *cp,
663 const real_t h = 1.0_re ) noexcept
664 {
665 return ( ( nullptr != inMF ) && ( nMFInputs > 0U ) ) ? setMF( inMF, io, mf, s, nullptr, cp, h ) : false;
666 }
667
680 bool setupInputMF( const tag io,
681 const tag mf,
682 mfFunction customMfs,
683 const real_t *cp,
684 const real_t h = 1.0_re ) noexcept
685 {
686 return ( ( nullptr != inMF ) && ( nMFInputs > 0U ) ) ? setMF( inMF, io, mf, custommf, customMfs, cp, h ) : false;
687 }
688
710 bool setupOutputMF( const tag io,
711 const tag mf,
712 const shapeMF s,
713 const real_t *cp,
714 const real_t h = 1.0_re ) noexcept
715 {
716 return ( ( nullptr != outMF ) && ( nMFOutputs > 0U ) ) ? setMF( outMF, io, mf, s, nullptr, cp, ( ( Mamdani == xType ) ? h : 1.0_re ) ) : false;
717 }
718
731 bool setupOutputMF( const tag io,
732 const tag mf,
733 mfFunction customMfs,
734 const real_t *cp,
735 const real_t h = 1.0_re ) noexcept
736 {
737 return ( ( nullptr != outMF ) && ( nMFOutputs > 0U ) ) ? setMF( outMF, io, mf, custommf, customMfs, cp, ( ( Mamdani == xType ) ? h : 1.0_re ) ) : false;
738 }
739
746 bool setInput( const tag t,
747 const real_t value ) noexcept;
748
756 bool getOutput( const tag t,
757 real_t &value ) const noexcept;
758
765 bool setParameter( const parameter p,
766 const paramValue x ) noexcept;
767
778 bool setDeFuzzMethod( deFuzzMethod m ) noexcept;
779
787 bool fuzzify( void ) noexcept;
788
798 bool deFuzzify( void ) noexcept;
799
806 bool inference( void ) noexcept;
807
815 bool setRuleWeights( real_t *rWeights ) noexcept;
816
821 bool isInitialized( void ) const {
822 return ( nullptr != xInput );
823 }
824
829 explicit operator bool() const noexcept {
830 return isInitialized();
831 }
832
838 size_t getNumberOfPoints( void ) const noexcept
839 {
840 return nPoints;
841 }
842
849 real_t operator[]( tag outTag ) const
850 {
851 /*cstat -CERT-STR34-C*/
852 return ( static_cast<size_t>( outTag ) < nOutputs ) ? xOutput[ outTag ].value : xInput[ nOutputs -1 ].value;
853 /*cstat +CERT-STR34-C*/
854 }
855
861 instance& operator<<( const tag& t ) {
862 if ( static_cast<size_t>( t ) < nInputs ) {
863 lastTag = t;
864 }
865 return *this;
866 }
867
873 instance& operator<<( const int& value ) {
874 if ( lastTag >= 0 ) {
875 xInput[ lastTag ].value = static_cast<real_t>(value);
876 }
877 return *this;
878 }
879
885 instance& operator<<( const real_t& value ) {
886 if ( lastTag >= 0 ) {
887 xInput[ lastTag ].value = value;
888 }
889 return *this;
890 }
891
892 friend class core;
893 };
894
907 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
908 class system {
909 private:
910 instance sys;
911 const rules *xRules;
912 input inputs[ numberOfInputs ];
913 output outputs[ numberOfOutputs ];
914 mf MFin[ numberOfInputSets ], MFout[ numberOfOutputSets ];
915 real_t ruleStrength[ numberOfRules ];
916 public:
917 constexpr system( const rules *r ) : xRules( r ) {};
918
923 inline bool setup( void )
924 {
925 return sys.setup( fType,
926 inputs, numberOfInputs,
927 outputs, numberOfOutputs,
928 MFin, numberOfInputSets,
929 MFout, numberOfOutputSets,
930 xRules, numberOfRules,
931 ruleStrength );
932 }
933
941 inline bool setupInput( const tag t,
942 const real_t Min,
943 const real_t Max ) noexcept
944 {
945 return sys.setupInput( t, Min, Max );
946 }
947
955 inline bool setupOutput( const tag t,
956 const real_t Min,
957 const real_t Max ) noexcept
958 {
959 return sys.setupOutput( t, Min, Max );
960 }
961
983 inline bool setupInputMF( const tag io,
984 const tag mf,
985 const shapeMF s,
986 const real_t *cp,
987 const real_t h = 1.0_re ) noexcept
988 {
989 return sys.setupInputMF( io, mf, s, cp, h );
990 }
991
1004 inline bool setupInputMF( const tag io,
1005 const tag mf,
1006 mfFunction customMfs,
1007 const real_t *cp,
1008 const real_t h = 1.0_re ) noexcept
1009 {
1010 return sys.setupInputMF( io, mf, customMfs, cp, h );
1011 }
1012
1034 inline bool setupOutputMF( const tag io,
1035 const tag mf,
1036 const shapeMF s,
1037 const real_t *cp,
1038 const real_t h = 1.0_re ) noexcept
1039 {
1040 return sys.setupOutputMF( io, mf, s, cp, h );
1041 }
1042
1055 inline bool setupOutputMF( const tag io,
1056 const tag mf,
1057 mfFunction customMfs,
1058 const real_t *cp,
1059 const real_t h = 1.0_re ) noexcept
1060 {
1061 return sys.setupOutputMF( io, mf, customMfs, cp, h );
1062 }
1063
1072 inline bool fuzzify( void ) noexcept
1073 {
1074 return sys.fuzzify();
1075 }
1076
1086 inline bool deFuzzify( void ) noexcept
1087 {
1088 return sys.deFuzzify();
1089 }
1090
1097 inline bool inference( void ) noexcept
1098 {
1099 return sys.inference();
1100 }
1101
1108 inline bool setInput( const tag t,
1109 const real_t value ) noexcept
1110 {
1111 return sys.setInput( t, value );
1112 }
1113
1121 inline bool getOutput( const tag t,
1122 real_t &value ) const noexcept
1123 {
1124 return sys.getOutput( t, value );
1125 }
1126
1133 inline bool setParameter( const parameter p,
1134 const paramValue x ) noexcept
1135 {
1136 return sys.setParameter( p, x );
1137 }
1138
1149 inline bool setDeFuzzMethod( deFuzzMethod m ) noexcept
1150 {
1151 return sys.setDeFuzzMethod( m );
1152 }
1153
1163 inline bool setRuleWeights( real_t *rWeights ) noexcept
1164 {
1165 return sys.setRuleWeights( rWeights );
1166 }
1167
1173 size_t getNumberOfPoints( void ) const noexcept
1174 {
1175 return sys.nPoints;
1176 }
1177
1184 real_t operator[]( tag outTag ) const
1185 {
1186 /*cstat -CERT-STR34-C*/
1187 return ( static_cast<size_t>( outTag ) < sys.nOutputs ) ? sys.xOutput[ outTag ].value : sys.xInput[ sys.nOutputs -1 ].value;
1188 /*cstat +CERT-STR34-C*/
1189 }
1190
1196 system& operator<<( const tag& t ) {
1197 if ( static_cast<size_t>( t ) < sys.nInputs ) {
1198 sys.lastTag = t;
1199 }
1200 return *this;
1201 }
1202
1208 system& operator<<( const int& value ) {
1209 if ( sys.lastTag >= 0 ) {
1210 sys.xInput[ sys.lastTag ].value = static_cast<real_t>( value );
1211 }
1212 return *this;
1213 }
1214
1220 system& operator<<( const real_t& value ) {
1221 if ( sys.lastTag >= 0 ) {
1222 sys.xInput[ sys.lastTag ].value = value;
1223 }
1224 return *this;
1225 }
1226
1231 bool isInitialized( void ) const {
1232 return sys.isInitialized();
1233 }
1234
1239 explicit operator bool() const noexcept {
1240 return sys.isInitialized();
1241 }
1242
1243 };
1244
1245 }
1246
1247}
1248
1249#endif /*QLIBS_FIS*/
Definition fis.hpp:200
A FIS Input object.
Definition fis.hpp:149
friend class instance
Definition fis.hpp:153
virtual ~input()
Definition fis.hpp:152
friend class system
Definition fis.hpp:156
friend class core
Definition fis.hpp:154
A FIS(Fuzzy Inference System) object.
Definition fis.hpp:500
bool setupOutputMF(const tag io, const tag mf, const shapeMF s, const real_t *cp, const real_t h=1.0_re) noexcept
Setup the output tag and points for the specified membership function.
Definition fis.hpp:710
bool setRuleWeights(real_t *rWeights) noexcept
Set weights to the rules of the inference system.
Definition fis.cpp:467
bool deFuzzify(void) noexcept
Perform the de-Fuzzification operation to compute the crisp outputs.
Definition fis.cpp:418
bool setupOutputMF(const tag io, const tag mf, mfFunction customMfs, const real_t *cp, const real_t h=1.0_re) noexcept
Set the output tag and points for the specified membership function.
Definition fis.hpp:731
bool setupInputMF(const tag io, const tag mf, const shapeMF s, const real_t *cp, const real_t h=1.0_re) noexcept
Setup the input tag and points for the specified membership function.
Definition fis.hpp:659
bool setDeFuzzMethod(deFuzzMethod m) noexcept
Change the default de-Fuzzification method of the FIS instance.
Definition fis.cpp:46
instance & operator<<(const int &value)
The value to set the previously selected input.
Definition fis.hpp:873
bool setup(const type t, input *const inputs, const size_t ni, output *const outputs, const size_t no, mf *const mf_inputs, const size_t nmi, mf *const mf_outputs, const size_t nmo, const rules *const r, const size_t n, real_t *rWeights=nullptr) noexcept
Setup and initialize the FIS instance.
Definition fis.cpp:71
bool isInitialized(void) const
Check if the FIS instance has been initialized.
Definition fis.hpp:821
size_t getNumberOfPoints(void) const noexcept
Get the number of points used on Mamdani to perform the de-fuzzification proccess.
Definition fis.hpp:838
bool setupOutput(const tag t, const real_t Min, const real_t Max) noexcept
Setup the output with the specified tag and set limits for it.
Definition fis.cpp:136
bool fuzzify(void) noexcept
Perform the fuzzification operation over the crisp inputs on the requested FIS object.
Definition fis.cpp:234
bool setParameter(const parameter p, const paramValue x) noexcept
Set parameters of the FIS instance.
Definition fis.cpp:7
virtual ~instance()
Definition fis.hpp:551
instance & operator<<(const real_t &value)
The value to set the previously selected input.
Definition fis.hpp:885
instance & operator<<(const tag &t)
Select the input to set using with the specified tag.
Definition fis.hpp:861
bool inference(void) noexcept
Perform the inference process on the FIS object.
Definition fis.cpp:478
bool setInput(const tag t, const real_t value) noexcept
Set a crisp value of the input with the specified tag.
Definition fis.cpp:170
friend class system
Definition fis.hpp:504
bool setupInput(const tag t, const real_t Min, const real_t Max) noexcept
Setup the input with the specified tag and set limits for it.
Definition fis.cpp:119
bool getOutput(const tag t, real_t &value) const noexcept
Get the de-fuzzified crisp value from the output with the specified tag.
Definition fis.cpp:185
real_t operator[](tag outTag) const
Get the de-fuzzified crisp value from the output with the specified tag.
Definition fis.hpp:849
friend class core
Definition fis.hpp:892
bool setupInputMF(const tag io, const tag mf, mfFunction customMfs, const real_t *cp, const real_t h=1.0_re) noexcept
Setup the input tag and points for the specified membership function.
Definition fis.hpp:680
Definition fis.hpp:129
friend class instance
Definition fis.hpp:139
virtual ~ioBase()
Definition fis.hpp:137
friend class system
Definition fis.hpp:142
friend class core
Definition fis.hpp:140
A FIS Membership Function.
Definition fis.hpp:335
mf()=default
friend class instance
Definition fis.hpp:355
virtual ~mf()
Definition fis.hpp:353
A FIS Output object.
Definition fis.hpp:163
friend class instance
Definition fis.hpp:188
virtual ~output()
Definition fis.hpp:178
bool storeAggregatedRegion(real_t *xData, real_t *yData, const size_t n) noexcept
Definition fis.cpp:155
bool storeAggregatedRegion(real_t(&xData)[numberOfPoints], real_t(&yData)[numberOfPoints]) noexcept
Definition fis.hpp:183
friend class system
Definition fis.hpp:191
friend class core
Definition fis.hpp:189
bool setupOutputMF(const tag io, const tag mf, mfFunction customMfs, const real_t *cp, const real_t h=1.0_re) noexcept
Set the output tag and points for the specified membership function.
Definition fis.hpp:1055
bool setupInputMF(const tag io, const tag mf, mfFunction customMfs, const real_t *cp, const real_t h=1.0_re) noexcept
Setup the input tag and points for the specified membership function.
Definition fis.hpp:1004
bool setupInputMF(const tag io, const tag mf, const shapeMF s, const real_t *cp, const real_t h=1.0_re) noexcept
Setup the input tag and points for the specified membership function.
Definition fis.hpp:983
system & operator<<(const int &value)
The value to set the previously selected input.
Definition fis.hpp:1208
bool setup(void)
Setup and initialize the FIS instance.
Definition fis.hpp:923
bool setParameter(const parameter p, const paramValue x) noexcept
Set parameters of the FIS instance.
Definition fis.hpp:1133
bool setupOutputMF(const tag io, const tag mf, const shapeMF s, const real_t *cp, const real_t h=1.0_re) noexcept
Set the output tag and points for the specified membership function.
Definition fis.hpp:1034
bool fuzzify(void) noexcept
Perform the fuzzification operation over the crisp inputs on the requested FIS object.
Definition fis.hpp:1072
real_t operator[](tag outTag) const
Get the de-fuzzified crisp value from the output with the specified tag.
Definition fis.hpp:1184
bool inference(void) noexcept
Perform the inference process on the FIS object.
Definition fis.hpp:1097
constexpr system(const rules *r)
Definition fis.hpp:917
size_t getNumberOfPoints(void) const noexcept
Get the number of points used on Mamdani to perform the de-fuzzification proccess.
Definition fis.hpp:1173
system & operator<<(const real_t &value)
The value to set the previously selected input.
Definition fis.hpp:1220
bool getOutput(const tag t, real_t &value) const noexcept
Get the de-fuzzified crisp value from the output with the specified tag.
Definition fis.hpp:1121
bool setupOutput(const tag t, const real_t Min, const real_t Max) noexcept
Setup the output with the specified tag and set limits for it.
Definition fis.hpp:955
bool isInitialized(void) const
Check if the FIS system has been initialized.
Definition fis.hpp:1231
bool setDeFuzzMethod(deFuzzMethod m) noexcept
Change the default de-Fuzzification method of the FIS instance.
Definition fis.hpp:1149
bool deFuzzify(void) noexcept
Perform the de-Fuzzification operation to compute the crisp outputs.
Definition fis.hpp:1086
system & operator<<(const tag &t)
Select the input to set using with the specified tag.
Definition fis.hpp:1196
bool setupInput(const tag t, const real_t Min, const real_t Max) noexcept
Setup the input with the specified tag and set limits for it.
Definition fis.hpp:941
bool setInput(const tag t, const real_t value) noexcept
Set a crisp value of the input with the specified tag.
Definition fis.hpp:1108
bool setRuleWeights(real_t *rWeights) noexcept
Set weights to the rules of the inference system.
Definition fis.hpp:1163
T Max(const T &first, const Args &... args)
Finds the maximum value among the provided arguments.
Definition ffmath.hpp:101
T Min(const T &first, const Args &... args)
Finds the minimum value among the provided arguments.
Definition ffmath.hpp:123
real_t(*)(const real_t a, const real_t b) fuzzyOperator
Definition fis.hpp:494
parameter
An enum with the allowed parameters that can be set on a FIS instance.
Definition fis.hpp:97
int16_t rules
Type definition to instantiate a set of fuzzy rules.
Definition fis.hpp:406
real_t(*)(output *const o, const deFuzzState stage) deFuzzFunction
Definition fis.hpp:493
type
An enum with the inference system types supported by qlibs::fis.
Definition fis.hpp:108
paramValue
An enum with the supported parameter values.
Definition fis.hpp:86
shapeMF
An enum with all the possible values to specify a membership function.
Definition fis.hpp:33
deFuzzMethod
An enum with all the possible de-Fuzzyfication methods.
Definition fis.hpp:70
rules tag
Used to define an enum of fis tags.
Definition fis.hpp:421
@ FIS_EvalPoints
Definition fis.hpp:102
@ FIS_Implication
Definition fis.hpp:98
@ FIS_AND
Definition fis.hpp:100
@ FIS_OR
Definition fis.hpp:101
@ FIS_Aggregation
Definition fis.hpp:99
@ Sugeno
Definition fis.hpp:110
@ Tsukamoto
Definition fis.hpp:111
@ Mamdani
Definition fis.hpp:109
@ FIS_PROD
Definition fis.hpp:88
@ FIS_MIN
Definition fis.hpp:87
@ FIS_PROBOR
Definition fis.hpp:90
@ FIS_SUM
Definition fis.hpp:91
@ FIS_MAX
Definition fis.hpp:89
@ sigmf
Definition fis.hpp:40
@ custommf
Definition fis.hpp:34
@ singletonmf
Definition fis.hpp:46
@ gbellmf
Definition fis.hpp:37
@ constantmf
Definition fis.hpp:53
@ tlinsmf
Definition fis.hpp:55
@ gaussmf
Definition fis.hpp:38
@ pimf
Definition fis.hpp:43
@ tconcavemf
Definition fis.hpp:57
@ concavemf
Definition fis.hpp:47
@ psigmf
Definition fis.hpp:42
@ tlinzmf
Definition fis.hpp:56
@ tzmf
Definition fis.hpp:60
@ cosmf
Definition fis.hpp:52
@ trimf
Definition fis.hpp:35
@ smf
Definition fis.hpp:44
@ linzmf
Definition fis.hpp:50
@ dsigmf
Definition fis.hpp:41
@ tsmf
Definition fis.hpp:59
@ gauss2mf
Definition fis.hpp:39
@ trampmf
Definition fis.hpp:61
@ spikemf
Definition fis.hpp:48
@ linsmf
Definition fis.hpp:49
@ zmf
Definition fis.hpp:45
@ trapmf
Definition fis.hpp:36
@ linearmf
Definition fis.hpp:54
@ tsigmf
Definition fis.hpp:58
@ rectmf
Definition fis.hpp:51
@ mom
Definition fis.hpp:73
@ wtsum
Definition fis.hpp:77
@ centroid
Definition fis.hpp:71
@ bisector
Definition fis.hpp:72
@ wtaver
Definition fis.hpp:76
@ lom
Definition fis.hpp:74
@ som
Definition fis.hpp:75
The Fuzzy Inference System namespace.
Definition fis.hpp:22
The qLibs++ library namespace.
Definition mat.hpp:18
float real_t
A type to instantiate a real variable double-precision of 64-bits IEEE 754.
Definition qlibs_types.hpp:43