Rval *selectERval(varInfo *v, int i) { int j; Rval *p; DPRINT2(3,"selectERval: find %dth ERval of var 0x%08x...\n",i,v); if (0 < i) { p = v->E; j = 1; while ((j < i) && p) { DPRINT2(3,"selectERval: ...not %dth (was 0x%08x)\n",j,p); p = p->next; j += 1; } #ifdef DEBUG if (p) DPRINT2(3,"selectERval: SUCCEEDED, %dth is 0x%08x\n",i,p); else DPRINT0(3,"selectERval: FAILED, ran out of ERval packets!\n"); #endif return(p); } else { DPRINT0(3,"selectERval: FAILED, can't select 0th value\n"); return(NULL); } }
int assignReal(double d, varInfo *v, int i) { Rval *q; DPRINT3(3,"assignReal: 0x%08x[%d] <== %lf",v,i,d); if (v) { if (v->T.basicType == T_STRING) { WerrprintfWithPos("Can't assign REAL value to STRING variable"); #ifdef VNMRJ jExpressionError(); #endif return(0); } else { if (v->T.basicType == T_UNDEF) { DPRINT0(3,", newly defined as REAL"); v->T.basicType = T_REAL; } if (i) { DPRINT1(3,", just to element %d\n",i); if (i <= v->T.size+1) { if ((q=selectRval(v,i)) == NULL) q = addNewRval(v); q->v.r = d; /* v->active = ACT_ON; */ return(1); } else { WerrprintfWithPos("Assignment to non-existent element (=%d)",i); #ifdef VNMRJ jExpressionError(); #endif return(0); } } else { DPRINT0(3,", to whole thing\n"); disposeRealRvals(v->R); v->T.size = 0; v->R = NULL; q = addNewRval(v); q->v.r = d; /* v->active = ACT_ON; */ } return(1); } } else { DPRINT0(3,", NULL var ptr\n"); return(0); } }
int assignEString(char *s, varInfo *v, int i) { Rval *q; DPRINT3(3,"assignEString: 0x%08x[%d] <== \"%s\"",v,i,s); if (v) { if (v->ET.basicType == T_REAL) { WerrprintfWithPos("Can't assign STRING value to REAL variable"); #ifdef VNMRJ jExpressionError(); #endif return(0); } else { if (v->ET.basicType == T_UNDEF) { DPRINT0(3,", newly defined as STRING"); v->ET.basicType = T_STRING; } if (i) { DPRINT1(3,", just to element %d\n",i); if (i <= v->ET.size+1) { if ((q=selectERval(v,i)) == NULL) q = addNewERval(v); else release(q->v.s); q->v.s = newString(s); return(1); } else { WerrprintfWithPos("Can't assign to non-existent element (%d)\n",i); #ifdef VNMRJ jExpressionError(); #endif return(0); } } else { DPRINT0(3,", to whole thing\n"); disposeStringRvals(v->E); v->ET.size = 0; v->E = NULL; q = addNewERval(v); q->v.s = newString(s); } return(1); } } else return(0); }
int autora(int argc, char *argv[], int retc, char *retv[]) { char tmpPath[MAXPATH]; int ival; DPRINT0("autora command invoked\n"); /* resume is implicit */ ival = ok_to_acquire(); if (ival != -2) release_console2(); if ( (ival != 0) && (ival != -4)) { /* Acquisition needs to be Idle or in automation mode */ report_acq_perm_error( argv[0], ival ); ABORT; } if (argc == 1) { strcpy(tmpPath,userdir); strcat(tmpPath,"/global"); DPRINT1("copying Global parameters to '%s' file.\n",tmpPath); if (P_save(GLOBAL,tmpPath)) { Werrprintf("Problem saving global parameters in '%s'.",tmpPath); } } P_getstring(GLOBAL,"autodir",&tmpPath[ 0 ], 1, MAXPATH); setAutoDir(tmpPath); if (send2Acq(11, tmpPath) < 0) Werrprintf("autora message was not sent"); RETURN; }
int resume(int argc, char *argv[], int retc, char *retv[]) { char resume_arg[MAXPATH]; DPRINT0("resume command invoked\n"); GET_ACQ_ID(resume_arg); if (send2Acq(13, resume_arg) < 0) Werrprintf("resume message was not sent"); RETURN; }
node *findMacro(char *n) { symbol *p; DPRINT1(3,"findMacro: named \"%s\"...",n); p=findName(macroCache,n); if (p == NULL) p = findName(tempCache,n); if (p != NULL) { DPRINT0(3," found!\n"); return((node *)(p->val)); } else { DPRINT0(3," NOT found!\n"); return(NULL); } }
varInfo *createVar(char *n) { symbol **pp; DPRINT1(3,"createVar: creating \"%s\"...\n",n); if ( (pp=selectVarTree(n)) ) return(RcreateVar(n,pp,ST_UNDEF)); else { DPRINT0(3,"createVar: could not select tree \n"); return(NULL); } }
void tossVar(register symbol *p) { register varInfo *v; if (p) { DPRINT1(3,"tossVar: symbol 0x%06x",p); if (p->name) { DPRINT2(3,", name is \"%s\" (at 0x%06x)",p->name,p->name); release(p->name); } if ( (v=(varInfo *)(p->val)) ) { DPRINT1(3,", varInfo 0x%06x",v); if (v->T.basicType == T_STRING) { DPRINT0(3,", STRING\n"); disposeStringRvals(v->R); disposeStringRvals(v->E); } else { DPRINT0(3,", REAL\n"); disposeRealRvals(v->R); disposeRealRvals(v->E); } #ifndef VNMRJ #ifdef VNMRTCL /* This function is used by the TCL interface * The function is in socket.c in the acqcomm library */ unsetMagicVar(v); #endif #endif release(v); } release(p); } }
int do_GE(pair *a, pair *b, pair *c) { DPRINT0(3,"do_GE: hand-off to do_LT...\n"); if (do_LT(a,b,c)) { if (a->R->v.r == 0.0) a->R->v.r = 1.0; else a->R->v.r = 0.0; DPRINT1(3,"do_GE: ...ok! (result is %f)\n",a->R->v.r); return(1); } else return(0); }
void pushTree() { if ((level+1) < 256) { DPRINT2(3,"pushTree: from level %d to %d\n",level,level+1); level += 1; local[level] = temp; temp = NULL; fixNames(local[level]); DPRINT0(3,"pushTree: ...done\n"); } else { fprintf(stderr,"magic: environment nesting is too deep\n"); exit(1); } }
int assignPair(pair *p, varInfo *v, int i) { Rval *r; DPRINT3(3,"assignPair: pair 0x%08x to var 0x%08x[%d]...\n",p,v,i); DSHOWPAIR(3,"assignPair: ",p); DSHOWVAR(3,"assignPair: ",v); if (v) { switch (p->T.basicType) { case T_UNDEF: return(0); case T_REAL: r = p->R; if (v->prot & P_ARR) { if ((r = r->next) || (i > 1)) { WerrprintfWithPos("cannot array parameter"); return(0); } r = p->R; } while (r) { if (assignReal(r->v.r,v,i)) { r = r->next; if (i == 0) i++; /* bump index to 2 */ i += 1; } else { return(0); } } DPRINT0(3,"assignPair: ...after\n"); DSHOWVAR(3,"assignPair: ",v); return(1); case T_STRING: r = p->R; if (v->prot & P_ARR) { if ((r = r->next) || (i > 1)) { WerrprintfWithPos("cannot array parameter"); return(0); } r = p->R; } while (r) if (assignString(r->v.s,v,i)) { r = r->next; if (i == 0) i++; /* bump index to 2 */ i += 1; } else return(0); DPRINT0(3,"assignPair: ...after\n"); DSHOWVAR(3,"assignPair: ",v); return(1); default: WerrprintfWithPos("unknown parameter assignment with basictype %d",p->T.basicType); return(0); } } return(0); }
void tossTemps() { DPRINT0(3,"tossTemps: just like it says\n"); tossVars(&temp); }
int main(int argc, char *argv[]) { static AdData data; /* to be init with 0 (debug only) */ AdData *p_ad = &data; int i, user_stat = 0; double time_one0, time_one; double nb_same_var_by_iter, nb_same_var_by_iter_tot; int nb_iter_cum; int nb_local_min_cum; int nb_swap_cum; int nb_reset_cum; double nb_same_var_by_iter_cum; int nb_restart_cum, nb_restart_min, nb_restart_max; double time_cum, time_min, time_max; int nb_iter_tot_cum, nb_iter_tot_min, nb_iter_tot_max; int nb_local_min_tot_cum, nb_local_min_tot_min, nb_local_min_tot_max; int nb_swap_tot_cum, nb_swap_tot_min, nb_swap_tot_max; int nb_reset_tot_cum, nb_reset_tot_min, nb_reset_tot_max; double nb_same_var_by_iter_tot_cum, nb_same_var_by_iter_tot_min, nb_same_var_by_iter_tot_max; int user_stat_cum, user_stat_min, user_stat_max; char buff[256], str[32]; /* Seeds generation */ int last_value; /* last value generated by the linear chaotic map */ int param_a; /* parameter 'a' for the linear chaotic map */ int param_c; /* parameter 'c' for the linear chaotic map */ long int print_seed ; struct timeval tv ; #if defined PRINT_COSTS char * tmp_filename=NULL ; #endif /* PRINT_COSTS */ #if defined MPI Main_MPIData mpi_data ; #endif Parse_Cmd_Line(argc, argv, p_ad); /************************ Initialize chaotic function **********************/ param_a = 5; /* Values by default from research paper */ param_c = 1; gettimeofday(&tv, NULL); /*********************** MPI & SEQ code Initialization *********************/ #if defined MPI mpi_data.param_a_ptr = ¶m_a ; mpi_data.param_c_ptr = ¶m_c ; mpi_data.last_value_ptr = &last_value ; mpi_data.p_ad = p_ad ; mpi_data.p_ad->main_mpi_data_ptr = &mpi_data ; mpi_data.print_seed_ptr = &print_seed ; mpi_data.tv_sec = tv.tv_sec ; mpi_data.count_ptr = &count ; #if defined STATS Gmpi_stats.nb_sent_messages = 0 ; Gmpi_stats.nb_sent_mymessages = 0 ; #endif #if defined PRINT_COSTS mpi_data.nb_digits_nbprocs_ptr = &nb_digits_nbprocs ; #endif MPI_Init( &argc , &argv ) ; MPI_Comm_rank(MPI_COMM_WORLD, &my_num) ; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size) ; TPRINT0("Program: %s", argv[0]) ; for( i=1 ; i< argc ; ++i ) PRINT0(" %s", argv[i]) ; PRINT0("\n") ; AS_MPI_initialization( &mpi_data ) ; #else /****************************** MPI -> SEQ *****************************/ TPRINT0("Program: %s", argv[0]) ; for( i=1 ; i< argc ; i++ ) PRINT0(" %s", argv[i]) ; PRINT0("\n") ; #if defined PRINT_COSTS nb_digits_nbprocs = 0 ; #endif /* PRINT_COSTS */ if (p_ad->seed < 0) { srandom((unsigned int)tv.tv_sec); /* INT_MAX / 6 (= 357.913.941) is a reasonable value to start with... I think... */ last_value = (int) Random(INT_MAX / 6); /* INT_MAX (= 2.147.483.647) is the max value for a signed 32-bit int */ p_ad->seed = randChaos(INT_MAX, &last_value, ¶m_a, ¶m_c); } print_seed = p_ad->seed; #endif /**************************** MPI */ #if defined PRINT_COSTS if( filename_pattern_print_cost==NULL ) { PRINT0("Please give a pattern for filename in which to save costs\n\n") ; exit(-1) ; } tmp_filename=(char*) malloc(sizeof(char)*strlen(filename_pattern_print_cost) + 2 + nb_digits_nbprocs ) ; if( nb_digits_nbprocs > 3 ) { PRINT0("You use a number of procs sup to 999. " "You must modify the code to adjust next line\n") ; exit(-1) ; } #if defined MPI /* TODO: How can we bypass the static char to format output in nxt line? */ sprintf(tmp_filename,"%s_p%03d", filename_pattern_print_cost,my_num) ; #else sprintf(tmp_filename,"%s_seq", filename_pattern_print_cost) ; #endif file_descriptor_print_cost = open(tmp_filename, O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) ; if( file_descriptor_print_cost == -1 ) { PRINTF("Cannot create file to print costs: file already exists?\n") ; return -1 ; } #endif /* PRINT_COSTS */ /********* Initialization of the pseudo-random generator with the seed ******/ srandom((unsigned)p_ad->seed); p_ad->nb_var_to_reset = -1; p_ad->do_not_init = 0; p_ad->actual_value = NULL; p_ad->base_value = 0; p_ad->break_nl = 0; /* defaults */ Init_Parameters(p_ad); if (p_ad->reset_limit >= p_ad->size) p_ad->reset_limit = p_ad->size - 1; setvbuf(stdout, NULL, _IOLBF, 0); //setlinebuf(stdout); if (p_ad->debug > 0 && !ad_has_debug) DPRINT0("Warning ad_solver is not compiled with debugging support\n") ; if (p_ad->log_file && !ad_has_log_file) DPRINT0("Warning ad_solver is not compiled with log file support\n") ; p_ad->size_in_bytes = p_ad->size * sizeof(int); p_ad->sol = malloc(p_ad->size_in_bytes); if (p_ad->nb_var_to_reset == -1) { p_ad->nb_var_to_reset = Div_Round_Up(p_ad->size * p_ad->reset_percent, 100); if (p_ad->nb_var_to_reset < 2) { p_ad->nb_var_to_reset = 2; PRINT0("increasing nb var to reset since too small, now = %d\n", p_ad->nb_var_to_reset); } } #if defined MPI AS_MPI_initialization_epilogue( &mpi_data ) ; #endif /********** Print configuration information + specific initialization *****/ PRINT0("current random seed used: %u (seed_0 %u) \n", (unsigned int)p_ad->seed, (unsigned int)print_seed) ; PRINT0("variables of loc min are frozen for: %d swaps\n", p_ad->freeze_loc_min) ; PRINT0("variables swapped are frozen for: %d swaps\n", p_ad->freeze_swap) ; if (p_ad->reset_percent >= 0) PRINT0("%d %% = ", p_ad->reset_percent) ; PRINT0("%d variables are reset when %d variables are frozen\n", p_ad->nb_var_to_reset, p_ad->reset_limit) ; PRINT0("probability to select a local min (instead of " "staying on a plateau): ") ; if (p_ad->prob_select_loc_min >=0 && p_ad->prob_select_loc_min <= 100) PRINT0("%d %%\n", p_ad->prob_select_loc_min) ; else PRINT0("not used\n") ; PRINT0("abort when %d iterations are reached " "and restart at most %d times\n", p_ad->restart_limit, p_ad->restart_max) ; PrintAllCompilationOptions() ; #if defined BACKTRACK /* Note: This has to be done after p_ad initialization! */ /* Gbacktrack_array_begin = 0 ; */ /* Gbacktrack_array_end = 0 ; */ /* Gconfiguration_size_in_bytes = p_ad->size_in_bytes ; */ /* for( i=0 ; i<SIZE_BACKTRACK ; i++ ) */ /* Gbacktrack_array[i].configuration = (unsigned int*) */ /* malloc(Gconfiguration_size_in_bytes) ; */ /* YC->all: do the rest of initilization */ gl_elitePool.config_list_begin = NULL; gl_elitePool.config_list_end = NULL; gl_elitePool.config_list_size = 0; gl_elitePool.nb_backtrack = 0; gl_elitePool.nb_variable_backtrack = 0; gl_elitePool.nb_value_backtrack = 0; gl_stockPool.config_list_begin = NULL; gl_stockPool.config_list_end = NULL; gl_stockPool.config_list_size = 0; backtrack_configuration *item; for (i = 0; i < SIZE_BACKTRACK; i++) { item = malloc(sizeof(backtrack_configuration)); item->configuration = malloc(p_ad->size_in_bytes); pushStock(item); } #endif TPRINT0("%d begins its resolution!\n", my_num) ; TPRINT0("count = %d\n", count); if (count <= 0) /* Note: MPI => count=1 */ { Set_Initial(p_ad); time_one0 = (double) User_Time(); Solve(p_ad); time_one = ((double) User_Time() - time_one0) / 1000; if (p_ad->exhaustive) DPRINTF("exhaustive search\n") ; if (count < 0) Display_Solution(p_ad); Verify_Sol(p_ad); if (p_ad->total_cost) PRINTF("*** NOT SOLVED (cost of this pseudo-solution: %d) ***\n", p_ad->total_cost) ; if (count == 0) { nb_same_var_by_iter = (double) p_ad->nb_same_var / p_ad->nb_iter; nb_same_var_by_iter_tot = (double) p_ad->nb_same_var_tot / p_ad->nb_iter_tot; PRINTF("%5d %8.2f %8d %8d %8d %8d %8.1f %8d %8d %8d %8d %8.1f", p_ad->nb_restart, time_one, p_ad->nb_iter, p_ad->nb_local_min, p_ad->nb_swap, p_ad->nb_reset, nb_same_var_by_iter, p_ad->nb_iter_tot, p_ad->nb_local_min_tot, p_ad->nb_swap_tot, p_ad->nb_reset_tot, nb_same_var_by_iter_tot); if (user_stat_fct) PRINTF(" %8d", (*user_stat_fct)(p_ad)); PRINTF("\n"); } else { PRINTF("in %.2f secs (%d restarts, %d iters, %d loc min, %d swaps, %d resets)\n", time_one, p_ad->nb_restart, p_ad->nb_iter_tot, p_ad->nb_local_min_tot, p_ad->nb_swap_tot, p_ad->nb_reset_tot); } #if defined BACKTRACK PRINTF("BACKTRACK STATS:\n"); PRINTF("Total number of performed backtracks: %d\n", gl_elitePool.nb_backtrack); PRINTF("Total number of performed backtracks starting from another variable: %d\n", gl_elitePool.nb_variable_backtrack); PRINTF("Total number of performed backtracks starting from another value: %d\n", gl_elitePool.nb_value_backtrack); #endif #if defined STATS print_stats() ; #endif return 0 ; } /* (count <= 0) */ if (user_stat_name) sprintf(str, " %8s |", user_stat_name); else *str = '\0'; snprintf(buff, 255, "|Count|restart| time | iters | loc min | swaps " "| resets | same/iter|%s\n", str); if (param_needed > 0) PRINT0("%*d\n", (int) strlen(buff)/2, p_ad->param) ; else if (param_needed < 0) PRINT0("%*s\n", (int) strlen(buff)/2, p_ad->param_file) ; PRINT0("%s", buff) ; for(i = 0; buff[i] != '\n'; ++i) if (buff[i] != '|') buff[i] = '-'; PRINT0("%s\n", buff) ; nb_restart_cum = time_cum = user_stat_cum = 0; nb_iter_cum = nb_local_min_cum = nb_swap_cum = nb_reset_cum = 0; nb_same_var_by_iter_cum = user_stat_cum = 0; nb_iter_tot_cum = nb_local_min_tot_cum = nb_swap_tot_cum = nb_reset_tot_cum = 0; nb_same_var_by_iter_tot_cum = 0; nb_restart_min = user_stat_min = (1 << 30); time_min = 1e100; nb_iter_tot_min = nb_local_min_tot_min = nb_swap_tot_min = nb_reset_tot_min = (1 << 30); nb_same_var_by_iter_tot_min = 1e100; nb_restart_max = user_stat_max = 0; time_max = 0; nb_iter_tot_max = nb_local_min_tot_max = nb_swap_tot_max = nb_reset_tot_max = 0; nb_same_var_by_iter_tot_max = 0; for(i = 1; i <= count; i++) { Set_Initial(p_ad); time_one0 = (double) User_Time(); Solve(p_ad); time_one = ((double) User_Time() - time_one0) / 1000; #if !defined MPI /* Slashes MPI output! */ if (disp_mode == 2 && nb_restart_cum > 0) PRINTF("\033[A\033[K"); PRINTF("\033[A\033[K\033[A\033[256D"); #endif Verify_Sol(p_ad); if (user_stat_fct) user_stat = (*user_stat_fct)(p_ad); nb_same_var_by_iter = (double) p_ad->nb_same_var / p_ad->nb_iter; nb_same_var_by_iter_tot = (double) p_ad->nb_same_var_tot / p_ad->nb_iter_tot; nb_restart_cum += p_ad->nb_restart; time_cum += time_one; nb_iter_cum += p_ad->nb_iter; nb_local_min_cum += p_ad->nb_local_min; nb_swap_cum += p_ad->nb_swap; nb_reset_cum += p_ad->nb_reset; nb_same_var_by_iter_cum += nb_same_var_by_iter; user_stat_cum += user_stat; nb_iter_tot_cum += p_ad->nb_iter_tot; nb_local_min_tot_cum += p_ad->nb_local_min_tot; nb_swap_tot_cum += p_ad->nb_swap_tot; nb_reset_tot_cum += p_ad->nb_reset_tot; nb_same_var_by_iter_tot_cum += nb_same_var_by_iter_tot; if (nb_restart_min > p_ad->nb_restart) nb_restart_min = p_ad->nb_restart; if (time_min > time_one) time_min = time_one; if (nb_iter_tot_min > p_ad->nb_iter_tot) nb_iter_tot_min = p_ad->nb_iter_tot; if (nb_local_min_tot_min > p_ad->nb_local_min_tot) nb_local_min_tot_min = p_ad->nb_local_min_tot; if (nb_swap_tot_min > p_ad->nb_swap_tot) nb_swap_tot_min = p_ad->nb_swap_tot; if (nb_reset_tot_min > p_ad->nb_reset_tot) nb_reset_tot_min = p_ad->nb_reset_tot; if (nb_same_var_by_iter_tot_min > nb_same_var_by_iter_tot) nb_same_var_by_iter_tot_min = nb_same_var_by_iter_tot; if (user_stat_min > user_stat) user_stat_min = user_stat; if (nb_restart_max < p_ad->nb_restart) nb_restart_max = p_ad->nb_restart; if (time_max < time_one) time_max = time_one; if (nb_iter_tot_max < p_ad->nb_iter_tot) nb_iter_tot_max = p_ad->nb_iter_tot; if (nb_local_min_tot_max < p_ad->nb_local_min_tot) nb_local_min_tot_max = p_ad->nb_local_min_tot; if (nb_swap_tot_max < p_ad->nb_swap_tot) nb_swap_tot_max = p_ad->nb_swap_tot; if (nb_reset_tot_max < p_ad->nb_reset_tot) nb_reset_tot_max = p_ad->nb_reset_tot; if (nb_same_var_by_iter_tot_max < nb_same_var_by_iter_tot) nb_same_var_by_iter_tot_max = nb_same_var_by_iter_tot; if (user_stat_max < user_stat) user_stat_max = user_stat; #if !defined(MPI) switch(disp_mode) { case 0: /* only last iter counters */ case 2: /* last iter followed by restart if needed */ PRINTF("|%4d | %5d%c| %8.2f | %8d | %8d | %8d | %8d | %8.1f |", i, p_ad->nb_restart, (p_ad->total_cost == 0) ? ' ' : 'N', time_one, p_ad->nb_iter, p_ad->nb_local_min, p_ad->nb_swap, p_ad->nb_reset, nb_same_var_by_iter); if (user_stat_fct) PRINTF(" %8d |", user_stat); PRINTF("\n"); if (disp_mode == 2 && p_ad->nb_restart > 0) { PRINTF("| | | |" " %8d | %8d | %8d | %8d | %8.1f |", p_ad->nb_iter_tot, p_ad->nb_local_min_tot, p_ad->nb_swap_tot, p_ad->nb_reset_tot, nb_same_var_by_iter_tot); if (user_stat_fct) PRINTF(" |"); PRINTF("\n"); } PRINTF("%s", buff); PRINTF("| avg | %5d | %8.2f | %8d | %8d | %8d | %8d | %8.1f |", nb_restart_cum / i, time_cum / i, nb_iter_cum / i, nb_local_min_cum / i, nb_swap_cum / i, nb_reset_cum / i, nb_same_var_by_iter_cum / i); if (user_stat_fct) PRINTF(" %8.2f |", (double) user_stat_cum / i); PRINTF("\n"); if (disp_mode == 2 && nb_restart_cum > 0) { PRINTF("| | | |" " %8d | %8d | %8d | %8d | %8.1f |", nb_iter_tot_cum / i, nb_local_min_tot_cum / i, nb_swap_tot_cum / i, nb_reset_tot_cum / i, nb_same_var_by_iter_tot_cum / i); if (user_stat_fct) PRINTF(" |"); PRINTF("\n"); } break; case 1: /* only total (restart + last iter) counters */ PRINTF("|%4d | %5d%c| %8.2f | %8d | %8d | %8d | %8d | %8.1f |", i, p_ad->nb_restart, (p_ad->total_cost == 0) ? ' ' : 'N', time_one, p_ad->nb_iter_tot, p_ad->nb_local_min_tot, p_ad->nb_swap_tot, p_ad->nb_reset_tot, nb_same_var_by_iter_tot); if (user_stat_fct) PRINTF(" %8d |", user_stat); PRINTF("\n"); PRINTF("%s", buff); PRINTF("| avg | %5d | %8.2f | %8d | %8d | %8d | %8d | %8.1f |", nb_restart_cum / i, time_cum / i, nb_iter_tot_cum / i, nb_local_min_tot_cum / i, nb_swap_tot_cum / i, nb_reset_tot_cum / i, nb_same_var_by_iter_tot_cum / i); if (user_stat_fct) PRINTF(" %8.2f |", (double) user_stat_cum / i); PRINTF("\n"); break; } #else /* MPI */ /* disp_mode equals 1 by default */ /* Prepare what will be sent to 0, and/or printed by 0 */ snprintf(mpi_data.results, RESULTS_CHAR_MSG_SIZE - 1, "|* %ld/(%d/%d) | %5d | %8.2f | %8d | %8d | %8d | %8d | %8.1f |", print_seed, my_num, mpi_size, nb_restart_cum / i, time_cum / i, nb_iter_tot_cum / i, nb_local_min_tot_cum / i, nb_swap_tot_cum / i, nb_reset_tot_cum / i, nb_same_var_by_iter_tot_cum / i); /* TODO: use if(user_stat_fct)? What is that? */ #endif /* MPI */ } /* for(i = 1; i <= count; i++) */ if (count <= 0) /* YC->DD: is it really possible here? return 0 before.*/ return 0; if( count > 1 ) { /* YC->DD: why this test has been removed? */ PRINTF("| min | %5d | %8.2f | %8d | %8d | %8d | %8d | %8.1f |", nb_restart_min, time_min, nb_iter_tot_min, nb_local_min_tot_min, nb_swap_tot_min, nb_reset_tot_min, nb_same_var_by_iter_tot_min); if (user_stat_fct) PRINTF(" %8d |", user_stat_min); PRINTF("\n"); PRINTF("| max | %5d | %8.2f | %8d | %8d | %8d | %8d | %8.1f |", nb_restart_max, time_max, nb_iter_tot_max, nb_local_min_tot_max, nb_swap_tot_max, nb_reset_tot_max, nb_same_var_by_iter_tot_max); if (user_stat_fct) PRINTF(" %8d |", user_stat_max); PRINTF("\n"); } #if defined BACKTRACK PRINTF("BACKTRACK STATS:\n"); PRINTF("Total number of performed backtracks: %d\n", gl_elitePool.nb_backtrack); PRINTF("Total number of performed backtracks starting from another variable: %d\n", gl_elitePool.nb_variable_backtrack); PRINTF("Total number of performed backtracks starting from another value: %d\n", gl_elitePool.nb_value_backtrack); /* flush pools */ while(gl_elitePool.config_list_size > 0) { item = popElite(); free(item->configuration); free(item); } while(gl_stockPool.config_list_size > 0) { item = popStock(); free(item->configuration); free(item); } #endif /* BACKTRACK */ #if defined STATS print_stats() ; #endif #if !( defined MPI ) #if defined PRINT_COSTS print_costs() ; #endif TDPRINTF("Processus ends now.\n") ; /* Seq code is now ending */ #else /* !( defined MPI) */ AS_MPI_completion( &mpi_data ) ; #endif /* MPI */ }