1.4.0
CCC
 
model_auto.cpp File Reference
#include "geoslib_old_f.h"
#include "geoslib_f.h"
#include "Enum/EAnam.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/String.hpp"
#include "Basic/OptDbg.hpp"
#include "Basic/VectorHelper.hpp"
#include "Covariances/CovAniso.hpp"
#include "Covariances/CovLMCTapering.hpp"
#include "Covariances/CovLMCConvolution.hpp"
#include "Covariances/CovLMCAnamorphosis.hpp"
#include "Model/Option_AutoFit.hpp"
#include "Model/Model.hpp"
#include "Model/Constraints.hpp"
#include "Model/ConsItem.hpp"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "Variogram/Vario.hpp"
#include "Geometry/GeometryHelper.hpp"
#include "Matrix/MatrixSquareGeneral.hpp"
#include <math.h>

Functions

static void st_modify_optvar_for_anam (Model *model, Option_VarioFit &optvar)
 
static void st_name_range (int ivar)
 
static void st_name_scale (int ivar)
 
static void st_name_rotation (int rank)
 
static void st_parid_decode (int parid, int *imod, int *icov, EConsElem *icons, int *ivar, int *jvar)
 
static int st_parid_encode (int imod, int icov, const EConsElem &icons, int ivar, int jvar)
 
static int st_parid_alloc (StrMod *strmod, int npar0)
 
static StrModst_model_auto_strmod_free (StrMod *strmod)
 
static StrModst_model_auto_strmod_alloc (Model *model1, Model *model2, int npar0, int norder, double hmax, VectorDouble &angles, const Option_VarioFit &optvar, int *npar)
 
static int st_get_vario_dimension (Vario *vario, int *nbexp_ret, int *npadir_ret)
 
static int st_get_vmap_dimension (const Db *dbmap, int nvar, int *nbexp_ret, int *npadir_ret)
 
static void st_mauto_rescale (int nvar, VectorDouble &varchol, Option_AutoFit &mauto)
 
static void st_goulard_verbose (int mode, Option_AutoFit &mauto)
 
static std::vector< StrExp > st_strexp_manage (int nbexp, int ndim)
 
static void st_compress_array (const Vario *vario, int npadir, VectorDouble &tabin, VectorDouble &tabout)
 
static double st_get_c00 (const Vario *vario, int idir, int ivar, int jvar)
 
static void st_load_gg (const Vario *vario, int npadir, std::vector< StrExp > &strexps, VectorDouble &gg)
 
static void st_prepar_goulard_vario (int imod)
 
static void st_load_ge (const Vario *vario, Model *model, int npadir, VectorDouble &dd, VectorDouble &ge)
 
static void st_load_wt (const Vario *vario, int wmode, int npadir, VectorDouble &wt)
 
static void st_goulard_score (const Option_AutoFit &mauto, int mode, int ncova, int iter, double crit)
 
static void st_goulard_debug_title (int nvar, int ncova)
 
static void st_goulard_debug_current (int nvar, int ncova, int iter, VectorDouble &sill, double crit)
 
static void st_keypair_sill (int mode, Model *model)
 
static void st_keypair_results (int mode, int icov, int nvar, double *valpro, double *vecpro)
 
static void st_sill_reset (int nvar, int ncova, VectorDouble &sill)
 
static int st_goulard_without_constraint (const Option_AutoFit &mauto, int nvar, int ncova, int npadir, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, VectorDouble &sill, double *crit_arg)
 
