gstlearn  0.2.1
Geostatistics & Machine Learning toolbox
NeighWork Class Reference

#include <NeighWork.hpp>

Public Member Functions

 NeighWork (const Db *dbin=nullptr, const ANeighParam *neighparam=nullptr)
 
 NeighWork (const NeighWork &r)
 
NeighWorkoperator= (const NeighWork &r)
 
virtual ~NeighWork ()
 
void initialize (const Db *dbin, const ANeighParam *neighparam)
 
void clear ()
 
VectorInt select (Db *dbout, int iech_out, const VectorInt &rankColCok=VectorInt(), bool verbose=false)
 
bool isUnchanged () const
 
void setIsChanged ()
 
VectorDouble summary (Db *dbout, int iech_out, const VectorInt &rankColCok=VectorInt())
 
void setFlagSimu (bool flagSimu)
 

Private Member Functions

void _unique (Db *dbout, int iech_out, VectorInt &ranks)
 
void _bench (Db *dbout, int iech_out, VectorInt &ranks)
 
int _moving (Db *dbout, int iech_out, VectorInt &ranks, double eps=EPSILON9)
 
bool _discardUndefined (int iech)
 
int _xvalid (Db *dbout, int iech_in, int iech_out, double eps=EPSILON9)
 
int _movingSectorDefine (double dx, double dy)
 
void _movingSectorNsmax (int nsel, VectorInt &ranks)
 
void _movingSelect (int nsel, VectorInt &ranks)
 
void _display (const VectorInt &ranks)
 
double _movingDist (Db *dbout, int iech_in, int iech_out)
 
bool _belongsToCell (Db *dbout, int iech, int iech_out)
 
void _checkUnchanged (const Db *dbout, int iech_out, const VectorInt &ranks)
 
void _clearMemory ()
 
void _resetFromMemory (bool flagSame, VectorInt &ranks, bool verbose)
 
bool _isSameTarget (const Db *dbout, int iech_out, VectorInt &ranks, bool verbose=false)
 
bool _isSameTargetBench (const Db *dbout, int iech_out, VectorInt &ranks, bool verbose=false)
 
bool _isSameTargetUnique (const Db *dbout, int iech_out, VectorInt &ranks, bool verbose=false)
 
void _updateColCok (const VectorInt &rankColCok, VectorInt &ranks, int iech_out)
 
bool _hiddenByFault (Db *dbout, int iech, int iech_out) const
 

Private Attributes

const Db_dbin
 
const ANeighParam_neighParam
 
bool _flagInitialized
 
bool _flagIsUnchanged
 
VectorInt _movingInd
 
VectorInt _movingIsect
 
VectorInt _movingNsect
 
VectorDouble _movingX1
 
VectorDouble _movingX2
 
VectorDouble _movingDst
 
bool _flagSimu
 
const Db_dbout
 
int _iechOut
 
VectorInt _nbghMemo
 

Constructor & Destructor Documentation

◆ NeighWork() [1/2]

NeighWork::NeighWork ( const Db dbin = nullptr,
const ANeighParam neighparam = nullptr 
)

◆ NeighWork() [2/2]

NeighWork::NeighWork ( const NeighWork r)

◆ ~NeighWork()

NeighWork::~NeighWork ( )
virtual

Member Function Documentation

◆ _belongsToCell()

bool NeighWork::_belongsToCell ( Db dbout,
int  iech,
int  iech_out 
)
private

◆ _bench()

void NeighWork::_bench ( Db dbout,
int  iech_out,
VectorInt ranks 
)
private

Search for the bench neighborhood, according to the last coordinate

Parameters
[in]dboutoutput Db structure
[in]iech_outrank of the output sample
[out]ranksVector of samples elected in the Neighborhood

◆ _checkUnchanged()

void NeighWork::_checkUnchanged ( const Db dbout,
int  iech_out,
const VectorInt ranks 
)
private

◆ _clearMemory()

void NeighWork::_clearMemory ( )
private

