Esempio n. 1
0
Path::Ptr PathTree::addChildren(unsigned int children, 
    Path::Ptr curPath, Path::Ptr frontPath, PathItem pI) {
        if (children > 1){
            FWK_DEBUG("Conn::ExplorePathTree::processQueueFront()" <<
                    " adding new Path to queue");
            Path::Ptr newPath = curPath->cloneIs();
            newPath->costIs(Dollars(newPath->cost().value() +
                    segmentCost(pI.seg, newPath->expediteSupport())));
            newPath->timeIs(Hours(newPath->time().value() +
                    segmentTime(pI.seg, newPath->expediteSupport())));
            newPath->distanceIs(Miles(newPath->distance().value() +
                    pI.seg->length().value()));
            path_.push_back(newPath);
            queue_.push(path_.back());
        } else {
            FWK_DEBUG("Conn::ExplorePathTree::processQueueFront() " <<
                    "adding same Path to queue");
            frontPath->costIs(Dollars(frontPath->cost().value() +
                    segmentCost(pI.seg, frontPath->expediteSupport())));
            frontPath->timeIs(Hours(frontPath->time().value() +
                    segmentTime(pI.seg, frontPath->expediteSupport())));
            frontPath->distanceIs(Miles(frontPath->distance().value() +
                    pI.seg->length().value()));
            queue_.push(frontPath);
        }
        queue_.back()->nextPathItemIs(pI);
        return queue_.back();
};
Esempio n. 2
0
PathTree::Addable ExplorePathTree::isAddable(Path::Ptr p, PathItem pI) {
    Path::PathItemIterator it = p->pathItemIter();
    for (unsigned int i= 0 ; i < p->pathItems(); ++i, ++it){
        if (it->loc->name() == pI.loc->name()){
            FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
                    " returns false(locAlreadyExists_)");
            return locAlreadyExists_;
        }
    }
    if (!pI.seg){
        FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
                " returns true");
        return addable_;//root
    }
    if ((exploreData_.expedited() == Segment::fullExpediteSupport()) &&
        pI.seg->expediteSupport() == Segment::noExpediteSupport()){
            FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
                    " returns false(expeditedNotMatching_)");
            return expeditedNotMatching_;
    }
    if (p->cost() + segmentCost(pI.seg, p->expediteSupport()) >
            exploreData_.cost()){
        FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
                " returns false(moneyLimitReached_)");
        return moneyLimitReached_;
    }
    if (p->time() + segmentTime(pI.seg, p->expediteSupport()) >
            exploreData_.time()){
        FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
                " returns false(timeLimitReached_)");
        return timeLimitReached_;
    }
    if (p->distance() + pI.seg->length() > exploreData_.distance()) {
        FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
                " returns false(lengthMaxReached)");
        std::cout << p->distance().value() + pI.seg->length().value() <<
                std::endl;;
        return lengthMaxReached_;
    }
    FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() <<
            " returns true");
    return addable_;
};