22 #ifndef __INFERENCE_ENGINE__H__ 23 #define __INFERENCE_ENGINE__H__ 32 #include <agrum/CN/polytope/LrsWrapper.h> 33 #include <agrum/CN/tools/varMod2BNsMap.h> 34 #include <agrum/tools/core/approximations/approximationScheme.h> 35 #include <agrum/tools/core/exceptions.h> 36 #include <agrum/tools/core/math/pow.h> 37 #include <agrum/tools/core/math/rational.h> 53 template <
typename GUM_SCALAR >
200 inline void updateExpectations_(
const NodeId& id,
const std::vector< GUM_SCALAR >& vertex);
214 const std::vector< GUM_SCALAR >& vertex,
215 const bool& elimRedund =
false);
422 const GUM_SCALAR&
expectationMin(
const std::string& varName)
const;
429 const GUM_SCALAR&
expectationMax(
const std::string& varName)
const;
506 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 512 #include <agrum/CN/inference/inferenceEngine_tpl.h> Potential< GUM_SCALAR > marginalMax(const NodeId id) const
Get the upper marginals of a given node id.
virtual ~InferenceEngine()
Destructor.
Potential< GUM_SCALAR > marginalMax(const std::string &varName) const
Get the upper marginals of a given variable name.
const GUM_SCALAR & expectationMax(const NodeId id) const
Get the upper expectation of a given node id.
void initExpectations_()
Initialize lower and upper expectations before inference, with the lower expectation being initialize...
void insertModals(const std::map< std::string, std::vector< GUM_SCALAR > > &modals)
Insert variables modalities from map to compute expectations.
margi oldMarginalMin_
Old lower marginals used to compute epsilon.
dynExpe dynamicExpMin_
Lower dynamic expectations.
void insertEvidence(const NodeProperty< std::vector< GUM_SCALAR > > &evidence)
Insert evidence from Property.
Potential< GUM_SCALAR > marginalMin(const std::string &varName) const
Get the lower marginals of a given variable name.
void updateCredalSets_(const NodeId &id, const std::vector< GUM_SCALAR > &vertex, const bool &elimRedund=false)
Given a node id and one of it's possible vertex, update it's credal set.
void insertModalsFile(const std::string &path)
Insert variables modalities from file to compute expectations.
INLINE void emplace(Args &&... args)
const GUM_SCALAR computeEpsilon_()
Compute approximation scheme epsilon using the old marginals and the new ones.
bool repetitiveInd_
True if using repetitive independence ( dynamic network only ), False otherwise.
bool repetitiveInd() const
Get the current independence status.
bool storeBNOpt_
Iterations limit stopping rule used by some algorithms such as CNMonteCarloSampling.
const std::string getApproximationSchemeMsg()
Get approximation scheme state.
virtual void insertEvidenceFile(const std::string &path)
Insert evidence from file.
void insertQueryFile(const std::string &path)
Insert query variables states from file.
const CredalNet< GUM_SCALAR > * credalNet_
A pointer to the Credal Net used.
bool storeVertices_
True if credal sets vertices are stored, False otherwise.
cluster t1_
Clusters of nodes used with dynamic networks.
bool storeVertices() const
Get the number of iterations without changes used to stop some algorithms.
cluster t0_
Clusters of nodes used with dynamic networks.
void initMarginalSets_()
Initialize credal set vertices with empty sets.
margi oldMarginalMax_
Old upper marginals used to compute epsilon.
const std::vector< std::vector< GUM_SCALAR > > & vertices(const NodeId id) const
Get the vertice of a given node id.
credalSet marginalSets_
Credal sets vertices, if enabled.
VarMod2BNsMap< GUM_SCALAR > * getVarMod2BNsMap()
Get optimum IBayesNet.
const std::vector< GUM_SCALAR > & dynamicExpMax(const std::string &varName) const
Get the upper dynamic expectation of a given variable prefix (without the time step included...
void dynamicExpectations()
Compute dynamic expectations.
void saveVertices(const std::string &path) const
Saves vertices to file.
void saveMarginals(const std::string &path) const
Saves marginals to file.
void storeVertices(const bool value)
void updateExpectations_(const NodeId &id, const std::vector< GUM_SCALAR > &vertex)
Given a node id and one of it's possible vertex obtained during inference, update this node lower and...
InferenceEngine(const CredalNet< GUM_SCALAR > &credalNet)
Construtor.
dynExpe modal_
Variables modalities used to compute expectations.
std::string toString() const
Print all nodes marginals to standart output.
const CredalNet< GUM_SCALAR > & credalNet() const
Get this creadal network.
margi evidence_
Holds observed variables states.
Potential< GUM_SCALAR > marginalMin(const NodeId id) const
Get the lower marginals of a given node id.
virtual void makeInference()=0
To be redefined by each credal net algorithm.
void initMarginals_()
Initialize lower and upper old marginals and marginals before inference, with the lower marginal bein...
query query_
Holds the query nodes states.
void repetitiveInit_()
Initialize t0_ and t1_ clusters.
dynExpe dynamicExpMax_
Upper dynamic expectations.
VarMod2BNsMap< GUM_SCALAR > dbnOpt_
Object used to efficiently store optimal bayes net during inference, for some algorithms.
void insertQuery(const NodeProperty< std::vector< bool > > &query)
Insert query variables and states from Property.
expe expectationMax_
Upper expectations, if some variables modalities were inserted.
void storeBNOpt(const bool value)
const GUM_SCALAR & expectationMin(const std::string &varName) const
Get the lower expectation of a given variable name.
void dynamicExpectations_()
Rearrange lower and upper expectations to suit dynamic networks.
expe expectationMin_
Lower expectations, if some variables modalities were inserted.
int timeSteps_
The number of time steps of this network (only usefull for dynamic networks).
void setRepetitiveInd(const bool repetitive)
const GUM_SCALAR & expectationMin(const NodeId id) const
Get the lower expectation of a given node id.
margi marginalMax_
Upper marginals.
void saveExpectations(const std::string &path) const
Saves expectations to file.
margi marginalMin_
Lower marginals.
virtual void eraseAllEvidence()
Erase all inference related data to perform another one.
const GUM_SCALAR & expectationMax(const std::string &varName) const
Get the upper expectation of a given variable name.
const std::vector< GUM_SCALAR > & dynamicExpMin(const std::string &varName) const
Get the lower dynamic expectation of a given variable prefix (without the time step included...
namespace for all credal networks entities