◆ _discardUndefined()

bool NeighWork::_discardUndefined ( int  iech)
private

Discard a sample for which all variables are undefined

Returns 1 if all variables are undefined; 0 otherwise

Parameters
[in]iechRank of the sample
Remarks
When the Neighborhood is performed in the case of Simulations
checking for all variables being undefined is performed
on ELoc::SIMU rather than on ELoc::Z

◆ _display()

void NeighWork::_display ( const VectorInt ranks)
private

Print the information selected in the neighborhood

Parameters
[in]ranksArray of the data ranks
  • -1 if not selected
  • >=0 gives the angular sector in ENeigh::MOVING

◆ _hiddenByFault()

bool NeighWork::_hiddenByFault ( Db dbout,
int  iech,
int  iech_out 
) const
private

◆ _isSameTarget()

bool NeighWork::_isSameTarget ( const Db dbout,
int  iech_out,
VectorInt ranks,
bool  verbose = false 
)
private

Checks if the current target matches the target previously treated in the same procedure. If match is reached, then there is no need to compute a new neighborhood: use the previous Vector of sample ranks. Store the references of the new 'dbout' and 'iech_out' for next optimizations

Parameters
dboutCurrent 'Db' structure for output
iech_outRank of the current target sample
ranksVector of selected samples
verboseVerbose option
Returns

◆ _isSameTargetBench()

bool NeighWork::_isSameTargetBench ( const Db dbout,
int  iech_out,
VectorInt ranks,
bool  verbose = false 
)
private

◆ _isSameTargetUnique()

bool NeighWork::_isSameTargetUnique ( const Db dbout,
int  iech_out,
VectorInt ranks,
bool  verbose = false 
)
private

◆ _moving()

int NeighWork::_moving ( Db dbout,
int  iech_out,
VectorInt ranks,
double  eps = EPSILON9 
)
private

Moving neighborhood search

Returns
Error return code
0 : No error
1 : The number of data is smaller than the minimum number of
data in Moving Neighborhood
Parameters
[in]dboutOutput Db structure
[in]iech_outRank of the target in the output Db structure
[in]epsTolerance
[out]ranksVector of samples elected in the Neighborhood

◆ _movingDist()

double NeighWork::_movingDist ( Db dbout,
int  iech_in,
int  iech_out 
)
private

Calculates the distance between an input sample and the target

Returns
Distance
Parameters
[in]dboutoutput Db structure
[in]iech_inRank of the sample in the input Db structure
[in]iech_outRank of the sample in the output Db structure

◆ _movingSectorDefine()

int NeighWork::_movingSectorDefine ( double  dx,
double  dy 
)
private

Returns the rank of the sector (using the first two coordinates)

Returns
Sector index
Parameters
[in]dxincrement along X
[in]dyincrement along Y

◆ _movingSectorNsmax()

void NeighWork::_movingSectorNsmax ( int  nsel,
VectorInt ranks 
)
private

For each angular sector, select the first samples until the maximum number of samples is reached

Parameters
[in]nselNumber of selected samples
[out]ranksArray of active data point ranks

◆ _movingSelect()

void NeighWork::_movingSelect ( int  nsel,
VectorInt ranks 
)
private

Select the closest data per sector, until the maximum number neighbors is reached

Parameters
[in]nselNumber of ellegible data points
[in]ranksRank of the ellegible samples
Remarks
The samples beyond the maximum number of neighbors have their
rank turned into -1

◆ _resetFromMemory()

void NeighWork::_resetFromMemory ( bool  flagSame,
VectorInt ranks,
bool  verbose 
)
private

◆ _unique()

void NeighWork::_unique ( Db dbout,
int  iech_out,
VectorInt ranks 
)
private

Select the unique neighborhood (or Image Neighborhood)

Parameters
[in]dboutoutput Db structure
[in]iech_outrank of the output sample
[out]ranksVector of samples elected in the Neighborhood

◆ _updateColCok()

