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(); };
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)); } } } };
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 } };