本文整理汇总了C++中Monitor::getDagNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ Monitor::getDagNodes方法的具体用法?C++ Monitor::getDagNodes怎么用?C++ Monitor::getDagNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monitor
的用法示例。
在下文中一共展示了Monitor::getDagNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replaceDag
void HillClimber::replaceDag(const RbVector<Move> &mvs, const RbVector<Monitor> &mons)
{
moves.clear();
monitors.clear();
// we need to replace the DAG nodes of the monitors and moves
const std::vector<DagNode*>& modelNodes = model->getDagNodes();
for (RbConstIterator<Move> it = mvs.begin(); it != mvs.end(); ++it)
{
Move *theMove = it->clone();
std::vector<DagNode*> nodes = theMove->getDagNodes();
for (std::vector<DagNode*>::const_iterator j = nodes.begin(); j != nodes.end(); ++j)
{
RevBayesCore::DagNode *theNode = *j;
// error checking
if ( theNode->getName() == "" )
{
std::cerr << "The move has the following nodes:\n";
for (std::vector<DagNode*>::const_iterator k = nodes.begin(); k != nodes.end(); ++k)
{
std::cerr << (*k)->getName() << std::endl;
}
std::cerr << "The model has the following nodes:\n";
for (std::vector<DagNode*>::const_iterator k = modelNodes.begin(); k != modelNodes.end(); ++k)
{
std::cerr << (*k)->getName() << std::endl;
}
throw RbException( "Unable to connect move '" + theMove->getMoveName() + "' to DAG copy because variable name was lost");
}
DagNode* theNewNode = NULL;
for (std::vector<DagNode*>::const_iterator k = modelNodes.begin(); k != modelNodes.end(); ++k)
{
if ( (*k)->getName() == theNode->getName() )
{
theNewNode = *k;
break;
}
}
// error checking
if ( theNewNode == NULL )
{
throw RbException("Cannot find node with name '" + theNode->getName() + "' in the model but received a move working on it.");
}
// now swap the node
theMove->swapNode( *j, theNewNode );
}
moves.push_back( *theMove );
delete theMove;
}
for (RbConstIterator<Monitor> it = mons.begin(); it != mons.end(); ++it)
{
Monitor *theMonitor = it->clone();
std::vector<DagNode*> nodes = theMonitor->getDagNodes();
for (std::vector<DagNode*>::const_iterator j = nodes.begin(); j != nodes.end(); ++j)
{
RevBayesCore::DagNode *theNode = (*j);
// error checking
if ( theNode->getName() == "" )
{
throw RbException( "Unable to connect monitor to DAG copy because variable name was lost");
}
DagNode* theNewNode = NULL;
for (std::vector<DagNode*>::const_iterator k = modelNodes.begin(); k != modelNodes.end(); ++k)
{
if ( (*k)->getName() == theNode->getName() )
{
theNewNode = *k;
break;
}
}
// error checking
if ( theNewNode == NULL )
{
throw RbException("Cannot find node with name '" + theNode->getName() + "' in the model but received a monitor working on it.");
}
// now swap the node
theMonitor->swapNode( *j, theNewNode );
}
monitors.push_back( *theMonitor );
delete theMonitor;
}
}