static void st_affect (int rank, double def_val, double lower_val, double upper_val, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static int st_compress_parid (int n_init, VectorInt &parid, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static void st_print (const char *name, int flag_end, int rank, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static void st_model_auto_strmod_print (int flag_title, StrMod *strmod, const Constraints &constraints, const Option_AutoFit &mauto, VectorDouble &param, VectorDouble &lower, VectorDouble &upper, int npar, int nbexp)
 
static void st_model_auto_scldef (StrMod *strmod, int npar, double hmax, VectorDouble &varchol, VectorDouble &scale)
 
static void st_model_auto_constraints_apply (StrMod *strmod, int npar, const Constraints &constraints, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static void st_model_auto_pardef (StrMod *strmod, int npar, double hmax, VectorDouble &varchol, VectorDouble &angles, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static void st_model_auto_strmod_define (StrMod *strmod, int npar, VectorDouble &param)
 
static int st_structure_reduce (StrMod *strmod, int imod, int icov, double hmax, double gmax, double tolsigma)
 
static void st_evaluate_vario (int imod, int nbexp, std::vector< StrExp > &strexps, StrMod *strmod, VectorDouble &tabge)
 
static void st_evaluate_vmap (int imod, StrMod *strmod, VectorDouble &tabge)
 
static int st_parid_match (StrMod *strmod, int npar, int imod0, int icov0, const EConsElem &icons0, int ivar0, int jvar0)
 
static int st_check_definite_positive (Model *model)
 
static int st_truncate_negative_eigen (int nvar, int icov0, VectorDouble &matcor, VectorDouble &matcoru)
 
static double st_sum_sills (int ivar0, int ncova, int nvar, VectorDouble &alpha)
 
static double st_score (int nvar, int nvs2, int ncova, int npadir, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, VectorDouble &matcor)
 
static int st_combineVariables (int ivar0, int jvar0)
 
static double st_minimize_P4 (int icov0, int ivar0, int ncova, int nvar, int npadir, double xrmax, VectorDouble &xr, VectorDouble &alpha, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, const VectorDouble &consSill)
 
void st_updateAlphaDiag (int icov0, int ivar0, int ncova, int nvar, VectorDouble &xr, VectorDouble &alpha, const VectorDouble &consSill)
 
static void st_updateOtherSills (int icov0, int ivar0, int ncova, int nvar, VectorDouble &alpha, VectorDouble &xr, VectorDouble &matcor)
 
static void st_updateCurrentSillGoulard (int icov0, int ivar0, int npadir, int nvar, int ncova, VectorDouble &wt, VectorDouble &ge, VectorDouble &gg, const VectorDouble &consSill, VectorDouble &matcor)
 
static void st_updateAlphaNoDiag (int icov0, int ivar0, int nvar, VectorDouble &xr, const VectorDouble &consSill, VectorDouble &matcor, VectorDouble &alpha)
 
static void st_updateCurrentSillDiag (int icov0, int ivar0, int nvar, VectorDouble &alpha, VectorDouble &xr, VectorDouble &matcor)
 
static int st_makeDefinitePositive (int icov0, int nvar, const VectorDouble &consSill, VectorDouble &matcor)
 
static int st_optimize_under_constraints (int nvar, int nvs2, int ncova, int npadir, const Constraints &constraints, const Option_AutoFit &mauto, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, VectorDouble &matcor, double *score)
 
static int st_initialize_goulard (int nvar, int nvs2, int ncova, int npadir, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, const VectorDouble &consSill, VectorDouble &matcor)
 
static void st_goulard_sill_to_model (int nvar, int ncova, VectorDouble &sill, Model *model)
 
static int st_goulard_with_constraints (const Constraints &constraints, const Option_AutoFit &mauto, int nvar, int ncova, int npadir, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, VectorDouble &sill)
 
static int st_sill_fitting_int (Model *model, const Option_AutoFit &mauto, int npadir, VectorDouble &wt, VectorDouble &gg, VectorDouble &ge, VectorDouble &wt2, VectorDouble &ge1, VectorDouble &ge2, VectorDouble &gg2, VectorDouble &alphau, VectorDouble &sill1)
 
static int st_goulard_fitting (int flag_reset, int flag_title, Model *model, const Constraints &constraints, const Option_AutoFit &mauto)
 
static int st_model_has_intrinsic (Model *model, const int *filter)
 
static int st_model_auto_strmod_reduce (StrMod *strmod, int *npar, double hmax, double gmax, VectorDouble &param, VectorDouble &lower, VectorDouble &upper, Constraints &constraints, Option_AutoFit &mauto)
 
static int st_model_define (Model *model, const Option_VarioFit &optvar)
 
static int st_alter_model_optvar (const Vario *vario, Model *model, Constraints &constraints, Option_VarioFit &optvar)
 
static int st_alter_vmap_optvar (const Db *dbmap, Model *model, Constraints &constraints, Option_VarioFit &optvar)
 
static int st_model_auto_count (const Vario *vario, Model *model1, Model *model2, Constraints &constraints, Option_VarioFit &optvar, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static void st_strmod_vario_evaluate (int nbexp, int npar, VectorDouble &param, VectorDouble &tabge)
 
static void st_prepar_goulard_vmap (int imod)
 
static void st_strmod_vmap_evaluate (int, int npar, VectorDouble &param, VectorDouble &tabge)
 
static void st_vario_varchol_manage (const Vario *vario, Model *model, VectorDouble &varchol)
 
static void st_vmap_varchol_manage (const Db *dbmap, VectorDouble &varchol)
 
static void st_model_post_update (StrMod *strmod, const Option_VarioFit &optvar)
 
static int st_manage_recint (const Option_AutoFit &mauto, int flag_exp, int ndim, int nvar, int nbexp, int ncova, int npadir)
 
static void st_regularize_init ()
 
int model_auto_fit (Vario *vario, Model *model, bool verbose, const Option_AutoFit &mauto_arg, const Constraints &cons_arg, const Option_VarioFit &optvar_arg)
 
int model_fitting_sills (Vario *vario, Model *model, const Constraints &constraints, const Option_AutoFit &mauto)
 
static int st_vmap_auto_count (const Db *dbmap, Model *model, Constraints &constraints, Option_VarioFit &optvar, VectorDouble &param, VectorDouble &lower, VectorDouble &upper)
 
static void st_load_vmap (int npadir, VectorDouble &gg, VectorDouble &wt)
 
int vmap_auto_fit (const DbGrid *dbmap, Model *model, bool verbose, const Option_AutoFit &mauto_arg, const Constraints &cons_arg, const Option_VarioFit &optvar_arg)
 
void constraints_print (const Constraints &constraints)
 
int modify_constraints_on_sill (Constraints &constraints)
 
double constraints_get (const Constraints &constraints, const EConsType &icase, int igrf, int icov, const EConsElem &icons, int iv1, int iv2)
 

Variables

static char string [STRING_LENGTH]
 
static char cov_name [STRING_LENGTH]
 
static int CONGRUENCY = 50
 
static double EpsFit = 1.e-12
 
static Regularize REGULARIZE
 
static std::vector< StrExp > STREXPS
 
static StrModSTRMOD = nullptr
 
static Option_AutoFit MAUTO
 
static Constraints CONSTRAINTS
 
static VectorInt INDG1
 
static VectorInt INDG2
 
static const DbGridDBMAP
 
static void(* ST_PREPAR_GOULARD )(int imod)
 
static Recint RECINT
 

Function Documentation

◆ constraints_get()

double constraints_get ( const Constraints constraints,
const EConsType &  icase,
int  igrf,
int  icov,
const EConsElem &  icons,
int  iv1,
int  iv2 
)

Return the constraint value (if defined) or TEST

Returns
Returned value or TEST
Parameters
[in,out]constraintsConstraints structure
[in]icaseParameter type (EConsType)
[in]igrfRank of the Gaussian Random Function
[in]icovRank of the structure (starting from 0)
[in]iconsType of the constraint (EConsElem)
[in]iv1Rank of the first variable
[in]iv2Rank of the second variable

◆ constraints_print()

void constraints_print ( const Constraints constraints)

Print the Auto Fitting Constraints Structure

Parameters
[in]constraintsConstraints structure

◆ model_auto_fit()

int model_auto_fit ( Vario vario,
Model model,
bool  verbose,
const Option_AutoFit mauto_arg,
const Constraints cons_arg,
const Option_VarioFit optvar_arg 
)

Automatic model fitting

Returns
Error returned code
Parameters
[in]varioVario structure containing the exp. variogram
[in]modelModel structure containing the basic structures
[in]verboseVerbose flag
[in]mauto_argOption_AutoFit structure
[in]cons_argConstraints structure
[in]optvar_argOpt_Vario structure

◆ model_fitting_sills()

int model_fitting_sills ( Vario vario,
Model model,
const Constraints constraints,
const Option_AutoFit mauto 
)

Fitting a model using an experimental variogram

Returns
Error return code
Parameters
[in]varioVario structure
[in,out]modelModel to be fitted
[in]constraintsConstraints structure
[in]mautoOption_AutoFit structure

◆ modify_constraints_on_sill()

int modify_constraints_on_sill ( Constraints constraints)

If a constraint concerns a sill, take its square root as it corresponds to a constraints on AIC (not on a sill directly) due to the fact that it will be processed in FOXLEG (not in GOULARD) This transform only makes sense for MONOVARIATE case (the test should have been performed beforehand)

Returns
Error code (if the sill constraint is negative)
Parameters
[in]constraintsConstraints structure

◆ st_affect()

static void st_affect ( int  rank,
double  def_val,
double  lower_val,
double  upper_val,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Affect values for default, lower and upper parameters

Parameters
[in]rankRank of the parameter
[in]def_valDefault distance
[in]lower_valLowest possible value
[in]upper_valHighest possible value
[in]paramArray of current values
[in]lowerArray of lower values
[in]upperArray of upper values

◆ st_alter_model_optvar()

static int st_alter_model_optvar ( const Vario vario,
Model model,
Constraints constraints,
Option_VarioFit optvar 
)
static

Define the options of the structure Opt_Vario

Returns
Error return code
Parameters
[in]varioVario structure containing the exp. variogram
[in]modelModel structure
[in]constraintsConstraints structure
[out]optvarOpt_Vario structure

◆ st_alter_vmap_optvar()

static int st_alter_vmap_optvar ( const Db dbmap,
Model model,
Constraints constraints,
Option_VarioFit optvar 
)
static

Define the options of the structure Opt_Vario

Parameters
[in]dbmapDb Grid structure containing the Vmap
[in]modelModel structure
[in]constraintsConstraints structure
[out]optvarOpt_Vario structure

◆ st_check_definite_positive()

static int st_check_definite_positive ( Model model)
static

Check if the resulting Model is definite positive

Returns
1 if the model is not definite positive
Parameters
[in]modelModel structure

◆ st_combineVariables()

static int st_combineVariables ( int  ivar0,
int  jvar0 
)
static

Return the rank of the variable pair, given the two variable ranks

Parameters
[in]ivar0Index of the first variable
[in]jvar0Index of the second variable

◆ st_compress_array()

static void st_compress_array ( const Vario vario,
int  npadir,
VectorDouble tabin,
VectorDouble tabout 
)
static

Compress the weights for the experimental variograms

Parameters
[in]varioVario structure
[in]npadirTotal number of lags
[in]tabinUncompressed array
[out]taboutCompressed array

◆ st_compress_parid()

static int st_compress_parid ( int  n_init,
VectorInt parid,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Compress the default, lower and upper arrays

Returns
nb_tot : Number of parameters (input)
Parameters
[in]n_initInitial number of parameters
[in,out]paridArray of parameters identificators
[in,out]paramArray of current values
[in,out]lowerArray of lower values
[in,out]upperArray of upper values

◆ st_evaluate_vario()

static void st_evaluate_vario ( int  imod,
int  nbexp,
std::vector< StrExp > &  strexps,
StrMod strmod,
VectorDouble tabge 
)
static

Calculates the values of the model corresponding to the experimentations stored in strexp

Parameters
[in]nbexpNumber of experimental conditions
[in]imodRank of the model
[in]strexpsArray of StrExp structures to be freed
[in]strmodStrMod structure
[out]tabgeArray of generic covariance values

◆ st_evaluate_vmap()

static void st_evaluate_vmap ( int  imod,
StrMod strmod,
VectorDouble tabge 
)
static

Calculates the values of the model corresponding to the experimentations stored in vmap

Parameters
[in]imodRank of the model
[in]strmodStrMod structure
[out]tabgeArray of generic covariance values

◆ st_get_c00()

static double st_get_c00 ( const Vario vario,
int  idir,
int  ivar,
int  jvar 
)
static

Find a possible value for C00 (for asymetric case only)

Returns
The value of C00
Parameters
[in]varioVario structure
[in]idirDirection structure
[in]ivarFirst variable
[in]jvarSecond variable
Remarks
This function is meant to provide a reasonable value for C00.
By default it returns the value of the central point
If this value if zero (with sw=0), it returns the closest non-zero
value

◆ st_get_vario_dimension()

static int st_get_vario_dimension ( Vario vario,
int *  nbexp_ret,
int *  npadir_ret 
)
static

Return the number of experimental conditions

Returns
Error return code if the returned argument are null
Parameters
[in]varioVario structure
[out]nbexp_retTotal number of experimental values (number of valid directions/lags/variables)
[out]npadir_retTotal number of lags for all directions

◆ st_get_vmap_dimension()

static int st_get_vmap_dimension ( const Db dbmap,
int  nvar,
int *  nbexp_ret,
int *  npadir_ret 
)
static

Return the number of experimental conditions

Returns
Error return code if the returned argument are null
Parameters
[in]dbmapDb structure
[in]nvarNumber of variables
[out]nbexp_retTotal number of experimental values (number of valid directions/lags/variables)
[out]npadir_retMaximum number of lags for all directions

◆ st_goulard_debug_current()

static void st_goulard_debug_current ( int  nvar,
int  ncova,
int  iter,
VectorDouble sill,
double  crit 
)
static

Display the current status for the Goulard algorithm

Parameters
[in]nvarNumber of variables
[in]ncovaNumber of basic structures
[in]iterRank of the iteration
[in]sillMatrix of sills
[in]critValeu for the convergence criterion

◆ st_goulard_debug_title()

static void st_goulard_debug_title ( int  nvar,
int  ncova 
)
static

Display the title for the Goulard algorithm

Parameters
[in]nvarNumber of variables
[in]ncovaNumber of basic structures

◆ st_goulard_fitting()

static int st_goulard_fitting ( int  flag_reset,
int  flag_title,
Model model,
const Constraints constraints,
const Option_AutoFit mauto 
)
static

General Routine for fitting a model using an experimental variogram

Returns
Error return code
Parameters
[in]flag_reset1 to reset the array of sill before usage
[in]flag_title1 to print the title
[in]modelModel to be fitted
[in]constraintsConstraints structure
[in]mautoOption_AutoFit structure

◆ st_goulard_score()

static void st_goulard_score ( const Option_AutoFit mauto,
int  mode,
int  ncova,
int  iter,
double  crit 
)
static

Display the Goulard final score

Parameters
[in]mode0 without; 1 with constraints
[in]mautoOption_AutoFit structure
[in]ncovaNumber of basic structures
[in]iterNumber of iterations
[in]critConvergence criterion

◆ st_goulard_sill_to_model()

static void st_goulard_sill_to_model ( int  nvar,
int  ncova,
VectorDouble sill,
Model model 
)
static

Copy the resulting sill into the Model

Parameters
[in]nvarNumber of variables
[in]ncovaNumber of covariances
[in]sillArray of sills
[out]modelFitted Model structure

◆ st_goulard_verbose()

static void st_goulard_verbose ( int  mode,
Option_AutoFit mauto 
)
static

Manage the verbose option for iterative Goulard when called from Foxleg

Parameters
[in]mode0 (before) or 1 (after) Goulard
[in]mautoOption_AutoFit

◆ st_goulard_with_constraints()

static int st_goulard_with_constraints ( const Constraints constraints,
const Option_AutoFit mauto,
int  nvar,
int  ncova,
int  npadir,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
VectorDouble sill 
)
static

Internal function for Goulard under constraints

Returns
Error returned code
Parameters
[in]constraintsConstraints structure
[in]mautoOption_AutoFit structure
[in]nvarNumber of variables
[in]ncovaNumber of covariances
[in]npadirMaximum number of lags for all directions
[in]wtArray of weights (Dimension: npadir)
[in]ggArray of experimental values (Dimension: npadir)
[in]geArray of model values (Dimension: npadir)
[out]sillArray of resulting sills

◆ st_goulard_without_constraint()

static int st_goulard_without_constraint ( const Option_AutoFit mauto,
int  nvar,
int  ncova,
int  npadir,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
VectorDouble sill,
double *  crit_arg 
)
static

Routine for fitting a model using an experimental variogram

Returns
Error return code
Parameters
[in]mautoOption_AutoFit structure
[in]nvarNumber of variables
[in]ncovaNumber of covariances
[in]npadirMaximum number of lags for all directions
[in]wtArray of weights (Dimension: npadir)
[in]ggArray of experimental values (Dimension: npadir)
[in]geArray of model values (Dimension: npadir)
[out]sillArray of resulting sills
[out]crit_argConvergence criterion
Remarks
Internal arrays:
MP : Contains the current Model (ijvar,ipadir)

◆ st_initialize_goulard()

static int st_initialize_goulard ( int  nvar,
int  nvs2,
int  ncova,
int  npadir,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
const VectorDouble consSill,
VectorDouble matcor 
)
static

Initialize the system for Goulard algorithm

Returns
Error return code
Parameters
[in]nvarNumber of variables
[in]nvs2Dimension of the triangular matrix (Dimension: nvar)
[in]ncovaNumber of basic structures
[in]npadirTotal number of lags
[in]wtArray of weights attached to variogram lags
[in]ggArray of experimental values
[in]geArray of generic covariance values
[in]consSillArray containing the constraints (optional)
[out]matcorMatrix of sills (Dimension: ncova * nvar * nvar)

◆ st_keypair_results()

static void st_keypair_results ( int  mode,
int  icov,
int  nvar,
double *  valpro,
double *  vecpro 
)
static

Store the results using the keypair mechanism

Parameters
[in]mode1 for setting; -1 for deleting
[in]icovRank of the covariance
[in]nvarNumber of variables
[in]valproArray of eigen values
[in]vecproArray of eigen vectors

◆ st_keypair_sill()

static void st_keypair_sill ( int  mode,
Model model 
)
static

Save the sill matrices in the keypair mechanism

Parameters
[in]mode1 for setting; -1 for deleting
[in]modelModel structure containing the basic structures

◆ st_load_ge()

static void st_load_ge ( const Vario vario,
Model model,
int  npadir,
VectorDouble dd,
VectorDouble ge 
)
static

Calculates the values of a generic covariance model corresponding to the lags of an experimental variogram

Parameters
[in]varioVario structure
[in]modelModel structure
[in]npadirTotal number of lags
[out]ddArray of distances (optional)
[out]geArray of generic covariance values (optional)

◆ st_load_gg()

static void st_load_gg ( const Vario vario,
int  npadir,
std::vector< StrExp > &  strexps,
VectorDouble gg 
)
static

Fill the array of pointers on the experimental conditions

Parameters
[in]varioVario structure
[in]npadirTotal number of lags
[out]strexpsAllocated array of StrExp (optional)
[out]ggAllocated array of experimental values

◆ st_load_vmap()

static void st_load_vmap ( int  npadir,
VectorDouble gg,
VectorDouble wt 
)
static

Fill the array of pointers on the experimental conditions

Parameters
[in]npadirMaximum number of lags for all directions
[out]ggAllocated array of experimental uncompressed values
[out]wtAllocated array of experimental uncompressed weights

◆ st_load_wt()

static void st_load_wt ( const Vario vario,
int  wmode,
int  npadir,
VectorDouble wt 
)
static

Calculates the weighting factors for each experimental variogram value of each directional variogram

Parameters
[in]varioVario structure
[in]wmodeType of the weighting procedure
[in]npadirTotal number of lags
[out]wtArray of weights attached to variogram lags

◆ st_makeDefinitePositive()

static int st_makeDefinitePositive ( int  icov0,
int  nvar,
const VectorDouble consSill,
VectorDouble matcor 
)
static

Make sure the current matrix of sills is definite positive (diagonal unchanged)

Parameters
[in]icov0Index of the target basic structure
[in]nvarNumber of variables
[in]consSillVector of optional constant sills
[in,out]matcorMatrices of sills

◆ st_manage_recint()

static int st_manage_recint ( const Option_AutoFit mauto,
int  flag_exp,
int  ndim,
int  nvar,
int  nbexp,
int  ncova,
int  npadir 
)
static

Manage memory for variogram fitting

Returns
Error returned code
Parameters
[in]mautoOption_AutoFit structure
[in]flag_exp1 for experimental variogram
[in]ndimSpace dimension
[in]nvarNumber of variables
[in]nbexpNumber of experimental variogram values
[in]ncovaNumber of covariances
[in]npadirTotal number of lags

◆ st_mauto_rescale()

static void st_mauto_rescale ( int  nvar,
VectorDouble varchol,
Option_AutoFit mauto 
)
static

Update the parameters of Option_AutoFit structure according to the parameters of the Experimental Variogram

Parameters
[in]nvarNumber of variables
[in]varcholCholesky decomposition of the variance matrix
[in]mautoOption_AutoFit

◆ st_minimize_P4()

static double st_minimize_P4 ( int  icov0,
int  ivar0,
int  ncova,
int  nvar,
int  npadir,
double  xrmax,
VectorDouble xr,
VectorDouble alpha,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
const VectorDouble consSill 
)
static

Minimization of the order-4 polynomial

Returns
Value for which the fourth order polynomial is minimum.
Parameters
[in]icov0Index of the target basic structure
[in]ivar0Index of the target variable
[in]ncovaNumber of basic structures
[in]nvarNumber of variables
[in]npadirMaximum number of lags for all directions
[in]xrmaxMaximum value for the solution
[in]xrCurrent vector of sqrt(constraint/(sum of the sills))
[in]alphaCurrent auxiliary matrices alpha
[in]wtArray of weights attached to variogram lags
[in]ggArray of experimental values
[in]geArray of generic covariance values
[in]consSillVector of constant required sills (optional)

◆ st_model_auto_constraints_apply()

static void st_model_auto_constraints_apply ( StrMod strmod,
int  npar,
const Constraints constraints,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Update default values, lower and upper bounds

Parameters
[in]strmodStrMod structure
[in]nparNumber of parameters to be inferred
[in]constraintsConstraints structure
[out]paramCurrent values for parameters
[out]lowerLower values for parameters
[out]upperUpper values for parameters

◆ st_model_auto_count()

static int st_model_auto_count ( const Vario vario,
Model model1,
Model model2,
Constraints constraints,
Option_VarioFit optvar,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Count the number of parameters

Returns
Number of parameters
-1 if one of the model components is not valid or
-2 if Goulard is not used althrough in multivariate
Parameters
[in]varioVario structure containing the exp. variogram
[in]model1Model first structure
[in]model2Model second structure
[in]constraintsConstraints structure
[in]optvarOpt_Vario structure
[out]paramArray giving the default parameter value
[out]lowerArray giving the minimum parameter value
[out]upperArray giving the maximum parameter value
Remarks
The arrays param, lower and upper are allocated by this function
(Dimension: Number of Parameters)
They should be freed by the user

◆ st_model_auto_pardef()

static void st_model_auto_pardef ( StrMod strmod,
int  npar,
double  hmax,
VectorDouble varchol,
VectorDouble angles,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Manage the default values of the parameters

Parameters
[in]strmodStrMod structure
[in]nparNumber of parameters to be inferred
[in]hmaxMaximum experimental distance
[in]varcholCholesky decomposition of the variance matrix
[in]anglesReference angles
[out]paramCurrent values for parameters
[out]lowerLower values for parameters
[out]upperUpper values for parameters

◆ st_model_auto_scldef()

static void st_model_auto_scldef ( StrMod strmod,
int  npar,
double  hmax,
VectorDouble varchol,
VectorDouble scale 
)
static

Manage the scaling factors of the parameters

Parameters
[in]strmodStrMod structure
[in]nparNumber of parameters to be inferred
[in]hmaxMaximum experimental distance
[in]varcholCholesky decomposition of the variance matrix
[out]scaleArray of scales

◆ st_model_auto_strmod_alloc()

static StrMod* st_model_auto_strmod_alloc ( Model model1,
Model model2,
int  npar0,
int  norder,
double  hmax,
VectorDouble angles,
const Option_VarioFit optvar,
int *  npar 
)
static

Allocate the pointers on the StrMod structure

Returns
Pointer to the newly allocated StrMod structure
Parameters
[in]model1Model structure
[in]model2Model structure
[in]npar0Initial number of parameters
[in]norderOrder of the Generalized Variogram
[in]hmaxMaximum experimental distance
[in]anglesReference angles (coming from the Variogram)
[in]optvarOpt_Vario structure
[out]nparFinal number of parameters

◆ st_model_auto_strmod_define()

static void st_model_auto_strmod_define ( StrMod strmod,
int  npar,
VectorDouble param 
)
static

Load the parameters in the Model structure

Parameters
[in]strmodStrMod structure
[in]nparNumber of parameters
[in]paramCurrent values for parameters

◆ st_model_auto_strmod_free()

static StrMod* st_model_auto_strmod_free ( StrMod strmod)
static

Free the pointer on the StrMod structure

Returns
Newly freed pointer
Parameters
[in]strmodPointer to the StrMod to be freed

◆ st_model_auto_strmod_print()

static void st_model_auto_strmod_print ( int  flag_title,
StrMod strmod,
const Constraints constraints,
const Option_AutoFit mauto,
VectorDouble param,
VectorDouble lower,
VectorDouble upper,
int  npar,
int  nbexp 
)
static

Print the resulting parameters of the Model

Parameters
[in]flag_title1 if the conditions must be printed
[in]strmodStrMod structure
[in]constraintsConstraints structure
[in]mautoOption_AutoFit structure
[in]paramCurrent values for parameters
[in]lowerArray of lower values
[in]upperArray of upper values
[in]nparNumber of parameters to be inferred
[in]nbexpNumber of experiments

◆ st_model_auto_strmod_reduce()

static int st_model_auto_strmod_reduce ( StrMod strmod,
int *  npar,
double  hmax,
double  gmax,
VectorDouble param,
VectorDouble lower,
VectorDouble upper,
Constraints constraints,
Option_AutoFit mauto 
)
static

Reduce the Model by discarding unnecessary basic structure(s)

Returns
1 if the Model has been reduced; 0 otherwise
Parameters
[in]strmodStrMod structure
[in]nparNumber of parameters
[in]hmaxMaximum distance value
[in]gmaxMaximum variogram value
[in]paramCurrent values for parameters
[in]lowerLower values for parameters
[in]upperUpper values for parameters
[in]constraintsConstraints structure
[in]mautoOption_AutoFit structure

◆ st_model_define()

static int st_model_define ( Model model,
const Option_VarioFit optvar 
)
static

Define the options of the model

Returns
Error return code
Parameters
[in]modelModel structure containing the basic structures
[in]optvarOpt_Vario structure

TODO [Cova] : To be restored? Why this?

◆ st_model_has_intrinsic()

static int st_model_has_intrinsic ( Model model,
const int *  filter 
)
static

Check if the model has (at least) one intrinsic structure

Returns
1 if model contains at least one intrinsic structure; 0 otherwise
Parameters
[in]modelModel structure containing the basic structures
[in]filterArray specifying if a basic structure is filtered (1) or not (0). This array is optional

◆ st_model_post_update()

static void st_model_post_update ( StrMod strmod,
const Option_VarioFit optvar 
)
static

Update of the resulting model after the automatic fit

Parameters
[in,out]strmodStrMod structure
[in]optvarOpt_Vario structure

◆ st_modify_optvar_for_anam()

static void st_modify_optvar_for_anam ( Model model,
Option_VarioFit optvar 
)
static

◆ st_name_range()

static void st_name_range ( int  ivar)
static

Compute the name of the range

Parameters
[in]ivarRank of the variable

◆ st_name_rotation()

static void st_name_rotation ( int  rank)
static

Compute the name of the rotation

Parameters
[in]rankRank of the angle

◆ st_name_scale()

static void st_name_scale ( int  ivar)
static

Compute the name of the scale factor

Parameters
[in]ivarRank of the variable

◆ st_optimize_under_constraints()

static int st_optimize_under_constraints ( int  nvar,
int  nvs2,
int  ncova,
int  npadir,
const Constraints constraints,
const Option_AutoFit mauto,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
VectorDouble matcor,
double *  score 
)
static

Optimization under constraints

Returns
The number of iteration required to reach convergence
Parameters
[in]nvarNumber of variables
[in]nvs2Dimension of the triangular matrix (Dimension: nvar)
[in]ncovaNumber of basic structures
[in]npadirTotal number of lags
[in]constraintsConstraints structure
[in]mautoOption_AutoFit structure
[in]wtArray of weights attached to variogram lags
[in]ggArray of experimental values
[in]geArray of generic covariance values
[in]matcorMatrix of sills
[out]scoreThe convergence score

◆ st_parid_alloc()

static int st_parid_alloc ( StrMod strmod,
int  npar0 
)
static

Define the list of parameters identificators

Returns
Number of parameters
Parameters
[in]strmodStrMod structure
[in]npar0Initial number of parameters to be inferred

◆ st_parid_decode()

static void st_parid_decode ( int  parid,
int *  imod,
int *  icov,
EConsElem *  icons,
int *  ivar,
int *  jvar 
)
static

Decode the parameter identificator

Parameters
[in]paridParameter identificator
[out]imodRank of the model
[out]icovRank of the covariance
[out]iconsType of the constraint (EConsElem)
[out]ivarRank of the first index
[out]jvarRank of the second index

◆ st_parid_encode()

static int st_parid_encode ( int  imod,
int  icov,
const EConsElem &  icons,
int  ivar,
int  jvar 
)
static

Encode the parameter identificator

Returns
Encoded parameter identificator
Parameters
[in]imodRank of the model
[in]icovRank of the covariance
[in]iconsType of the constraint (EConsElem)
[in]ivarRank of the first index
[in]jvarRank of the second index

◆ st_parid_match()

static int st_parid_match ( StrMod strmod,
int  npar,
int  imod0,
int  icov0,
const EConsElem &  icons0,
int  ivar0,
int  jvar0 
)
static

Find the rank of the 'parid' which matches several criteria

Returns
Rank of the 'parid' or -1 if not found
Parameters
[in]strmodStrMod structure
[in]nparNumber of parid
[in]imod0Rank of the target model (or -1)
[in]icov0Rank of the target covariance (or -1)
[in]icons0Target type of the constraint (EConsElem)
[in]ivar0Target first variable (or -1)
[in]jvar0Target second variable (or -1)

◆ st_prepar_goulard_vario()

static void st_prepar_goulard_vario ( int  imod)
static

Prepare the array for Goulard's algorithm in the case of Variogram calculation

Parameters
[in]imodRank of the model

◆ st_prepar_goulard_vmap()

static void st_prepar_goulard_vmap ( int  imod)
static

Prepare the array for Goulard's algorithm in the case of VarioMap calculation

Parameters
[in]imodRank of the model

◆ st_print()

static void st_print ( const char *  name,
int  flag_end,
int  rank,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Prints a parameter of the basic structure

Parameters
[in]nameName of the parameter
[in]flag_end1 to add the end_of_line symbol - 0 otherwise
[in]rankRank of the parameter
[in]paramArray of current values
[in]lowerArray of lower values
[in]upperArray of upper values

◆ st_regularize_init()

static void st_regularize_init ( )
static

Initialize the internal structure for regularization

◆ st_score()

static double st_score ( int  nvar,
int  nvs2,
int  ncova,
int  npadir,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
VectorDouble matcor 
)
static

Evaluate the score

Returns
Value for the score
Parameters
[in]nvarNumber of variables
[in]nvs2Dimension of the triangular matrix (Dimension: nvar)
[in]ncovaNumber of basic structures
[in]npadirTotal number of lags
[in]wtArray of weights attached to variogram lags
[in]ggArray of experimental values
[in]geArray of generic covariance values
[in]matcorMatrix of sills

◆ st_sill_fitting_int()

static int st_sill_fitting_int ( Model model,
const Option_AutoFit mauto,
int  npadir,
VectorDouble wt,
VectorDouble gg,
VectorDouble ge,
VectorDouble wt2,
VectorDouble ge1,
VectorDouble ge2,
VectorDouble gg2,
VectorDouble alphau,
VectorDouble sill1 
)
static

Routine for fitting a model using an experimental variogram for the Intrinsic case

Returns
Error return code
Parameters
[in]modelModel to be fitted
[in]mautoOption_AutoFit structure
[in]npadirMaximum number of lags for all directions
[in]wtArray of weights (Dimension: npadir)
[in]ggArray of experimental values (Dimension: npadir)
[in]geArray of model values (Dimension: npadir)
[in]wt2Array of weights (Dimension: npadir)
[in]ge1Array of model values (Dimension: npadir)
[in]ge2Array of model values (Dimension: npadir)
[in]gg2Array of experimental values (Dimension: npadir)
[out]alphauArray
[out]sill1Array of resulting sills
Remarks
Internal arrays:
MP : Contains the current Model (ijvar,ipadir)

◆ st_sill_reset()

static void st_sill_reset ( int  nvar,
int  ncova,
VectorDouble sill 
)
static

Reset the array of sills

Parameters
[in]nvarNumber of variables
[in]ncovaNumber of covariances
[out]sillArray of resulting sills

◆ st_strexp_manage()

static std::vector<StrExp> st_strexp_manage ( int  nbexp,
int  ndim 
)
static

Manage the array of StrExp structures

Returns
The vector of StrExp structures
Parameters
[in]nbexpNumber of items
[in]ndimSpace dimension

◆ st_strmod_vario_evaluate()

static void st_strmod_vario_evaluate ( int  nbexp,
int  npar,
VectorDouble param,
VectorDouble tabge 
)
static

Evaluate the model for an experiment

Returns
Value of the model
Parameters
[in]nbexpNumber of experimental conditions
[in]nparNumber of parameters
[in]paramCurrent values for parameters
[out]tabgeArray of resulting values

◆ st_strmod_vmap_evaluate()

static void st_strmod_vmap_evaluate ( int  ,
int  npar,
VectorDouble param,
VectorDouble tabge 
)
static

Evaluate the model for an experiment

Returns
Value of the model
Parameters
[in]nparNumber of parameters
[in]paramCurrent values for parameters
[out]tabgeArray of resulting values

◆ st_structure_reduce()

static int st_structure_reduce ( StrMod strmod,
int  imod,
int  icov,
double  hmax,
double  gmax,
double  tolsigma 
)
static

Check if the basic structure can be compressed

Returns
1 if it can be removed; 0 otherwise
Parameters
[in]strmodStrMod structure
[in]imodRank of the Model
[in]icovRank of the basic structure
[in]hmaxMaximum distance
[in]gmaxMaximum variance
[in]tolsigmaPercentage of the variance

◆ st_sum_sills()

static double st_sum_sills ( int  ivar0,
int  ncova,
int  nvar,
VectorDouble alpha 
)
static

Sum the sill of all the structures

Returns
The sum of the sills over all the sill matrices for a given variable
Parameters
[in]ivar0Index of the variable
[in]ncovaNumber of basic structures
[in]nvarNumber of variables
[in]alphaThe coregionalisation matrices (Dim: nvar^2 x ncova )

◆ st_truncate_negative_eigen()

static int st_truncate_negative_eigen ( int  nvar,
int  icov0,
VectorDouble matcor,
VectorDouble matcoru 
)
static

Cut negative eigen values

Returns
1 if all eigen values are strictly positive
Parameters
[in]nvarNumber of variables
[in]icov0Rank of the target basic structure
[in]matcorMatrix of sills
[out]matcoruMatrix of sills (can coincide with input matcor)

◆ st_updateAlphaDiag()

void st_updateAlphaDiag ( int  icov0,
int  ivar0,
int  ncova,
int  nvar,
VectorDouble xr,
VectorDouble alpha,
const VectorDouble consSill 
)

Update alpha from xr (diagonal only)

Parameters
[in]icov0Target basic structure
[in]ivar0Target variable
[in]ncovaNumber of basic structures
[in]nvarNumber of variables
[in]xrCurrent vector of sqrt(constraint/(sum of the sills))
[in,out]alphaCurrent auxiliary matrices alpha
[in]consSillVector of constant Sill (optional)

◆ st_updateAlphaNoDiag()

static void st_updateAlphaNoDiag ( int  icov0,
int  ivar0,
int  nvar,
VectorDouble xr,
const VectorDouble consSill,
VectorDouble matcor,
VectorDouble alpha 
)
static

Update 'sills' for the structures other than the current one

Parameters
[in]icov0Target basic structure
[in]ivar0Index of the variable
[in]nvarNumber of variables
[in]xrCurrent vector of sqrt(constraint/(sum of the sills))
[in]consSillVector of optional constant sills
[in]matcorMatrices of sills
[out]alphaCurrent auxiliary matrices alpha

◆ st_updateCurrentSillDiag()

static void st_updateCurrentSillDiag ( int  icov0,
int  ivar0,
int  nvar,
VectorDouble alpha,
VectorDouble xr,
VectorDouble matcor 
)
static

Update the sill matrix for the current structure 'icov0' (diagonal only)

Parameters
[in]icov0Target basic structure
[in]ivar0Index of the variable
[in]nvarNumber of variables
[in]alphaCurrent auxiliary matrices alpha
[in]xrCurrent vector of sqrt(constraint/(sum of the sills))
[out]matcorMatrices of sills

◆ st_updateCurrentSillGoulard()

static void st_updateCurrentSillGoulard ( int  icov0,
int  ivar0,
int  npadir,
int  nvar,
int  ncova,
VectorDouble wt,
VectorDouble ge,
VectorDouble gg,
const VectorDouble consSill,
VectorDouble matcor 
)
static

Update the sill matrix for the current structure (except diagonal in the constrained case)

Parameters
[in]icov0Target basic structure
[in]ivar0Target variable
[in]npadirMaximum number of lags for all directions
[in]nvarNumber of variables
[in]ncovaNumber of basic structures
[in]wtArray of weights attached to variogram lags
[in]geArray of generic covariance values
[in]ggArray of experimental values
[in]consSillVector of optional constrained sills
[out]matcorMatrices of sills

◆ st_updateOtherSills()

static void st_updateOtherSills ( int  icov0,
int  ivar0,
int  ncova,
int  nvar,
VectorDouble alpha,
VectorDouble xr,
VectorDouble matcor 
)
static

Update 'sills' for the structures other than the current one

Parameters
[in]icov0Target basic structure
[in]ivar0Target variable
[in]ncovaNumber of basic structures
[in]nvarNumber of variables
[in]alphaCurrent auxiliary matrices alpha
[in]xrCurrent vector of sqrt(constraint/(sum of the sills))
[out]matcorCurrent sills matrices

◆ st_vario_varchol_manage()

static void st_vario_varchol_manage ( const Vario vario,
Model model,
VectorDouble varchol 
)
static

Define Cholesky decomposition of the variance-covariance matrix

Parameters
[in]varioVario structure
[in]modelModel structure
[out]varcholCholesky array
Remarks
In the case of Automatic Model Fitting with Properties,
we consider that the variance (of the Variogram) cannot
serve as initial value for the sill of the Model

◆ st_vmap_auto_count()

static int st_vmap_auto_count ( const Db dbmap,
Model model,
Constraints constraints,
Option_VarioFit optvar,
VectorDouble param,
VectorDouble lower,
VectorDouble upper 
)
static

Count the number of parameters

Returns
Number of parameters
-1 if one of the model components is not valid
-2 if Goulard is not used althrough in multivariate
Parameters
[in]dbmapDb grid structure containing the Vmap
[in]modelModel structure
[in]constraintsConstraint structure
[in]optvarOpt_Vario structure
[out]paramArray giving the default parameter value
[out]lowerArray giving the minimum parameter value
[out]upperArray giving the maximum parameter value

◆ st_vmap_varchol_manage()

static void st_vmap_varchol_manage ( const Db dbmap,
VectorDouble varchol 
)
static

Define Cholesky decomposition of the variance-covariance matrix

Parameters
[in]dbmapDb structure
[out]varcholCholesky array

◆ vmap_auto_fit()

int vmap_auto_fit ( const DbGrid dbmap,
Model model,
bool  verbose,
const Option_AutoFit mauto_arg,
const Constraints cons_arg,
const Option_VarioFit optvar_arg 
)

Automatic model fitting

Returns
Error returned code
Parameters
[in]dbmapDb Grid structure containing the Vmap
[in]modelModel structure containing the basic structures
[in]verboseVerbose flag
[in]mauto_argOption_AutoFit structure
[in]cons_argConstraints structure
[in]optvar_argOpt_Vario structure

Variable Documentation

◆ CONGRUENCY

int CONGRUENCY = 50
static

◆ CONSTRAINTS

Constraints CONSTRAINTS
static

◆ cov_name

char cov_name[STRING_LENGTH]
static

◆ DBMAP

const DbGrid* DBMAP
static

◆ EpsFit

double EpsFit = 1.e-12
static

◆ INDG1

VectorInt INDG1
static

◆ INDG2

VectorInt INDG2
static

◆ MAUTO

Option_AutoFit MAUTO
static

◆ RECINT

Recint RECINT
static

◆ REGULARIZE

Regularize REGULARIZE
static

◆ ST_PREPAR_GOULARD

void(* ST_PREPAR_GOULARD) (int imod) ( int  imod)
static

◆ STREXPS

std::vector<StrExp> STREXPS
static

◆ string

char string[STRING_LENGTH]
static

◆ STRMOD

StrMod* STRMOD = nullptr
static