本文整理汇总了C++中Arc::getScoreDelta方法的典型用法代码示例。如果您正苦于以下问题:C++ Arc::getScoreDelta方法的具体用法?C++ Arc::getScoreDelta怎么用?C++ Arc::getScoreDelta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arc
的用法示例。
在下文中一共展示了Arc::getScoreDelta方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertDisappearanceSwapArcs
void Magnusson::insertDisappearanceSwapArcs(Arc* a)
{
/*
When a disappearance swap arc is used while tracking,
it means the new track did end instead of another one,
and the other track continued the path that the new one now picks up.
*/
Node *source = a->getSourceNode();
Node *target = a->getTargetNode();
assert(target == &graph_->getSinkNode());
for(Node::ArcIt outIt = source->getOutArcsBegin(); outIt != source->getOutArcsEnd(); ++outIt)
{
Node *alternativeTarget = (*outIt)->getTargetNode();
assert(alternativeTarget != nullptr);
if(alternativeTarget == target || graph_->isSpecialNode(alternativeTarget) || (*outIt)->getType() == Arc::Swap)
continue;
typedef std::vector< std::tuple<Node*, Arc*, Arc*, double> > SwapCandidateVector;
SwapCandidateVector swapArcCandidates;
for(Node::ArcIt inIt = alternativeTarget->getInArcsBegin(); inIt != alternativeTarget->getInArcsEnd(); ++inIt)
{
Node *alternativeSource = (*inIt)->getSourceNode();
assert(alternativeSource != nullptr);
if(alternativeSource == source || graph_->isSpecialNode(alternativeSource) || (*inIt)->getType() == Arc::Swap)
continue;
// find diappearance arc of alternativeSource
Arc* alternativeDisappearanceArc = nullptr;
for(Node::ArcIt appIt = alternativeSource->getOutArcsBegin(); appIt != alternativeSource->getOutArcsEnd(); ++appIt)
{
if((*appIt)->getTargetNode() == &graph_->getSinkNode())
{
alternativeDisappearanceArc = *appIt;
break;
}
}
if(alternativeDisappearanceArc == nullptr)
throw std::runtime_error("alternative target did not have disappearance arc...");
// found a candidate
double score = alternativeDisappearanceArc->getScoreDelta() + (*outIt)->getScoreDelta() - a->getPreviousScoreDelta();
// save it for adding later (otherwise the iterator inIt is invalidated!)
swapArcCandidates.push_back(std::make_tuple(alternativeSource, *outIt, alternativeDisappearanceArc, score));
#ifdef DEBUG_LOG
std::stringstream debugString;
debugString << "!!! Adding Disappearance SWAP ARC between ";
if(alternativeSource->getUserData())
debugString << alternativeSource->getUserData();
else
debugString << alternativeSource;
debugString << " and ";
if(alternativeTarget->getUserData())
debugString << alternativeTarget->getUserData();
else
debugString << alternativeTarget;
debugString << " with score " << score;
DEBUG_MSG(debugString.str());
DEBUG_MSG("\twith replacement arcs: in=" << *outIt << " and out=" << alternativeDisappearanceArc);
DEBUG_MSG("\tdeletes arc: " << a);
#endif
}
for(SwapCandidateVector::iterator swapIt = swapArcCandidates.begin(); swapIt != swapArcCandidates.end(); ++swapIt)
{
Arc* alternativeDisappearanceArc;
Arc* originalInArc;
Node* alternativeSource;
double score;
std::tie(alternativeSource, originalInArc, alternativeDisappearanceArc, score) = *swapIt;
Arc* arc = new Arc(alternativeSource,
alternativeTarget,
Arc::Swap,
{score},
nullptr,
std::make_shared<MagnussonSwapArcUserData>(a, originalInArc, alternativeDisappearanceArc)
);
a->registerObserverArc(arc);
swapArcs_.push_back(arc);
}
}
}