-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDriver.cpp
More file actions
135 lines (109 loc) · 4.03 KB
/
Driver.cpp
File metadata and controls
135 lines (109 loc) · 4.03 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Driver.cpp
*
* Created on: Nov 20, 2016
* Author: rocco
g++ -std=c++0x Bot.cpp Driver.cpp Exchange.cpp ExperimentType.cpp fakeTime.cpp GenAlg.cpp GraphAttributes.cpp Individual.cpp LList.cpp Node.cpp Population.cpp Queue.cpp Results.cpp Stock.cpp -lpthread
*/
#include "Driver.h"
#include "Exchange.h"
#include "GenAlg.h"
#include <iostream>
#include <string>
#include <stdlib.h>
void printX(int num)
{
for (int k=0; k < num; k++)
{
cout << "x";
}
}
int main()
{
//TODO
// Call GA here
// Make into a multithreaded Genetic Algorithm
// Each exchange object will hold two moving average lengths,
// the type of moving averge 'D' (day) 'H' (hour) 'M' (min),
// and the number of experiments
Exchange* temp = new Exchange(10,40,'A',2);
Results data;
cout <<"Done .1.." << endl;
GenAlg* solutionFinder = new GenAlg();
solutionFinder->runGA(10000,10);
//Testing Population class
/*
Population test(10000, 5);
test.generateGeneration0();
test.printPop();
test.runIndividualFitnessAlgorithm();
test.printPop();
Individual father = test.randomlySelectFromPop();
Individual mother = test.randomlySelectFromPop();
Individual child;
cout << "Father: " << "Mov1: " << father.getAttributeAt(0) << " Mov2: " << father.getAttributeAt(1) << " SF: " << father.getAttributeAt(2) << endl ;
cout << "Mother: " << "Mov1: " << mother.getAttributeAt(0) << " Mov2: " << mother.getAttributeAt(1)<< " SF: " << mother.getAttributeAt(2) << endl ;
child = test.reproduce(father, mother);
cout << "Child: " << "Mov1: " << child.getAttributeAt(0) << " Mov2: " << child.getAttributeAt(1) << " SF: " << child.getAttributeAt(2) << endl ;
test.addChildToPos(0, child);
cout << "Adding child..." << endl;
test.printPop();
cout << "Testing fitness function" << endl;
// test.runIndividualFitnessAlgorithm();
*/
// data = temp->getFitness(100,10000);
// Within each exchange, a series of different tests will be performed
// that will vary the savings Factor and the initial starting money
// Savings factor will vary from 2% to 50% of initial starting money
// whereas initial starting money will be either 10k, 50k, 100k, 500k
//data = temp->getFitness(200, 10000);
// TODO
// Keep track of the range of perfomance for those with high
// fitness values, update results.h with an int array that holds
// how many occurrences of a certain range
//TODO
// Wrap the data from a set of experiments so that it contains:
// the distribution[], starting Money,
// cout <<"Done .2.." << endl;
// cout << "Fitness: " << data.getTotalValue() << endl; // access the fitness value
// cout << "Min: " << data.getMin() << " | Max: " << data.getMax() << endl;
// cout << "Graph attr: min - " << data.getAttributesForDistr()->getMin() << " max - " << data.getAttributesForDistr()->getMax() << " ";
// cout << "interval - " << data.getAttributesForDistr()->getInterval() << endl;
// Only access the distrubtion graph if it is one of the chosen individuals
// from the population
/*
int num=0;
cout << "Distribution performance " << endl;
int range = data.getAttributesForDistr()->getMin();
for (int j=0; j < 40; j++)
{
cout << range << " - ";
range+= data.getAttributesForDistr()->getInterval();
cout << range << " : ";
num = data.getNumberOfOccurencesAt(j);
printX(num);
cout << endl;
}
//delete temp;
*/
// cout << "+++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
/*
cout << "Graph Perf-vs-Price attr: min - " << data.getAttributesForPerfVsPrice()->getMin() << " max - " << data.getAttributesForPerfVsPrice()->getMax() << " ";
cout << "interval - " << data.getAttributesForPerfVsPrice()->getInterval() << endl;
int range1 =data.getAttributesForPerfVsPrice()->getMin();
for (int k=0; k < 40; k++)
{
//cout << range1 << " - ";
range1+=data.getAttributesForPerfVsPrice()->getInterval();
//cout << range1 << " : ";
for (int p=0; p < data.getSizeOfListAt(k); p++ )
{
//cout << " " << data.getListAt_PositionAt(k,p) << " ";
}
//cout << endl;
}
*/
//tempF = temp->getFitness(20,5,10);
// cout << "Fitness: " << tempF << endl;
return 0;
}