gstlearn  1.0.0
CCC
Rule Class Reference

#include <Rule.hpp>

Inheritance diagram for Rule:
AStringable ASerializable RuleShadow RuleShift

Public Member Functions

 Rule (double rho=0.)
 
 Rule (const Rule &r)
 
Ruleoperator= (const Rule &r)
 
virtual ~Rule ()
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 
int resetFromNames (const VectorString &nodnames, double rho=0.)
 
int resetFromCodes (const VectorInt &nodes, double rho=0.)
 
int resetFromNumericalCoding (const VectorInt &n_type, const VectorInt &n_facs, double rho=0.)
 
int resetFromFaciesCount (int nfacies, double rho=0.)
 
virtual String displaySpecific () const
 
virtual int particularities (Db *db, const Db *dbprop, Model *model, int flag_grid_check, int flag_stat) const
 
virtual bool checkModel (const Model *model, int nvar=0) const
 
virtual int gaus2facData (PropDef *propdef, Db *dbin, Db *dbout, int *flag_used, int ipgs, int isimu, int nbsimu)
 
virtual int gaus2facResult (PropDef *propdef, Db *dbout, int *flag_used, int ipgs, int isimu, int nbsimu) const
 
virtual int evaluateBounds (PropDef *propdef, Db *dbin, Db *dbout, int isimu, int igrf, int ipgs, int nbsimu) const
 
int getFlagProp () const
 
const ERule & getModeRule () const
 
double getRho () const
 
const NodegetMainNode () const
 
void setFlagProp (int flagProp)
 
void setRho (double rho) const
 
void setModeRule (const ERule &modeRule)
 TODO : Check if mutable is really necessary. More...
 
int setProportions (const VectorDouble &proportions=VectorDouble()) const
 
int statistics (int verbose, int *node_tot, int *nfac_tot, int *nmax_tot, int *ny1_tot, int *ny2_tot, double *prop_tot) const
 
int getFaciesNumber () const
 
int getGRFNumber () const
 
int getY1Number () const
 
int getY2Number () const
 
bool isYUsed (int igrf) const
 
VectorInt whichGRFUsed () const
 
double getProportion (int facies)
 
VectorDouble getThresh (int facies) const
 
VectorDouble getThreshFromRectangle (int rect, int *facies)
 
int getFaciesFromGaussian (double y1, double y2) const
 
void updateShift () const
 
- Public Member Functions inherited from AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (int level) const final
 
- Public Member Functions inherited from ASerializable
 ASerializable ()
 
 ASerializable (const ASerializable &r)
 
ASerializableoperator= (const ASerializable &r)
 
virtual ~ASerializable ()
 
bool deserialize (std::istream &is, bool verbose=true)
 
bool serialize (std::ostream &os, bool verbose=true) const
 
bool dumpToNF (const String &neutralFilename, bool verbose=false) const
 

Static Public Member Functions

static Rulecreate (double rho=0.)
 
static RulecreateFromNF (const String &neutralFilename, bool verbose=true)
 
static RulecreateFromNames (const VectorString &nodnames, double rho=0.)
 
static RulecreateFromCodes (const VectorInt &nodes, double rho=0.)
 
static RulecreateFromNumericalCoding (const VectorInt &n_type, const VectorInt &n_facs, double rho=0.)
 
static RulecreateFromFaciesCount (int nfacies, double rho=0.)
 
- Static Public Member Functions inherited from ASerializable
static String buildFileName (int status, const String &filename, bool ensureDirExist=false)
 
static String getHomeDirectory (const String &sub="")
 
static String getWorkingDirectory ()
 
static String getTestData (const String &subdir, const String &filename)
 
static String getFileIdentity (const String &filename, bool verbose=false)
 
static void setContainerName (bool useDefault, const String &containerName="", bool verbose=false)
 
static void unsetContainerName ()
 
static void setPrefixName (const String &prefixName)
 
static void unsetPrefixName ()
 
static const StringgetContainerName ()
 
static const StringgetPrefixName ()
 
static bool createDirectory (const String &dir)
 
static String getExecDirectory ()
 
static String getDirectory (const String &path)
 

Protected Member Functions

