Skip to content

Commit a5c2d5f

Browse files
Added project files
1 parent 0676a44 commit a5c2d5f

File tree

111 files changed

+8292
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+8292
-0
lines changed

dep/fl/Console.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
Author: Juan Rada-Vilela, Ph.D.
3+
Copyright (C) 2010-2014 FuzzyLite Limited
4+
All rights reserved
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 GNU Lesser General Public License as published by the Free
10+
Software Foundation, either version 3 of the License, or (at your option)
11+
any later version.
12+
13+
fuzzylite is distributed in the hope that it will be useful, but WITHOUT
14+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public License
19+
along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
20+
21+
fuzzylite™ is a trademark of FuzzyLite Limited.
22+
23+
*/
24+
25+
#ifndef FL_CONSOLE_H
26+
#define FL_CONSOLE_H
27+
28+
#include "fl/fuzzylite.h"
29+
30+
#include <map>
31+
#include <string>
32+
#include <vector>
33+
34+
namespace fl {
35+
class Engine;
36+
37+
class FL_API Console {
38+
public:
39+
40+
struct Option {
41+
std::string key, value, description;
42+
43+
explicit Option(const std::string& key = "", const std::string& value = "", const std::string& description = "") :
44+
key(key), value(value), description(description) {
45+
}
46+
};
47+
48+
static const std::string KW_INPUT_FILE;
49+
static const std::string KW_INPUT_FORMAT;
50+
static const std::string KW_OUTPUT_FILE;
51+
static const std::string KW_OUTPUT_FORMAT;
52+
static const std::string KW_EXAMPLE;
53+
static const std::string KW_DECIMALS;
54+
static const std::string KW_DATA_INPUT;
55+
static const std::string KW_DATA_MAXIMUM;
56+
static const std::string KW_DATA_EXPORT_HEADER;
57+
static const std::string KW_DATA_EXPORT_INPUTS;
58+
59+
static Engine* mamdani();
60+
static Engine* takagiSugeno();
61+
62+
protected:
63+
static std::map<std::string, std::string> parse(int argc, char** argv);
64+
static void process(const std::map<std::string, std::string>& options);
65+
66+
static void process(const std::string& input, std::ostream& writer,
67+
const std::string& inputFormat, const std::string& outputFormat,
68+
const std::map<std::string, std::string>& options);
69+
70+
static int readCharacter();
71+
static void interactive(std::ostream& writer, Engine* engine);
72+
static std::string interactiveHelp();
73+
74+
static void exportAllExamples(const std::string& from, const std::string& to);
75+
static void exportAllExamples(const std::string& from, const std::string& to, const std::string& path);
76+
#ifdef FL_CPP11
77+
static void benchmarkExamples(const std::string& path, int runs);
78+
#endif
79+
80+
public:
81+
static std::string usage();
82+
static std::vector<Option> availableOptions();
83+
84+
static int main(int argc, char** argv);
85+
};
86+
87+
}
88+
89+
#endif /* FL_CONSOLE_H */
90+

