28 #ifndef GUM_LEARNING_GRAPH_CHANGES_SELECTOR_4_DIGRAPH_H 29 #define GUM_LEARNING_GRAPH_CHANGES_SELECTOR_4_DIGRAPH_H 33 #include <agrum/agrum.h> 34 #include <agrum/tools/core/priorityQueue.h> 35 #include <agrum/tools/core/sequence.h> 36 #include <agrum/tools/core/set.h> 37 #include <agrum/tools/graphs/diGraph.h> 38 #include <agrum/BN/learning/scores_and_tests/score.h> 39 #include <agrum/BN/learning/structureUtils/graphChange.h> 50 template <
typename STRUCTURAL_CONSTRAINT,
51 typename GRAPH_CHANGES_GENERATOR,
52 template <
typename >
class ALLOC = std::allocator >
56 using GeneratorType = GRAPH_CHANGES_GENERATOR;
65 STRUCTURAL_CONSTRAINT& constraint,
66 GRAPH_CHANGES_GENERATOR& changes_generator);
70 const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT,
71 GRAPH_CHANGES_GENERATOR,
76 GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT,
77 GRAPH_CHANGES_GENERATOR,
122 bool empty(
const NodeId i);
236 const NodeId target_node);
239 void updateScores__(
const Set< std::size_t >& changes_to_recompute);
250 #include <agrum/BN/learning/structureUtils/graphChangesSelector4DiGraph_tpl.h> bool isChangeValid__(const std::size_t index) const
indicates whether a given change is valid or not
bool empty()
indicates whether the selector still contains graph changes
GeneratorType & graphChangeGenerator() const noexcept
returns the generator used by the selector
INLINE void emplace(Args &&... args)
NodeProperty< std::vector< NodeId, ALLOC< NodeId > > > parents__
the set of parents of each node (speeds-up score computations)
void updateScores__(const Set< std::size_t > &changes_to_recompute)
perform the necessary updates of the scores
Set< NodeId > queues_to_update__
the set of queues to update when applying several changes
GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > & operator=(const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &from)
copy operator
const GraphChange & bestChange()
returns the best graph change to examine
void applyChange(const GraphChange &change)
indicate to the selector that a change has been applied
void illegal2LegalChanges__(Set< std::size_t > &changes_to_recompute)
remove the now legal changes from the illegal set
void findLegalChangesNeedingUpdate__(Set< std::size_t > &changes_to_recompute, const NodeId target_node)
finds the changes that are affected by a given node modification
~GraphChangesSelector4DiGraph()
destructor
Set< std::size_t > illegal_changes__
the set of changes known to be currently illegal (due to the constraints)
void getNewChanges__()
get from the graph change generator a new set of changes
GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > & operator=(GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &&from)
move operator
void applyChangeWithoutScoreUpdate(const GraphChange &change)
indicate to the selector that one of serveral changes has been applied
bool queues_valid__
indicates whether we need to recompute whether the queue is empty or not
STRUCTURAL_CONSTRAINT * constraint__
the set of constraints used to determine valid changes
const GraphChange & bestChange(const NodeId i)
returns the best graph change to examine related to the ith node
Score< ALLOC > * score__
the scoring function
GRAPH_CHANGES_GENERATOR * changes_generator__
the generator that returns the set of possible changes
NodeProperty< double > node_current_scores__
the current score of each node
double bestScore()
return the score of the best graph change
bool empty(const NodeId i)
indicates whether the selector contains graph changes related to the ith node
GraphChangesSelector4DiGraph(GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &&from)
move constructor
GraphChangesSelector4DiGraph(Score< ALLOC > &score, STRUCTURAL_CONSTRAINT &constraint, GRAPH_CHANGES_GENERATOR &changes_generator)
default constructor
void updateScoresAfterAppliedChanges()
recompute all the scores after the application of several changes
std::vector< std::pair< NodeId, double > > nodesUnsortedWithScore() const
returns the set of queues top priorities
std::vector< std::pair< double, double > > change_scores__
the scores for the head and tail of all the changes
std::vector< std::pair< NodeId, double > > nodesSortedByBestScore() const
returns the set of queues sorted by decreasing top priority
void setGraph(DiGraph &graph)
sets the graph from which scores are computed
Sequence< GraphChange > changes__
a sequence containing all the possible changes
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
void invalidateChange__(const std::size_t change_index)
put a change into the illegal set
GraphChangesSelector4DiGraph(const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &from)
copy constructor
double bestScore(const NodeId i)
return the score of the best graph change related to the ith node
bool isChangeValid(const GraphChange &change) const
indicates whether a given change is valid or not