예제 #1
0
void ConnectPathTree::processQueueFront() {
    Path::Ptr frontPath = queue_.front();
    if (frontPath->lastPathItem().loc->name() == end_->name()) return;
    FWK_DEBUG("Conn::ExplorePathTree::processQueueFront() with path: " << frontPath->lastPathItem().loc->name() );
    unsigned int children = 0;
    Location::PtrConst curLoc = frontPath->lastPathItem().loc;
    Location::OutSegmentIteratorConst it = curLoc->outSegmenterIterConst();
    Path::Ptr curPath = frontPath->cloneIs();
    for (unsigned int i = 0; i < curLoc->outSegments(); ++it, ++i){
        if (!segExists((*it)->name())) continue; 
        PathItem pI = pathItem(*it);
        if (isAddable(frontPath, pI) == addable_) {
            ++children;
            Path::Ptr newPath = addChildren(children, curPath, frontPath, pI);
            if (queue_.back()->lastPathItem().seg->expediteSupport() == Segment::noExpediteSupport() &&
                queue_.back()->expediteSupport() == Segment::fullExpediteSupport()) {
                queue_.back()->expediteSupportIs( Segment::noExpediteSupport());
            } 
            
            if (queue_.back()->expediteSupport() == Segment::fullExpediteSupport() &&
                queue_.back()->lastPathItem().loc->name() == end_->name()) {
                ++children;
                addChildren(children, curPath, frontPath, pI);
                queue_.back()->expediteSupportIs( Segment::noExpediteSupport());
                queue_.back()->costIs(Dollars(queue_.back()->cost().value() * (2.0/3.0)));
                queue_.back()->timeIs(Hours(queue_.back()->time().value()  * 1.3));
            }
        }
    }
};
예제 #2
0
Path::Ptr Path::cloneIs(){
    FWK_DEBUG("Conn::Path::cloneIs()");
    Path::Ptr clonedPath = new Path();
    clonedPath->traversedItems_ = traversedItems_;
    clonedPath->costIs(cost());
    clonedPath->timeIs(time());
    return clonedPath;
};
예제 #3
0
파일: Path.cpp 프로젝트: karlssonper/cs249a
PathTree::PathTree(Location::PtrConst _root, Conn * _owner) : owner_(_owner)
{
    FWK_DEBUG("Conn::PathTree::PathTree() with root: " << _root->name());
    PathItem pI;
    pI.loc = _root;
    Path::Ptr p = new Path();
    p->nextPathItemIs(pI);
    path_.push_back(p);
    queue_.push(path_.back());
};
예제 #4
0
PathTree::Addable ConnectPathTree::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_;
        }
    }
    FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() << " returns true");
    return addable_;
};
예제 #5
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_;
    }
    FWK_DEBUG("Conn::isAddable() with curLoc: " << pI.loc->name() << " returns true");
    return addable_;
};
예제 #6
0
void ExplorePathTree::processQueueFront() {
    Path::Ptr frontPath = queue_.front();
    FWK_DEBUG("Conn::ExplorePathTree::processQueueFront() with path: " << frontPath->lastPathItem().loc->name() );
    unsigned int children = 0;
    Location::PtrConst curLoc = frontPath->lastPathItem().loc;
    Location::OutSegmentIteratorConst it = curLoc->outSegmenterIterConst();
    Path::Ptr curPath = frontPath->cloneIs();
    for (unsigned int i = 0; i < curLoc->outSegments(); ++it, ++i){
        if (!segExists((*it)->name())) continue; 
        PathItem pI = pathItem(*it);
        if (isAddable(frontPath, pI) == addable_) {
            ++children;
            addChildren(children, curPath, frontPath, pI);
        }
    }
    if (children != 0 && curPath->pathItems() > 1){
        path_.push_back(curPath->cloneIs());//add current
    }
};
예제 #7
0
파일: Path.cpp 프로젝트: karlssonper/cs249a
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();
};