/**************************************************************************** Initializes a player research iterator. ****************************************************************************/ struct iterator *research_iter_init(struct research_iter *it) { struct iterator *base = ITERATOR(it); base->get = research_iter_get; it->index = -1; if (game.info.team_pooled_research) { base->next = research_iter_team_next; base->valid = research_iter_team_valid; } else { base->next = research_iter_player_next; base->valid = research_iter_player_valid; } base->next(base); return base; }
void WidgetManager::onAfterEvents() { ITERATOR(m_moduleArray[i]->onAfterEvents()); }
void WidgetManager::onAI() { ITERATOR(m_moduleArray[i]->onAI()); }
void WidgetManager::onUserInput(UserInput* ui) { ITERATOR(m_moduleArray[i]->onUserInput(ui)); }
void WidgetManager::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { ITERATOR(m_moduleArray[i]->onSimulation(rdt, sdt, idt)); }
LinkWeight_Metric::LinkWeight_Metric(Network *net) : Metric(net) { map<pair<string, string>, double> values; printf("Creating LinkWeight metric\n"); double max_metric = 0.0; double min_metric = 1.0; printf("Network has %d links\n", net->links.size()); for(int i=0; i < net->size(); i++) { Node &ni = net->getNode(i); for(int j=0; j < net->size(); j++) { if( i == j) continue; Node &nj = net->getNode(j); if( net->areLinked(ni,nj)) { double w = net->getLinkWeight(ni,nj); values[make_pair(ni.id,nj.id)] = w; //printf("%s -> %s = %f\n", //ni.id.c_str(),nj.id.c_str(), w); } } } ITERATOR(values) it; for(it = values.begin();it != values.end();it++){ double cost = it->second; max_metric = fmax(max_metric,cost); min_metric = fmin(min_metric,cost); } printf("max_metric %f min_metric %f\n", max_metric, min_metric); max_cost = -1.0; for(it = values.begin();it != values.end();it++){ string sid = (it->first).first; string tid = (it->first).second; double met = it->second; if( fabs(max_metric -min_metric) > EPSILON ) { met = (met - min_metric)/(max_metric - min_metric); } double cost; if(prob.lambda < 0) cost = (1 - met); else{ cost = 1 + prob.lambda*(1-met); } //printf("Setting link cost .%s. .%s. %f\n", //sid.c_str(), tid.c_str(), cost); max_cost = fmax(max_cost,cost); metric[make_pair(sid,tid)] = cost; } printf("max_cost %f\n", max_cost); //max_cost = -1.0; }