#define USECHRONO #undef HAVE_MPI #include "eval.hpp" #include #include #include #include using namespace aed; using namespace std; //---:---<*>---:---<*>- COMIENZA CODIGO FUNCION --:---<*>---:---<*>---:---<*> // COMPLETAR DNI y NOMBRE AQUI: // Nombre: Lucas Bircher int DNI=43426577; //dado el cjto S, devuelve el mayor subconjunto propio de S(segun la relacion de orden R) //cuyo promedio sea el más cercano en val abs al promedio de los elementos de S completo float promedio(set &s){ float promedio = 0; auto itS = s.begin(); while(itS != s.end()){ promedio += *itS; itS++; } promedio = promedio / s.size(); return (promedio); } // true si sa es mayor que sb bool es_mayor(set &sa, set &sb){ auto itsa = sa.begin(); auto itsb = sb.begin(); int max_a = 0; while(itsa != sa.end()){ if(*itsa > max_a ){ max_a = *itsa; } itsa++; } int max_b = 0; while(itsb != sb.end()){ if(*itsb > max_b){ max_b = *itsb; } itsb++; } if(max_a > max_b){ return true; } if(max_b > max_a){ return false; } if(max_a == max_b){ sa.erase(max_a); sb.erase(max_b); return (es_mayor(sa,sb)); } } void get_largest_subset(set &S, set &C) { if(S.empty()) return; float prom_estandar = promedio(S); float mejor_prom = 10000; auto its = S.begin(); int s_size = S.size(); s_size--; while(its != S.end()){ set aux; aux.clear(); aux.insert(*its); auto its2 = S.begin(); while(its2 != S.end() and (aux.size() != s_size )){ aux.insert(*its2); //ver distancias float distancia_prom = abs(promedio(aux) - prom_estandar); if(distancia_prom < mejor_prom){ C = aux; mejor_prom = distancia_prom; } if(distancia_prom == mejor_prom){ if(es_mayor(aux,C)){ C = aux; mejor_prom = distancia_prom; } } its2++; } its++; } } //---:---<*>---:---<*>- FINALIZA CODIGO FUNCION --:---<*>---:---<*>---:---<*> int main() { Eval ev; int vrbs=0; ev.eval<1>(get_largest_subset,vrbs); return 0; }