本文整理汇总了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;
}