void NeighWork::_updateColCok ( const VectorInt rankColCok,
VectorInt ranks,
int  iech_out 
)
private

Update the set of selected samples in case of colocated option This is done only if:

  • the colocation option is ON (vector of colocated variable is defined)
  • at least one of the colocated variables at the target is valid
  • the target does not coincide with a sample already selected If the colocation option is validated, an additional member is added to 'ranks': it value is conventionally set to -1.
    Parameters
    rankColCokVector of Colocated Variables
    ranksVector of samples already selected
    iech_outRank of the targt site (in dbout)

◆ _xvalid()

int NeighWork::_xvalid ( Db dbout,
int  iech_in,
int  iech_out,
double  eps = EPSILON9 
)
private

Mask the data sample in the case of cross-validation

Returns
1 if the sample is masked; 0 otherwise
Parameters
[in]dboutoutput Db structure
[in]iech_inRank in the input Db structure
[in]iech_outRank in the output Db structure
[in]epsTolerance

◆ clear()

void NeighWork::clear ( )

Clear all the local storage in the NeighWork structure

◆ initialize()

void NeighWork::initialize ( const Db dbin,
const ANeighParam neighparam 
)

Initialize the neighborhood search

Parameters
[in]dbininput Db structure
[in]neighparamDescription of the ANeighParam parameters
Remarks
When the Neighborhood is performed in the case of Simulations
checking for all variables being undefined is performed
on ELoc::SIMU rather than on ELoc::Z

◆ isUnchanged()

bool NeighWork::isUnchanged ( ) const
inline

◆ operator=()

NeighWork & NeighWork::operator= ( const NeighWork r)

◆ select()

VectorInt NeighWork::select ( Db dbout,
int  iech_out,
const VectorInt rankColCok = VectorInt(),
bool  verbose = false 
)

Select the neighborhood

Returns
Vector of sample ranks in neighborhood (empty when error)
Parameters
[in]dboutoutput Db structure
[in]iech_outValid Rank of the sample in the output Db
[in]rankColCokVector of Colcok information (optional)
[in]verboseVerbose option

◆ setFlagSimu()

void NeighWork::setFlagSimu ( bool  flagSimu)
inline

◆ setIsChanged()

void NeighWork::setIsChanged ( )

◆ summary()

VectorDouble NeighWork::summary ( Db dbout,
int  iech_out,
const VectorInt rankColCok = VectorInt() 
)

Returns the main Neighborhood Parameters for a given target as a vector:

  • 0 : Number of active samples
  • 1 : Minimum distance
  • 2 : Maximum distance
  • 3 : Number of non-empty sectors
  • 4 : Number of consecutive empty sectors
Parameters
[in]dboutoutput Db structure
[in]iech_outValid Rank of the sample in the output Db
[in]rankColCokVector of ColCok information (optional)

Member Data Documentation

◆ _dbin

const Db* NeighWork::_dbin
private

◆ _dbout

const Db* NeighWork::_dbout
private

◆ _flagInitialized

bool NeighWork::_flagInitialized
private

◆ _flagIsUnchanged

bool NeighWork::_flagIsUnchanged
private

◆ _flagSimu

bool NeighWork::_flagSimu
private

◆ _iechOut

int NeighWork::_iechOut
private

◆ _movingDst

VectorDouble NeighWork::_movingDst
mutableprivate

◆ _movingInd

VectorInt NeighWork::_movingInd
mutableprivate

◆ _movingIsect

VectorInt NeighWork::_movingIsect
mutableprivate

◆ _movingNsect

VectorInt NeighWork::_movingNsect
mutableprivate

◆ _movingX1

VectorDouble NeighWork::_movingX1
mutableprivate

◆ _movingX2

VectorDouble NeighWork::_movingX2
mutableprivate

◆ _nbghMemo

VectorInt NeighWork::_nbghMemo
mutableprivate

◆ _neighParam

const ANeighParam* NeighWork::_neighParam
private

The documentation for this class was generated from the following files: