本文整理汇总了C++中Arc::isIncident方法的典型用法代码示例。如果您正苦于以下问题:C++ Arc::isIncident方法的具体用法?C++ Arc::isIncident怎么用?C++ Arc::isIncident使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arc
的用法示例。
在下文中一共展示了Arc::isIncident方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createConsEdgeActivation
int FacilityLocation::createConsEdgeActivation()
{
// TODO
// Implementação do corte a seguir: os vértices roteadores da árvore VPN não poderão ser
// folhas na solução. Isso implica que deverá existir pelo menos dois arcos com extremidada
// em cada vértice roteador:
//
// 2 y_i \leq \sum\limits_{e \in \delta(i)} z_e + \sum\limits_{p \in P} x_{ip}, \forall i \in I
int numCons = 0;
VariableHash::iterator vit;
Row::ROWSENSE sense = Row::LESS;
int maxnnz = vHash[Variable::V_X].size() + vHash[Variable::V_Z].size() + 1;
double rhs = 0.0;
int colVarX, colVarZ, colVarY;
for (auto & varY : vHash[Variable::V_Y])
{
int colVarY = varY.second;
Vertex vertex = varY.first.getVertex1();
Constraint c(maxnnz, sense, rhs);
c.setType(Constraint::C_EDGE_ACTIVATION);
c.setNode(vertex);
c.rowAddVar(colVarY, 2.0);
for (auto & varZ : vHash[Variable::V_Z])
{
colVarZ = varZ.second;
Arc arc = varZ.first.getArc();
//if (arc.getHead() == vertex.getCode() || arc.getTail() == vertex.getCode())
if (arc.isIncident(vertex))
{
c.rowAddVar(colVarZ, -1.0);
}
}
for (auto & varX : vHash[Variable::V_X])
{
colVarX = varX.second;
Arc arc = varX.first.getArc();
//if (arc.getHead() == vertex.getCode() || arc.getTail() == vertex.getCode())
if (arc.isIncident(vertex))
{
c.rowAddVar(colVarX, -1.0);
}
}
if (c.getRowNnz() > 0)
{
bool isInserted = addRow(&c);
if (isInserted)
{
c.setRowIdx(getNRows() - 1);
cHash[c] = c.getRowIdx();
numCons++;
}
}
}
return numCons;
}