本文整理汇总了C++中sp::InteractionsGraph::out_edges方法的典型用法代码示例。如果您正苦于以下问题:C++ InteractionsGraph::out_edges方法的具体用法?C++ InteractionsGraph::out_edges怎么用?C++ InteractionsGraph::out_edges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp::InteractionsGraph
的用法示例。
在下文中一共展示了InteractionsGraph::out_edges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeDiagonalInteractionBlock
void LinearOSNS::computeDiagonalInteractionBlock(const InteractionsGraph::VDescriptor& vd)
{
DEBUG_BEGIN("LinearOSNS::computeDiagonalInteractionBlock(const InteractionsGraph::VDescriptor& vd)\n");
// Computes matrix _interactionBlocks[inter1][inter1] (and allocates memory if
// necessary) one or two DS are concerned by inter1 . How
// _interactionBlocks are computed depends explicitely on the type of
// Relation of each Interaction.
// Warning: we suppose that at this point, all non linear
// operators (G for lagrangian relation for example) have been
// computed through plug-in mechanism.
// Get dimension of the NonSmoothLaw (ie dim of the interactionBlock)
SP::InteractionsGraph indexSet = simulation()->indexSet(indexSetLevel());
SP::Interaction inter = indexSet->bundle(vd);
// Get osi property from interaction
// We assume that all ds in vertex_inter have the same osi.
SP::OneStepIntegrator Osi = indexSet->properties(vd).osi;
//SP::OneStepIntegrator Osi = simulation()->integratorOfDS(ds);
OSI::TYPES osiType = Osi->getType();
// At most 2 DS are linked by an Interaction
SP::DynamicalSystem DS1;
SP::DynamicalSystem DS2;
unsigned int pos1, pos2;
// --- Get the dynamical system(s) (edge(s)) connected to the current interaction (vertex) ---
if (indexSet->properties(vd).source != indexSet->properties(vd).target)
{
DEBUG_PRINT("a two DS Interaction\n");
DS1 = indexSet->properties(vd).source;
DS2 = indexSet->properties(vd).target;
}
else
{
DEBUG_PRINT("a single DS Interaction\n");
DS1 = indexSet->properties(vd).source;
DS2 = DS1;
// \warning this looks like some debug code, but it gets executed even with NDEBUG.
// may be compiler does something smarter, but still it should be rewritten. --xhub
InteractionsGraph::OEIterator oei, oeiend;
for (std11::tie(oei, oeiend) = indexSet->out_edges(vd);
oei != oeiend; ++oei)
{
// note : at most 4 edges
DS2 = indexSet->bundle(*oei);
if (DS2 != DS1)
{
assert(false);
break;
}
}
}
assert(DS1);
assert(DS2);
pos1 = indexSet->properties(vd).source_pos;
pos2 = indexSet->properties(vd).target_pos;
// --- Check block size ---
assert(indexSet->properties(vd).block->size(0) == inter->nonSmoothLaw()->size());
assert(indexSet->properties(vd).block->size(1) == inter->nonSmoothLaw()->size());
// --- Compute diagonal block ---
// Block to be set in OSNS Matrix, corresponding to
// the current interaction
SP::SiconosMatrix currentInteractionBlock = indexSet->properties(vd).block;
SP::SiconosMatrix leftInteractionBlock, rightInteractionBlock;
RELATION::TYPES relationType;
double h = simulation()->currentTimeStep();
// General form of the interactionBlock is : interactionBlock =
// a*extraInteractionBlock + b * leftInteractionBlock * centralInteractionBlocks
// * rightInteractionBlock a and b are scalars, centralInteractionBlocks a
// matrix depending on the integrator (and on the DS), the
// simulation type ... left, right and extra depend on the relation
// type and the non smooth law.
relationType = inter->relation()->getType();
VectorOfSMatrices& workMInter = *indexSet->properties(vd).workMatrices;
inter->getExtraInteractionBlock(currentInteractionBlock, workMInter);
unsigned int nslawSize = inter->nonSmoothLaw()->size();
// loop over the DS connected to the interaction.
bool endl = false;
unsigned int pos = pos1;
for (SP::DynamicalSystem ds = DS1; !endl; ds = DS2)
{
assert(ds == DS1 || ds == DS2);
endl = (ds == DS2);
unsigned int sizeDS = ds->dimension();
// get _interactionBlocks corresponding to the current DS
// These _interactionBlocks depends on the relation type.
leftInteractionBlock.reset(new SimpleMatrix(nslawSize, sizeDS));
inter->getLeftInteractionBlockForDS(pos, leftInteractionBlock, workMInter);
DEBUG_EXPR(leftInteractionBlock->display(););
// Computing depends on relation type -> move this in Interaction method?
if (relationType == FirstOrder)
{
//.........这里部分代码省略.........
示例2: updateInteractionBlocks
//.........这里部分代码省略.........
{
computeInteractionBlock(*ei);
}
// allocation for transposed block
// should be avoided
if (itar > isrc) // upper block has been computed
{
if (!indexSet->properties(ed1).lower_block)
{
indexSet->properties(ed1).lower_block.
reset(new SimpleMatrix(indexSet->properties(ed1).upper_block->size(1),
indexSet->properties(ed1).upper_block->size(0)));
}
indexSet->properties(ed1).lower_block->trans(*indexSet->properties(ed1).upper_block);
indexSet->properties(ed2).lower_block = indexSet->properties(ed1).lower_block;
}
else
{
assert(itar < isrc); // lower block has been computed
if (!indexSet->properties(ed1).upper_block)
{
indexSet->properties(ed1).upper_block.
reset(new SimpleMatrix(indexSet->properties(ed1).lower_block->size(1),
indexSet->properties(ed1).lower_block->size(0)));
}
indexSet->properties(ed1).upper_block->trans(*indexSet->properties(ed1).lower_block);
indexSet->properties(ed2).upper_block = indexSet->properties(ed1).upper_block;
}
}
}
}
else // not symmetric => follow out_edges for each vertices
{
DEBUG_PRINT("OneStepNSProblem::updateInteractionBlocks(). Non symmetric case\n");
InteractionsGraph::VIterator vi, viend;
for (std11::tie(vi, viend) = indexSet->vertices();
vi != viend; ++vi)
{
DEBUG_PRINT("OneStepNSProblem::updateInteractionBlocks(). Computation of diaganal block\n");
SP::Interaction inter = indexSet->bundle(*vi);
unsigned int nslawSize = inter->nonSmoothLaw()->size();
if (! indexSet->properties(*vi).block)
{
indexSet->properties(*vi).block.reset(new SimpleMatrix(nslawSize, nslawSize));
}
if (!isLinear || !_hasBeenUpdated)
{
computeDiagonalInteractionBlock(*vi);
}
/* on a undirected graph, out_edges gives all incident edges */
InteractionsGraph::OEIterator oei, oeiend;
/* interactionBlock must be zeroed at init */
std::map<SP::SiconosMatrix, bool> initialized;
for (std11::tie(oei, oeiend) = indexSet->out_edges(*vi);
oei != oeiend; ++oei)
{
/* on adjoint graph there is at most 2 edges between source and target */
InteractionsGraph::EDescriptor ed1, ed2;
std11::tie(ed1, ed2) = indexSet->edges(indexSet->source(*oei), indexSet->target(*oei));
if (indexSet->properties(ed1).upper_block)
示例3: displayBlocks
void MLCPProjectOnConstraints::displayBlocks(SP::InteractionsGraph indexSet)
{
std::cout << "MLCPProjectOnConstraints::displayBlocks(SP::InteractionsGraph indexSet) " << std::endl;
std::cout << " indexSet :" << indexSet << std::endl;
InteractionsGraph::VIterator vi, viend;
for (std11::tie(vi, viend) = indexSet->vertices();
vi != viend; ++vi)
{
SP::Interaction inter = indexSet->bundle(*vi);
std::cout << " vertex :" << *vi << std::endl;
std::cout << " bundle :" << indexSet->bundle(*vi) << std::endl;
if (indexSet->blockProj[*vi])
{
std::cout << " blockProj ";
indexSet->blockProj[*vi]->display();
}
InteractionsGraph::OEIterator oei, oeiend;
for (std11::tie(oei, oeiend) = indexSet->out_edges(*vi);
oei != oeiend; ++oei)
{
unsigned int isrc = indexSet->index(indexSet->source(*oei));
unsigned int itar = indexSet->index(indexSet->target(*oei));
std::cout << " isrc :" << isrc << std::endl;
std::cout << " itar :" << itar << std::endl;
InteractionsGraph::EDescriptor ed1, ed2;
std::cout << " outedges :" << *oei << std::endl;
std11::tie(ed1, ed2) = indexSet->edges(indexSet->source(*oei), indexSet->target(*oei));
std::cout << " edges(ed1,ed2) :" << ed1 << " " << ed2 << std::endl;
std::cout << " (ed1)->upper_blockProj : ";
if (indexSet->upper_blockProj[ed1])
{
std::cout << indexSet->upper_blockProj[ed1] << " :" ;
indexSet->upper_blockProj[ed1]->display();
}
else
std::cout << "NULL " << std::endl;
std::cout << " (ed1)->lower_blockProj : ";
if (indexSet->lower_blockProj[ed1])
{
std::cout << indexSet->lower_blockProj[ed1] << " :" ;
indexSet->lower_blockProj[ed1]->display();
}
else
std::cout << "NULL " << std::endl;
std::cout << " (ed2)->upper_blockProj : ";
if (indexSet->upper_blockProj[ed2])
{
std::cout << indexSet->upper_blockProj[ed2] << " :" ;
indexSet->upper_blockProj[ed2]->display();
}
else
std::cout << "NULL" << std::endl;
std::cout << " (ed2)->lower_blockProj : ";
if (indexSet->lower_blockProj[ed2])
{
std::cout << indexSet->lower_blockProj[ed2] << " :" ;
indexSet->lower_blockProj[ed2]->display();
}
else
std::cout << "NULL" << std::endl;
}
}
}
示例4: updateInteractionBlocks
void MLCPProjectOnConstraints::updateInteractionBlocks()
{
// The present functions checks various conditions and possibly
// compute interactionBlocks matrices.
//
// Let interi and interj be two Interactions.
//
// Things to be checked are:
// 1 - is the topology time invariant?
// 2 - does interactionBlocks[interi][interj] already exists (ie has been
// computed in a previous time step)?
// 3 - do we need to compute this interactionBlock? A interactionBlock is
// to be computed if interi and interj are in IndexSet1 AND if interi and
// interj have common DynamicalSystems.
//
// The possible cases are:
//
// - If 1 and 2 are true then it does nothing. 3 is not checked.
// - If 1 == true, 2 == false, 3 == false, it does nothing.
// - If 1 == true, 2 == false, 3 == true, it computes the
// interactionBlock.
// - If 1==false, 2 is not checked, and the interactionBlock is
// computed if 3==true.
//
#ifdef MLCPPROJ_DEBUG
std::cout << " " << std::endl;
std::cout << "===================================================" << std::endl;
std::cout << "MLCPProjectOnConstraints::updateInteractionBlocks()" << std::endl;
#endif
// Get index set from Simulation
SP::InteractionsGraph indexSet = simulation()->indexSet(indexSetLevel());
// It seems that index() in not update in Index(0)
// see comment in void Simulation::updateIndexSets()
if (indexSetLevel() == 0)
{
indexSet->update_vertices_indices();
indexSet->update_edges_indices();
}
bool isLinear = simulation()->model()->nonSmoothDynamicalSystem()->isLinear();
// we put diagonal informations on vertices
// self loops with bgl are a *nightmare* at the moment
// (patch 65198 on standard boost install)
if (indexSet->properties().symmetric)
{
RuntimeException::selfThrow
(" MLCPProjectOnConstraints::updateInteractionBlocks() - not yet implemented for symmetric case");
}
else // not symmetric => follow out_edges for each vertices
{
if (!_hasBeenUpdated)
{
// printf("MLCPProjectOnConstraints::updateInteractionBlocks must be updated.\n");
_n = 0;
_m = 0;
_curBlock = 0;
}
InteractionsGraph::VIterator vi, viend;
for (std11::tie(vi, viend) = indexSet->vertices();
vi != viend; ++vi)
{
SP::Interaction inter = indexSet->bundle(*vi);
unsigned int nslawSize = std11::static_pointer_cast<OSNSMatrixProjectOnConstraints>
(_M)->computeSizeForProjection(inter);
#ifdef MLCPPROJ_DEBUG
std::cout << " " << std::endl;
std::cout << "Start to work on Interaction " << inter->number() << "of vertex" << *vi << std::endl;
#endif
if (! indexSet->blockProj[*vi])
{
#ifdef MLCPPROJ_DEBUG
std::cout << "Allocation of blockProj of size " << nslawSize << " x " << nslawSize << " for interaction " << inter->number() << std::endl;
#endif
indexSet->blockProj[*vi].reset(new SimpleMatrix(nslawSize, nslawSize));
}
if (!isLinear || !_hasBeenUpdated)
{
computeDiagonalInteractionBlock(*vi);
}
//.........这里部分代码省略.........
示例5: postComputeLagrangianR
void MLCPProjectOnConstraints::postComputeLagrangianR(SP::Interaction inter, unsigned int pos)
{
SP::LagrangianR lr = std11::static_pointer_cast<LagrangianR>(inter->relation());
#ifdef MLCPPROJ_DEBUG
printf("MLCPProjectOnConstraints::postComputeLagrangian inter->y(0)\n");
inter->y(0)->display();
printf("MLCPProjectOnConstraints::postComputeLagrangian lr->jachq \n");
lr->jachq()->display();
printf("MLCPProjectOnConstraints::postComputeLagrangianR q before update\n");
SP::InteractionsGraph indexSet = simulation()->indexSet(indexSetLevel());
InteractionsGraph::VDescriptor ui = indexSet->descriptor(inter);
InteractionsGraph::OEIterator oei, oeiend;
for(std11::tie(oei, oeiend) = indexSet->out_edges(ui);
oei != oeiend; ++oei)
{
SP::LagrangianDS lds = std11::static_pointer_cast<LagrangianDS>(indexSet->bundle(*oei));
lds->q()->display();
}
#endif
//unsigned int sizeY = inter->nonSmoothLaw()->size();
// y and lambda vectors
SP::SiconosVector lambda = inter->lambda(0);
SP::SiconosVector y = inter->y(0);
unsigned int sizeY = std11::static_pointer_cast<OSNSMatrixProjectOnConstraints>
(_M)->computeSizeForProjection(inter);
// Copy _w/_z values, starting from index pos into y/lambda.
//setBlock(*_w, y, sizeY, pos, 0);
setBlock(*_z, lambda, sizeY, pos, 0);
#ifdef MLCPPROJ_DEBUG
printf("MLCPP lambda of Interaction is pos =%i :\n", pos);
// aBuff->display();
lambda->display();
unsigned int nslawsize = inter->nonSmoothLaw()->size();
SP::SiconosVector aBuff(new SiconosVector(nslawsize));
setBlock(*_z, aBuff, sizeY, pos, 0);
SP::SiconosMatrix J = lr->jachq();
SP::SimpleMatrix aux(new SimpleMatrix(*J));
aux->trans();
// SP::SiconosVector tmp(new SiconosVector(*(lr->q())));
// prod(*aux, *aBuff, *(tmp), false);
// //prod(*aux,*lambda,*(lr->q()),false);
// std:: std::cout << " tmp = tmp + J^T * lambda" << std::endl;
// tmp->display();
#endif
// // WARNING : Must not be done here. and should be called with the correct time.
// // compute p(0)
// inter->computeInput(0.0 ,0);
// // \warning aBuff should normally be in lambda[0]
// // The update of the position in DS should be made
// // in MoreauJeanOSI::upateState or ProjectedMoreauJeanOSI::updateState
// SP::SiconosMatrix J=lr->jachq();
// SP::SimpleMatrix aux(new SimpleMatrix(*J));
// aux->trans();
// SP::SiconosVector tmp (new SiconosVector(*(lr->q())));
// std:: std::cout << " tmp ="<<std::endl;
// tmp->display();
// std:: std::cout << " lr->q() ="<<std::endl;
// lr->q()->display();
// //prod(*aux,*lambda,*(lr->q()),false);
// prod(*aux,*aBuff,*(tmp),false);
// std:: std::cout << " tmp = tmp + J * lambda"<<std::endl;
// tmp->display();
// // The following step should be done on MoreauJeanOSI::upateState or ProjectedMoreauJeanOSI::updateState
// DSIterator itDS = inter->dynamicalSystemsBegin();
// while(itDS!=inter->dynamicalSystemsEnd())
// {
// Type::Siconos dsType = Type::value(**itDS);
// if((dsType !=Type::LagrangianDS) and
// (dsType !=Type::LagrangianLinearTIDS) )
// {
// RuntimeException::selfThrow("MLCPProjectOnConstraint::postCompute- ds is not of Lagrangian DS type.");
// }
// SP::LagrangianDS d = std11::static_pointer_cast<LagrangianDS> (*itDS);
// SP::SiconosVector q = d->q();
// *q += *d->p(0);
// std::cout << " q=" << std::endl;
// q->display();
// itDS++;
// }
// if ((*lr->q() - *tmp).normInf() > 1e-12)
//.........这里部分代码省略.........