Skip to content

Commit

Permalink
Adding temp rule
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Oct 5, 2023
1 parent f7d239d commit ba8e1a4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
29 changes: 29 additions & 0 deletions include/barry/models/geese/counters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
*
*
*/
#define PHYLO_RULE_LAMBDA(a) barry::Rule_fun_type<PhyloArray, PhyloRuleData> a = \
[](const PhyloArray & Array, size_t i, size_t j, PhyloRuleData & data)

#define PHYLO_COUNTER_LAMBDA(a) barry::Counter_fun_type<PhyloArray, PhyloCounterData> a = \
[](const PhyloArray & Array, size_t i, size_t j, PhyloCounterData & data)

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 14 additions & 3 deletions include/barry/models/geese/geese-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ inline std::vector< double > keygen_full(
std::vector< double > dat = {
static_cast<double>(array.nrow()) * 100000 +
static_cast<double>(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
Expand All @@ -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<double>(cell)) * pow10;
// pow10 *= 10.0;
// }

return dat;

}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions include/barry/models/geese/geese-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions include/barry/models/geese/geese-types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};

Expand Down
4 changes: 4 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@

0 comments on commit ba8e1a4

Please sign in to comment.