std::vector<RobotState> RobotNeighbours::operator()(RobotState s) { static std::vector<Vector2D> lookUp = accs(constraints.maxAcc); std::vector<RobotState> result; Vector2D newPos = s.pos.add(s.speed); unsigned int newTime = s.elapsedTime + 1; Environment currentEnv = env.getAfterTime(newTime); if(!currentEnv.isSound(Circle(newPos,constraints.r))) { return result; } for(auto dV : lookUp) { Vector2D newV = s.speed.add(dV); if(newV.length() <= constraints.maxV) { RobotState newState; newState.pos = newPos; newState.speed = newV; newState.elapsedTime = newTime; result.push_back(newState); } } return result; }
/* sthresh if as > sthresh sa=1 if as<= sthresh sa=0 */ void baccs(struct atomgrp* ag, struct prm* prm, float r_solv, short cont_acc, short rpr, float sthresh) { int n_at=ag->natoms; int i; float* as= (float*)_mol_malloc(n_at*sizeof(float)); accs(ag, prm, r_solv, cont_acc, rpr, as); for(i=0; i<n_at; i++)ag->atoms[i].sa=as[i]>sthresh?1:0; free(as); }
void lbann_callback_print::on_test_end(Model* m) { lbann_comm* comm = m->get_comm(); if (comm->am_model_master()) { DataType test_acc = m->get_test_accuracy(); if (comm->am_world_master()) { std::vector<DataType> accs(comm->get_num_models()); comm->intermodel_gather(test_acc, accs); for (size_t i = 0; i < accs.size(); ++i) { std::cout << "Model " << i << " external validation accuracy: "; std::cout << accs[i] << "%" << std::endl; } } else { comm->intermodel_gather(test_acc, comm->get_intermodel_master()); } } }
void ScoreSet::setMinOptMax(int & nmin, int & noptimal, int & nmax) const { if (scores.size() <= 0) return; const float desiredLeft = 1.00; const float desiredRight = 0.25; std::map<int, Score>::const_iterator best = scores.begin(); std::pair<float, float> accs(0.0, 1.0); std::pair<float, float> err = std::pair<float, float>(pow(desiredLeft - accs.first, 2), pow(desiredRight - accs.second, 2)); std::map<int, Score>::const_iterator divider; // Find the divider divider = scores.begin(); while (1) { // Can be more efficient at recomputing scores std::pair<float, float> naccs = calculateLRAccuracies(divider); std::pair<float, float> nerr = std::pair<float, float>(pow(desiredLeft - naccs.first, 2), pow(desiredRight - naccs.second, 2)); if (divider == scores.end()) std::cout << "Line: " << scores.rbegin()->first << "/" << scores.rbegin()->first + 1 << std::endl; else std::cout << "Line: " << divider->first - 1 << "/" << divider->first << std::endl; std::cout << "Acc: " << naccs.first << " " << naccs.second << " " << naccs.first + naccs.second << std::endl; std::cout << "Err: " << nerr.first << " " << nerr.second << " " << nerr.first + nerr.second << std::endl; if (nerr.first + nerr.second <= err.first + err.second) { best = divider; accs = naccs; err = nerr; } if (divider != scores.end()) divider++; else break; } if (best == scores.end()) nmax = scores.rbegin()->first + 1; else nmax = best->first; std::cout << "Drawn Line: " << nmax - 1 << "/" << nmax << std::endl; // Find the optimal play speed std::map<int, Score>::const_iterator optimal = best; std::map<int, Score>::const_iterator previous; const float improvementThreshold = 0.01; divider = best; while (divider != scores.begin()) { previous = divider; --divider; optimal = divider; std::pair<float, float> naccs2 = calculateLRAccuracies(previous); std::pair<float, float> naccs1 = calculateLRAccuracies(divider); if (naccs1.first - naccs2.first < improvementThreshold) break; } noptimal = optimal->first; std::cout << "Optimal: " << noptimal << std::endl; const float pgrowthLimit = 1.25; float pgrowth = static_cast<float>(nmax) / noptimal; if (pgrowth < pgrowthLimit) // { pgrowth = pgrowthLimit; noptimal = nmax / pgrowth; } nmin = noptimal / pgrowth; }