19 class dvar_hs_smatrix;
31 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
32 const int xs = [](
unsigned int size)->
int
34 assert(size <= INT_MAX);
35 return static_cast<int>(size);
37 const int us = [](
unsigned int size)->
int
39 assert(size <= INT_MAX);
40 return static_cast<int>(size);
43 const int xs =
static_cast<int>(x.
size());
44 const int us =
static_cast<int>(u0.
size());
51 cerr <<
"Error we should not be here" <<
endl;
77 int & vxs = (
int&)(xs);
83 for (
int i=smin;i<=smax;i++)
93 cerr <<
"can't do importance sampling with bounded random effects"
94 " at present" <<
endl;
105 if (vsparse_triplet==0)
110 for (
int i=mmin;i<=mmax;i++)
112 (*vsparse_triplet)(1,i)=lst(1,i);
113 (*vsparse_triplet)(2,i)=lst(2,i);
120 (*vsparse_triplet).allocate(mmin,mmax,us,us);
121 for (
int i=mmin;i<=mmax;i++)
123 (*vsparse_triplet)(1,i)=lst(1,i);
124 (*vsparse_triplet)(2,i)=lst(2,i);
131 if (vsparse_triplet_adjoint==0)
136 for (
int i=mmin;i<=mmax;i++)
138 (*vsparse_triplet_adjoint)(1,i)=lst(1,i);
139 (*vsparse_triplet_adjoint)(2,i)=lst(2,i);
144 if (!
allocated(*vsparse_triplet_adjoint))
146 (*vsparse_triplet_adjoint).allocate(mmin,mmax,us,us);
147 for (
int i=mmin;i<=mmax;i++)
149 (*vsparse_triplet_adjoint)(1,i)=lst(1,i);
150 (*vsparse_triplet_adjoint)(2,i)=lst(2,i);
154 vsparse_triplet->
get_x()=vy(ii,ii+mmax-mmin).
shift(1);
177 for (
int is=1;is<=nsamp;is++)
183 vy(xs+1,xs+us).
shift(1)+=tau;
185 vy(xs+1,xs+us).
shift(1)-=tau;
207 =
value(sample_value(is))-fhat;
210 vf=min_vf-
log(
mean(
exp(min_vf-sample_value)));
216 int samplesize=nsamp/nfunnelblocks;
217 int ubound=samplesize;
220 ivector blocksizes(1,nfunnelblocks);
221 for (
int iblock=1;iblock<=nfunnelblocks;iblock++)
224 if (lbound>nsamp)
break;
229 for (
int is=lbound;is<=ubound;is++)
235 vy(xs+1,xs+us).
shift(1)+=tau;
237 vy(xs+1,xs+us).
shift(1)-=tau;
258 =
value(sample_value(icount))-fhat;
269 fvalues(mean_count)=tmp;
270 blocksizes(mean_count)=icount;
276 double fm=
mean(
value(fvalues(1,mean_count)));
278 vf=-fm-
log(nfval*blocksizes(1,mean_count)/
sum(blocksizes(1,mean_count)));
284 vf-=us*0.91893853320467241;
306 vy(xs+1,xs+us).
shift(1)=u0;
311 for (
int i=1;i<=xs;i++)
313 for (
int i=1;i<=us;i++)
318 int mmin=vsparse_triplet_adjoint->
indexmin();
319 int mmax=vsparse_triplet_adjoint->
indexmax();
320 vsparse_triplet_adjoint->
get_x()
321 =g(ii,ii+mmax-mmin).
shift(1);
Description not yet available.
laplace_approximation_calculator * lapprox
dcompressed_triplet * sparse_triplet2
static void set_NO_DERIVATIVES(void)
Disable accumulation of derivative information.
Description not yet available.
dvar_vector & shift(int min)
Description not yet available.
static void set_active_random_effects(void)
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Vector of double precision numbers.
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static int sparse_hessian_flag
double calculate_importance_sample_shess(const dvector &x, const dvector &u0, const dmatrix &Hess, const dvector &_xadjoint, const dvector &_uadjoint, const dmatrix &_Hessadjoint, function_minimizer *pmin)
Description not yet available.
static dvariable reset(const dvar_vector &x)
double mean(const dvector &vec)
Returns computed mean of vec.
dvector * importance_sampling_values
void gradcalc(int nvar, const dvector &g)
static int stddev_vscale(const dvar_vector &d, const dvar_vector &x)
dcompressed_triplet * vsparse_triplet_adjoint
int num_importance_samples
prnstream & endl(prnstream &)
Description not yet available.
Array of integers(int) with indexes from index_min to indexmax.
dvar_vector & get_x(void)
static objective_function_value * pobjfun
Description not yet available.
static void xinit(const dvector &x)
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Description not yet available.
Description not yet available.
dvector & shift(int min)
Shift valid range of subscripts.
double norm2(const d3_array &a)
Return sum of squared elements in a.
Description not yet available.
double ln_det(const dmatrix &m1, int &sgn)
Compute log determinant of a constant matrix.
unsigned int size() const
Get number of elements in array.
void ad_begin_funnel(void)
Description not yet available.
static int have_bounded_random_effects
virtual void AD_uf_outer()
dvar_compressed_triplet * vsparse_triplet
Description not yet available.
Description not yet available.
static void set_YES_DERIVATIVES(void)
Enable accumulation of derivative information.
static void get_cHessian_contribution(dmatrix, int)
Description not yet available.
void initialize(const dvector &ww)
Description not yet available.
dvector value(const df1_one_vector &v)
dvector return_choleski_factor_solve(hs_smatrix *PL, dvector &eps)
static int get_num_quadratic_prior(void)
hs_smatrix * return_choleski_decomp(dcompressed_triplet &st)
Fundamental data type for reverse mode automatic differentiation.
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static void set_inactive_only_random_effects(void)