[aGrUM] adding some missing cpp files

parent 8e1fd1a8
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/GibbsSampling.h>
template class gum::GibbsSampling<float>;
......
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/MonteCarloSampling.h>
template class gum::MonteCarloSampling<float>;
......
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/importanceSampling.h>
template class gum::ImportanceSampling<float>;
......
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/loopySamplingInference.h>
template class gum::LoopySamplingInference<float, gum::WeightedSampling>;
......
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/BayesNetInference.h>
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/approximateInference.h>
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/estimator.h>
template class gum::Estimator<float>;
......
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/evidenceInference.h>
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/jointTargetedInference.h>
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/marginalTargetedInference.h>
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/relevantPotentialsFinderType.h>
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/tools/samplingInference.h>
template class gum::SamplingInference<float>;
......
......@@ -199,44 +199,32 @@ namespace gum {
* @param hardEv hard evidences values
*
*/
virtual void _onContextualize(BayesNetFragment< GUM_SCALAR >* bn){};
virtual void _onContextualize(BayesNetFragment< GUM_SCALAR >* bn);
virtual void _onEvidenceAdded(const NodeId id, bool isHardEvidence) {
if (!isHardEvidence) {
GUM_ERROR(FatalError, "Approximated inference only accept hard evidence");
}
};
virtual void _onEvidenceAdded(const NodeId id, bool isHardEvidence);
virtual void _onEvidenceErased(const NodeId id, bool isHardEvidence){};
virtual void _onEvidenceErased(const NodeId id, bool isHardEvidence);
virtual void _onAllEvidenceErased(bool contains_hard_evidence){};
virtual void _onAllEvidenceErased(bool contains_hard_evidence);
virtual void _onEvidenceChanged(const NodeId id, bool hasChangedSoftHard) {
if (hasChangedSoftHard) {
GUM_ERROR(FatalError, "Approximated inference only accept hard evidence");
}
};
virtual void _onEvidenceChanged(const NodeId id, bool hasChangedSoftHard);
virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR >* bn){};
virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR >* bn);
virtual void _updateOutdatedBNStructure(){};
virtual void _updateOutdatedBNStructure();
virtual void _updateOutdatedBNPotentials(){};
virtual void _updateOutdatedBNPotentials();
virtual void _onMarginalTargetAdded(const NodeId id){};
virtual void _onMarginalTargetAdded(const NodeId id);
virtual void _onMarginalTargetErased(const NodeId id){};
virtual void _onMarginalTargetErased(const NodeId id);
virtual void _onAllMarginalTargetsAdded(){};
virtual void _onAllMarginalTargetsAdded();
virtual void _onAllMarginalTargetsErased(){};
virtual void _onAllMarginalTargetsErased();
virtual void _onStateChanged() {
if (this->isInferenceReady()) {
__estimator.clear();
}
};
virtual void _onStateChanged();
private:
BayesNetFragment< GUM_SCALAR >* __samplingBN;
......
......@@ -185,11 +185,70 @@ namespace gum {
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_addVarSample(NodeId nod,
Instantiation* I) {
Instantiation* I) {
gum::Instantiation Itop = gum::Instantiation(*I);
I->add(samplingBN().variable(nod));
I->chgVal(samplingBN().variable(nod),
samplingBN().cpt(nod).extract(Itop).draw());
}
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onContextualize(
BayesNetFragment< GUM_SCALAR >* bn){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onEvidenceAdded(const NodeId id,
bool isHardEvidence) {
if (!isHardEvidence) {
GUM_ERROR(FatalError, "Approximated inference only accept hard evidence");
}
};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onEvidenceErased(const NodeId id,
bool isHardEvidence){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onAllEvidenceErased(
bool contains_hard_evidence){};
template < typename GUM_SCALAR >
void
SamplingInference< GUM_SCALAR >::_onEvidenceChanged(const NodeId id,
bool hasChangedSoftHard) {
if (hasChangedSoftHard) {
GUM_ERROR(FatalError, "Approximated inference only accept hard evidence");
}
};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onBayesNetChanged(
const IBayesNet< GUM_SCALAR >* bn){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_updateOutdatedBNStructure(){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_updateOutdatedBNPotentials(){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onMarginalTargetAdded(const NodeId id){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onMarginalTargetErased(const NodeId id){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onAllMarginalTargetsAdded(){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onAllMarginalTargetsErased(){};
template < typename GUM_SCALAR >
void SamplingInference< GUM_SCALAR >::_onStateChanged() {
if (this->isInferenceReady()) {
__estimator.clear();
}
};
}
/***************************************************************************
* Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <agrum/BN/inference/weightedSampling.h>
template class gum::WeightedSampling<float>;
......
......@@ -110,7 +110,7 @@ namespace gum {
// ========================================================================
/// @{
ApproximationScheme( bool v = false );
ApproximationScheme(bool v = false);
virtual ~ApproximationScheme();
......@@ -129,13 +129,13 @@ namespace gum {
* @param eps The new epsilon value.
* @throw OutOfLowerBound Raised if eps < 0.
*/
void setEpsilon( double eps );
void setEpsilon(double eps);
/**
* @brief Returns the value of epsilon.
* @return Returns the value of epsilon.
*/
double epsilon( void ) const;
double epsilon(void) const;
/**
* @brief Disable stopping criterion on epsilon.
......@@ -164,13 +164,13 @@ namespace gum {
* @param rate The minimal epsilon rate.
* @throw OutOfLowerBound if rate<0
*/
void setMinEpsilonRate( double rate );
void setMinEpsilonRate(double rate);
/**
* @brief Returns the value of the minimal epsilon rate.
* @return Returns the value of the minimal epsilon rate.
*/
double minEpsilonRate( void ) const;
double minEpsilonRate(void) const;
/**
* @brief Disable stopping criterion on epsilon rate.
......@@ -198,13 +198,13 @@ namespace gum {
* @param max The maximum number of iterations.
* @throw OutOfLowerBound Raised if max <= 1.
*/
void setMaxIter( Size max );
void setMaxIter(Size max);
/**
* @brief Returns the criterion on number of iterations.
* @return Returns the criterion on number of iterations.
*/
Size maxIter( void ) const;
Size maxIter(void) const;
/**
* @brief Disable stopping criterion on max iterations.
......@@ -232,19 +232,19 @@ namespace gum {
* @param timeout The timeout value in seconds.
* @throw OutOfLowerBound Raised if timeout <= 0.0.
*/
void setMaxTime( double timeout );
void setMaxTime(double timeout);
/**
* @brief Returns the timeout (in seconds).
* @return Returns the timeout (in seconds).
*/
double maxTime( void ) const;
double maxTime(void) const;
/**
* @brief Returns the current running time in second.
* @return Returns the current running time in second.
*/
double currentTime( void ) const;
double currentTime(void) const;
/**
* @brief Disable stopping criterion on timeout.
......@@ -270,25 +270,25 @@ namespace gum {
* @param p The new period value.
* @throw OutOfLowerBound Raised if p < 1.
*/
void setPeriodSize( Size p );
void setPeriodSize(Size p);
/**
* @brief Returns the period size.
* @return Returns the period size.
*/
Size periodSize( void ) const;
Size periodSize(void) const;
/**
* @brief Set the verbosity on (true) or off (false).
* @param v If true, then verbosity is turned on.
*/
void setVerbosity( bool v );
void setVerbosity(bool v);
/**
* @brief Returns true if verbosity is enabled.
* @return Returns true if verbosity is enabled.
*/
bool verbosity( void ) const;
bool verbosity(void) const;
/**
* @brief Returns the approximation scheme state.
......@@ -309,7 +309,7 @@ namespace gum {
* @throw OperationNotAllowed Raised if the scheme did not performed or
* if verbosity is set to false.
*/
const std::vector<double>& history() const;
const std::vector< double >& history() const;
/**
* @brief Initialise the scheme.
......@@ -328,7 +328,7 @@ namespace gum {
* @brief Update the scheme w.r.t the new error and increment steps.
* @param incr The new increment steps.
*/
void updateApproximationScheme( unsigned int incr = 1 );
void updateApproximationScheme(unsigned int incr = 1);
/**
* @brief Returns the remaining burn in.
......@@ -351,7 +351,12 @@ namespace gum {
* @throw OperationNotAllowed Raised if state !=
* ApproximationSchemeSTATE::Continue.
*/
bool continueApproximationScheme( double error );
bool continueApproximationScheme(double error);
/**
* @brief reset the approximation scheme
*/
void reset();
/// @}
......@@ -360,7 +365,7 @@ namespace gum {
* @brief Stop the scheme given a new state.
* @param new_state The scheme new state.
*/
void _stopScheme( ApproximationSchemeSTATE new_state );
void _stopScheme(ApproximationSchemeSTATE new_state);
protected:
/// Current epsilon.
......@@ -382,7 +387,7 @@ namespace gum {
ApproximationSchemeSTATE _current_state;
/// The scheme history, used only if verbosity == true.
std::vector<double> _history;
std::vector< double > _history;
/// Threshold for convergence.
double _eps;
......
......@@ -30,6 +30,7 @@
* @author Pierre-Henri WUILLEMIN
*/
#include <agrum/config.h>
// To help IDE parser
#include <agrum/core/approximations/approximationScheme.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment