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


C++ StarLink类代码示例

本文整理汇总了C++中StarLink的典型用法代码示例。如果您正苦于以下问题:C++ StarLink类的具体用法?C++ StarLink怎么用?C++ StarLink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StarLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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_];

};
开发者ID:jingzbu,项目名称:TAsK,代码行数:26,代码来源:PASWithStep.cpp

示例2: preVisit

bool DAGraph::explore(int vertex, bool *visited){
	
	visited[vertex] = true;
	preVisit(vertex);
	std::list<StarLink*> &linksList = (nodes_[vertex])->outLinks;
	int index = -1;
	bool backEdgeDetected = false;
	StarLink* link = NULL;
	for(std::list<StarLink*>::iterator it = linksList.begin(); it != linksList.end(); ++it){
		link = *it;
		index = link->getNodeToIndex();
		if (checkPositiveFlow(link->getIndex())) {
			handleExploredLink(link);
			if ((nodes_[index])->pre == 0) {
				backEdgeDetected = explore(index, visited);
				if (backEdgeDetected) return true;
			}
			if ((nodes_[index])->pre > 0 && (nodes_[index])->post == 0) {
				return handleBackEdge(link);
			}
		} 
	}
	postVisit(vertex);
	return false;
};
开发者ID:jingzbu,项目名称:TAsK,代码行数:25,代码来源:DAGraph.cpp

示例3: indexes

void Utils::getCommonLinks(PathBasedFlowMove *paths, std::list<StarLink*> &list, int nbLinks){
	std::vector<int> indexes(nbLinks);
	std::vector<int> indexesTmp(nbLinks);
	std::vector<StarLink*> links(nbLinks);
	int size = 0;
	for (int i = 0; i < nbLinks; ++i) {
		indexes[i] = 0;
		indexesTmp[i] = 0;
		links[i] = NULL;
	}
	int index = -1;
	Path *path = NULL;
	int nbPaths = 0;
	for (PathAndDirection *pathDir = paths->beginPathDirection(); pathDir != NULL; 
			pathDir = paths->getNextPathDirection()) {
		path = pathDir->getPath();
		++nbPaths;
		for(StarLinkIterator it = path->begin(); it != path->end(); ++it){
			StarLink* link = *it;
			index = link->getIndex();
			if (indexes[index] == 0) {
				indexesTmp[size] = index;
				++size;
				links[index] = link;
			}
			++indexes[index];
		}
	}
	for (int i = 0; i < size; ++i) {
		index = indexesTmp[i];
		if (indexes[index] == nbPaths) {
			list.push_back(links[index]);
		}
	}
};
开发者ID:josmartin,项目名称:TAsK,代码行数:35,代码来源:Utils.cpp

示例4: total

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;
};
开发者ID:josmartin,项目名称:TAsK,代码行数:26,代码来源:Utils.cpp

示例5: findLinkIndex

int findLinkIndex(int tail, int head, StarNetwork* net, int guessIndex){
	StarLink* link = net->getLink(guessIndex);
	assert(link != NULL);
	if (link->getNodeFrom() == tail && link->getNodeTo() == head) {
		return link->getIndex();
	}
	return -1;
};
开发者ID:josmartin,项目名称:TAsK,代码行数:8,代码来源:TollsManagement.cpp

示例6: calculatePathDerivativeForDisjoint

FPType Utils::calculatePathDerivativeForDisjoint(const std::list<StarLink*> &list){
	StarLink* link = NULL;
	FPType der = 0.0;
	for (std::list<StarLink*>::const_iterator it = list.begin(); it != list.end(); ++it) {
		link = *it;
		der += link->getDerivative();
	}
	return der;
};
开发者ID:josmartin,项目名称:TAsK,代码行数:9,代码来源:Utils.cpp

示例7: assert

