/* CHECKPOINT_CLSF 16nov94 wmt: add log messages Checkpointing option, see file checkpoint.text */ void checkpoint_clsf( clsf_DS clsf) { fxlstr msg_string; clsf_DS *temp; time_t now; now = get_universal_time(); sprintf( msg_string, " [checkpt clsf (j=%d, cycle=%d) at %s] ", clsf->n_classes, clsf->checkpoint->current_cycle, format_universal_time( now)); clsf->checkpoint->accumulated_try_time += now - G_search_cycle_begin_time; if (eqstring( G_checkpoint_file, "") == TRUE) { fprintf( stderr, "ERROR: checkpoint_clsf called with G_checkpoint_file = " "\"\" does nothing\n"); exit(1); } else { temp = (clsf_DS *) malloc( sizeof( clsf_DS)); temp[0] = clsf; save_clsf_seq( temp, 1, G_checkpoint_file, G_save_compact_p, "chkpt"); free( temp); to_screen_and_log_file( msg_string, G_log_file_fp, G_stream, TRUE); G_last_checkpoint_written = get_universal_time(); G_search_cycle_begin_time = now; /* start cycle time after writing file */ } }
//! Get the current day in universal date as a ymd_type static typename date_type::ymd_type universal_day_ymd() { ::std::tm* curr = get_universal_time(); return ymd_type(curr->tm_year + 1900, curr->tm_mon + 1, curr->tm_mday); }
//! Get the current day in universal date as a ymd_type static typename date_type::ymd_type universal_day_ymd() { ::std::tm result; ::std::tm* curr = get_universal_time(result); return ymd_type(static_cast<unsigned short>(curr->tm_year + 1900), static_cast<unsigned short>(curr->tm_mon + 1), static_cast<unsigned short>(curr->tm_mday)); }
/* RANDOM_SET_CLSF 10nov94 wmt: initialize n_used_list 05jan95 wmt: upgrade calculations to ac-x code 17may95 wmt: Convert from srand/rand to srand48/lrand48 This resets the classification 'clsf to size n-classes and uses choose-random-prototype to randomly initializes any added classes, or all classes with 'random-start. Classes are initialized by choosing one class as a prototype and adding 1% from two others for variance. The function modifies the classification and returns the number of classes and the marginal probability. */ int random_set_clsf( clsf_DS clsf, int n_classes, int delete_duplicates, int display_wts, unsigned int initial_cycles_p, FILE *log_file_fp, FILE *stream) { int n, i, n_data, index_0, *used_list, n_used_list = 0, num_atts = 0, n_others; int index_1, *used_cls_list, n_used_cls_list = 0, m; class_DS *classes, class; float proto_wt, wt_0, wt_1; n_classes = max(1, min((int) ceil((double) n_classes), clsf_DS_max_n_classes(clsf))); adjust_clsf_DS_classes(clsf, n_classes); n_data = clsf->database->n_data; for (i=0; i<clsf->database->n_atts; i++) if (eqstring( clsf->database->att_info[i]->type, "dummy") != TRUE) num_atts++; classes = clsf->classes; proto_wt = (float) n_data / n_classes; wt_0 = 0.95 * proto_wt; n_others = min( num_atts, (int) ceil( (double) (n_data / 2))); wt_1 = (0.05 * proto_wt) / n_others; used_list = (int *) malloc( n_classes * sizeof(int)); used_cls_list = (int *) malloc( (n_others + 1) * sizeof(int)); for (i=0; i<n_classes; i++) used_list[i] = 0; /* primary cases for all classes */ srand48( (long) (get_universal_time())); /* re-init random number generator */ for (n=0; n<n_classes; n++) { class = classes[n]; index_0 = new_random( n_data, used_list, n_used_list); used_list[n_used_list] = index_0; n_used_list++; for (i=0; i<n_others; i++) used_cls_list[i] = 0; /* secondary cases for each class */ used_cls_list[0] = index_0; /* printf("\nclass-index %d index_0 %d\n", n, index_0); */ n_used_cls_list = 1; class->wts = fill( class->wts, 0.0, class->num_wts, n_data); class->wts[index_0] = wt_0; for (m=0; m<n_others; m++) { index_1 = new_random( n_data, used_cls_list, n_used_cls_list); /* printf("index_1 %d ", index_1); */ used_cls_list[n_used_cls_list] = index_1; n_used_cls_list++; class->wts[index_1] = wt_1; } /* printf("\n"); */ /* for (i=0; i<class->num_wts; i++) */ /* printf("%f ", class->wts[i]); */ class->w_j = max( proto_wt, clsf->min_class_wt); } free(used_list); free(used_cls_list); return(initialize_parameters(clsf, display_wts, delete_duplicates, initial_cycles_p, log_file_fp, stream)); }