virtual bool _serialize (std::ostream &os, bool verbose=false) const override
 Interface for ASerializable. More...
 
virtual bool _deserialize (std::istream &is, bool verbose=false) override
 
String _getNFName () const override
 
void setMainNodeFromNodNames (const VectorInt &n_type, const VectorInt &n_facs)
 
void setMainNodeFromNodNames (const VectorString &nodnames)
 
int setMainNodeFromNodNames (const VectorInt &nodes)
 
int replicateInvalid (Db *dbin, Db *dbout, int jech) const
 
VectorString buildNodNames (int nfacies)
 
- Protected Member Functions inherited from ASerializable
bool _fileOpenWrite (const String &filename, std::ofstream &os, bool verbose=false) const
 
bool _fileOpenRead (const String &filename, std::ifstream &is, bool verbose=false) const
 

Private Member Functions

void _ruleDefine (std::ostream &os, const Node *node, int from_type, int from_rank, int from_vers, int *rank) const
 
void _nodNamesToIds (const VectorString &nodes, VectorInt &n_type, VectorInt &n_facs)
 
void _clear ()
 

Private Attributes

ERule _modeRule
 
int _flagProp
 
double _rho
 
Node_mainNode
 

Additional Inherited Members

- Static Protected Member Functions inherited from ASerializable
static bool _commentWrite (std::ostream &os, const String &comment)
 
template<typename T >
static bool _recordWrite (std::ostream &os, const String &title, const T &val)
 
template<typename T >
static bool _recordWriteVec (std::ostream &os, const String &title, const VectorT< T > &vec)
 
template<typename T >
static bool _recordRead (std::istream &is, const String &title, T &val)
 
template<typename T >
static bool _recordReadVec (std::istream &is, const String &title, VectorT< T > &vec, int nvalues)
 
static bool _onlyBlanks (char *string)
 
static bool _tableRead (std::istream &is, const String &string, int ntab, double *tab)
 
static bool _tableWrite (std::ostream &os, const String &string, int ntab, const VectorDouble &tab)
 

Constructor & Destructor Documentation

◆ Rule() [1/2]

Rule::Rule ( double  rho = 0.)

◆ Rule() [2/2]

Rule::Rule ( const Rule r)

◆ ~Rule()

Rule::~Rule ( )
virtual

Member Function Documentation

◆ _clear()

void Rule::_clear ( )
private

◆ _deserialize()

bool Rule::_deserialize ( std::istream &  is,
bool  verbose = false 
)
overrideprotectedvirtual

Implements ASerializable.

Reimplemented in RuleShift, and RuleShadow.

◆ _getNFName()

String Rule::_getNFName ( ) const
inlineoverrideprotectedvirtual

Implements ASerializable.

Reimplemented in RuleShift, and RuleShadow.

◆ _nodNamesToIds()

void Rule::_nodNamesToIds ( const VectorString nodes,
VectorInt n_type,
VectorInt n_facs 
)
private

◆ _ruleDefine()

void Rule::_ruleDefine ( std::ostream &  os,
const Node node,
int  from_type,
int  from_rank,
int  from_vers,
int *  rank 
) const
private

◆ _serialize()

bool Rule::_serialize ( std::ostream &  os,
bool  verbose = false 
) const
overrideprotectedvirtual

Interface for ASerializable.

Implements ASerializable.

Reimplemented in RuleShift, and RuleShadow.

◆ buildNodNames()

VectorString Rule::buildNodNames ( int  nfacies)
protected

◆ checkModel()

bool Rule::checkModel ( const Model model,
int  nvar = 0 
) const
virtual

Reimplemented in RuleShift.

◆ create()

Rule * Rule::create ( double  rho = 0.)
static

◆ createFromCodes()

Rule * Rule::createFromCodes ( const VectorInt nodes,
double  rho = 0. 
)
static

◆ createFromFaciesCount()

Rule * Rule::createFromFaciesCount ( int  nfacies,
double  rho = 0. 
)
static

◆ createFromNames()

Rule * Rule::createFromNames ( const VectorString nodnames,
double  rho = 0. 
)
static

◆ createFromNF()

Rule * Rule::createFromNF ( const String neutralFilename,
bool  verbose = true 
)
static

