Skip to content

Commit

Permalink
makeDistTree quality computation (no -noqual) uses threads
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrover committed Mar 23, 2021
1 parent c25b4a9 commit 1331f7d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 15 deletions.
67 changes: 56 additions & 11 deletions phylogeny/distTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8012,6 +8012,26 @@ Real DistTree::getUnoptimizable () const



namespace
{

void setErrorDensity_array (size_t from,
size_t to,
Notype /*&res*/,
const VectorPtr<DiGraph::Node> &nodeVec,
Real c)
{
FOR_START (size_t, i, from, to)
{
DTNode* dtNode = const_static_cast <DTNode*> (nodeVec [i]);
dtNode->setErrorDensity (c);
}
}

}



void DistTree::setErrorDensities ()
{
ASSERT (optimizable ());
Expand All @@ -8024,11 +8044,14 @@ void DistTree::setErrorDensities ()

const Real c = absCriterion / (Real) n;
ASSERT (c >= 0.0);
for (DiGraph::Node* node : nodes) // --> Threads ??
{
DTNode* dtNode = static_cast <DTNode*> (node);
dtNode->setErrorDensity (c);
}

VectorPtr<DiGraph::Node> nodeVec; nodeVec. reserve (nodes. size ());
for (DiGraph::Node* node : nodes)
nodeVec << node;
nodeVec. randomOrder ();

vector<Notype> notypes;
arrayThreads (false, setErrorDensity_array, nodeVec. size (), notypes, cref (nodeVec), c);
}


Expand Down Expand Up @@ -8068,25 +8091,47 @@ void DistTree::setLeafNormCriterion ()



void DistTree::setNodeMaxDeformationDissimNum ()
namespace
{
ASSERT (optimizable ());

for (DiGraph::Node* node : nodes) // --> Threads ??

void setNodeMaxDeformationDissimNum_array (size_t from,
size_t to,
Notype /*&res*/,
const VectorPtr<DiGraph::Node> &nodeVec,
const DistTree &tree)
{
FOR_START (size_t, i, from, to)
{
DTNode* dtNode = static_cast <DTNode*> (node);
DTNode* dtNode = const_static_cast <DTNode*> (nodeVec [i]);
dtNode->maxDeformationDissimNum = dissims_max;
Real target = 0.0;
for (const uint dissimNum : dtNode->pathDissimNums)
{
const Dissim& dissim = dissims [dissimNum];
const Dissim& dissim = tree. dissims [dissimNum];
if (dissim. validMult ())
if (maximize (target, dissim. getDeformation ()))
dtNode->maxDeformationDissimNum = dissimNum;
}
}
}

}



void DistTree::setNodeMaxDeformationDissimNum ()
{
ASSERT (optimizable ());

VectorPtr<DiGraph::Node> nodeVec; nodeVec. reserve (nodes. size ());
for (DiGraph::Node* node : nodes)
nodeVec << node;
nodeVec. randomOrder ();

vector<Notype> notypes;
arrayThreads (false, setNodeMaxDeformationDissimNum_array, nodeVec. size (), notypes, cref (nodeVec), cref (*this));
}



Real DistTree::getDeformation_mean () const
Expand Down
6 changes: 3 additions & 3 deletions phylogeny/distTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ struct DTNode : Tree::TreeNode
// Deterministic <=> (bool)seed
// Invokes: getDistTree().rand
// Time: O(log(n))
void setErrorDensity (Real absCriterion_ave);
// Output: errorDensity
// Time: O(|pathDissimNums|)
private:
void saveFeatureTree (ostream &os,
bool withTime,
Expand All @@ -506,9 +509,6 @@ struct DTNode : Tree::TreeNode
Vector<uint/*dissimNum*/> getLcaDissimNums ();
// Return: dissimNum's s.t. getDistTree().dissims[dissimNum].lca = this
// Invokes: DTNode::pathDissimNums.sort()
void setErrorDensity (Real absCriterion_ave);
// Output: errorDensity
// Time: O(|pathDissimNums|)
VectorPtr<Leaf> getSparseLeafMatches (const string &targetName,
size_t depth_max,
bool subtractDissims,
Expand Down
4 changes: 3 additions & 1 deletion version.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#define VERSION "1.5.6"
#define VERSION "1.5.8"


// 1.5.8 03/22/2021 makeDistTree: quality calculation uses threads
// 1.5.7 03/21/2021 FeatureTree::globalSingletonsSize bug
// 1.5.6 03/17/2021 feature tree: only-optional features are removed;
// Genome::coreNonSingletons does not include optionalCore[]
// oneFeatureInTree => Genome::coreSet has no optional nominal attributes
Expand Down

0 comments on commit 1331f7d

Please sign in to comment.