本文整理汇总了C++中Arc::getHead方法的典型用法代码示例。如果您正苦于以下问题:C++ Arc::getHead方法的具体用法?C++ Arc::getHead怎么用?C++ Arc::getHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arc
的用法示例。
在下文中一共展示了Arc::getHead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createVarZ
int FacilityLocation::createVarZ()
{
int nVars = 0;
double coeff = 0.0;
double lb = 0.;
double ub = 1.;
VariableHash::iterator vit;
Variable::VARTYPE varType = Variable::V_Z;
Column::COLTYPE colType = choseColType(pType, lb, ub);
// @teste
//colType = Column::CONTINUOUS;
double bMinus = 0.;
double bPlus = 0.;
for (int i = 1; i <= g->nVertices; ++i)
{
bMinus += g->vertices[i].getIngree();
bPlus += g->vertices[i].getEgree();
}
(bMinus < bPlus) ? coeff = bMinus : coeff = bPlus;
// * Variable z_e:
// *
// * Used to indicate whether the edges e = (i, j) is used to connect the
// * two core vertex i \in I and j \in I
for (int i = 1; i <= g->nVertices; ++i)
{
Vertex* v = &(g->vertices[i]);
// @annotation: comment next filter to resolve instances where
// the vpn terminals may be considered internal nodes
// 20160125
if (v->isTerminal())
continue;
for (int j = 0; j < g->adjList[i].size(); ++j)
{
Vertex* u = &(g->adjList[i][j].getTail());
Arc* arc = &(g->adjList[i][j]);
// @annotation: comment next filter to resolve instances where
// the vpn terminals may be considered internal nodes
// 20160125
if (arc->getHead().isTerminal() || arc->getTail().isTerminal())
continue;
Variable var(colType, coeff, lb, ub);
var.setType(varType);
var.setArc(arc->toEdge());
vit = vHash[varType].find(var);
if (vit != vHash[varType].end())
continue;
bool isInserted = addCol(&var);
if (isInserted)
{
var.setColIdx(getNCols() - 1);
vHash[varType][var] = var.getColIdx();
++nVars;
}
}
}
return nVars;
}
示例2: builSolutionGraph
void FacilityLocation::builSolutionGraph()
{
if (s == NULL)
s = new Graph();
activeRouters = 0;
activeArcs = 0;
s->nVertices = g->nVertices;
s->nTerminals = g->nTerminals;
s->nArcs = g->nArcs;
s->reserve(g->nVertices + 1);
for (int i = 0; i < g->nTerminals; ++i)
{
Vertex terminal = g->terminals[i];
s->addTerminal(terminal);
s->addVertex(terminal);
}
for (auto& vit : vHash[Variable::V_Y])
{
int col = vit.second;
Variable var = vit.first;
Vertex v = var.getVertex1();
int code = v.getCode();
if (!v.isTerminal() && fabs(xSol[col] - 1.0) < SOLVER_EPS)
{
++activeRouters;
v.setColor("red");
s->vertices[code] = v;
}
}
printf("");
for (auto & vit : vHash[Variable::V_X])
{
Arc arc = vit.first.getArc();
int col = vit.second;
if (fabs(xSol[col] - 1.0) < SOLVER_EPS)
{
Vertex router = arc.getHead();
Vertex terminal = arc.getTail();
auto & element = g->arcSet[router.getCode()].find(arc);
if (element != g->arcSet[router.getCode()].end())
{
arc.setColor("red");
arc.setPenwidht(3.5);
s->addArc(arc);
}
else
{
std::vector<Arc> path;
findShortestPath(router, terminal, g, path);
for (int i = 0; i < path.size(); ++i)
{
Arc aux = path[i];
aux.setColor("red");
aux.setPenwidht(1.5);
s->addArc(aux);
s->vertices[aux.getHead().getCode()].setColor("red");
}
activeArcs += path.size();
printf("");
}
}
}
printf("");
for (auto& vit : vHash[Variable::V_Z])
{
Variable v = vit.first;
int col = vit.second;
Arc arc = v.getArc();
if (fabs(xSol[col] - 1.0) < SOLVER_EPS)
{
++activeArcs;
arc.setColor("red");
arc.setPenwidht(3.5);
}
else
{
arc.setColor("black");
arc.setStyle("dotted");
arc.setPenwidht(1.0);
}
s->addArc(arc);
}
printf("");
#ifdef DEBUG
//.........这里部分代码省略.........