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


C++ Flow::getQosCons方法代码示例

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


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

示例1: compute

//------------------------------------------------------------------------------
//  Path SamcraBeforeAlgorithm::compute(const Flow &flow)
//------------------------------------------------------------------------------
Path SamcraBeforeAlgorithm::compute(const Flow &flow)
{
    TRACE("SamcraBeforeAlgorithm::compute -->");

    Path result;
    Topology *topology = flow.getTopology();
    int number_of_nodes = topology->getNumNodes();
    int number_of_qos = topology->getNumQos();
	int min_k = 0; int k_used = 0; // used by samcra
	int* max = (int*) calloc(number_of_nodes + 1, sizeof(int));
	int** adj = (int**) allocMatrix(number_of_nodes + 1,
	                                number_of_nodes + 1, sizeof(int));

	double* flow_qos = (double*) calloc(number_of_qos + 1, sizeof(double));
	double*** datadj = (double***) calloc(number_of_qos + 1, sizeof(double**));
	for (int counter=1; counter <= number_of_qos; ++counter)
	{
		datadj[counter] = (double**) allocMatrix(number_of_nodes + 1,
		                  number_of_nodes + 1, sizeof(double));
		flow_qos[counter] = flow.getQosCons()[counter-1];
    }

	// filling adj and datadj, while pruning links with insuf. available cap.
    for (LinkListIterator iter = topology->getLinkIterator(); iter(); ++iter)
   {
        Link* link = *iter;
		if (link->getReservableCapacity() >= flow.getRequestedCapacity())
	    {
	        int source = link->getSource();
	        int destination = link->getDestination();
			adj[source + 1][++max[source + 1]] = destination + 1;
			for (int qos=1; qos <= number_of_qos; ++qos)
			{
				datadj[qos][source+1][max[source+1]] = link->getQoS(qos-1);
			} // end: for (qos
		} // end: if (link
    } // end: for (LinkListIterator

	// allocating memory for the path
	int path_length = 0;
	int* path = (int*) calloc(number_of_nodes + 1, sizeof(int));

	// invoking SAMCRA
    TRACE("SamcraBeforeAlgorithm::compute: Invoking SAMCRA");
#ifndef NO_TIMER
    Timer timer;
    timer.start();
#endif // NO_TIMER
    samcrapath( flow.getSource()+1, flow.getDestination()+1,
	            adj, max, datadj, number_of_qos, flow_qos,
	            number_of_nodes, path, &path_length, &min_k, &k_used);
    TRACE("SamcraBeforeAlgorithm::compute: End SAMCRA");


	// because function returns the path vector from the destination "d" to the
	// source "s" it is necessary to invert the array
	for (int counter=1; counter <= path_length; ++counter)
	{
	    result.push_front(path[counter]-1);
	}
#ifndef NO_TIMER
    const_cast<Flow&>(flow).setTime(timer.read());
#endif // NO_TIMER

	// freeing memory
	free(path);
	for (int counter = 1; counter <= number_of_qos; ++counter)
	{
		freeMatrix((void**) datadj[counter], number_of_nodes + 1);
	}
	free(datadj);
	free(flow_qos);
	freeMatrix((void**) adj, number_of_nodes + 1);
	free(max);

    TRACE("SamcraBeforeAlgorithm::compute <--");
    return result;
}
开发者ID:prashanthvarma,项目名称:DeSiNe,代码行数:81,代码来源:SamcraBeforeAlgorithm.cpp


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