double GeneticAlgorithm::findFitness (int i) const { cout << "in FIND FITNESS (" << i << ") " << gt.size() << ":"; GeneTree* tmpgt = gt[i]; cout << "&1&" << endl; vector& gtref= gt[i]->getVector(); // CALLS MAKEEMPTY RANDOMLY HERE cout << "&1.5&" << endl; GeneNode* tmpgn = gtref[0]; cerr << "&2& " << tmpgn->data.first << ":" << tmpgn->data.second << ":::" << tmpgn << endl; tmpgn->print(); // STUFFS UP HERE cout << ":" << endl; // these would be randomised and run a few time to get an average fitness function double h = 25.0, d = 50.0; map m; m['h'] = 30; m['d'] = 40; cout << "evaluating theta and velocity" << endl; // TODO use trees to evaluate this :) cout << 'a' << endl; GeneNode const* gn = gt[i]->getVector()[0]; cout << 'b' << endl; double theta = evaluateTree(gn, m); double v = evaluateTree(gt[i]->getVector()[1], m); double y = 9.8*d*d/(2*v*sin(theta)) + cos(theta)*d; double abs = y-h; if (y - h < 0) abs*=-1; cout << "end FIND FITNESS "; gt[i]->print(); cout << endl; return abs; }