FPType NonAdditivePC::calculate(Path *path, int odIndex) const{
	assert(path != NULL && odIndex >=0);
	TollType totalToll = 0;
	FPType totalTime = 0.0;
	for (StarLinkIterator it = path->begin(); it != path->end(); ++it) {
		StarLink* link = *it;
		totalTime += link->getTime();
		totalToll += tolls_[link->getIndex()];
	}
	return calculate(totalTime, totalToll, odIndex);
};
开发者ID:josmartin,项目名称:TAsK,代码行数:11,代码来源:NonAdditivePC.cpp

示例8: assignRndTolls

void assignRndTolls(ShortestPath* shPath, int destIndex, TollContainerType& tolls, 
		FPType probabylity, TollType maxToll){
	StarLink *link = shPath->getInComeLink(destIndex);
	int nextDest = link->getNodeFromIndex();
	int linkIndex = -1;
	while (link != NULL) {
		linkIndex = link->getIndex();
		tolls[linkIndex] = getRndNumberWithProbability(tolls[linkIndex], probabylity, maxToll);
		nextDest = link->getNodeFromIndex();
		link = shPath->getInComeLink(nextDest);
	}
};
开发者ID:josmartin,项目名称:TAsK,代码行数:12,代码来源:TollsManagement.cpp

示例9: 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;
};
开发者ID:josmartin,项目名称:TAsK,代码行数:13,代码来源:DescDirectionPathISP.cpp

示例10: printShPath

void DAGraph::printShPath(int node){
	StarLink *prevMin = (nodes_[node])->minLink;
	int prevNode = -1; 
	std::cout << "Cost = " << (nodes_[node])->minDist << std::endl;
	FPType cost = 0.0;
	while (prevMin != NULL){
		prevNode = prevMin->getNodeFromIndex();
		cost += prevMin->getTime();
		std::cout << "[" << prevMin->getNodeToIndex() << ", " << prevNode << "] " 
				<< prevMin->getFlow() << "-";
		prevMin = (nodes_[prevNode])->minLink;
	}
	std::cout << std::endl;
};
开发者ID:jingzbu,项目名称:TAsK,代码行数:14,代码来源:DAGraph.cpp

示例11: xCoord

void KMLNetOutput::createKML(const std::string& fileWithNodes, const std::string& kmlFileName){

	std::cout << "KML will be written to: " << kmlFileName << std::endl;
	int nbNodes = net_->getNbNodes();
	std::vector<FPType> xCoord(nbNodes, 0);
	std::vector<FPType> yCoord(nbNodes, 0);
	std::vector<int> nodeID(nbNodes, 0);
	
	readCoord(fileWithNodes, xCoord, yCoord, nodeID);

	FileWriter writeKml(kmlFileName);
	writeKml.writeLine(createKmlHeader());
	
	for (StarLink* link = net_->beginOnlyLink(); link != NULL; link = net_->getNextOnlyLink()) {
		if (shouldCreatePlacemark(link)) {
			int tail = link->getNodeFromIndex();
			int head = link->getNodeToIndex();
			FPType x1 = xCoord[tail];
			FPType y1 = yCoord[tail];
			FPType x2 = xCoord[head];
			FPType y2 = yCoord[head];
			if (x1 == 0 && y1 == 0) std::cout << "Missing node coordinate: " << link->getNodeFrom() << 
								" link: " << link->toString() << std::endl; 
			if (x2 == 0 && y2 == 0) std::cout << "Missing node coordinate: " << link->getNodeTo() << 
								" link: " << link->toString() << std::endl;
			if (x1 != 0 && y1 != 0 && x2 != 0 && y2 != 0) 
				writeKml.writeLine(createPlacemark(x1, y1, x2, y2, link)); 
		}
	}

	writeKml.writeLine(createKmlFooter());
};
开发者ID:josmartin,项目名称:TAsK,代码行数:32,代码来源:KMLNetOutput.cpp

示例12: getInLinks