dep/fl/Engine.h

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
Author: Juan Rada-Vilela, Ph.D.
3+
Copyright (C) 2010-2014 FuzzyLite Limited
4+
All rights reserved
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 GNU Lesser General Public License as published by the Free
10+
Software Foundation, either version 3 of the License, or (at your option)
11+
any later version.
12+
13+
fuzzylite is distributed in the hope that it will be useful, but WITHOUT
14+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public License
19+
along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
20+
21+
fuzzylite™ is a trademark of FuzzyLite Limited.
22+
23+
*/
24+
25+
#ifndef FL_ENGINE_H
26+
#define FL_ENGINE_H
27+
28+
#include "fl/fuzzylite.h"
29+
30+
#include "fl/defuzzifier/IntegralDefuzzifier.h"
31+
32+
#include <string>
33+
#include <vector>
34+
35+
namespace fl {
36+
37+
class InputVariable;
38+
class OutputVariable;
39+
class Variable;
40+
class RuleBlock;
41+
class Hedge;
42+
class TNorm;
43+
class SNorm;
44+
class Defuzzifier;
45+
46+
class FL_API Engine {
47+
private:
48+
void copyFrom(const Engine& source);
49+
protected:
50+
std::string _name;
51+
std::vector<InputVariable*> _inputVariables;
52+
std::vector<OutputVariable*> _outputVariables;
53+
std::vector<RuleBlock*> _ruleblocks;
54+
55+
void updateReferences() const;
56+
57+
public:
58+
explicit Engine(const std::string& name = "");
59+
Engine(const Engine& other);
60+
Engine& operator=(const Engine& other);
61+
virtual ~Engine();
62+
FL_DEFAULT_MOVE(Engine)
63+
64+
//TODO: remove int resolution in v6.0
65+
virtual void configure(const std::string& conjunctionT,
66+
const std::string& disjunctionS,
67+
const std::string& activationT,
68+
const std::string& accumulationS,
69+
const std::string& defuzzifier,
70+
int resolution = IntegralDefuzzifier::defaultResolution());
71+
72+
virtual void configure(TNorm* conjunction, SNorm* disjunction,
73+
TNorm* activation, SNorm* accumulation,
74+
Defuzzifier* defuzzifier);
75+
76+
virtual bool isReady(std::string* status = fl::null) const;
77+
78+
virtual void process();
79+
80+
virtual void restart();
81+
82+
virtual void setName(const std::string& name);
83+
virtual std::string getName() const;
84+
85+
virtual void setInputValue(const std::string& name, scalar value);
86+
virtual scalar getOutputValue(const std::string& name);
87+
88+
89+
virtual std::string toString() const;
90+
91+
enum Type {
92+
Mamdani, Larsen, TakagiSugeno,
93+
Tsukamoto, InverseTsukamoto, Hybrid, Unknown
94+
};
95+
virtual Type type(std::string* name = fl::null, std::string* reason = fl::null) const;
96+
97+
virtual Engine* clone() const;
98+
99+
virtual std::vector<Variable*> variables() const;
100+
101+
/**
102+
* Operations for iterable datatype _inputVariables
103+
*/
104+
virtual void addInputVariable(InputVariable* inputVariable);
105+
virtual InputVariable* setInputVariable(InputVariable* inputVariable, int index);
106+
virtual void insertInputVariable(InputVariable* inputVariable, int index);
107+
virtual InputVariable* getInputVariable(int index) const;
108+
virtual InputVariable* getInputVariable(const std::string& name) const;
109+
virtual InputVariable* removeInputVariable(int index);
110+
virtual InputVariable* removeInputVariable(const std::string& name);
111+
virtual bool hasInputVariable(const std::string& name) const;
112+
virtual int numberOfInputVariables() const;
113+
virtual const std::vector<InputVariable*>& inputVariables() const;
114+
virtual void setInputVariables(const std::vector<InputVariable*>& inputVariables);
115+
virtual std::vector<InputVariable*>& inputVariables();
116+
117+
/**
118+
* Operations for iterable datatype _outputVariables
119+
*/
120+
virtual void addOutputVariable(OutputVariable* outputVariable);
121+
virtual OutputVariable* setOutputVariable(OutputVariable* outputVariable, int index);
122+
virtual void insertOutputVariable(OutputVariable* outputVariable, int index);
123+
virtual OutputVariable* getOutputVariable(int index) const;
124+
virtual OutputVariable* getOutputVariable(const std::string& name) const;
125+
virtual bool hasOutputVariable(const std::string& name) const;
126+
virtual OutputVariable* removeOutputVariable(int index);
127+
virtual OutputVariable* removeOutputVariable(const std::string& name);
128+
virtual int numberOfOutputVariables() const;
129+
virtual const std::vector<OutputVariable*>& outputVariables() const;
130+
virtual void setOutputVariables(const std::vector<OutputVariable*>& outputVariables);
131+
virtual std::vector<OutputVariable*>& outputVariables();
132+
133+
/**
134+
* Operations for iterable datatype _ruleblocks
135+
*/
136+
virtual void addRuleBlock(RuleBlock* ruleblock);
137+
virtual RuleBlock* setRuleBlock(RuleBlock* ruleBlock, int index);
138+
virtual void insertRuleBlock(RuleBlock* ruleblock, int index);
139+
virtual RuleBlock* getRuleBlock(int index) const;
140+
virtual RuleBlock* getRuleBlock(const std::string& name) const;
141+
virtual bool hasRuleBlock(const std::string& name) const;
142+
virtual RuleBlock* removeRuleBlock(int index);
143+
virtual RuleBlock* removeRuleBlock(const std::string& name);
144+
virtual int numberOfRuleBlocks() const;
145+
virtual const std::vector<RuleBlock*>& ruleBlocks() const;
146+
virtual void setRuleBlocks(const std::vector<RuleBlock*>& ruleBlocks);
147+
virtual std::vector<RuleBlock*>& ruleBlocks();
148+
149+
};
150+
151+
}
152+
#endif /* FL_ENGINE_H */

dep/fl/Exception.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Author: Juan Rada-Vilela, Ph.D.
3+
Copyright (C) 2010-2014 FuzzyLite Limited
4+
All rights reserved
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 GNU Lesser General Public License as published by the Free
10+
Software Foundation, either version 3 of the License, or (at your option)
11+
any later version.
12+
13+
fuzzylite is distributed in the hope that it will be useful, but WITHOUT
14+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public License
19+
along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
20+
21+
fuzzylite™ is a trademark of FuzzyLite Limited.
22+
23+
*/
24+
25+
#ifndef FL_EXCEPTION_H
26+
#define FL_EXCEPTION_H
27+
28+
#include "fl/fuzzylite.h"
29+
30+
#include <exception>
31+
#include <string>
32+
#include <vector>
33+
34+
namespace fl {
35+
36+
class FL_API Exception : public std::exception {
37+
protected:
38+
std::string _what;
39+
public:
40+
explicit Exception(const std::string& what);
41+
Exception(const std::string& what, const std::string& file, int line,
42+
const std::string& function);
43+
virtual ~Exception() FL_INOEXCEPT FL_IOVERRIDE;
44+
FL_DEFAULT_COPY_AND_MOVE(Exception)
45+
46+
virtual void setWhat(const std::string& what);
47+
virtual std::string getWhat() const;
48+
virtual const char* what() const FL_INOEXCEPT FL_IOVERRIDE;
49+
50+
virtual void append(const std::string& whatElse);
51+
virtual void append(const std::string& file, int line, const std::string& function);
52+
virtual void append(const std::string& whatElse,
53+
const std::string& file, int line, const std::string& function);
54+
55+
static std::string btCallStack();
56+
57+
static void signalHandler(int signal);
58+
static void convertToException(int signal);
59+
static void terminate();
60+
static void catchException(const std::exception& exception);
61+
62+
63+
};
64+
65+
}
66+
#endif /* FL_EXCEPTION_H */

0 commit comments

Comments
 (0)