00001 /* 00002 * $Id$ 00003 * 00004 * Author: David Fournier 00005 * Copyright (c) 2008-2012 Regents of the University of California 00006 */ 00011 #include <admodel.h> 00012 00017 void function_minimizer::mcmc_eval(void) 00018 { 00019 gradient_structure::set_NO_DERIVATIVES(); 00020 initial_params::current_phase=initial_params::max_number_phases; 00021 uistream* pifs_psave = NULL; 00022 00023 initial_params::set_active_random_effects(); 00024 00025 int nvar1=initial_params::nvarcalc(); // get the number of active parameters 00026 int nvar = 0; 00027 00028 pifs_psave= new 00029 uistream((char*)(ad_comm::adprogram_name + adstring(".psv"))); 00030 if (!pifs_psave || !(*pifs_psave)) 00031 { 00032 cerr << "Error opening file " 00033 << (char*)(ad_comm::adprogram_name + adstring(".psv")) 00034 << endl; 00035 if (pifs_psave) 00036 { 00037 delete pifs_psave; 00038 pifs_psave=NULL; 00039 return; 00040 } 00041 } 00042 else 00043 { 00044 (*pifs_psave) >> nvar; 00045 if (nvar!=nvar1) 00046 { 00047 cout << "Incorrect value for nvar in file " 00048 << "should be " << nvar1 << " but read " << nvar << endl; 00049 if (pifs_psave) 00050 { 00051 delete pifs_psave; 00052 pifs_psave=NULL; 00053 } 00054 return; 00055 } 00056 } 00057 00058 independent_variables y(1,nvar); 00059 00060 for (;;) 00061 { 00062 if (pifs_psave->eof()) 00063 { 00064 break; 00065 } 00066 else 00067 { 00068 (*pifs_psave) >> y; 00069 if (pifs_psave->eof()) 00070 { 00071 break; 00072 } 00073 int ii=1; 00074 initial_params::restore_all_values(y,ii); 00075 initial_params::xinit(y); 00076 /*double ll=-*/get_monte_carlo_value(nvar,y); 00077 } 00078 } 00079 00080 if (pifs_psave) 00081 { 00082 delete pifs_psave; 00083 pifs_psave=NULL; 00084 } 00085 }
Generated on Tue Mar 8 2016 19:51:34 for ADMB Documentation by 1.8.0 |