FPType DAGraph::checkOFlowsFeasibility(){
	int nbNodes = net_->getNbNodes(); 
	FPType total[nbNodes];
	for (int i = 0; i < nbNodes; ++i) {
		total[i] = 0.0;
	}
	// load demands
	for (OriginIterator it = mat_->begin(); it != mat_->end(); ++it){
		Origin* origin = *it;
		if (origin->getIndex() == originIndex_){
			for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
				PairOD* dest = *jt;
				FPType demand = dest->getDemand();
				total[origin->getIndex()] += demand;
				total[dest->getIndex()] -= demand;
			}
			break;
		}
	}
	//travers network and check
	
	int i = -1;
	StarLink* link = NULL;
	std::list<StarLink*> inLinks;
	for (int j = 0; j < nodeSize_; ++j) {
    	i = nodeIndexes_[j];
    	getInLinks(i, inLinks);
    	for (std::list<StarLink*>::iterator it = inLinks.begin(); it != inLinks.end(); ++it){
      		link = *it;
			total[link->getNodeFromIndex()] -= getOriginFlow(link->getIndex());
			total[link->getNodeToIndex()] += getOriginFlow(link->getIndex());
		}
	
	}
	
	FPType max = 0.0;
		
	for (int i = 0; i < net_->getNbNodes(); ++i) {
		if (fabs(total[i]) > max) {	
			max = fabs(total[i]);
		}
	}
	return max;
};
开发者ID:jingzbu,项目名称:TAsK,代码行数:44,代码来源:DAGraph.cpp

示例13: Path

bool ODSet::improveSet(){
	shPath_->calculate(originIndex_, destIndex_, index_);
	FPType minDist = shPath_->getCost(destIndex_);
	if (minDist - minDist_ < -zeroFlow_) { // if we add link costs in different order path 
											// costs might not be the same
		Path *path = new Path();
		path->setCurrCost(minDist);
		StarLink *link = shPath_->getInComeLink(destIndex_);
		int nextDest = link->getNodeFromIndex();
		while (link != NULL) {
			path->addLinkToPath(link);
			nextDest = link->getNodeFromIndex();
			link = shPath_->getInComeLink(nextDest);
		}
		addPath(path);
		return true;
	}
	return false;
};
开发者ID:pedrocamargo,项目名称:TAsK,代码行数:19,代码来源:ODSet.cpp

示例14: beginAscPass

void DAGraph::buildMinMaxTrees(int destIndex){
	int index = -1;

	for (int i = 0; i < nodeSize_; ++i) {
		index = nodeIndexes_[i];
		nodes_[index]->minDist = std::numeric_limits<FPType>::infinity( );
		nodes_[index]->maxDist = 0.0;
	}
	nodes_[originIndex_]->minDist = 0.0; // set to zero for origin 
	
	// find shortest and longest paths with positive flow
	FPType dist = 0.0;
	FPType time = 0.0;
	int i = beginAscPass();
	
	assert(originIndex_ == i); //-- TODO: theoretically there might be 
					// an alternative top order that starts with another node -- 
					// not clear what to do in this case
	StarLink* link = NULL;
	for (; i != -1; i = getNextAscPass()) {
		std::list<StarLink*> &linksList = nodes_[i]->incomeLinks;
		for (std::list<StarLink*>::iterator it = linksList.begin(); it != linksList.end(); ++it) {
			link = *it;
			index = link->getNodeFromIndex();
			assert(nodes_[index] != NULL);
			time = link->getTime();
			dist = nodes_[index]->minDist + time; // min dist
			if (dist < nodes_[i]->minDist) {
				nodes_[i]->minDist = dist;
				nodes_[i]->minLink = link; 
			}
			dist = nodes_[index]->maxDist + time; // max dist
			if (dist >= nodes_[i]->maxDist) {
				nodes_[i]->maxDist = dist;
				nodes_[i]->maxLink = link; 
			}
		}
		
		if (i == destIndex) break;
	}
};
开发者ID:jingzbu,项目名称:TAsK,代码行数:41,代码来源:DAGraph.cpp

示例15: 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();
		}
	}

};
开发者ID:pedrocamargo,项目名称:TAsK,代码行数:24,代码来源:ODSet.cpp


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