Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
fis.hpp
1
9#ifndef QLIBS_FIS
10#define QLIBS_FIS
11
12#include <include/qlibs_types.hpp>
13
17namespace qlibs {
18
22 namespace fis {
23
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 };
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;
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 );
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
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)
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
822 size_t getNumberOfPoints( void ) const noexcept
823 {
824 return nPoints;
825 }
826
833 real_t operator[]( tag outTag ) const
834 {
835 /*cstat -CERT-STR34-C*/
836 return ( static_cast<size_t>( outTag ) < nOutputs ) ? xOutput[ outTag ].value : xInput[ nOutputs -1 ].value;
837 /*cstat +CERT-STR34-C*/
838 }
839
845 instance& operator<<( const tag& t ) {
846 if ( static_cast<size_t>( t ) < nInputs ) {
847 lastTag = t;
848 }
849 return *this;
850 }
851
857 instance& operator<<( const int& value ) {
858 if ( lastTag >= 0 ) {
859 xInput[ lastTag ].value = static_cast<real_t>(value);
860 }
861 return *this;
862 }
863
869 instance& operator<<( const real_t& value ) {
870 if ( lastTag >= 0 ) {
871 xInput[ lastTag ].value = value;
872 }
873 return *this;
874 }
875
876 friend class core;
877 };
878
891 template<type fType, size_t numberOfInputs, size_t numberOfOutputs, size_t numberOfInputSets, size_t numberOfOutputSets, size_t numberOfRules>
892 class system {
893 private:
894 instance sys;
895 const rules *xRules;
896 input inputs[ numberOfInputs ];
897 output outputs[ numberOfOutputs ];
898 mf MFin[ numberOfInputSets ], MFout[ numberOfOutputSets ];
899 real_t ruleStrength[ numberOfRules ];
900 public:
901 constexpr system( const rules *r ) : xRules( r ) {};
902
907 inline bool setup( void )
908 {
909 return sys.setup( fType,
910 inputs, numberOfInputs,
911 outputs, numberOfOutputs,
912 MFin, numberOfInputSets,
913 MFout, numberOfOutputSets,
914 xRules, numberOfRules,
915 ruleStrength );
916 }
917
925 inline bool setupInput( const tag t,
926 const real_t Min,
927 const real_t Max ) noexcept
928 {
929 return sys.setupInput( t, Min, Max );
930 }
931
939 inline bool setupOutput( const tag t,
940 const real_t Min,
941 const real_t Max ) noexcept
942 {
943 return sys.setupOutput( t, Min, Max );
944 }
945
967 inline bool setupInputMF( const tag io,
968 const tag mf,
969 const shapeMF s,
970 const real_t *cp,
971 const real_t h = 1.0_re ) noexcept
972 {
973 return sys.setupInputMF( io, mf, s, cp, h );
974 }
975
988 inline bool setupInputMF( const tag io,
989 const tag mf,
990 mfFunction customMfs,
991 const real_t *cp,
992 const real_t h = 1.0_re ) noexcept
993 {
994 return sys.setupInputMF( io, mf, customMfs, cp, h );
995 }
996
1018 inline bool setupOutputMF( const tag io,
1019 const tag mf,
1020 const shapeMF s,
1021 const real_t *cp,
1022 const real_t h = 1.0_re ) noexcept
1023 {
1024 return sys.setupOutputMF( io, mf, s, cp, h );
1025 }
1026
1039 inline bool setupOutputMF( const tag io,
1040 const tag mf,
1041 mfFunction customMfs,
1042 const real_t *cp,
1043 const real_t h = 1.0_re ) noexcept
1044 {
1045 return sys.setupOutputMF( io, mf, customMfs, cp, h );
1046 }
1047
1056 inline bool fuzzify( void ) noexcept
1057 {
1058 return sys.fuzzify();
1059 }
1060
1070 inline bool deFuzzify( void ) noexcept
1071 {
1072 return sys.deFuzzify();
1073 }
1074
1081 inline bool inference( void ) noexcept
1082 {
1083 return sys.inference();
1084 }
1085
1092 inline bool setInput( const tag t,
1093 const real_t value ) noexcept
1094 {
1095 return sys.setInput( t, value );
1096 }
1097
1105 inline bool getOutput( const tag t,
1106 real_t &value ) const noexcept
1107 {
1108 return sys.getOutput( t, value );
1109 }
1110
1117 inline bool setParameter( const parameter p,
1118 const paramValue x ) noexcept
1119 {
1120 return sys.setParameter( p, x );
1121 }
1122
1133 inline bool setDeFuzzMethod( deFuzzMethod m ) noexcept
1134 {
1135 return sys.setDeFuzzMethod( m );
1136 }
1137
1147 inline bool setRuleWeights( real_t *rWeights ) noexcept
1148 {
1149 return sys.setRuleWeights( rWeights );
1150 }
1151
1157 size_t getNumberOfPoints( void ) const noexcept
1158 {
1159 return sys.nPoints;
1160 }
1161
1168 real_t operator[]( tag outTag ) const
1169 {
1170 /*cstat -CERT-STR34-C*/
1171 return ( static_cast<size_t>( outTag ) < sys.nOutputs ) ? sys.xOutput[ outTag ].value : sys.xInput[ sys.nOutputs -1 ].value;
1172 /*cstat +CERT-STR34-C*/
1173 }
1174
1180 system& operator<<( const tag& t ) {
1181 if ( static_cast<size_t>( t ) < sys.nInputs ) {
1182 sys.lastTag = t;
1183 }
1184 return *this;
1185 }
1186
1192 system& operator<<( const int& value ) {
1193 if ( sys.lastTag >= 0 ) {
1194 sys.xInput[ sys.lastTag ].value = static_cast<real_t>( value );
1195 }
1196 return *this;
1197 }
1198
1204 system& operator<<( const real_t& value ) {
1205 if ( sys.lastTag >= 0 ) {
1206 sys.xInput[ sys.lastTag ].value = value;
1207 }
1208 return *this;
1209 }
1210 };
1212 }
1213
1214}
1215
1216#endif /*QLIBS_FIS*/
Definition fis.hpp:200
A FIS Input object.
Definition fis.hpp:149
virtual ~input()
Definition fis.hpp:152
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:857
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
size_t getNumberOfPoints(void) const noexcept
Get the number of points used on Mamdani to perform the de-fuzzification proccess.
Definition fis.hpp:822
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:869
instance & operator<<(const tag &t)
Select the input to set using with the specified tag.
Definition fis.hpp:845
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
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:833
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
virtual ~ioBase()
Definition fis.hpp:137
A FIS Membership Function.
Definition fis.hpp:335
mf()=default
virtual ~mf()
Definition fis.hpp:353
A FIS Output object.
Definition fis.hpp:163
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
A wrapper for the FIS object.
Definition fis.hpp:892
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:1039
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:988
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:967
system & operator<<(const int &value)
The value to set the previously selected input.
Definition fis.hpp:1192
bool setup(void)
Setup and initialize the FIS instance.
Definition fis.hpp:907
bool setParameter(const parameter p, const paramValue x) noexcept
Set parameters of the FIS instance.
Definition fis.hpp:1117
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:1018
bool fuzzify(void) noexcept
Perform the fuzzification operation over the crisp inputs on the requested FIS object.
Definition fis.hpp:1056
real_t operator[](tag outTag) const
Get the de-fuzzified crisp value from the output with the specified tag.
Definition fis.hpp:1168
bool inference(void) noexcept
Perform the inference process on the FIS object.
Definition fis.hpp:1081
constexpr system(const rules *r)
Definition fis.hpp:901
size_t getNumberOfPoints(void) const noexcept
Get the number of points used on Mamdani to perform the de-fuzzification proccess.
Definition fis.hpp:1157
system & operator<<(const real_t &value)
The value to set the previously selected input.
Definition fis.hpp:1204
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:1105
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:939
bool setDeFuzzMethod(deFuzzMethod m) noexcept
Change the default de-Fuzzification method of the FIS instance.
Definition fis.hpp:1133
bool deFuzzify(void) noexcept
Perform the de-Fuzzification operation to compute the crisp outputs.
Definition fis.hpp:1070
system & operator<<(const tag &t)
Select the input to set using with the specified tag.
Definition fis.hpp:1180
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:925
bool setInput(const tag t, const real_t value) noexcept
Set a crisp value of the input with the specified tag.
Definition fis.hpp:1092
bool setRuleWeights(real_t *rWeights) noexcept
Set weights to the rules of the inference system.
Definition fis.hpp:1147
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 qLibs++ library namespace.
Definition fp16.cpp:4
float real_t
A type to instantiate a real variable double-precision of 64-bits IEEE 754.
Definition qlibs_types.hpp:43