◆ createFromNumericalCoding()

Rule * Rule::createFromNumericalCoding ( const VectorInt n_type,
const VectorInt n_facs,
double  rho = 0. 
)
static

◆ displaySpecific()

String Rule::displaySpecific ( ) const
virtual

Reimplemented in RuleShift, and RuleShadow.

◆ evaluateBounds()

int Rule::evaluateBounds ( PropDef propdef,
Db dbin,
Db dbout,
int  isimu,
int  igrf,
int  ipgs,
int  nbsimu 
) const
virtual

Set the bounds and possibly add replicates

Returns
Error return code
Parameters
[in]propdefPropDef structure
[in]dbinDb structure
[in]dboutDb grid structure
[in]isimuRank of the simulation (if EProcessOper::CONDITIONAL)
[in]igrfRank of the GRF
[in]ipgsRank of the GS
[in]nbsimuNumber of simulations (if EProcessOper::CONDITIONAL)

Reimplemented in RuleShift, and RuleShadow.

◆ gaus2facData()

int Rule::gaus2facData ( PropDef propdef,
Db dbin,
Db dbout,
int *  flag_used,
int  ipgs,
int  isimu,
int  nbsimu 
)
virtual

Combine the underlying GRF into a facies value at data points

Returns
Error return code
Parameters
[in]propdefProps structure
[in]dbinDb input structure
[in]dboutDb output structure
[in]flag_used1 if the gaussian is used; 0 otherwise
[in]ipgsRank of the PGS
[in]isimuRank of the simulation
[in]nbsimuNumber of simulations
Remarks
Attributes ELoc::GAUSFAC are mandatory
Attributes ELoc::FACIES are mandatory

Reimplemented in RuleShadow.

◆ gaus2facResult()

int Rule::gaus2facResult ( PropDef propdef,
Db dbout,
int *  flag_used,
int  ipgs,
int  isimu,
int  nbsimu 
) const
virtual

Combine the underlying GRF into a facies value

Returns
Error return code
Parameters
[in]propdefProps structure
[in]dboutDb output structure
[in]flag_used1 if the gaussian is used; 0 otherwise
[in]ipgsRank of the PGS
[in]isimuRank of the simulation
[in]nbsimuNumber of simulations
Remarks
Attributes ELoc::FACIES and ELoc::SIMU are mandatory

Reimplemented in RuleShift, and RuleShadow.

◆ getFaciesFromGaussian()

int Rule::getFaciesFromGaussian ( double  y1,
double  y2 
) const

Convert the two underlying GRFs into facies

Returns
The facies rank or 0 (facies not found)
Parameters
[in]y1Value of the first underlying GRF
[in]y2Value of the second underlying GRF
Remarks
If one of the two GRF is undefined, the resulting facies is 0

◆ getFaciesNumber()

int Rule::getFaciesNumber ( ) const

◆ getFlagProp()

int Rule::getFlagProp ( ) const
inline

◆ getGRFNumber()

int Rule::getGRFNumber ( ) const

◆ getMainNode()

const Node* Rule::getMainNode ( ) const
inline

◆ getModeRule()

const ERule& Rule::getModeRule ( ) const
inline

◆ getProportion()

double Rule::getProportion ( int  facies)

Returns the proportion of a given facies

Parameters
faciesFacies rank (starting from 1)
Returns
Proportion of the given Facies

◆ getRho()

double Rule::getRho ( ) const
inline

◆ getThresh()

VectorDouble Rule::getThresh ( int  facies) const

Return the vector of bounds for a given facies

Parameters
faciesRank of the target facies (starting from 1)
Returns
The vector of bounds organized as [t1min, t1max, t2min, t2max]

◆ getThreshFromRectangle()

VectorDouble Rule::getThreshFromRectangle ( int  rect,
int *  facies 
)

◆ getY1Number()

int Rule::getY1Number ( ) const

◆ getY2Number()

int Rule::getY2Number ( ) const

◆ isYUsed()

bool Rule::isYUsed ( int  igrf) const

◆ operator=()

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

◆ particularities()

int Rule::particularities ( Db db,
const Db dbprop,
Model model,
int  flag_grid_check,
int  flag_stat 
) const
virtual

