File: investment_portfolio.cpp

package info (click to toggle)
fuzzylite 6.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,420 kB
  • sloc: cpp: 25,880; java: 1,370; sh: 85; xml: 12; makefile: 10
file content (62 lines) | stat: -rw-r--r-- 2,603 bytes parent folder | download | duplicates (5)
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
#include <fl/Headers.h>

int main(int argc, char** argv){
//Code automatically generated with fuzzylite 6.0.

using namespace fl;

Engine* engine = new Engine;
engine->setName("investment_portfolio");
engine->setDescription("");

InputVariable* Age = new InputVariable;
Age->setName("Age");
Age->setDescription("");
Age->setEnabled(true);
Age->setRange(20.000, 100.000);
Age->setLockValueInRange(false);
Age->addTerm(new ZShape("Young", 30.000, 90.000));
Age->addTerm(new SShape("Old", 30.000, 90.000));
engine->addInputVariable(Age);

InputVariable* RiskTolerance = new InputVariable;
RiskTolerance->setName("RiskTolerance");
RiskTolerance->setDescription("");
RiskTolerance->setEnabled(true);
RiskTolerance->setRange(0.000, 10.000);
RiskTolerance->setLockValueInRange(false);
RiskTolerance->addTerm(new ZShape("Low", 2.000, 8.000));
RiskTolerance->addTerm(new SShape("High", 2.000, 8.000));
engine->addInputVariable(RiskTolerance);

OutputVariable* PercentageInStocks = new OutputVariable;
PercentageInStocks->setName("PercentageInStocks");
PercentageInStocks->setDescription("");
PercentageInStocks->setEnabled(true);
PercentageInStocks->setRange(0.000, 100.000);
PercentageInStocks->setLockValueInRange(false);
PercentageInStocks->setAggregation(new EinsteinSum);
PercentageInStocks->setDefuzzifier(new Centroid(200));
PercentageInStocks->setDefaultValue(fl::nan);
PercentageInStocks->setLockPreviousValue(false);
PercentageInStocks->addTerm(new Gaussian("AboutFifteen", 15.000, 10.000));
PercentageInStocks->addTerm(new Gaussian("AboutFifty", 50.000, 10.000));
PercentageInStocks->addTerm(new Gaussian("AboutEightyFive", 85.000, 10.000));
engine->addOutputVariable(PercentageInStocks);

RuleBlock* ruleBlock = new RuleBlock;
ruleBlock->setName("");
ruleBlock->setDescription("");
ruleBlock->setEnabled(true);
ruleBlock->setConjunction(new EinsteinProduct);
ruleBlock->setDisjunction(new EinsteinSum);
ruleBlock->setImplication(new EinsteinProduct);
ruleBlock->setActivation(new General);
ruleBlock->addRule(Rule::parse("if Age is Young or RiskTolerance is High then PercentageInStocks is AboutEightyFive", engine));
ruleBlock->addRule(Rule::parse("if Age is Old or RiskTolerance is Low then PercentageInStocks is AboutFifteen", engine));
ruleBlock->addRule(Rule::parse("if Age is not extremely Old and RiskTolerance is not extremely Low then PercentageInStocks is AboutFifty with 0.500", engine));
ruleBlock->addRule(Rule::parse("if Age is not extremely Young and RiskTolerance is not extremely High then PercentageInStocks is AboutFifty with 0.500", engine));
engine->addRuleBlock(ruleBlock);


}