diff --git a/include/barry/models/geese/counters.hpp b/include/barry/models/geese/counters.hpp index 0c97ec314..772eccaba 100644 --- a/include/barry/models/geese/counters.hpp +++ b/include/barry/models/geese/counters.hpp @@ -33,6 +33,9 @@ * * */ +#define PHYLO_RULE_LAMBDA(a) barry::Rule_fun_type a = \ + [](const PhyloArray & Array, size_t i, size_t j, PhyloRuleData & data) + #define PHYLO_COUNTER_LAMBDA(a) barry::Counter_fun_type a = \ [](const PhyloArray & Array, size_t i, size_t j, PhyloCounterData & data) @@ -2046,6 +2049,32 @@ inline void counter_pairwise_first_gain( * @param rules A pointer to a `PhyloRules` object (`Rules`<`PhyloArray`, `PhyloRuleData`>). */ ///@{ +inline void rule_leafs( + PhyloSupport * support +) { + + PHYLO_RULE_LAMBDA(tmp_rule) + { + if (Array.D().has_leaf) + { + return Array(i, j) != 9u; + } + + return true; + }; + + support->get_rules()->add_rule( + tmp_rule, + PhyloRuleData(), + "Fix annotated leafs", + "Reduces the support by fixing the cells of annotated leafs." + ); + + return; + +} + + /** * @brief Overall functional gains * @param support Support of a model. diff --git a/include/barry/models/geese/geese-bones.hpp b/include/barry/models/geese/geese-bones.hpp index f38104d1d..2cee3aefb 100644 --- a/include/barry/models/geese/geese-bones.hpp +++ b/include/barry/models/geese/geese-bones.hpp @@ -42,8 +42,12 @@ inline std::vector< double > keygen_full( std::vector< double > dat = { static_cast(array.nrow()) * 100000 + static_cast(array.ncol()), - 1000000.0, // state of the parent - array.D_ptr()->duplication ? 1.0 : 0.0 // type of the parent + // state of the parent + 1000000.0, + // type of the parent + array.D_ptr()->duplication ? 1.0 : 0.0, + // Annotations with zeros + 0.0 }; // State of the parent @@ -53,6 +57,13 @@ inline std::vector< double > keygen_full( pow10 *= 10.0; } + // // Annotations with zeros + // pow10 = 1.0; + // for (const auto & cell: array.get_data()) { + // dat[3u] += (cell == 9u ? 2.0 : static_cast(cell)) * pow10; + // pow10 *= 10.0; + // } + return dat; } @@ -116,7 +127,7 @@ class Geese { */ ///@{ std::mt19937 * rengine = nullptr; - PhyloModel * model = nullptr; + PhyloModel * model = nullptr; std::vector< std::vector< bool > > states; size_t n_zeros = 0u; ///< Number of zeros size_t n_ones = 0u; ///< Number of ones diff --git a/include/barry/models/geese/geese-meat.hpp b/include/barry/models/geese/geese-meat.hpp index bccde6180..5f36b43ca 100644 --- a/include/barry/models/geese/geese-meat.hpp +++ b/include/barry/models/geese/geese-meat.hpp @@ -141,6 +141,9 @@ inline void Geese::init(size_t bar_width) { this->model->store_psets(); + // // Adding static rule + // rule_leafs(model->get_support_fun()); + } // Checking rseed, this is relevant when dealing with a flock. In the case of diff --git a/include/barry/models/geese/geese-types.hpp b/include/barry/models/geese/geese-types.hpp index c3c6e8676..445b83f78 100644 --- a/include/barry/models/geese/geese-types.hpp +++ b/include/barry/models/geese/geese-types.hpp @@ -25,18 +25,17 @@ class NodeData { */ std::vector< bool > states = {}; - /** - * - */ - bool duplication = true; + bool duplication = true; ///< Whether the node is a duplication. + bool has_leaf = false; ///< Whether the node has a leaf as offspring. - // NodeData() : blengths(0u), states(0u) {}; NodeData( const std::vector< double > & blengths_, const std::vector< bool > & states_, - bool duplication_ = true - ) : blengths(blengths_), states(states_), duplication(duplication_) {}; + bool duplication_ = true, + bool has_leaf_ = false + ) : blengths(blengths_), states(states_), duplication(duplication_), + has_leaf(has_leaf_) {}; // ~NodeData() {}; diff --git a/tests/Makefile b/tests/Makefile index a8587e695..9d37cf358 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -50,3 +50,7 @@ main.cachegrind.out: main.o 10.o: 10-geese-predict.cpp $(CPP) $(CPPFLAGS) -O2 -g 10-geese-predict.cpp -o 10.o + +# Target depends on cpp file +%.o: %.cpp + $(CPP) $(CPPFLAGS) -O2 -g $< -o $@