int main(){ //Config leerArchivoConfig(); inicializarEstructuras(); conectarAlSWAP(); //servidor crearHiloInterprete(); gestionarConexiones(); return 0; }
int main() { printf("***************HOLA SOY UN PROCESO NODO\n****************"); t_config_nodo* arch_config; pthread_mutex_init(&numeroMap,NULL); pthread_mutex_init(&numeroReduce,NULL); printf("Cargando archivo de Configuracion\n"); arch_config= malloc(sizeof(t_config_nodo)); arch_config = leerArchivoConfig(ARCHIVO_CONFIG); int sockfs; pthread_t hiloFS; // pthread_t hiloJobs; // pthread_t hiloNodos; t_hilofs paramHiloFS; //sockfs = 1; sockfs = crearCliente(arch_config->IP_FS,arch_config->PUERTO_FS); paramHiloFS.socket = sockfs; paramHiloFS.IP_NODO = arch_config->IP_NODO; paramHiloFS.PUERTO_NODO = arch_config->PUERTO_NODO; paramHiloFS.ARCH_BIN = arch_config->ARCH_BIN; paramHiloFS.NODO_NEW = arch_config->NODO_NEW; paramHiloFS.DIR_TEMP = arch_config->DIR_TEMP; paramHiloFS.ID = arch_config->ID; pthread_create(&hiloFS, NULL, (void*)conexionFS, (void*) ¶mHiloFS); // pthread_create(&hiloJobs, NULL, (void*)conexionJobs, (void*) &arch_config->PUERTO_NODO); if (crearServerMultiHilo(arch_config->PUERTO_NODO,(void*)conexionJobs) == 0) printf("Nodo en la espera de conexiones de JOBs y otros Nodos\n"); // pthread_create(&hiloNodos, NULL, (void*)conexionNodos, (void*) &arch_config->PUERTO_NODO); pthread_join(hiloFS,NULL); //pthread_join(hiloJobs,NULL); // pthread_join(hiloNodos,NULL); //Probando un mensaje mandado del nodo al FS //send(sockfs,ip,1000 ,0); //printf("\n"); //munmap(DATOS,sizeof(DATOS)); return 0; }
int main(int argc, char const *argv[]) { int termino = 0, offsetHost = 0; if (argv[1] == string("CSPLib")) { while (!termino) { // Configuración string NOMBRE_INSTANCIA = argv[2]; int ITERACIONES_TS = atoi(argv[3]), LARGO_LISTA_TABU = atoi(argv[4]); // Declaración de variables string PATH = "Instancias PPP/Instancias CSPLib/"; clock_t t_ini, t_fin; map<int, int> posicionesGuests; vector<int> hosts; double secs; pair <int, matrix> resultado; matrix matrizInicial; PPP problema; int CANTHOSTS; // Leyendo archivo de la instancia problema = leerArchivo(PATH + NOMBRE_INSTANCIA + ".txt"); // Seteando hosts y guests CANTHOSTS = problema.T + offsetHost; vector< pair<int, int> > yatesHosts = getNMayores(CANTHOSTS, problema.vtrK); for(unsigned i = 0; i < yatesHosts.size(); ++i) hosts.push_back(yatesHosts[i].second); posicionesGuests = getPosicionGuests(problema.Y, hosts); // Ejecutando algoritmos t_ini = clock(); matrizInicial = greedy(posicionesGuests, hosts, problema); resultado = tabuSearch(matrizInicial, posicionesGuests, hosts, problema, ITERACIONES_TS, LARGO_LISTA_TABU); t_fin = clock(); if (resultado.first != 0) { offsetHost++; continue; } secs = (double) (t_fin - t_ini) / CLOCKS_PER_SEC; // Escribiendo el archivo de salida escribirOutput(NOMBRE_INSTANCIA, hosts, posicionesGuests, resultado.second, problema, secs, resultado.first); termino = 1; } } else if (argv[1] == string("PPP")) { // Configuración int ITERACIONES_TS = atoi(argv[3]), LARGO_LISTA_TABU = atoi(argv[4]); // Declaración de variables string NOMBRE_INSTANCIA, ARCHIVO_SALIDA; string PATH = "Instancias PPP/"; clock_t t_ini, t_fin; map<int, int> posicionesGuests; vector<int> hosts; double secs; pair <int, matrix> resultado; matrix matrizInicial; PPP problema; // Leyendo archivo de la instancia y seteando hosts y guests if (argv[2] == string("m1")) { NOMBRE_INSTANCIA = string(argv[1]) + "_m1"; hosts = leerArchivoConfig(PATH + "Configuraciones/Configuraciones_m1.txt")["pp1_m"]; ARCHIVO_SALIDA = NOMBRE_INSTANCIA; } else if (argv[2] == string("m2")) { NOMBRE_INSTANCIA = string(argv[1]) + "_m2"; hosts = leerArchivoConfig(PATH + "Configuraciones/Configuraciones_m2.txt")["pp1_m2"]; ARCHIVO_SALIDA = NOMBRE_INSTANCIA; } else { NOMBRE_INSTANCIA = string(argv[1]); hosts = leerArchivoConfig(PATH + "Configuraciones/Configuraciones.txt")[argv[2]]; ARCHIVO_SALIDA = NOMBRE_INSTANCIA + "_" + string(argv[2]); } // Leyendo archivo de la instancia problema = leerArchivo(PATH + NOMBRE_INSTANCIA + ".txt"); posicionesGuests = getPosicionGuests(problema.Y, hosts); // Ejecutando algoritmos t_ini = clock(); matrizInicial = greedy(posicionesGuests, hosts, problema); cout << "Trabajando... Si es que el problema es PPP normal se demora entre 2 a 3 minutos." << endl << endl; resultado = tabuSearch(matrizInicial, posicionesGuests, hosts, problema, ITERACIONES_TS, LARGO_LISTA_TABU); t_fin = clock(); secs = (double) (t_fin - t_ini) / CLOCKS_PER_SEC; // Escribiendo el archivo de salida escribirOutput(ARCHIVO_SALIDA, hosts, posicionesGuests, resultado.second, problema, secs, resultado.first); } return 0; }