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


C++ Network::SumAllExitPr方法代码示例

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


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

示例1: stochastic_greedy_partition

/*
 * Procedure will be following:
 *	1) in random sequential order, each node is moved to its neighbor module that results in the largest gain of the map eq.
 *	   If no move results in a gain of the map equation, the node stays in its original module.
 *	2) repeated 1) procedure, each time in a new random sequential order, until no move generates a gain of the map EQ.
 *
 *	The 1) procedure is implemented in Network::move() function.
 */
void stochastic_greedy_partition(Network &network, int numTh, double threshold, double vThresh, int maxIter, bool prior, bool fineTune, bool fast) {

	double oldCodeLength = network.CodeLength();
	int iter = 0;
	bool stop = false;

	struct timeval outer_T1, outer_T2;
	struct timeval inner_T1, inner_T2;
	struct timeval seq_T1, seq_T2;
	struct timeval convert_T1, convert_T2;

	double tSequential = 0.0;

	gettimeofday(&outer_T1, NULL);

	int nActiveUnits = (fineTune) ? network.NNode() : network.superNodes.size();
	cout << nActiveUnits << ", ";


	// set initial active nodes list ...
	vector<char>(nActiveUnits).swap(network.isActives);
	vector<int>(nActiveUnits).swap(network.activeNodes);
	for (int i = 0; i < nActiveUnits; i++) {
		network.activeNodes[i] = i;
		network.isActives[i] = 0;	// initially set inactive nodes.
	}


	int numMoved = 0;

	while (!stop && iter < maxIter) {
		gettimeofday(&inner_T1, NULL);

		oldCodeLength = network.CodeLength();

		if (fineTune) {
			if (numTh == 1) {
				if (prior)
					numMoved = network.prioritize_move(vThresh);
				else
					numMoved = network.move();
			}
			else { 
				if (prior)
					numMoved = network.prioritize_parallelMove(numTh, tSequential, vThresh);
				else
					numMoved = network.parallelMove(numTh, tSequential);
			}
		} 
		else {
			if (numTh == 1) {
				if (prior)
					numMoved = network.prioritize_moveSPnodes(vThresh);
				else 
					numMoved = network.moveSuperNodes();		// If at least one node is moved, return true. Otherwise, return false.
			}
			else {
				if (prior) 
					numMoved = network.prioritize_parallelMoveSPnodes(numTh, tSequential, vThresh);
				else
					numMoved = network.parallelMoveSuperNodes(numTh, tSequential);
			}
		}
		iter++;

		if (oldCodeLength - network.CodeLength() >= 0 && (oldCodeLength - network.CodeLength())/log(2.0) < threshold)
			stop = true;	//moved = false;

		gettimeofday(&inner_T2, NULL);

		// Print code length per iteration for DEBUG purpose.
		cout << "Iteration " << iter << ": code length =\t" << network.CodeLength()/log(2.0) << "\t, ";
		cout << "elapsed time:\t" << elapsedTimeInSec(inner_T1, inner_T2) << "\t(sec), ";
		cout << "accumulated time:\t" << elapsedTimeInSec(outer_T1, inner_T2) << "\t(sec)\t";
		cout << "sumExitPr = " << network.SumAllExitPr() << "\t";
		cout << "numMoved:\t" << numMoved << endl;
	}

	gettimeofday(&seq_T1, NULL);

	int outerLoop = 1;

	network.updateMembersInModule();
	
	gettimeofday(&seq_T2, NULL);
	tSequential += elapsedTimeInSec(seq_T1, seq_T2);

	if (fast)
		return;

	double tConvert = 0.0;

//.........这里部分代码省略.........
开发者ID:uwescience,项目名称:RelaxMap,代码行数:101,代码来源:OmpRelaxmap.cpp


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