xnumber_t DFG::calcNormConst(stateMaskVec_t const & stateMasks)
  {
    if (inMessages_.size() == 0)
      initMessages();

    return calcNormConst(stateMasks, inMessages_, outMessages_);
  }
示例#2
0
文件: perfmon.cpp 项目: Jinxiaohai/QT
PerfMon::PerfMon(QWidget *parent) :
    QWidget(parent)
{
    initVariables();
    initContextMenu();
    initMessages();
}
 void DFG::runSumProduct(stateMaskVec_t const & stateMasks)
 {
   if (inMessages_.size() == 0) 
     initMessages();
   
   runSumProduct(stateMasks, inMessages_, outMessages_);
 }
 xnumber_t DFG::runMaxSum(stateMaskVec_t const & stateMasks, vector<unsigned> & maxVariables)
 {
   // init data structures
   if (inMessages_.size() == 0)
     initMessages();
   if (maxNeighborStates_.size() == 0)
     initMaxNeighbourStates();
   
   return runMaxSum(stateMasks, maxVariables, inMessages_, outMessages_, maxNeighborStates_);
 }
 Game():
 window(sf::VideoMode(500, 400), "Okno aplikacji"),
 messages_text("Komunikaty:"),
 player(nullptr),
 turn(0),
 left_button(false)
 {
     window.setFramerateLimit(100);
     loadFont();
     initBoard();
     initLines();
     initAreas();
     initMessages();
     initButton();
 }
/*! \brief Initializes a receiver node
 *
 *		Initializes a ROS node, a socket for receiving
 *		and ROS tf messages
 * @retval TRUE Initialization successful
 * @retval FALSE Initialization failed
 */
bool QNodeReceiver::readyForAction() {

	//return early if initialization of ROS node failed
	if (!initNode()) {
		return false;
	}

	//return early if socket setup failed
	if (!socketReady()) {
		return false;
	}

	//initialize ROS tf messages
	initMessages();

	//display a ready to receive message if node is started
	if (ros::isStarted()) {
		display(INFO, QString("Ready to receive"));
	}
	return true;
}
示例#7
0
void InferenceEngineBP::computeBeliefs(Beliefs &beliefs, FeatureGenerator *fGen, 
	DataSequence *X, Model *m, int bComputePartition, int seqLabel, bool bUseStatePerNodes)
{  
	// Variable definition  
	int xi, xj, nbNodes, seqLength;
	std::map<int,BPNode*> nodes; // tree graph
	std::map<int,BPNode*>::iterator itm;
	std::list<BPNode*>::iterator itl;
	BPNode* root;
	iMatrix adjMat;
	iVector nbStates;
	dVector*  phi_i  = 0; // singleton potentials
	dMatrix** phi_ij = 0; // pairwise potentials
	dVector** msg    = 0; // messages

	if( m->isMultiViewMode() )
		m->getAdjacencyMatrixMV(adjMat, X);
	else {
		uMatrix uAdjMat;
		m->getAdjacencyMatrix(uAdjMat, X);
		adjMat.resize(uAdjMat.getWidth(),uAdjMat.getHeight());
		for(xi=0; xi<uAdjMat.getHeight(); xi++)
			for(xj=0; xj<uAdjMat.getWidth(); xj++)
				adjMat(xi,xj) = uAdjMat(xi,xj);
	}

	nbNodes = adjMat.getHeight(); 
	seqLength = X->length();

	// Create a vector that contains nbStates
	nbStates.create(nbNodes);
	for(xi=0; xi<nbNodes; xi++)
		nbStates[xi] = (m->isMultiViewMode()) 
			? m->getNumberOfStatesMV(xi/seqLength) : m->getNumberOfStates();

	// Create BPGraph from adjMat
	for(xi=0; xi<nbNodes; xi++) {		
		BPNode* v = new BPNode(xi, nbStates[xi]);
		nodes.insert( std::pair<int,BPNode*>(xi,v) );
	}
	for(xi=0; xi<nbNodes; xi++) {
		for(xj=xi+1; xj<nbNodes; xj++) {
			if( !adjMat(xi,xj) ) continue;
			nodes[xi]->addNeighbor(nodes[xj]);
			nodes[xj]->addNeighbor(nodes[xi]);
		}
	}

	// Initialize  
	initMessages(msg, X, m, adjMat, nbStates);
	initBeliefs(beliefs, X, m, adjMat, nbStates);
	initPotentials(phi_i, phi_ij, fGen, X, m, adjMat, nbStates, seqLabel);
	
	// Message update
	root = nodes[0]; // any node can be the root node
	{
		for(itl=root->neighbors.begin(); itl!=root->neighbors.end(); itl++)
			collect(root, *itl, phi_i, phi_ij, msg);
		for(itl=root->neighbors.begin(); itl!=root->neighbors.end(); itl++)
			distribute(root, *itl, phi_i, phi_ij, msg);
	}
	updateBeliefs(beliefs, phi_i, phi_ij, msg, X, m, adjMat);

	// Clean up
	for(xi=0; xi<nbNodes; xi++) { 		
		delete[] msg[xi]; msg[xi] = 0; 
		delete[] phi_ij[xi]; phi_ij[xi] = 0;
	}
	delete[] msg; msg=0;
	delete[] phi_i; phi_i = 0;
	delete[] phi_ij;  phi_ij  = 0; 

	for(itm=nodes.begin(); itm!=nodes.end(); itm++) 
		delete (*itm).second; 
	nodes.clear();   
}
 // init data structures given in DFG.
 void DFG::initMessages()
 {
   initMessages(inMessages_, outMessages_);
 }