Esempio n. 1
0
void free_MCMC(MCMC_info *MCMC) {
    int           i_P, i_DS;
    int           i_array;
    MCMC_DS_info *current_DS;
    MCMC_DS_info *next_DS;

    SID_log("Freeing MCMC structure...", SID_LOG_OPEN);

    // Parameter arrays
    for(i_P = 0; i_P < MCMC->n_P; i_P++)
        SID_free(SID_FARG MCMC->P_names[i_P]);
    SID_free(SID_FARG MCMC->P_names);
    SID_free(SID_FARG MCMC->P_init);
    SID_free(SID_FARG MCMC->P_new);
    SID_free(SID_FARG MCMC->P_last);
    SID_free(SID_FARG MCMC->P_chain);
    SID_free(SID_FARG MCMC->P_limit_min);
    SID_free(SID_FARG MCMC->P_limit_max);
    if(MCMC->n_arrays > 0) {
        for(i_array = 0; i_array < MCMC->n_arrays; i_array++) {
            SID_free(SID_FARG MCMC->array[i_array]);
            SID_free(SID_FARG MCMC->array_name[i_array]);
        }
        SID_free(SID_FARG MCMC->array);
        SID_free(SID_FARG MCMC->array_name);
    }

    // Covariance and displacement vector
    free_MCMC_covariance(MCMC);

    // Random number generator
    if(MCMC->RNG != NULL)
        free_RNG(MCMC->RNG);

    // Dataset arrays
    free_MCMC_arrays(MCMC);
    free_MCMC_DS(MCMC);

    // Communicators
    SID_Comm_free(&(MCMC->comm));

    SID_log("Done.", SID_LOG_CLOSE);
}
Esempio n. 2
0
void restart_MCMC(MCMC_info *MCMC){

  SID_log("Resetting MCMC structure for a fresh run...",SID_LOG_OPEN);

  MCMC->flag_integrate_on       =FALSE;
  MCMC->flag_analysis_on        =TRUE;
  MCMC->first_map_call          =TRUE;
  MCMC->first_link_call         =TRUE;
  MCMC->flag_init_chain         =TRUE;
  MCMC->first_chain_call        =TRUE; 
  MCMC->first_parameter_call    =TRUE; 
  MCMC->first_likelihood_call   =TRUE; 
  MCMC->ln_likelihood_last      =0.; 
  MCMC->ln_likelihood_new       =0.; 
  MCMC->ln_likelihood_chain     =0.;
  MCMC->n_success               =0;
  MCMC->n_propositions          =0;
  MCMC->n_map_calls             =0;

  free_MCMC_covariance(MCMC);
  free_MCMC_arrays(MCMC);

  SID_log("Done.",SID_LOG_CLOSE);
}