APEMoST
|
#include <stdio.h>
#include <stdlib.h>
#include "mcmc_struct.h"
#include "markov_chain.h"
#include "mcmc_gettersetter.h"
Go to the source code of this file.
Defines | |
#define | DUMP_FORMAT "%.15e" |
#define | NOASSERT |
#define | assert(cond) |
Functions | |
mcmc * | mcmc_load (const char *filename, const char *datafilename) |
mcmc * | mcmc_load_params (const char *filename) |
void | mcmc_load_data (mcmc *m, const char *datafilename) |
void | mcmc_reuse_data (mcmc *m, const mcmc *m_orig) |
mcmc * | mcmc_free (mcmc *m) |
void | mcmc_check (const mcmc *m) |
void | mcmc_append_current_parameters (mcmc *m) |
void | mcmc_dump_y_dat (mcmc *m, const gsl_vector *y_dat, const char *filename) |
void | mcmc_dump_flush (const mcmc *m) |
void | mcmc_dump_close (mcmc *m) |
void | mcmc_open_dump_files (mcmc *m, const char *suffix, int index, char *mode) |
void | mcmc_dump_current (const mcmc *m) |
void | mcmc_dump_probabilities (const mcmc *m, int n_values, const char *suffix) |
void | mcmc_check_best (mcmc *m) |
void | calc_model (mcmc *m, const gsl_vector *old_values) |
void | calc_model_for (mcmc *m, const unsigned int i, const double old_value) |
#define assert | ( | cond | ) |
Referenced by analyse_data_probability(), analyse_marginal_distributions(), assess_acceptance_rate(), calc_deviation(), calc_marginal_distribution(), calc_model(), calc_same(), countlines(), do_step_for(), dup_vector(), find_min_max(), get_vector_from_array(), linreg_n(), main(), markov_chain_calibrate_alt(), markov_chain_calibrate_linear_regression(), markov_chain_calibrate_orig(), max_vector(), mcmc_check(), mcmc_dump_close(), mcmc_init(), mcmc_load_params(), mcmc_open_dump_files(), mcmc_reuse_data(), min_vector(), parallel_tempering_decide_swap_nonrandom(), parallel_tempering_decide_swap_now(), parallel_tempering_decide_swap_random(), run_sampler(), set_params(), set_params_for(), and setup_chains().
#define DUMP_FORMAT "%.15e" |
Public methods of the class How many digits should be used for writing numbers out?
If you find the precision too low, increase here. If you find the program too slow, decrease here.
Referenced by calc_marginal_distribution(), main(), mcmc_dump_current(), write_calibration_summary(), write_calibrations_file(), and write_params_file().
#define NOASSERT |
Turns additional sanity checks off.
One could think that turning this off would improve performance, but tests have shown the modification is not significant.
void calc_model | ( | mcmc * | m, |
const gsl_vector * | old_values | ||
) |
update the model according to the new parameter values and recalculate the probability for the model
m | |
old_values | previous values, or NULL |
References apply_formula(), assert, mcmc::data, get_beta(), get_n_par(), get_params_for(), get_prior(), Problem::LogLike, p, mcmc::params, Problem::Prior, set_prior(), set_prob(), and SIGMA.
Referenced by calc_model_for(), calibrate_first(), calibrate_rest(), main(), and markov_chain_step().
void calc_model_for | ( | mcmc * | m, |
const unsigned int | i, | ||
const double | old_value | ||
) |
update the model as the new parameter value i changed and recalculate the probability for the model
m | |
i | index of the parameter value that changed |
old_value | previous value of the parameter |
References calc_model().
Referenced by main(), and markov_chain_step_for().
void mcmc_append_current_parameters | ( | mcmc * | m | ) |
adds the current parameter values to params_distr as nth iteration was: add_values
m |
References mcmc_dump_current(), and mcmc::n_iter.
Referenced by run_sampler(), test_append(), and test_write_prob().
void mcmc_check | ( | const mcmc * | m | ) |
checks the pointers and dimensions
References assert, mcmc::data, mcmc::n_par, mcmc::params, mcmc::params_best, and mcmc::params_step.
Referenced by burn_in(), calibrate_first(), calibrate_rest(), main(), markov_chain_step(), markov_chain_step_for(), mcmc_load_data(), mcmc_reuse_data(), setup_chains(), and test_write_prob().
void mcmc_check_best | ( | mcmc * | m | ) |
check if a new best value has been found
m |
References dump_v, mcmc::params, mcmc::prob, mcmc::prob_best, and set_params_best().
Referenced by assess_acceptance_rate(), burn_in(), markov_chain_calibrate_orig(), and run_sampler().
void mcmc_dump_close | ( | mcmc * | m | ) |
close output files
References assert, mcmc::files, get_n_par(), mem_free, and r.
Referenced by mcmc_free().
void mcmc_dump_current | ( | const mcmc * | m | ) |
append current parameters to files, unflushed.
References DUMP_FORMAT, mcmc::files, get_n_par(), and mcmc::params.
Referenced by mcmc_append_current_parameters().
void mcmc_dump_flush | ( | const mcmc * | m | ) |
flush output files
References mcmc::files, and get_n_par().
Referenced by report(), and test_write_prob().
void mcmc_dump_probabilities | ( | const mcmc * | m, |
int | n_values, | ||
const char * | suffix | ||
) |
write probability/distribution (params_distr) out to files.
The files are named after the parameter names, with .prob.dump appended. You can use those files to build a histogram of where the algorithm has been (and how often) to find out
m | |
n_values | use the n last iterations. if negative, all are used. |
suffix | added to output filename as a suffix |
void mcmc_dump_y_dat | ( | mcmc * | m, |
const gsl_vector * | y_dat, | ||
const char * | filename | ||
) |
References mcmc::data.
Referenced by test_write().
frees the memory used by the class
x = mcmc_free(x)
; References mcmc::data, debug, get_n_par(), IFSEGV, mcmc_dump_close(), mem_free, mcmc::params, mcmc::params_accepts, mcmc::params_best, mcmc::params_descr, mcmc::params_max, mcmc::params_min, mcmc::params_rejects, mcmc::params_step, r, and mcmc::random.
Referenced by prepare_and_run_sampler(), test_append(), test_create(), test_load(), test_random(), test_write(), and test_write_prob().
mcmc* mcmc_load | ( | const char * | filename, |
const char * | datafilename | ||
) |
create and initialize a mcmc class using the configuration given in
filename | file containing the model parameters |
datafilename | x/y observed data |
References mcmc_load_data(), and mcmc_load_params().
Referenced by test_load(), test_random(), test_write(), and test_write_prob().
void mcmc_load_data | ( | mcmc * | m, |
const char * | datafilename | ||
) |
loads the data from the given file as x/y values
m | |
datafilename |
References dump_s, IFDEBUGPARSER, and mcmc_check().
Referenced by main(), mcmc_load(), and setup_chains().
mcmc* mcmc_load_params | ( | const char * | filename | ) |
create and initialize a mcmc class using the configuration given in
filename | file containing the model parameters |
References assert, countlines(), dump_i, IFDEBUGPARSER, mcmc_init(), openfile(), and r.
Referenced by main(), mcmc_load(), and setup_chains().
void mcmc_open_dump_files | ( | mcmc * | m, |
const char * | suffix, | ||
int | index, | ||
char * | mode | ||
) |
open dump files The filenames are created by the scheme paramname+suffix+"-"+index+extension
m | |
suffix | |
index | |
mode | 'w' for writing, 'a' for append, 'r' for reading |
References assert, ASSURE_DUMP_ENABLED, dump_s, mcmc::files, get_n_par(), IFVERBOSE, mem_calloc, mem_free, mcmc::n_par, and mcmc::params_descr.
Referenced by prepare_and_run_sampler(), and test_write_prob().
reference to another object for x and y-data.
m | the object to fill |
m_orig | the object with loaded data |
References assert, mcmc::data, debug, IFDEBUGPARSER, and mcmc_check().
Referenced by setup_chains().