本文整理汇总了C++中DagNode::touch方法的典型用法代码示例。如果您正苦于以下问题:C++ DagNode::touch方法的具体用法?C++ DagNode::touch怎么用?C++ DagNode::touch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DagNode
的用法示例。
在下文中一共展示了DagNode::touch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeSampler
void HillClimber::initializeSampler( void )
{
std::vector<DagNode *>& dagNodes = model->getDagNodes();
std::vector<DagNode *> orderedStochNodes = model->getOrderedStochasticNodes( );
// Get rid of previous move schedule, if any
if ( schedule )
{
delete schedule;
}
schedule = NULL;
// Get initial lnProbability of model
// first we touch all nodes so that the likelihood is dirty
for (std::vector<DagNode *>::iterator i=dagNodes.begin(); i!=dagNodes.end(); i++)
{
DagNode *the_node = *i;
the_node->setMcmcMode( true );
the_node->setPriorOnly( false );
the_node->touch();
}
int numTries = 0;
int maxNumTries = 100;
double lnProbability = 0.0;
for ( ; numTries < maxNumTries; numTries ++ )
{
// a flag if we failed to find a valid starting value
bool failed = false;
lnProbability = 0.0;
for (std::vector<DagNode *>::iterator i=dagNodes.begin(); i!=dagNodes.end(); i++)
{
DagNode* node = (*i);
node->touch();
double lnProb = node->getLnProbability();
if ( !RbMath::isAComputableNumber(lnProb) )
{
std::stringstream ss;
ss << "Could not compute lnProb for node " << node->getName() << "." << std::endl;
node->printValue( ss );
ss << std::endl;
RBOUT( ss.str() );
// set the flag
failed = true;
break;
}
lnProbability += lnProb;
}
// now we keep all nodes so that the likelihood is stored
for (std::vector<DagNode *>::iterator i=dagNodes.begin(); i!=dagNodes.end(); i++)
{
(*i)->keep();
}
if ( failed == true )
{
std::cout << "Drawing new initial states ... " << std::endl;
for (std::vector<DagNode *>::iterator i=orderedStochNodes.begin(); i!=orderedStochNodes.end(); i++)
{
if ( !(*i)->isClamped() && (*i)->isStochastic() )
{
(*i)->redraw();
(*i)->reInitialized();
}
else if ( (*i)->isClamped() )
{
// make sure that the clamped node also recompute their probabilities
(*i)->reInitialized();
(*i)->touch();
}
}
}
else
{
break;
}
}
if ( numTries == maxNumTries )
{
std::stringstream msg;
msg << "Unable to find a starting state with computable probability";
if ( numTries > 1 )
{
//.........这里部分代码省略.........