本文整理汇总了C++中StarLink::getFlow方法的典型用法代码示例。如果您正苦于以下问题:C++ StarLink::getFlow方法的具体用法?C++ StarLink::getFlow怎么用?C++ StarLink::getFlow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StarLink
的用法示例。
在下文中一共展示了StarLink::getFlow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkFeasibility
FPType Utils::checkFeasibility(StarNetwork *net, ODMatrix *mat){
std::vector<FPType> total(net->getNbNodes());
for (int i = 0; i < net->getNbNodes(); ++i) {
total[i] = 0.0;
}
// load demands
for (OriginIterator it = mat->begin(); it != mat->end(); ++it){
Origin* origin = *it;
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
PairOD* dest = *jt;
total[origin->getIndex()] += dest->getDemand();
total[dest->getIndex()] -= dest->getDemand();
}
}
//travers network and check
for (StarLink *link = net->beginOnlyLink(); link != NULL; link = net->getNextOnlyLink()) {
total[link->getNodeFromIndex()] -= link->getFlow();
total[link->getNodeToIndex()] += link->getFlow();
}
FPType maxVal = 0.0;
for (int i = 0; i < net->getNbNodes(); ++i) {
if (fabs(total[i]) > maxVal) maxVal = fabs(total[i]);
}
return maxVal;
};
示例2: calcFlowStep
FPType DAGraphBWithStep::calcFlowStep(Path* minPath, Path* maxPath) const{
int nbLinks = net_->getNbLinks();
std::vector<FPType> x(nbLinks);
std::vector<FPType> y(nbLinks);
std::vector<int> indexes(nbLinks);
for(StarLinkIterator it = maxPath->begin(); it != maxPath->end(); ++it){
y[(*it)->getIndex()] = 0.0;
}
for (StarLinkIterator it = minPath->begin(); it != minPath->end(); ++it) {
y[(*it)->getIndex()] = 0.0;
}
int linkIndex = -1;
int size = 0;
// projecting path direction onto links
FPType descDirection = minPath->getCurrCost() - maxPath->getCurrCost();
FPType oFlow = 0.0;
FPType maxPathFlow = std::numeric_limits<FPType>::infinity( );
for(StarLinkIterator it = maxPath->begin(); it != maxPath->end(); ++it){
StarLink* link = *it;
linkIndex = link->getIndex();
x[linkIndex] = link->getFlow();
y[linkIndex] += descDirection;
indexes[size] = linkIndex;
++size;
oFlow = getOriginFlow(linkIndex);
if (oFlow < maxPathFlow) maxPathFlow = oFlow;
}
if (maxPathFlow == 0.0) {
return 0.0;
}
for (StarLinkIterator it = minPath->begin(); it != minPath->end(); ++it) {
StarLink* link = *it;
linkIndex = link->getIndex();
x[linkIndex] = link->getFlow();
y[linkIndex] -= descDirection;
indexes[size] = linkIndex;
++size;
}
(lineSearch_->getDerivative())->setDataPointers(size, x, y, indexes);
// calculating upper bound for line search
FPType ub = -maxPathFlow / descDirection;
assert(ub > 0.0);
return (lineSearch_->execute(0.0, ub) * -descDirection);
};
示例3: printMaxShPath
void DAGraph::printMaxShPath(int node){
StarLink *prevMax = (nodes_[node])->maxLink;
int prevNode = -1;
std::cout << "Cost = " << (nodes_[node])->maxDist << std::endl;
FPType cost = 0.0;
while (prevMax != NULL){
prevNode = prevMax->getNodeFromIndex();
cost += prevMax->getFlow() * prevMax->getTime();
std::cout << "[" << prevMax->getNodeToIndex() << ", " << prevNode << "] "
<< prevMax->getFlow() << " - ";
prevMax = (nodes_[prevNode])->maxLink;
}
std::cout << std::endl;
};
示例4: getFlowShift
FPType PASWithStep::getFlowShift() {
FPType x[nbLinks_];
FPType y[nbLinks_];
int indexes[nbLinks_];
int size = 0;
FPType dir[2];
dir[cheapSegm_] = expCost_ - cheapCost_;
dir[1 - cheapSegm_] = -dir[cheapSegm_];
StarLink* link = NULL;
int linkIndex = -1;
for (int i = 0; i < 2; ++i) {
for (std::list<StarLink*>::const_iterator it = segments_[i].begin();
it != segments_[i].end(); ++it) {
link = *it;
linkIndex = link->getIndex();
x[linkIndex] = link->getFlow();
y[linkIndex] = dir[i];
indexes[size] = linkIndex;
++size;
}
}
(lineSearch_->getDerivative())->setDataPointers(size, x, y, indexes);
return lineSearch_->execute(0.0, totalShift_ / dir[cheapSegm_]) * dir[cheapSegm_];
};
示例5: calculateDerivative
FPType DescDirectionPathISP::calculateDerivative(Path* path) const{
FPType der = 0.0;
FPType flow = 0.0;
for (StarLinkIterator it = path->begin(); it != path->end(); ++it) {
StarLink* link = *it;
flow = link->getFlow();
if (flow < slope_) {
flow = slope_;
}
der += link->getDerivative();
}
return der;
};
示例6: projectPathFlowOnLinks
void ODSet::projectPathFlowOnLinks(){
FPType flow = 0.0;
for (PathIterator pathIt = begin(); pathIt != end(); ++pathIt) {
Path* path = *pathIt;
flow = path->getFlow() - path->getPrevFlow();
if (fabs(flow) > zeroFlow_) {
for (StarLinkIterator it = path->begin(); it != path->end(); ++it) {
(*it)->addFlow(flow);
}
}
}
for (PathIterator pathIt = begin(); pathIt != end(); ++pathIt) {
Path* path = *pathIt;
for (StarLinkIterator it = path->begin(); it != path->end(); ++it) {
StarLink* link = *it;
if (link->getFlow() < zeroFlow_) {
link->setFlow(0.0);
}
link->updateTime();
}
}
};