当前位置: 首页>>代码示例>>C++>>正文


C++ Arc::getScoreDelta方法代码示例

本文整理汇总了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);
        }
    }
}
开发者ID:chaubold,项目名称:dpct,代码行数:90,代码来源:magnusson.cpp


注:本文中的Arc::getScoreDelta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。