comparison TrainingScoreManager.h @ 29:e7af34b1af83

animated sliders throughput calculation
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 03 Nov 2014 18:27:58 +0000
parents 8124f46eda65
children 78b51f924ec1
comparison
equal deleted inserted replaced
28:953db6518738 29:e7af34b1af83
21 int targetBandHit; // eg bullseye = 0 edge = 7 21 int targetBandHit; // eg bullseye = 0 edge = 7
22 float timeAllowed; 22 float timeAllowed;
23 int score; 23 int score;
24 ofColor colorBand; 24 ofColor colorBand;
25 string displayText; 25 string displayText;
26 float bits;
26 }; 27 };
27 28
28 class TrainingScoreManager{ 29 class TrainingScoreManager{
29 30
30 // equiv of score bit of testController 31 // equiv of score bit of testController
31 public: 32 public:
32 33
33 TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> answer, int timeAllowed) const { 34 TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> startPosition, vector<int> answer, int timeAllowed) const {
34 TrainingTestResult result; 35 TrainingTestResult result;
35 stringstream msg; 36 stringstream msg;
36 int score = 0; 37 int score = 0;
37 // work out euc distance from actual point 38 // work out euc distance from actual point
38 //for_each(answer.begin(),answer.end(),printThing<int>()); 39 //for_each(answer.begin(),answer.end(),printThing<int>());
39 //for_each(targetParams.begin(),targetParams.end(),printThing<int>()); 40 //for_each(targetParams.begin(),targetParams.end(),printThing<int>());
41 float initDist = euclideanDistance(startPosition, answer);
40 float dist = euclideanDistance(targetParams, answer); 42 float dist = euclideanDistance(targetParams, answer);
41 auto dimComp = sqrt(6.0); 43
44 float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.);
45
46 cout << TP << endl;
47
48 auto dimComp = sqrt(TOTAL_NUM_PARAMS);
42 int band = -1; 49 int band = -1;
43 if (dist < TARGET_SCORE_CC_BAND*dimComp){ 50 if (dist < TARGET_SCORE_CC_BAND*dimComp){
44 score = 50; 51 score = 50;
45 band = 1; 52 band = 1;
46 53
112 119
113 120
114 return result; 121 return result;
115 } 122 }
116 private: 123 private:
117 124 float calculateThroughput(int numDims, float endDistance, float startDistance, float time) const{
125
126 float ISSR = numDims * log2( startDistance / endDistance);
127 cout << "start: " << startDistance << endl;
128 cout << "end: " << endDistance << endl;
129 cout << "ISSR: " << ISSR << endl;
130 float TP = ISSR / time;
131 return TP;
132 }
118 float euclideanDistance(vector<int> v1, vector<int> v2) const{ 133 float euclideanDistance(vector<int> v1, vector<int> v2) const{
119 if (v1.size() != v2.size()){ 134 if (v1.size() != v2.size()){
120 cout << "ERROR ERROR: vectors must be same length for Mr Euclid"; 135 cout << "ERROR ERROR: vectors must be same length for Mr Euclid";
121 return 0.; 136 return 0.;
122 } 137 }