60 template <
typename GRAPH_CHANGES_
SELECTOR >
62 selector.setGraph(dag);
64 unsigned int nb_changes_applied = 0;
65 Idx applied_change_with_positive_score = 0;
72 double best_score = 0;
73 double current_score = 0;
74 double delta_score = 0;
77 applied_change_with_positive_score = 0;
81 const auto& change = selector.bestChange();
82 delta_score = selector.deltaScore(change,
true);
84 if ((nb_changes_applied > 0) || (delta_score > 0)) {
85 if (delta_score > 0) {
86 ++applied_change_with_positive_score;
87 }
else if (current_score > best_score) {
88 best_score = current_score;
92 selector.applyChange(change);
93 current_score += delta_score;
100 if (applied_change_with_positive_score) {
102 nb_changes_applied = 0;
113 auto& res_dag = current_score > best_score ? dag : best_dag;
117 selector.finalizeGraph(res_dag);
123 template < GUM_Numeric GUM_SCALAR,
typename GRAPH_CHANGES_
SELECTOR,
typename PARAM_ESTIMATOR >
125 PARAM_ESTIMATOR& estimator,
A class that, given a structure and a parameter estimator returns a full Bayes net.
void updateApproximationScheme(unsigned int incr=1)
Update the scheme w.r.t the new error and increment steps.
bool continueApproximationScheme(double error)
Update the scheme w.r.t the new error.
void initApproximationScheme()
Initialise the scheme.
void stopApproximationScheme()
Stop the approximation scheme.
Exception : the element we looked for cannot be found.
static BayesNet< GUM_SCALAR > createBN(ParamEstimator &estimator, const DAG &dag)
create a BN from a DAG using a one pass generator (typically ML)
Size _MaxNbDecreasing_
the max number of changes decreasing the score that we allow to apply
BayesNet< GUM_SCALAR > learnBN(GRAPH_CHANGES_SELECTOR &selector, PARAM_ESTIMATOR &estimator, DAG initial_dag=DAG())
learns the structure and the parameters of a BN
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
the classes to account for structure changes in a graph
Size Idx
Type for indexes.
The local search learning with tabu list algorithm (for directed graphs).
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities