bool
CompositeUndoStackObserver::_mark_one(UndoObserverRecordList& list, UndoStackObserver& o)
{
	UndoStackObserverRecord eq_comp(o);

	UndoObserverRecordList::iterator i = std::find_if(list.begin(), list.end(), std::bind1st(std::equal_to< UndoStackObserverRecord >(), eq_comp));

	if (i != list.end()) {
		(*i).to_remove = true;
		return true;
	} else {
		return false;
	}
}
Example #2
0
StochGenMatrix* sTreeImpl::createA() 
{
  //is this node a dead-end for this process?
  if(commWrkrs==MPI_COMM_NULL)
    return new StochGenDummyMatrix(m_id);

  StochGenMatrix* A = NULL;
  if (m_id==0) {
    CoinPackedMatrix Arow; 
    Arow.reverseOrderedCopyOf( in.getFirstStageConstraints() );
    assert(false==Arow.hasGaps());  

    // number of nz in the rows corresponding to eq constraints
    int nnzB=countNNZ( Arow, 
		       in.getFirstStageRowLB(), 
		       in.getFirstStageRowUB(), 
		       eq_comp());
    //printf("%d  -- 1st stage my=%lu nx=%lu nnzB=%d\n", commie, m_my, m_nx, nnzB);
    A = new StochGenMatrix( m_id, MY, N, 
			    m_my, 0,   0,    // A does not exist for the root
			    m_my, m_nx, nnzB, // B is 1st stage eq matrix
			    commWrkrs );
    extractRows( Arow,
		 in.getFirstStageRowLB(), in.getFirstStageRowUB(), eq_comp(),
		 A->Bmat->krowM(), A->Bmat->jcolM(), A->Bmat->M() );

  } else {
    int scen=m_id-1;
    CoinPackedMatrix Arow, Brow; 
    Arow.reverseOrderedCopyOf( in.getLinkingConstraints(scen) );
    Brow.reverseOrderedCopyOf( in.getSecondStageConstraints(scen) );

    int nnzA=countNNZ( Arow, in.getSecondStageRowLB(scen), 
		       in.getSecondStageRowUB(scen), eq_comp() );
    int nnzB=countNNZ( Brow, in.getSecondStageRowLB(scen), 
		       in.getSecondStageRowUB(scen), eq_comp() );

    A = new StochGenMatrix( m_id, MY, N, 
			    m_my, parent->m_nx, nnzA, 
			    m_my, m_nx,         nnzB,
			    commWrkrs );
    //cout << commie << "  -- 2nd stage my=" << m_my << " nx=" << m_nx 
    // << "  1st stage nx=" << parent->m_nx << "  nnzA=" << nnzA << " nnzB=" << nnzB << endl;
    extractRows( Arow,
		 in.getSecondStageRowLB(scen), 
		 in.getSecondStageRowUB(scen), 
		 eq_comp(),
		 A->Amat->krowM(), A->Amat->jcolM(), A->Amat->M() );
    extractRows( Brow,
		 in.getSecondStageRowLB(scen), 
		 in.getSecondStageRowUB(scen), 
		 eq_comp(),
		 A->Bmat->krowM(), A->Bmat->jcolM(), A->Bmat->M() );
  }
  
  for(size_t it=0; it<children.size(); it++) {
    StochGenMatrix* child = ((sTreeImpl*)children[it])->createA();
    A->AddChild(child);
  }
  return A;
}