Define the particularities of the PGS model

Returns
Error return code
Parameters
[in]dbDb structure
[in]dbpropDb structure used for proportions
[in]modelModel structure (only used for shift option)
[in]flag_grid_check1 if grid is compulsory; 0 otherwise (only for SHIFT)
[in]flag_stat1 for stationary; 0 otherwise

Reimplemented in RuleShift, and RuleShadow.

◆ replicateInvalid()

int Rule::replicateInvalid ( Db dbin,
Db dbout,
int  jech 
) const
protected

Check if the current replicate can be added

Returns
1 if the point is a duplicate; 0 otherwise
Parameters
[in]dbinDb structure
[in]dboutDb output structure
[in]jechRank of the replicate

◆ resetFromCodes()

int Rule::resetFromCodes ( const VectorInt nodes,
double  rho = 0. 
)

◆ resetFromFaciesCount()

int Rule::resetFromFaciesCount ( int  nfacies,
double  rho = 0. 
)

◆ resetFromNames()

int Rule::resetFromNames ( const VectorString nodnames,
double  rho = 0. 
)

◆ resetFromNumericalCoding()

int Rule::resetFromNumericalCoding ( const VectorInt n_type,
const VectorInt n_facs,
double  rho = 0. 
)

This entry is specific for the Rule inference procedure

Parameters
n_typeVector of items: 0 for Facies, 1 for G1 threshold; 2 for G2 threshold
n_facsVector of facies: XXX for Facies, 0 for thresholds
rhoGRFs correlation coefficient
Returns

◆ setFlagProp()

void Rule::setFlagProp ( int  flagProp)
inline

◆ setMainNodeFromNodNames() [1/3]

void Rule::setMainNodeFromNodNames ( const VectorInt n_type,
const VectorInt n_facs 
)
protected

◆ setMainNodeFromNodNames() [2/3]

int Rule::setMainNodeFromNodNames ( const VectorInt nodes)
protected

Initialization of the nodes of the Rule (from the ASCII file).

Parameters
nodesNode description (6 * number of nodes) 0 : Type of the parent 1 : Rank of the parent 2 : Orientation of the parent 3 : Information type: 0 (idle) - 1 (Threshold along Y1) - 2 (Threshold along Y2) 4 : Rank of the node (starting from 1) 5 : Rank of the facies
Returns
Newly created Rule structure

◆ setMainNodeFromNodNames() [3/3]

void Rule::setMainNodeFromNodNames ( const VectorString nodnames)
protected

◆ setModeRule()

void Rule::setModeRule ( const ERule &  modeRule)
inline

TODO : Check if mutable is really necessary.

◆ setProportions()

int Rule::setProportions ( const VectorDouble proportions = VectorDouble()) const

Define constant proportions

Parameters
proportionsThe vector of constant proportions. It should be dimensioned to the number of facies. If absent, all proportions are considered equal.
Returns

◆ setRho()

void Rule::setRho ( double  rho) const
inline

◆ statistics()

int Rule::statistics ( int  verbose,
int *  node_tot,
int *  nfac_tot,
int *  nmax_tot,
int *  ny1_tot,
int *  ny2_tot,
double *  prop_tot 
) const

Calculates the statistics from the Lithotype Rule

Returns
Error return code
Parameters
[in]verbose1 for a verbose output; 0 otherwise
[out]node_totNumber of nodes
[out]nfac_totNumber of facies
[out]nmax_totNumber of (different) facies
[out]ny1_totNumber of thresholds for Y1
[out]ny2_totNumber of thresholds for Y2
[out]prop_totTotal proportion
Remarks
The tolerance on the sum of the proportions can be defined
using set_keypair("TolSumProportions",newtol)

◆ toString()

String Rule::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

Reimplemented from AStringable.

◆ updateShift()

void Rule::updateShift ( ) const

◆ whichGRFUsed()

VectorInt Rule::whichGRFUsed ( ) const

Member Data Documentation

◆ _flagProp

int Rule::_flagProp
mutableprivate

◆ _mainNode

Node* Rule::_mainNode
private

◆ _modeRule

ERule Rule::_modeRule
private

◆ _rho

double Rule::_rho
mutableprivate

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