Revision 1805
trunk/src/nh99/xxmcmc2.cpp (revision 1805)  

1 
/* 

2 
* $Id$ 

3 
* 

4 
* Author: David Fournier 

5 
* Copyright (c) 20082012 Regents of the University of California 

6 
*/ 

7 
#include <admodel.h> 

8  
9 
//ofstream tmpof("testmc"); 

10  
11 
#if defined(__GNU__)  defined(UNIXKLUDGE)  defined(__SUN__) 

12 
#define getch getchar 

13 
#endif 

14  
15 
#ifdef __GNUDOS__ 

16 
#include <gccmanip.h> 

17 
#endif 

18  
19 
#if defined (__ZTC__)  defined(__TURBOC__)  defined(__WAT32__) \ 

20 
 defined (_MSC_VER) 

21 
# if !defined(__linux__) 

22 
# include <conio.h> 

23 
# endif 

24 
#endif 

25  
26 
//double better_rand(long int&); 

27 
void store_mcmc_values(const ofstream& ofs); 

28 
void set_labels_for_mcmc(void); 

29 
void save_mcmc_for_gui(const dvector& mcmc_values,dmatrix &mdm,int& ids); 

30 
void save_mcmc_for_gui1(const dvector& mcmc_values, 

31 
dmatrix &mdm,int& ids,int& iwrap,ivector& no); 

32  
33 
void check_java_flags(int& start_flag,int& quit_flag,int& der_flag, 

34 
int& next_flag); 

35 
void print_hist_data(const dmatrix& hist, const dmatrix& values, const dvector& h, 

36 
dvector& m, const dvector& s, const dvector& parsave, long int iseed, double size_scale); 

37  
38 
void read_hessian_matrix_and_scale1(int nvar, const dmatrix& _SS,double s, 

39 
int flag=0); 

40  
41 
int minnz(const dvector& x); 

42 
int maxnz(const dvector& xa); 

43  
44 
int read_hist_data(const dmatrix& hist, const dvector& h, 

45 
dvector& m, const dvector& s, const dvector& parsave,long int& iseed, const double& size_scale); 

46  
47 
void make_preliminary_hist(const dvector& s, const dvector& m,int nsim, const dmatrix& values, 

48 
dmatrix& hist, const dvector& h,int slots,double total_spread,int probflag=0); 

49  
50 
void add_hist_values(const dvector& s, const dvector& m, const dmatrix& hist, 

51 
dvector& mcmc_values,double llc, const dvector& h,int nslots, 

52 
double total_spreadd,int probflag=0); 

53  
54 
void add_guihist_values(const dvector& s, const dvector& m, 

55 
const dmatrix& _hist, dvector& mcmcnumber_values, double llc, 

56 
const dvector& h,int nslots,double total_spread); 

57  
58 
void write_empirical_covariance_matrix(int ncor, const dvector& s_mean, const dmatrix& s_covar, 

59 
adstring& prog_name); 

60  
61 
void read_empirical_covariance_matrix(int nvar, const dmatrix& S, const adstring& prog_name); 

62  
63  
64 
void read_hessian_matrix_and_scale(int nvar, const dmatrix& S, const dvector& pen_vector); 

65  
66 
int user_stop(void); 

67  
68 
extern int ctlc_flag; 

69 
class admb_javapointers; 

70 
extern admb_javapointers * adjm_ptr; 

71  
72 
dvector new_probing_bounded_multivariate_normal(int nvar, const dvector& a1, const dvector& b1, 

73 
dmatrix& ch, const double& wght,double pprobe, random_number_generator& rng); 

74  
75 
void new_probing_bounded_multivariate_normal_mcmc(int nvar, const dvector& a1, const dvector& b1, 

76 
dmatrix& ch, const double& wght, const dvector& _y,double pprobe, random_number_generator& rng); 

77  
78 
//void newton_raftery_bayes_estimate(double cbf,int ic, const dvector& lk,double d); 

79 
void newton_raftery_bayes_estimate_new(double cbf,int ic, const dvector& lk,double d); 

80  
81 
void ad_update_mcmc_stats_report 

82 
(int feval,int iter,double fval,double gmax); 

83  
84 
void ad_update_function_minimizer_report(int feval,int iter,int phase, 

85 
double fval,double gmax,const char * cbuf); 

86 
void ad_update_mcmc_report(dmatrix& m,int i,int j,int ff=0); 

87 
void ad_update_mcmchist_report(dmatrix& mcmc_values,ivector& number_offsets, 

88 
dvector& mean_mcmc_values,dvector& h,int ff=0); 

89  
90 
void ADSleep(int); 

91  
92 
#if !defined(USE_ADPVM) 

93 
void function_minimizer::pvm_master_mcmc_routine(int nmcmc,int iseed0, 

94 
double dscale,int restart_flag){;} 

95 
#else 

96 
void function_minimizer::pvm_master_mcmc_routine(int nmcmc,int iseed0,double dscale, 
Also available in: Unified diff