Exemplo n.º 1
0
inline std::pair<
    typename DIRECTED_GRAPH::in_edge_iterator,
    typename DIRECTED_GRAPH::in_edge_iterator
>
in_edges(typename DIRECTED_GRAPH::vertex_descriptor v,
        DIRECTED_GRAPH const& g)
{ return in_edges(v, g.impl()); }
Exemplo n.º 2
0
  bool is_adj_dispatch(Graph& g, Vertex a, Vertex b, bidirectional_tag)
  {
    typedef typename graph_traits<Graph>::edge_descriptor 
      edge_descriptor;
    typename graph_traits<Graph>::adjacency_iterator vi, viend, 
      adj_found;
    boost::tie(vi, viend) = adjacent_vertices(a, g);
    adj_found = std::find(vi, viend, b);
    if (adj_found == viend)
      return false;  

    typename graph_traits<Graph>::out_edge_iterator oi, oiend, 
      out_found;
    boost::tie(oi, oiend) = out_edges(a, g);
    out_found = std::find_if(oi, oiend, incident_to(b, g));
    if (out_found == oiend)
      return false;

    typename graph_traits<Graph>::in_edge_iterator ii, iiend, 
      in_found;
    boost::tie(ii, iiend) = in_edges(b, g);
    in_found = std::find_if(ii, iiend, incident_from(a, g));
    if (in_found == iiend)
      return false;

    return true;
  }
Exemplo n.º 3
0
void GraphNeighborsOfPlaces(PetriGraphType& g,
  const std::set<int64_t>& place_id, F func) {
  auto seen=std::set<int64_t>();

  auto report=[&seen, &func, &g] (int64_t id) {
    SMVLOG(BOOST_LOG_TRIVIAL(trace) << "transition " << id);
    assert(g[id].color==PetriGraphColor::Transition);
    if (seen.find(id)==seen.end()) {
      func(id);
      seen.insert(id);
    }
  };

  for ( auto p : place_id) {
    SMVLOG(BOOST_LOG_TRIVIAL(trace) << "neighbors of place " << p);
    assert(g[p].color==PetriGraphColor::Place);
    auto ie=in_edges(p, g);
    for (; ie.first!=ie.second; ++ie.first) {
      report(source(*ie.first, g));
    }
    auto oe=out_edges(p, g);
    for (; oe.first!=oe.second; ++oe.first) {
      report(target(*oe.first, g));
    }
  }
}
Exemplo n.º 4
0
//***********************************************************************
// visitor definition
//***********************************************************************
// examine_vertex to test if we are at end of search
void SyntacticAnalysisXmlLogger::DumpGraphVisitor::examine_vertex(LinguisticGraphVertex v,
        const LinguisticGraph& g)
{
//   DUMPERLOGINIT;
//   LDEBUG << "DumpGraphVisitor: examine_vertex " << v << LENDL;

    if (v == m_lastVertex)
    {
        bool finished = true;
        LinguisticGraphInEdgeIt it, it_end;
        boost::tie(it, it_end) = in_edges(v, g);
        while (finished && (it != it_end))
        {
            if (get(boost::vertex_color, g,source(*it, g)) != Color::black())
            {
                finished = false;
            }
            it++;
        }
        if (finished)
        {
//       LDEBUG << "DumpGraphVisitor: finished" << LENDL;
            throw EndOfSearch();
        }
    }
}
Exemplo n.º 5
0
     /*!
       boost::graph doesn't recommend th to insert/remove vertices, so a vertex removal is
       simulated by disconnecting the vertex from the graph

       - No edge is disconnected if the vertices id's do not exist in the graph
       - All removed edges are stored for future reinsertion
       - All parallel edges are disconnected (automatically by boost)

       ![disconnect_vertex(2) on an UNDIRECTED graph](disconnectVertexUndirected.png)
       ![disconnect_vertex(2) on a DIRECTED graph](disconnectVertexDirected.png)

       @param [IN] *p_vertex* original vertex id of the starting point of the edge
       */
     void disconnect_vertex(int64_t p_vertex) {
         V g_vertex;
         boost_edge_t d_edge;
         // nothing to do, the vertex doesnt exist
         if (!get_gVertex(p_vertex, g_vertex)) return;
         EO_i out, out_end;
         // store the edges that are going to be removed
         for (boost::tie(out, out_end) = out_edges(g_vertex, graph);
                 out != out_end; ++out) {
             d_edge.id = graph[*out].id;
             d_edge.source = graph[source(*out, graph)].id;
             d_edge.target = graph[target(*out, graph)].id;
             d_edge.cost = graph[*out].cost;
             //        d_edge.reverse_cost = -1;
             removed_edges.push_back(d_edge);
         }

         // special case
         if (m_gType == DIRECTED) {
             EI_i in, in_end;
             for (boost::tie(in, in_end) = in_edges(g_vertex, graph);
                     in != in_end; ++in) {
                 d_edge.id = graph[*in].id;
                 d_edge.source = graph[source(*in, graph)].id;
                 d_edge.target = graph[target(*in, graph)].id;
                 d_edge.cost = graph[*in].cost;
                 //           d_edge.reverse_cost = -1;
                 removed_edges.push_back(d_edge);
             }
         }

         V d_vertex = boost::vertex(vertices_map.find(p_vertex)->second, graph);
         // delete incomming and outgoing edges from the vertex
         boost::clear_vertex(d_vertex, graph);
     }
Exemplo n.º 6
0
 std::pair<ParentsIterator, ParentsIterator>
 parents(VertexID v, const TaskGraph &tg)
{
  InEdgeIterator e,e_end;
  tie(e,e_end) = in_edges(v,tg);
  ParentsIterator c(e,&tg),c_end(e_end,&tg);
  return make_pair(c,c_end);
}
Exemplo n.º 7
0
    void constraints() {
      function_requires< IncidenceGraphConcept<G> >();
      function_requires< MultiPassInputIteratorConcept<in_edge_iterator> >();

      p = in_edges(v, g);
      n = in_degree(v, g);
      e = *p.first;
      const_constraints(g);
    }
Exemplo n.º 8
0
void MergeAllParents::mergeAll(std::pair<ParentsIterator,ParentsIterator> pair,
             VertexID child,
             set<VertexID> &A,
             set<VertexID> &B)
{
  set<VertexID> parents2;
  set<VertexID> parents1;
  set<VertexID>::iterator pit,Aelt,Belt;
  ParentsIterator p,p_end,p2,p2_end;
  InEdgeIterator e,e_end;

  for (tie(p,p_end) = pair; p != p_end; p++) {
    if (*p != m_invartask) {
      parents1.insert(*p);
    }
  }

  for (pit=parents1.begin(); pit != parents1.end(); pit++) {
    addContainsTask(child,*pit);

    for (tie(p2,p2_end) = parents(*pit,*m_taskgraph); p2 != p2_end; p2++) {
      if (parents1.find(*pit) == parents1.end() && *p2 != m_invartask)
  parents2.insert(*p2);
    }
    // Add edge from parents^2 to child
    for(tie(e,e_end) = in_edges(*pit,*m_taskgraph); e != e_end; e++) {
      // Adding edge here invalidates pair iterators
      if (parents1.find(source(*e,*m_taskgraph)) == parents1.end()) {
  EdgeID newEdge = add_edge(source(*e,*m_taskgraph),child,m_taskgraph);
  ResultSet &set = getResultSet(newEdge,m_taskgraph);
  ResultSet &oldSet = getResultSet(*e,m_taskgraph);
  set.make_union(&oldSet);
      }
    }
  }

  // Add edge from new node to all in A
  for (Aelt=A.begin(); Aelt != A.end(); Aelt++) {
    add_edge(child,*Aelt,m_taskgraph);
  }

  // Can not iterate through pair since add_edge above invalidates that
  // iterator.
  for (pit=parents1.begin(); pit != parents1.end(); pit++) {
    if (B.find(*pit) == B.end() && *pit != m_invartask) {
      (*m_taskRemoved)[*pit] = true;
      clear_vertex(*pit,*m_taskgraph);
      remove_vertex(*pit,*m_taskgraph);
    }
  }

  // Remove edges from elts in B to child, the elts are already dupl. into child.
  for (Belt = B.begin(); Belt != B.end(); Belt++) {
    remove_edge(*Belt,child,*m_taskgraph);
  }
}
Exemplo n.º 9
0
    void PhyEngine::threadLoop()
    {
        //Do a topological sort of the graph (sorts in reverse topological order)
        vector<unsigned> revTopoOrder;
        topological_sort(engineGraph_, back_inserter(revTopoOrder), b::vertex_index_map(b::identity_property_map()));

        //The main loop of this engine thread
        try{
            while(true)
            {
                b::this_thread::interruption_point();

                //Check message queue for ReconfigSets
                ReconfigSet currentReconfigSet;
                while(reconfigQueue_.tryPop(currentReconfigSet))
                {
                    vector< ParametricReconfig >::iterator paramIt;
                    for(paramIt = currentReconfigSet.paramReconfigs.begin();
                        paramIt != currentReconfigSet.paramReconfigs.end();
                        ++paramIt)
                    {
                        reconfigureParameter(*paramIt);
                    }
                }

                //Go through components in topological order
                for(vector<unsigned>::reverse_iterator i = revTopoOrder.rbegin(); i != revTopoOrder.rend(); ++i)
                {
                    if(i == revTopoOrder.rbegin()) //First component in the graph
                    {
                        components_[*i]->doProcess();
                    }
                    else
                    {
                        InEdgeIterator edgeIt, edgeItEnd;
                        for(b::tie(edgeIt, edgeItEnd) = in_edges(*i, engineGraph_); edgeIt != edgeItEnd; ++edgeIt)
                        {
                            //If there's data available in an input buffer, process it
                            while( engineGraph_[*edgeIt].theBuffer->hasData() )
                            {
                                components_[*i]->doProcess();
                            }
                        }
                    }
                }
            }
        }
        catch(IrisException& ex)
        {
            LOG(LFATAL) << "Error in engine " << engineName_ << ": " << ex.what() << " - Engine thread exiting.";
        }
        catch(b::thread_interrupted&)
        {
            LOG(LINFO) << "Thread in Engine " << engineName_ << " interrupted";
        }
    }
Exemplo n.º 10
0
 typename filtered_graph<G, EP, VP>::degree_size_type
 in_degree(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
            const filtered_graph<G, EP, VP>& g)
 {
   typename filtered_graph<G, EP, VP>::degree_size_type n = 0;
   typename filtered_graph<G, EP, VP>::in_edge_iterator f, l;
   for (boost::tie(f, l) = in_edges(u, g); f != l; ++f)
     ++n;
   return n;
 }
Exemplo n.º 11
0
 std::pair<typename filtered_graph<G, EP, VP>::in_edge_iterator,
           typename filtered_graph<G, EP, VP>::in_edge_iterator>
 in_edges(typename filtered_graph<G, EP, VP>::vertex_descriptor u,
           const filtered_graph<G, EP, VP>& g)
 {
   typedef filtered_graph<G, EP, VP> Graph;
   typename Graph::InEdgePred pred(g.m_edge_pred, g.m_vertex_pred, g);
   typedef typename Graph::in_edge_iterator iter;
   typename graph_traits<G>::in_edge_iterator f, l;
   boost::tie(f, l) = in_edges(u, g.m_g);
   return std::make_pair(iter(pred, f, l), iter(pred, l, l));
 }
Exemplo n.º 12
0
 void print_in_edges(const IncidenceGraph& G, Name name)
 {
   typename graph_traits<IncidenceGraph>::vertex_iterator ui,ui_end;
   for (boost::tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) {
     std::cout << get(name,*ui) << " <-- ";
     typename graph_traits<IncidenceGraph>
       ::in_edge_iterator ei, ei_end;
     for(boost::tie(ei,ei_end) = in_edges(*ui,G); ei != ei_end; ++ei)
       std::cout << get(name,source(*ei,G)) << " ";
     std::cout << std::endl;
   }
 }
Exemplo n.º 13
0
std::vector<std::tuple<int64_t,int,int>>
GraphInputsOfTransition(Graph& g, int64_t trans_id) {
  assert(g[trans_id].color==PetriGraphColor::Transition);
  std::vector<std::tuple<int64_t,int,int>> place_ids;

  auto initer=in_edges(trans_id, g);
  for (; initer.first!=initer.second; ++initer.first) {
    auto sc=g[*initer.first].stochiometric_coefficient;
    auto place_id=source(*initer.first, g);
    assert(g[place_id].color==PetriGraphColor::Place);
    auto level=g[place_id].token_layer;
    place_ids.push_back(std::make_tuple(place_id, level, sc));
  }
  return place_ids;
}
Exemplo n.º 14
0
void SingleChildMerge::mergeTasks(VertexID n1, VertexID n2)
{
  VertexID p,c;
  OutEdgeIterator oute,oute_end;
  InEdgeIterator ine,ine_end;
  tie(p,c)=determineParent(n1,n2);

  set<VertexID> parents,children;
  set<VertexID>::iterator child;

  for (tie(ine,ine_end)=in_edges(p,*m_taskgraph); ine != ine_end; ++ine) {
    assert(p != source(*ine,*m_taskgraph));
    parents.insert(source(*ine,*m_taskgraph));
  }
  for (tie(oute,oute_end)= out_edges(c,*m_taskgraph); oute != oute_end; ++oute) {
    assert(c != target(*oute,*m_taskgraph));
    children.insert(target(*oute,*m_taskgraph));
  }
  // Add edges from newtask = p to children and update costs.
  for(child = children.begin(); child != children.end(); ++child) {
    EdgeID newEdge,oldEdge;
    bool tmp;
    tie(newEdge,tmp)= add_edge(p,*child,*m_taskgraph);
    tie(oldEdge,tmp) = edge(c,*child,*m_taskgraph);

    //cerr << "old cost: " << getCommCost(oldEdge) << endl;
    setCommCost(newEdge,
    getCommCost(oldEdge),m_taskgraph);
  }


  addContainsTask(p,c); // Need to store that c is in p to be able to
      // go back to orig task graph when generating code.

  // Remove task and edges to the task
  (*m_taskRemoved)[c]=true;
  clear_vertex(c,*m_taskgraph);


  remove_vertex(c,*m_taskgraph);
}
Exemplo n.º 15
0
void test_in_out_edges(const G& g) 
{
  typedef boost::graph_traits< G > Traits;
  typedef typename Traits::vertex_iterator vertex_iterator;
  typedef typename Traits::in_edge_iterator in_edge_iterator;
  typedef typename Traits::out_edge_iterator out_edge_iterator;
  typedef typename Traits::vertex_descriptor vertex_descriptor;

  // check that the sets of in out edges are the same
  vertex_iterator vb, ve;
  for(boost::tie(vb, ve) = vertices(g); vb != ve; ++vb) {
    id_map v_ids;
    std::vector<vertex_descriptor> in, out;
    in_edge_iterator ieb, iee;
    for(boost::tie(ieb, iee) = in_edges(*vb, g); ieb != iee; ++ieb) {
      std::pair<id_map::iterator, bool> r =
        v_ids.insert(get(boost::vertex_index, g, source(*ieb, g)));
      assert(r.second);
      in.push_back(source(*ieb, g));
    }
    out_edge_iterator oeb, oee;
    for(boost::tie(oeb, oee) = out_edges(*vb, g); oeb != oee; ++oeb) {
      std::pair<id_map::iterator, bool> r =
        v_ids.insert(get(boost::vertex_index, g, target(*oeb, g)));
      // insertion must fail
      assert(!r.second);
      out.push_back(target(*oeb, g));
    }
    // did we walk the vertices in the same order?
    assert(in.size() == out.size());
    assert(std::equal(in.begin(), in.end(), out.begin()));
    assert(in.size() == in_degree(*vb, g));
    assert(out.size() == out_degree(*vb, g));
    assert(in.size() == degree(*vb, g));
    assert(degree(*vb, g) == in_degree(*vb, g));
    assert(degree(*vb, g) == out_degree(*vb, g));
  }
}
Exemplo n.º 16
0
void test_in_edges(const G& g) 
{
  typedef boost::graph_traits< G > Traits;
  typedef typename Traits::vertex_iterator vertex_iterator;
  typedef typename Traits::in_edge_iterator in_edge_iterator;
  typedef typename Traits::vertex_descriptor vertex_descriptor;

  vertex_iterator vb, ve;
  for(boost::tie(vb, ve) = vertices(g); vb != ve; ++vb) {
    id_map v_ids;
    vertex_descriptor around = *vb;
    in_edge_iterator ieb, iee;
    for(boost::tie(ieb, iee) = in_edges(*vb, g); ieb != iee; ++ieb) {
      vertex_descriptor t = target(*ieb, g);
      vertex_descriptor s = source(*ieb, g);
      assert(t == around);
      assert(s != around);
      std::pair<id_map::iterator, bool> r =
        v_ids.insert(get(boost::vertex_index, g, source(*ieb, g)));
      assert(r.second);
    }
  }
}
Exemplo n.º 17
0
static int implement_lospre_assignment(const assignment_lospre a, T_t &T, G_t &G, const iCode *ic) // Assignment has to be passed as a copy (not reference), since the transformations on the tree-decomposition will invalidate it otherwise.
{
  operand *tmpop;
  unsigned substituted = 0, split = 0;

  typedef typename boost::graph_traits<G_t>::edge_iterator edge_iter_t;
  typedef typename boost::graph_traits<G_t>::edge_descriptor edge_desc_t;
  std::set<edge_desc_t> calculation_edges; // Use descriptor, not iterator due to possible invalidation of iterators when inserting vertices or edges.
  edge_iter_t e, e_end;
  for(boost::tie(e, e_end) = boost::edges(G); e != e_end; ++e)
    if(!((a.global[boost::source(*e, G)] & true) && !G[boost::source(*e, G)].invalidates) && (a.global[boost::target(*e, G)] & true))
      calculation_edges.insert(*e);

  if(!calculation_edges.size())
    return(0);

#ifdef DEBUG_LOSPRE
  std::cout << "Optimizing at " << ic->key << "\n"; std::cout.flush();
#endif

  tmpop = newiTempOperand (operandType (IC_RESULT (ic)), TRUE);
  tmpop->isvolatile = false;
#ifdef DEBUG_LOSPRE
  std::cout << "New tmpop: " << OP_SYMBOL_CONST(tmpop)->name << " "; printTypeChain(operandType (IC_RESULT(ic)), stdout); std::cout << "\n";
#endif

  for(typename std::set<edge_desc_t>::iterator i = calculation_edges.begin(); i != calculation_edges.end(); ++i)
  {
    split_edge(T, G, *i, ic, tmpop);
    split++;
  }

  typedef typename boost::graph_traits<G_t>::vertex_iterator vertex_iter_t;
  vertex_iter_t v, v_end;

  for(boost::tie(v, v_end) = boost::vertices(G); v != v_end; ++v)
    {
      if(!G[*v].uses)
        continue;
      typename boost::graph_traits<G_t>::in_edge_iterator e = in_edges(*v, G).first;
      if (a.global.size() <= *v)
        continue;
      if(!((a.global[*v] & true) && !G[*v].invalidates || boost::source(*e, G) < a.global.size() && (a.global[boost::source(*e, G)] & true)))
        continue;
#ifdef DEBUG_LOSPRE
      std::cout << "Substituting ic " << G[*v].ic->key << "\n";
#endif
      substituted++;

      iCode *ic = G[*v].ic;
      //if (IC_LEFT (ic) && IS_ITEMP (IC_LEFT (ic)))
      //  bitVectUnSetBit (OP_SYMBOL (IC_LEFT (ic))->uses, ic->key);
      //if (IC_RIGHT (ic) && IS_ITEMP (IC_RIGHT (ic)))
       // bitVectUnSetBit (OP_SYMBOL (IC_RIGHT (ic))->uses, ic->key);
      IC_RIGHT(ic) = tmpop;
      //bitVectSetBit (OP_SYMBOL (IC_RIGHT(ic))->uses, ic->key);
      if (!POINTER_SET (ic))
        {
          IC_LEFT(ic) = 0;
          ic->op = '=';
          IC_RESULT(ic) = operandFromOperand (IC_RESULT (ic));
          IC_RESULT(ic)->isaddr = 0;
        }
      if(IS_OP_VOLATILE(IC_RESULT (ic)))
        continue;

      {
        typedef typename boost::graph_traits<G_t>::adjacency_iterator adjacency_iter_t;
        adjacency_iter_t c, c_end;
        boost::tie(c, c_end) = adjacent_vertices(*v, G);
        if (c != c_end)
          forward_lospre_assignment(G, *c, ic, a);
      }
    }

  if(substituted <= 0)
    {
      std::cerr << "Introduced " << OP_SYMBOL_CONST(tmpop)->name << ", but did not substitute any calculations.\n";
      return (-1);
    }

  if(substituted < split) // Todo: Remove this warning when optimization for speed instead of code size is implemented!
    std::cout << "Introduced " << OP_SYMBOL_CONST(tmpop)->name << ", but did substitute only " << substituted << " calculations, while introducing "<< split << ".\n"; std::cout.flush();

  return(1);
}
Exemplo n.º 18
0
	const in_edge_range_t getInEdges( const vertex_descriptor& v ) const { return in_edges( v, _graph ); }
Exemplo n.º 19
0
void LRACC::LRACC_dual()
{
///*
 	//float stepsize = 0.00025*(1-iter_lagrangian+MAX_LAGRANGIAN_NUM);
  float stepsize = 0.001;
  cout<<"#"<<iter_lagrangian<< "\t LRACC_DUAL parameters"<< endl;
	for(TPLGY_EITER eiter = edges(circuit).first;eiter!=edges(circuit).second;eiter++)
	{
		TPLGY_VDES src = source(*eiter,circuit);
		TPLGY_VDES tgt = target(*eiter,circuit);
		float ai,aj,di;
		if ((circuit[src].info->type == IN1) || (circuit[src].info->type == FFMS&&in_degree(src, circuit) == 0)){
			aj = 0;
		}
		else{
			aj = mu_sigma[circuit[src].info->name].first;
		}
		if ((circuit[tgt].info->type == OUT1) || (circuit[tgt].info->type == FFMS&&out_degree(tgt, circuit) == 0))
		{
			ai = Time_Limit;
			di = 0;
		}
		else
		{
			ai = mu_sigma[circuit[tgt].info->name].first;
			di = gate_sizes[circuit[tgt].info->name][1]*gate_sizes[circuit[tgt].info->name][2];
		}
		circuit[*eiter].lm+=stepsize*(aj+di-ai);
		//cout<<"new lm = "<<circuit[*eiter].lm<<std::endl;
		if(circuit[*eiter].lm<0)
			circuit[*eiter].lm = 0;
	}
	//project to KKT condition space
	for (VDES_CONTAINER::iterator ii = order.begin(); ii != order.end(); ++ii)
  {
		if(circuit[*ii].info->type==OUT1) continue;
		if(circuit[*ii].info->type==FFMS&&out_degree(*ii,circuit)==0) continue;
		float out_lm = 0;
		for(TPLGY_OEITER oeiter = out_edges(*ii,circuit).first;oeiter!=out_edges(*ii,circuit).second;oeiter++)
		{
			out_lm+=circuit[*oeiter].lm;
		}
		circuit[*ii].lm = out_lm;
		float in_lm = 0;
		for(TPLGY_IEITER ieiter = in_edges(*ii,circuit).first;ieiter!=in_edges(*ii,circuit).second;ieiter++)
		{
			in_lm+=circuit[*ieiter].lm;
		}
		if(in_lm==0) continue;
		for(TPLGY_IEITER ieiter = in_edges(*ii,circuit).first;ieiter!=in_edges(*ii,circuit).second;ieiter++)
		{
			circuit[*ieiter].lm*=out_lm/in_lm;
		}
	}
	float tmp = (total_a-Area_Limit)/Area_Limit; 
	//if(tmp>0.01) tmp = (1*tmp);
	//else if(tmp<0.01&&tmp>0) tmp = 0.01*1;
	//lm_a += stepsize*tmp;
  //if (lm_a < 0)
  {
  	lm_a = 0;
  }
	cout<<"Area_lm ="<<lm_a<<endl<<endl;
	//*/
	//float stepsize = 0.002*(1-iter_lagrangian+MAX_LAGRANGIAN_NUM);
 	/*float stepsize = 0.02;
  cout<<"#"<<iter_lagrangian<< "\t LRACC_DUAL parameters"<< endl;
	//update lm based on this hyperplane
	for (VDES_CONTAINER::iterator ii = order.begin(); ii != order.end(); ++ii)
  {
		TPLGY_VDES fgate = *ii;
    if (BIT_TEST(circuit[fgate].info->flag, OUTPUT_LOAD))
    {
    	continue;//skip the OUTPUT gate
    }
   	if (BIT_TEST(circuit[fgate].info->flag, INPUT_DRIVER))
    {
    	circuit[fgate].lm = 0;///???????????? just for simplicity
      continue;
    } 
 		string nm = (circuit[fgate].info)->name;
		//cout<<nm<<": "<<circuit[fgate].lm;
		float tmp = -arrival_time_slack[nm].second/Time_Limit;
		if(tmp>=0.01) tmp = (15*tmp);
		else if(tmp<0.01&&tmp>0) tmp = 15*0.01;
		tmp*=gate_sizes[circuit[fgate].info->name][1]*gate_sizes[circuit[fgate].info->name][2];
		circuit[fgate].lm += stepsize*tmp;
    if (circuit[fgate].lm <= 0)
    {
    	circuit[fgate].lm = 0;
    }
		//cout<<" -> lm="<<circuit[fgate].lm<<endl;//the Lagrangian value after calculate
  }
	float tmp = (total_a-Area_Limit)/Area_Limit; 
	//if(tmp>0.01) tmp = (1*tmp);
	//else if(tmp<0.01&&tmp>0) tmp = 0.01*1;
	//lm_a += stepsize*tmp;
  //if (lm_a < 0)
  {
  	lm_a = 0;
  }
	cout<<"Area_lm ="<<lm_a<<endl<<endl;//*/


	/*
	//update history based on last iteration
	dual_hist_obj.push_back(total_p);
	dual_hist_subg.push_back(make_pair(total_a-Area_Limit,arrival_time_slack));	
	//find the supporting hyperplane(this hyperplane will correspond to a history)
	vector<float> min(dual_hist_obj.size(),0);
	for(int i=0;i<dual_hist_obj.size();i++)
	{
		for (VDES_CONTAINER::iterator ii = order.begin(); ii != order.end(); ++ii)
    {
        fgate = *ii;
        if (BIT_TEST(circuit[fgate].info->flag, OUTPUT_LOAD||INPUT_DRIVER))
        {
            continue;//skip the OUTPUT gate
        }
    	  string nm = (circuit[fgate].info)->name;
        min[i] -= ((dual_hist_subg[i].second)[nm].second)*circuit[fgate].lm;
		}
		min[i] += (dual_hist_obj[i]);
		min[i] += (dual_hist_subg[i].first)*lm_a;
	}
	int idx = distance(min.begin(),min_element(min.begin(),min.end()));
	//update lm based on this hyperplane
	for (VDES_CONTAINER::iterator ii = order.begin(); ii != order.end(); ++ii)
  {
		fgate = *ii;
    if (BIT_TEST(circuit[fgate].info->flag, OUTPUT_LOAD))
    {
    	continue;//skip the OUTPUT gate
    }
   	if (BIT_TEST(circuit[fgate].info->flag, INPUT_DRIVER))
    {
    	circuit[fgate].lm = 0;///???????????? just for simplicity
      continue;
    } 
	
 		string nm = (circuit[fgate].info)->name;
		float tmp = -(dual_hist_subg.back().second)[nm].second*(dual_hist_subg.back().second)[nm].first/Time_Limit;
		if(tmp>=0.01) tmp = (30*tmp);
		else if(tmp<0.01&&tmp>0) tmp = 30*0.01;
		circuit[fgate].lm += stepsize*tmp;
    if (circuit[fgate].lm <= 0)
    {
    	circuit[fgate].lm = 0;
    }
		else cout<<nm<<" -> lm="<<circuit[fgate].lm<<endl;//the Lagrangian value after calculate
  }
	float tmp = (dual_hist_subg.back().first)/Area_Limit; 
	if(tmp>0.01) tmp = (20*tmp);
	else if(tmp<0.01&&tmp>0) tmp = 20*0.05;
	lm_a += stepsize*tmp;
  if (lm_a < 0)
  {
  	lm_a = 0;
  }
	cout<<"Area_lm ="<<lm_a<<endl<<endl;//*/
}
Exemplo n.º 20
0
	friend std::pair<in_edge_iterator, in_edge_iterator> in_edges(vertex_descriptor v, const Self &g) {
		return in_edges(v, g.g);
	}
Exemplo n.º 21
0
void GreedyPosTagger::processVertex(LinguisticGraphVertex vx,AnalysisGraph* anagraph) const
{
  LinguisticGraph* graph=anagraph->getGraph();
  LinguisticGraphVertex startVx=anagraph->firstVertex();
  LinguisticGraphVertex endVx=anagraph->lastVertex();

  PTLOGINIT;
  if (vx==startVx || vx==endVx)
  {
    return;
  }
  MorphoSyntacticData* data=get(vertex_data,*graph,vx);
  Token* token=get(vertex_token,*graph,vx);
  if (data==0)
  {
    LERROR << "MorphoSyntacticData of vertex " << vx << " is NULL !";
    return;
  }
  LDEBUG << "process vertex : " << vx << " : " 
    << Common::Misc::limastring2utf8stdstring(token->stringForm());

  MorphoSyntacticData* posdata=new MorphoSyntacticData(*data);
  put(vertex_data,*graph,vx,posdata);
  
  set<LinguisticCode> micros=posdata->allValues(*m_microAccessor);
  LinguisticCode selectedMicro;


  if (micros.size()==0)
  {
    LWARN << "Token " 
      << Common::Misc::limastring2utf8stdstring(token->stringForm()) 
      << " has no possible dicowords ! build a DicoWord with category 0";
    selectedMicro=0;
  }
  else if (micros.size()==1)
  {
    // no choice, put this category
    selectedMicro=*(micros.begin());
    LDEBUG << "GreedyPosTagging : only one choice : " << selectedMicro;
  }
  else
  {
    // choose the most probable dicoWord
    set<LinguisticCode>::iterator dwItr,dwMaxTri,dwMaxBi;
    float maxTri=0;
    float maxBi=0;
    LinguisticCode cat1(0),cat2(0);

    LinguisticGraphInEdgeIt inItr,inItrEnd;
    boost::tie(inItr,inItrEnd)=in_edges(vx,*graph);
    for (;inItr!=inItrEnd;inItr++)
    {
      LinguisticGraphVertex predVx=source(*inItr,*graph);
      MorphoSyntacticData* m2=get(vertex_data,*graph,predVx);
      if (predVx==startVx && m2!=0 && !m2->empty())
      {
        cat2=m_microCatPonctuForte;
      }
      else
      {
        
        cat2=m_microAccessor->readValue(m2->begin()->properties);

        LinguisticGraphInEdgeIt inItr2,inItr2End;
        boost::tie(inItr2,inItr2End)=in_edges(vx,*graph);
        for (;inItr2!=inItr2End;inItr2++)
        {
          LinguisticGraphVertex predpredVx=source(*inItr2,*graph);
          MorphoSyntacticData* m1=get(vertex_data,*graph,predpredVx);
          if (predpredVx==startVx && m1!=0 && !m1->empty())
          {
            cat1=m_microCatPonctuForte;
          }
          else
          {
            cat1=m_microAccessor->readValue(m1->begin()->properties);
          }
          // search better trigram
          for (dwItr=micros.begin();dwItr!=micros.end();dwItr++)
          {
            float p=m_trigramMatrix->freq(cat1,cat2,*dwItr);
            if (p>maxTri)
            {
              maxTri=p;
              dwMaxTri=dwItr;
            }
          }
        }
      }
      if (maxTri==0)
      {
        // no trigram has been found, search bigram
        for (dwItr=micros.begin();dwItr!=micros.end();dwItr++)
        {
          float p=m_bigramMatrix->freq(cat1,*dwItr);
          if (p>maxBi)
          {
            maxBi=p;
            dwMaxBi=dwItr;
          }
        }

      }


    }

    if (maxTri!=0)
    {
      // choose best trigram
      LDEBUG << "found trigram : choose " << *dwMaxTri << " (p=" << maxTri << ")";
      selectedMicro=*dwMaxTri;
    }
    else if (maxBi!=0)
    {
      // choose best bigram
      LDEBUG << "found bigram : choose " << *dwMaxBi << " (p=" << maxBi << ")";
      selectedMicro=*dwMaxBi;
    }
    else
    {
      // no trigram nor bigram has been found
      // choose better probability as source in bigram then as target in bigram
      LWARN << "Found no trigram nor bigram (" << cat1 << "," << cat2 << ") ! try heuristics to find a microcategory";
      for (dwItr=micros.begin();dwItr!=micros.end();dwItr++)
      {
        float p=m_bigramMatrix->freq(m_microCatPonctuForte,*dwItr);
        if (p>maxBi)
        {
          maxBi=p;
          dwMaxBi=dwItr;
        }
      }
      if (maxBi!=0)
      {
        LDEBUG << "found bigram with ponctu forte : choose " << *dwMaxBi <<  " (p=" << maxBi << ")";
        selectedMicro=*dwMaxBi;
      }
      else
      {
        selectedMicro=*(micros.begin());
        LDEBUG << "choose first : " << selectedMicro;
      }
    }
  }
  
  // filter linguisticelement
  CheckDifferentPropertyPredicate cdpp(m_microAccessor,selectedMicro);
  posdata->erase(remove_if(posdata->begin(),posdata->end(),cdpp),posdata->end());
  
}
void generate_cpp_poa_modules_visitor::examine_vertex
  (vertex_descriptor v, modules_tree_type const& modules)
{
  namespace karma = boost::spirit::karma;
  namespace phoenix = boost::phoenix;
  typedef boost::property_map<modules_tree_type, module_property_t>
    ::const_type module_map;
  module_map map = get(module_property_t(), modules);
  module const& m = *boost::get(map, v);
  std::cout << "Module " << m.name << std::endl;
  typedef modules_tree_type::in_edge_iterator in_edge_iterator;

  if(!m.interfaces.empty())
  {

  std::vector<std::string> modules_names;
  {
    vertex_descriptor vx = v;
    module const* mx = &*boost::get(map, vx);
    std::pair<in_edge_iterator, in_edge_iterator> edges;
    while(mx->name != "")
    {
      modules_names.push_back(mx->name);

      edges = in_edges(vx, modules);
      vx = source(*edges.first, modules);
      mx = &*boost::get(map, vx);
    }
  }

  bool prepend_poa = modules_names.empty();
  
  if(!prepend_poa)
  {
    std::string name = "POA_" + modules_names.back();
    open_namespace(state->iterator, name);
  }

  for(std::vector<std::string>::const_reverse_iterator
        first = prepend_poa ? modules_names.rbegin() : boost::next(modules_names.rbegin())
        , last = modules_names.rend()
        ;first != last; ++first)
    open_namespace(state->iterator, *first);

  morbid::idl_compiler::generator::cpp_poa_stub_generator
    <output_iterator_type, parser_iterator_type>
    cpp_poa_stub_generator;
  morbid::idl_compiler::generator::header_local_stub_generator
    <output_iterator_type, parser_iterator_type>
    header_local_stub_generator;

  if(!m.interfaces.empty())
  {
    open_namespace(state->iterator, ""); // anonymous namespace

    for(std::vector<interface_>::const_iterator first = m.interfaces.begin()
          , last = m.interfaces.end(); first != last; ++first)
    {
      std::vector<std::string> base_name(modules_names.rbegin(), modules_names.rend());
      bool r = karma::generate(state->iterator, header_local_stub_generator
                               (phoenix::val(*first)
                                , phoenix::val(base_name))
                               , first->definition);
      if(!r) throw std::runtime_error("Failed generating header_local_stub_generator");
    }

    *state->iterator++ = '}';
    karma::generate(state->iterator, karma::eol);
  }

  for(std::vector<interface_>::const_iterator first = m.interfaces.begin()
        , last = m.interfaces.end(); first != last; ++first)
  {
    bool r = karma::generate(state->iterator, cpp_poa_stub_generator(phoenix::val(*first)
                                                                     , prepend_poa)
                             , first->definition);
    if(!r) throw std::runtime_error("Failed generating header_poa_stub_generator");
  }

  for(std::vector<std::string>::const_reverse_iterator
        first = modules_names.rbegin()
        , last = modules_names.rend()
        ;first != last; ++first)
  {
    *state->iterator++ = '}';
    *state->iterator++ = ' ';
    *state->iterator++ = '/';
    *state->iterator++ = '/';
    state->iterator = std::copy(first->begin(), first->end(), state->iterator);
    karma::generate(state->iterator, karma::eol);
  }
  }
}
Exemplo n.º 23
0
 void const_constraints(const G& g) {
   p = in_edges(v, g);
   n = in_degree(v, g);
   e = *p.first;
 }
Exemplo n.º 24
0
//! init virtual fucntion inheritance
void Classhierarchy::inheritVirtualFunctions()
{
        // prepare LUT for multiple declarations
        //map<SgNode *, set<SgNode *> > multDec;
                
        property_map< dbgType, boost::vertex_classhierarchy_t>::type chMap = boost::get( boost::vertex_classhierarchy, *this );
        graph_traits< dbgType >::vertex_iterator vi,vend;
        tie(vi,vend) = vertices( *this );
        //graph_traits< dbgType >::vertex_descriptor par=*vi, succ=*vi;

        // output info
        for(; vi!=vend; vi++) {
                //cerr << " BCH v i"<< get(vertex_index,*this,*vi)<< " i1" << get(vertex_index1, *this, *vi)<<","<< get(vertex_name, *this, *vi) << endl;
                for( set<SgNode*>::iterator chd= chMap[*vi].defined.begin(); chd!= chMap[*vi].defined.end(); chd++) {
                        SgFunctionDeclaration *funcDec = isSgFunctionDeclaration( *chd );
                        //cerr << " BCH chd " << funcDec->get_mangled_name().str()<< endl; // debug
                        //cerr << " BCH chd " << funcDec->get_mangled_name().str()<< " "<< (int)funcDec->get_type() << endl; // debug
                }
        }

        // search for multiple declarations
        tie(vi,vend) = vertices( *this );
        for(; vi!=vend; vi++) {
                for(set<SgNode*>::iterator chd= chMap[*vi].defined.begin(); chd!= chMap[*vi].defined.end(); chd++) {
                        SgFunctionDeclaration *funcDec = isSgFunctionDeclaration( *chd );
                        bool found = true;
                        while(found) {
                                found = false;
                                for(set<SgNode*>::iterator chdComp = chMap[*vi].defined.begin(); 
                                                (chdComp!= chMap[*vi].defined.end())&&(!found); ) {
                                        SgFunctionDeclaration *compDec = isSgFunctionDeclaration( *chdComp );
                                        if(chdComp != chd) {
                                                //if( compDec->get_type() == funcDec->get_type() ) { // ??? TODO fix type comparison?
                                                if(compareFunctionDeclarations(compDec, funcDec)) {
                                                        //cerr << " BCH REM " << funcDec->get_mangled_name().str()<< " " << compDec->get_mangled_name().str() << endl; // debug
                                                        chMap[*vi].multDeclarations[ funcDec ].insert( compDec );
                                                        found = true;
                                                        chMap[*vi].defined.erase( chdComp ); // should return new iterator in newer STL standard??
                                                        //chVertexData::iterator chdComp2 = (chMap[*vi]).erase( chdComp );
                                                        //chdComp = chdComp2;
                //cerr << " BCH removing i"<< get(vertex_index,*this,*vi)<< " i1" << get(vertex_index1, *this, *vi)<<","<< get(vertex_name, *this, *vi) << endl;
                                                }
                                        }
                                        if(!found) chdComp++;
                                }
                        } // found
                        
                }
                //if( get( vertex_dbg_data,  *this , *vi).get_id() == edges[i].get_sourceId() ) {
                //par = *vi;
                //parFound = true;
                //}
        }


        //typedef std::deque< boostVert > container;
        //cerr << " TOPO START " << endl;
        std::deque< dbgVertex > torder;
        try {
                boost::topological_sort(*this, std::back_inserter(torder));
        } catch(boost::not_a_dag) {
                cerr << "CH -  BOOST ERROR: NOT A DAG!!!!!??? " << endl;
                assert( false );
                return;
        }
        //cerr << " TOPO END " << endl;

        //cerr << " -- " << endl; // debug
        
        for( std::deque< dbgVertex >::iterator vi=torder.begin(); vi!=torder.end(); vi++) {
                dbgVertex srcVert = *vi; // current vertex in the topo order
                //cerr << "XTOPO v i"<< get(vertex_index,*this,*vi)<< " i1" << get(vertex_index1, *this, *vi)<<","<< get(vertex_name, *this, *vi) << endl;

                for(set<SgNode*>::iterator chd= chMap[srcVert].defined.begin(); chd!= chMap[srcVert].defined.end(); chd++) {
                        SgFunctionDeclaration *defMF = isSgFunctionDeclaration( *chd );
                        
                        bool erased = true;
                        while(erased) {
                                erased = false;
                                for(set<SgNode*>::iterator inhd= chMap[srcVert].inherited.begin(); 
                                                inhd!= chMap[srcVert].inherited.end() && (!erased); ) {
                                        SgFunctionDeclaration *inhMF = isSgFunctionDeclaration( *inhd );
                                        if(compareFunctionDeclarations(defMF, inhMF)) {
                                                // own function overrides, so delete old one
                                                chMap[srcVert].inherited.erase( *inhd );
                                                erased = true;
                //cerr << "  TOPO MF:"<< defMF->get_mangled_name().str()<< " overrides MF:"<< inhMF->get_mangled_name().str() << endl; // debug
                                        }
                                        if(!erased) inhd++;
                                }
                        }
                        
                }               
                // add to inherited functions
                for(set<SgNode*>::iterator chd= chMap[srcVert].defined.begin(); chd!= chMap[srcVert].defined.end(); chd++) {
                        chMap[srcVert].inherited.insert( *chd );
                }

                // inherit own methods to child classes
                graph_traits<dbgType>::in_edge_iterator ii,iend;
                tie(ii,iend) = in_edges(*vi, *this);
                for(; ii!=iend; ii++) {
                        //dbgVertex srcVert = source(*ii,*this);
                        // methods inherited from this class to the other one
                        dbgVertex child = source(*ii, *this);
                //cerr << " T inherits to "<< get(vertex_index,*this,child)<< " i1" << get(vertex_index1, *this, child)<<","<< get(vertex_name, *this, child) << endl;
                        //for(set<SgNode*>::iterator chd= chMap[srcVert].defined.begin(); chd!= chMap[srcVert].defined.end(); chd++) {
                        for(set<SgNode*>::iterator chd= chMap[srcVert].inherited.begin(); chd!= chMap[srcVert].inherited.end(); chd++) {
                                SgFunctionDeclaration *inhFunc = isSgFunctionDeclaration( *chd );
                                bool virt = false;
                //cerr << "  TOPO v srch1" << endl;
                                if(inhFunc->isVirtual()) virt = true;
                                // also check multiple declarations
                //cerr << "  TOPO v srch2" << endl;
                                if(!virt) {
                                        for(set<SgNode *>::iterator si=chMap[srcVert].multDeclarations[inhFunc].begin(); 
                                                        si != chMap[srcVert].multDeclarations[inhFunc].end(); si++) {
                                                SgFunctionDeclaration *inhDup = isSgFunctionDeclaration( *si );
                                                if(inhDup->isVirtual()) virt = true;
                //cerr << "  TOPO v srch "<< inhDup->get_mangled_name().str() << endl; // debug
                                        }
                                }
                                        // TODO check virtual inheritance? other declarations?
                                if(virt) {
                                        //cerr << " VIRT " << inhFunc->get_mangled_name().str() << endl; // debug
                                        // and now... ??
                                }
                                chMap[child].inherited.insert( inhFunc );
                        }
                        //cerr << " BOOST v <<< " << get(vertex_index1, *this, boost::target(*ii,*this) )<<","<< get(vertex_name, *this, boost::target(*ii,*this) ) << endl; // debug
                }

        }

        // add own methods to all inherited ones
        for( std::deque< dbgVertex >::iterator vi=torder.begin(); vi!=torder.end(); vi++) {
        }

}
Exemplo n.º 25
0
//! search for all possible (virtual) function calls 
vector<SgMemberFunctionDeclaration*> 
Classhierarchy::searchMemberFunctionCalls(SgMemberFunctionDeclaration* mfCall)
{
        vector<SgMemberFunctionDeclaration*> retvec;
        property_map< dbgType, boost::vertex_classhierarchy_t>::type chMap = boost::get( boost::vertex_classhierarchy, *this );

        SgClassDefinition *classDef  = mfCall->get_scope();
        SgName                                           classname = classDef->get_qualified_name(); // MANGLE
        string                                           cnamestr  = classname.str();
        graph_traits< dbgType >::vertex_iterator vi,vend;
        dbgVertex vdesc = *vi;
        bool foundVertex = false;
        tie(vi,vend) = vertices( *this );
        for(; vi!=vend; vi++) {
                //cerr << " BCH v i"<< get(vertex_index,*this,*vi)<< " i1" << get(vertex_index1, *this, *vi)<<","<< get(vertex_name, *this, *vi) << endl;
                if( get(vertex_dbg_data, *this, *vi).get_typeName() == cnamestr ) {
                        //cerr << " SMF srch "<< cnamestr <<" vi "<< get(vertex_index,*this,*vi)<< " i1" << get(vertex_index1, *this, *vi)<<","<< get(vertex_name, *this, *vi) << endl;
                        vdesc = *vi;
                        foundVertex = true;
                        break;
                }
        }
        if(!foundVertex) { cerr << " SMF srch "<< cnamestr <<" vi "<< get(vertex_index,*this,*vi)<< " i1" << get(vertex_index1, *this, *vi)<<","<< get(vertex_name, *this, *vi) << endl; }
        assert( foundVertex );

        set<dbgVertex> treeset;
        treeset.insert( vdesc );

        // first find "highest" class in CH that still provides this MF
        dbgVertex vhighest = vdesc; // first assume its the current one
        graph_traits<dbgType>::out_edge_iterator oi,oend;
        tie(oi,oend) = out_edges( vdesc, *this);
        for(; oi!=oend; oi++) {
                //cerr << " SMF inherits from "<< get(vertex_index,*this,target(*oi,*this))<< " i1" << get(vertex_index1, *this, target(*oi,*this))<<","<< get(vertex_name, *this, target(*oi,*this)) << endl;
                
                // does any of the base classes implement the member function?
                bool noParentImpl = true; 
                
                // check if this base class also implements MF
                for(set<SgNode*>::iterator chd= chMap[target(*oi,*this)].inherited.begin(); 
                                chd!= chMap[target(*oi,*this)].inherited.end(); chd++) {
                        SgFunctionDeclaration *inhFunc = isSgFunctionDeclaration( *chd );
                        bool virt = false;
                        //cerr << "  TOPO v srch1" << endl;
                        if(inhFunc->isVirtual()) virt = true;
                        if( (virt) && (compareFunctionDeclarations(inhFunc,mfCall)) ) {
                                // remeber for traversal
                                treeset.insert( target(*oi, *this) );
                                noParentImpl = false;
                        }
                }
                if(noParentImpl) {
                        // we found it
                        vhighest = target(*oi, *this);
                        break;
                }
        }
        //cerr << " SMF high "<< cnamestr <<" vi "<< get(vertex_index,*this,vhighest)<< " i1" << get(vertex_index1, *this, vhighest)<<","<< get(vertex_name, *this, vhighest) << endl; 

        // now traverse class hierachy downwards, for all children that implement this function, add to set
        set<dbgVertex> tovisit;
        set<dbgVertex> visited;
        tovisit.insert( vhighest );
        //hier weiter
        while( tovisit.size() > 0 ) {
                dbgVertex currVert = *(tovisit.begin());
                tovisit.erase( currVert );
                visited.insert( currVert );
        //cerr << " SMF visi "<< get(vertex_index,*this,currVert)<< " i1" << get(vertex_index1, *this, currVert)<<","<< get(vertex_name, *this, currVert) << endl; 
                for(set<SgNode*>::iterator chd= chMap[currVert].defined.begin(); chd!= chMap[currVert].defined.end(); chd++) {
                        SgMemberFunctionDeclaration*inhFunc = isSgMemberFunctionDeclaration( *chd );
                        if(compareFunctionDeclarations(inhFunc,mfCall)) {
                                retvec.push_back( inhFunc );
                        }
                }
                graph_traits<dbgType>::in_edge_iterator ii,iend;
                tie(ii,iend) = in_edges( currVert, *this);
                for(; ii!=iend; ii++) {
                        dbgVertex child = source(*ii, *this);
                        // only insert of not already visited
                        set<dbgVertex>::iterator found = visited.find( child );
                        if(found == visited.end()) 
                                tovisit.insert( child );
                }
        }

        //retvec.push_back( mfCall );
        return retvec;
}
void generate_cpp_modules_visitor::examine_vertex
  (vertex_descriptor v, modules_tree_type const& modules)
{
  namespace karma = boost::spirit::karma;
  namespace phoenix = boost::phoenix;
  typedef boost::property_map<modules_tree_type, module_property_t>
    ::const_type module_map;
  module_map map = get(module_property_t(), modules);
  module const& m = *boost::get(map, v);
  std::cout << "Module " << m.name << std::endl;
  typedef modules_tree_type::in_edge_iterator in_edge_iterator;

  if(state->opened_modules.size() < 2)
  {
    if(!state->opened_modules.empty())
      idl_compiler::open_namespace(state->iterator, m.name);
    state->opened_modules.push_back(v);
  }
  else
  {
    std::pair<in_edge_iterator, in_edge_iterator>
      edges = in_edges(v, modules);
    vertex_descriptor b = source(*edges.first, modules);
    assert(boost::distance(edges) == 1);
    if(state->opened_modules.back() == b)
    {
      std::cout << "Should open " << m.name << std::endl;
      idl_compiler::open_namespace(state->iterator, m.name);
      state->opened_modules.push_back(v);
    }
    else
    {
      module const& before = *boost::get(map, b);
      std::cout << "Should close " << before.name << std::endl;

      *state->iterator++ = '}';
      *state->iterator++ = ' ';
      *state->iterator++ = '/';
      *state->iterator++ = '/';
      state->iterator = std::copy(before.name.begin(), before.name.end(), state->iterator);
      karma::generate(state->iterator, karma::eol);

      state->opened_modules.pop_back();

      std::cout << "And then open " << m.name << std::endl;

      idl_compiler::open_namespace(state->iterator, m.name);
      state->opened_modules.push_back(v);
    }
  }

  morbid::idl_compiler::generator::header_remote_stub_generator
    <output_iterator_type, parser_iterator_type>
    header_remote_stub_generator;
  morbid::idl_compiler::generator::cpp_stub_generator
    <output_iterator_type, parser_iterator_type>
    cpp_stub_generator;

  std::vector<std::string> modules_name;
  for(std::vector<vertex_descriptor>::const_iterator
        first = state->opened_modules.begin()
        , last = state->opened_modules.end()
        ;first != last; ++first)
  {
    module const* mx = &*boost::get(map, *first);
    modules_name.push_back(mx->name);
  }

  if (!m.interfaces.empty())
  {
    
    open_namespace(state->iterator, ""); // anonymous namespace

    for(std::vector<interface_>::const_iterator first = m.interfaces.begin()
          , last = m.interfaces.end(); first != last; ++first)
    {
      std::vector<std::string> base_name(modules_name);
      base_name.push_back(first->definition.name);
      bool r = karma::generate(state->iterator, header_remote_stub_generator
                               (phoenix::val(*first), phoenix::ref(base_name))
                               , first->definition);
      if(!r) throw std::runtime_error("Failed generating header_remote_stub_generator");
    }

    *state->iterator++ = '}';
    karma::generate(state->iterator, karma::eol);
  }

  for(std::vector<interface_>::const_iterator first = m.interfaces.begin()
        , last = m.interfaces.end(); first != last; ++first)
  {
    std::vector<std::string> base_name(boost::next(modules_name.begin()), modules_name.end());
    base_name.push_back(first->definition.name);
    bool r = karma::generate(state->iterator, cpp_stub_generator(phoenix::val(*first), phoenix::ref(base_name))
                             , first->definition);
    if(!r) throw std::runtime_error("Failed generating header_stub_generator");
  }

}
Exemplo n.º 27
0
void BBSISPOptimizerJP::generateBBRecords(void)
{
	cfgVertexIter vp;
	cfgOutEdgeIter epo;
	cfgInEdgeIter epi;
	CFGVertex v;
	CFGEdge e;

	// group bb_address, wcet activation count  (represented by the flow value of the in_edges) and cost (isp/SDRAM) (represented as the costs of the out_edges)


	// cycle all nodes and get properties from every bb
	for (vp = vertices(cfg); vp.first != vp.second; ++vp.first)
	{
		v = *vp.first;
//		LOG_DEBUG(logger, "Checking node: " <<  (get(startAddrStringNProp, v)).c_str() << " 0x" << hex << get(startAddrNProp, v) << " type: " << get(nodeTypeNProp, v));
		if(get(nodeTypeNProp, v) == BasicBlock)
		{
			bb_record_t tmp;

			// set assignment variable id (needed for ilp generation)
			tmp.id = v;

			// get address
			tmp.address = get(startAddrNProp, v);

			// get size
			tmp.size = get(bbSizeNProp, v);

			tmp.benefit = 0;


			uint32_t total_edge_activation=0;

#ifdef BB_COST_DO_NOT_DEPEND_ON_BB_EXIT
			uint32_t offchip_cost = 0;
			uint32_t onchip_cost = 0;
			uint32_t cur_cost = 0;
			for(epo = out_edges(v, cfg); epo.first != epo.second; ++epo.first) 
			{
				e = *epo.first;
				uint32_t cost = get(costEProp, e);
				uint32_t mem_penalty = get(memPenaltyEProp, e);
//				LOG_DEBUG(logger, "cost: " << cost << " mem_penalty: " << mem_penalty);
				if(cur_cost == 0)
				{
					cur_cost = cost + mem_penalty;
				}
				else
				{
					// all out edges from one basic block have the same cost (because the cost of the bb is assigned to it's out edges)
					assert(cur_cost == cost + mem_penalty);
				}

				cost = get(costOffChipEProp, e);
				if(offchip_cost == 0)
				{
					offchip_cost = cost;
				}
				else
				{
					// all out edges from one basic block have the same cost (because the cost of the bb is assigned to it's out edges)
					assert(offchip_cost == cost);
				}

				cost = get(costOnChipEProp, e);
				if(onchip_cost == 0)
				{
					onchip_cost = cost;
				}
				else
				{
					// all out edges from one basic block have the same cost (because the cost of the bb is assigned to it's out edges)
					assert(onchip_cost == cost);
				}
			}

			// get the activation count for the wcet critical path
			for(epi = in_edges(v, cfg); epi.first != epi.second; ++epi.first)
			{
				e = *epi.first;
				total_edge_activation += get(actEProp, e);
			}

			switch((analysis_metric_t) conf->getUint(CONF_USE_METRIC))
			{
				case WCET_RATIO_FILES:
				case WCET:
					{
						tmp.benefit = (cur_cost - onchip_cost) * total_edge_activation;
						break;
					}
				case MDIC:
					{
						tmp.benefit = cur_cost * total_edge_activation;
						break;
					}
				case MPL:
					{
						tmp.benefit = cur_cost;
					}
				default:
					{
						assert(false);
					}
			}
#else
			for(epo = out_edges(v, cfg); epo.first != epo.second; ++epo.first) 
			{
				e = *epo.first;
				uint32_t cost = get(costEProp, e);
				uint32_t mem_penalty = get(memPenaltyEProp, e);
				uint32_t edge_activation = get(actEProp, e);
				uint32_t offchip_cost = get(costOffChipEProp, e);
				uint32_t onchip_cost = get(costOnChipEProp, e);
				uint32_t cur_cost = cost + mem_penalty;


				LOG_DEBUG(logger, "node: " << "0x" << hex << tmp.address << dec << " cost: " << cost << " mem_penalty: " << mem_penalty << " activation: " << edge_activation);

				// only get the cost of the activated edges (the edge that is on the WCP)
				if(edge_activation != 0)
				{
					switch((analysis_metric_t) conf->getUint(CONF_USE_METRIC))
					{
						case WCET_RATIO_FILES:
						case WCET:
							{
								assert(cur_cost == offchip_cost);
								assert(mem_penalty == offchip_cost - onchip_cost);
								tmp.benefit += (mem_penalty) * edge_activation;
								break;
							}
						case MDIC:
							{
								tmp.benefit += cur_cost * edge_activation;
								break;
							}
						case MPL:
						default:
							{
								assert(false);
							}
					}
				}
			}

#endif


			LOG_DEBUG(logger, "Creating bb_record: a" << tmp.id << " addr: 0x" << hex << tmp.address << " Size: " << dec << tmp.size << " activation_count: " << total_edge_activation << " benefit: " << tmp.benefit);

			bb_data.push_back(tmp);

			registerNodeIdMapping(v, tmp.id);

			registerBlockLastInstrDisplacement(tmp.address, get(bbCodeNProp, v));
		}
	}

}
Exemplo n.º 28
0
LimaStatusCode GreedyPosTagger::process(
  AnalysisContent& analysis) const
{

  // start postagging here !
  TimeUtils::updateCurrentTime();
  PTLOGINIT;
  LINFO << "start greedy posTagging";

  AnalysisGraph* anagraph=static_cast<AnalysisGraph*>(analysis.getData("AnalysisGraph"));
  
  AnalysisGraph* posgraph=new AnalysisGraph("PosGraph",m_language,false,true,*anagraph);

  // walk on the vertex but don't process a vertex if one
  // of its predecessor hasn't been processed.
  LinguisticGraph* graph=posgraph->getGraph();
  LinguisticGraphVertex endVx=posgraph->lastVertex();

  map<LinguisticGraphVertex,uint64_t> processed;
  set<LinguisticGraphVertex> toProcess;
  toProcess.insert(anagraph->firstVertex());
  set<LinguisticGraphVertex> nextToProcess;
  set<LinguisticGraphVertex>::iterator toProcessItr;
  map<LinguisticGraphVertex,uint64_t>::iterator processedItr;
  LinguisticGraphInEdgeIt inItr,inItrEnd;
  LinguisticGraphOutEdgeIt outItr,outItrEnd;

  while (toProcess.size()!=0)
  {

    //cout << "toProcess is ";
    //        copy(toProcess.begin(),toProcess.end(),ostream_iterator<LinguisticGraphVertex>(cout,","));
    //        cout << endl;

    for (toProcessItr=toProcess.begin();
         toProcessItr!=toProcess.end();
         toProcessItr++)
    {

      // process vertex
      processVertex(*toProcessItr,anagraph);
      processed.insert(make_pair(*toProcessItr,out_degree(*toProcessItr,*graph)));
      //cerr << "processed : insert " << *toProcessItr << " with " << out_degree(*toProcessItr,*graph) << endl;

      // remove processed if necessary
      boost::tie(inItr,inItrEnd)=in_edges(*toProcessItr,*graph);
      for (;inItr!=inItrEnd;inItr++)
      {
        processedItr=processed.find(source(*inItr,*graph));
        processedItr->second--;
        //cerr << "processed : vertex " << processedItr->first << " decremented to " << processedItr->second << endl;
        if (processedItr->second==0)
        {
          //cerr << "processed : remove " << processedItr->first << endl;
          processed.erase(processedItr);
        }
      }

      // check and add nex vertex to process
      boost::tie(outItr,outItrEnd)=out_edges(*toProcessItr,*graph);
      for (;outItr!=outItrEnd;outItr++)
      {
        LinguisticGraphVertex next=target(*outItr,*graph);
        if (next==endVx)
        {
          continue;
        }
        // check if all in vertices have been processed
        boost::tie(inItr,inItrEnd)=in_edges(next,*graph);
        bool ok=true;
        for (;inItr!=inItrEnd;inItr++)
        {
          if (processed.find(source(*inItr,*graph))==processed.end())
          {
            ok=false;
            break;
          }
        }
        if (ok)
        {
          nextToProcess.insert(next);
        }
      }

    }

    toProcess.clear();
    toProcess.swap(nextToProcess);

  }

  TimeUtils::logElapsedTime("GreedyPosTagger");
  return SUCCESS_ID;
}
    std::vector<Solution> HeuristicsSolver::solve_fast_backward() const {
        std::vector<Solution> sols;
        auto h1 = g->get_source_vertex().second;
        auto h2 = g->get_sink_vertex().second;
        struct EdgeWithCost {
            Edge e;
            double c;
            double rc;
        };

        for(int i = 0; i < prob->params.greedy_reruns; i++) {
            auto current = h2;
            Path path;
            auto tot_c = 0.0f, tot_rc = 0.0f;
            auto done = false;

            while(current != h1) {
                std::vector<EdgeWithCost> in_e;

                for(auto ep = in_edges(current, g->graph); ep.first != ep.second; ++ep.first) {
                    auto v_orig = source(*ep.first, g->graph);

                    if(erased.find(v_orig) != erased.end() &&
                       erased.at(v_orig).find(*ep.first) != erased.at(v_orig).end()) { continue; }

                    auto n_orig = *g->graph[v_orig];
                    auto dual = g->dual_of(n_orig);
                    EdgeWithCost ewc = {*ep.first, g->graph[*ep.first]->cost, g->graph[*ep.first]->cost - dual};

                    auto closes_cycle = false;
                    for(const auto &e : path) {
                        if(n_orig.n_type == NodeType::REGULAR_PORT &&
                           n_orig.port == g->graph[target(e, g->graph)]->port) {
                            closes_cycle = true;
                            break;
                        }
                    }

                    if(!closes_cycle) {
                        in_e.push_back(ewc);
                    }
                }

                if(in_e.size() == 0) {
                    break;
                }

                std::sort(in_e.begin(), in_e.end(),
                          [this](const auto &ewc1, const auto &ewc2) {
                              return (ewc1.rc > ewc2.rc);
                          });

                auto rnd_idx = (int) (rand() % (std::min(prob->params.greedy_max_outarcs, (int) in_e.size())));
                auto chosen = in_e[rnd_idx];

                path.push_back(chosen.e);
                tot_c += chosen.c;
                tot_rc += chosen.rc;

                current = source(chosen.e, g->graph);

                if(current == h1) {
                    done = true;
                }
            }

            if(done) {
                sols.push_back(Solution(path, tot_c, tot_rc, g->vessel_class, g));
            }
        }

        return sols;
    }
Exemplo n.º 30
0
uint32_t BBSISPOptimizerWCP::generateOptimalILPFormulationForSequentialCode(CFGVertex start, CFGVertex end, uint32_t running_id, vector<CFGEdge>& leavingEdges)
{
	vector<CFGVertex> processing;
	vector<CFGVertex> processed;

	processing.push_back(start);

	cfgOutEdgeIter ep;

	LOG_DEBUG(logger, "Processing from: " << start  << " [" << get(startAddrStringNProp, start) << "]" << " to " << end << " [" << get(startAddrStringNProp, end) << "]" << ".");

	while(processing.size() != 0)
	{
		if(logger->isDebugEnabled())
		{
			ostringstream s;
			for(uint32_t i = 0; i < processing.size(); i++)
			{
				s << "(" << processing[i] << ")";
			}
			LOG_DEBUG(logger, "Size of processing list: " << processing.size() << " contains:" << s.str());
		}

		CFGVertex actual_cfg = processing.back();
		processing.pop_back();

		LOG_DEBUG(logger, "Processing " << actual_cfg << " " << get(startAddrStringNProp, actual_cfg));

		// ensure that each node is only handled once.
		bool node_already_processed = false;
		for(uint32_t j = 0; j<processed.size(); j++)
		{
			if(actual_cfg == processed[j])
			{
				node_already_processed = true;
			}
		}
		if(!node_already_processed)
		{
			if(actual_cfg != end)
			{
				if(get(nodeTypeNProp, actual_cfg) == CallPoint)
				{
					// create virtual node for function
					CFGVertex v;
					uint32_t function_id = running_id;
					CFGVertex cfg_return_point = actual_cfg; // to temporally initialize the vertex
					cfgVertexIter vp;
					bool found_return = false;
					// find the right return point for the call point
					uint32_t context_addr = get(endAddrNProp, actual_cfg);
					for (vp = vertices(cfg); (vp.first != vp.second)&&(!found_return); ++vp.first)
					{
						v = *vp.first;
						if((get(nodeTypeNProp, v) == ReturnPoint) && (context_addr == get(endAddrNProp, v)))
						{
							found_return = true;
							cfg_return_point = v;
						}
					}
					assert(found_return);


					stringstream cfg_ilp;

					assert(out_degree(actual_cfg, cfg) == 1);
					cfgOutEdgeIter eop = out_edges(actual_cfg, cfg);
					CFGVertex function_entry_cfg = target(*eop.first, cfg);
					assert(in_degree(cfg_return_point, cfg) == 1);
					cfgInEdgeIter eip = in_edges(cfg_return_point, cfg);
					CFGVertex function_exit_cfg = source(*eip.first, cfg);

					FunctionMap::iterator pos = functionMap.find(function_entry_cfg);

					if(pos == functionMap.end())
					{
						vector<CFGEdge> function_leaving_edges;
						// create ilp for the function body
						running_id = generateOptimalILPFormulationForSequentialCode(function_entry_cfg, function_exit_cfg, ++running_id, function_leaving_edges);
						LOG_DEBUG(logger, "Returned from function to processing from: " << start << " to " << end << ".");
						assert(function_leaving_edges.empty());
						
						FunctionMap::iterator ins_pos;
						bool ins_bool;
						tie(ins_pos, ins_bool) = functionMap.insert(make_pair(function_entry_cfg, function_id));
						assert(ins_bool);
						// create cost for the function with function_id
						cfg_ilp << "cf" << function_id << " = " << " w" << function_entry_cfg  << ";" << endl;

					}
					else
					{
						function_id = pos->second;
					}
					// connect call point with virtual function node wfXctxY
					cfg_ilp << "w" << actual_cfg << " >= wf" << function_id << "c" << hex << context_addr << dec << getPenaltyForFunctionEntering(actual_cfg, function_entry_cfg) << ";" << endl;
					// connect virtual function node with return point, and taking cost of function into account
					// NOTICE the cost of the function exit node (which is an Exit node) to the node to which it is returned (which is an ReturnPoint node) does not need to be considered, because it is free of cost.
					cfg_ilp << "wf" << function_id << "c" << hex << context_addr << dec <<  " >= w" << cfg_return_point << " + cf" << function_id << getPenaltyForFunctionExit(cfg_return_point, function_exit_cfg) << ";" << endl;

					cfg_ilps.push_back(cfg_ilp.str());
					processing.push_back(cfg_return_point);

				}
				else
				{
					for(ep = out_edges(actual_cfg, cfg); ep.first != ep.second; ++ep.first) 
					{
						bool found_loop_head = false;
						uint32_t loop_id = running_id;
						vector<CFGVertex> loop_exits;
						vector<CFGEdge> irregular_loop_exit_edges;
						CFGEdge eo = *ep.first;
						CFGEdge back_edge;
						CFGVertex target_cfg = target(eo, cfg);

						edge_type_t etype = get(edgeTypeEProp, eo);
						if((etype == ForwardStep) || (etype == ForwardJump) || (etype == Meta))
						{

							LOG_DEBUG(logger, "Checking out-edges From: " << actual_cfg << " " << get(startAddrStringNProp, actual_cfg) << " To: " << target_cfg << " " << get(startAddrStringNProp, target_cfg) << " Type: " << etype << " Edge " << eo);

							LoopDataMap::iterator pos = loopMap.find(target_cfg);
							if(pos != loopMap.end())
							{
								if((target_cfg != start) &&  (pos->second.exitNode != end))
								{
									LOG_DEBUG(logger, "Target of out edge " <<  eo << ". " << target_cfg << " is a loop head. Backedge is: " <<  pos->second.backEdge << " exit node is: " <<  pos->second.exitNode);

									loop_exits.push_back(pos->second.exitNode);
									found_loop_head = true;

									stringstream cfg_ilp;
									int32_t loop_bound = getLoopBoundForLoopHead(target_cfg, pos->second.backEdge);
									cfg_ilp << "cl" << loop_id << " = " << loop_bound+1 /* the value from the flow facts determines the number of invocations of the back_edge, i.e. the number of times the loop is entered  */ << " w" << pos->second.startNode;
									if(get(nodeTypeNProp, pos->second.exitNode) == BasicBlock)
									{
										// charge the cost of the loop conserving edge, i.e. of the bottom node of the loop body
										// The cost of this basic block for the loop exiting edge is charged, on connection of the virtual loop node with the code after the loop (see calculation of wlXX and the usage of the variable loop_exits).
										if(!conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION))
										{
											cfg_ilp << " + " << loop_bound << " ce" << source(pos->second.backEdge,cfg) << "t" << target(pos->second.backEdge, cfg);
										}
										else // conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION)
										{
											cfg_ilp << " + " << getEdgeCostConstraint(pos->second.backEdge, loop_bound);
										}
									}
									else
									{
										assert(false); // could there be a loop with a non basic block node at the end??
									}

									cfg_ilp << ";" << endl;
									cfg_ilps.push_back(cfg_ilp.str());

									// create ilp for the loop body
									running_id = generateOptimalILPFormulationForSequentialCode(pos->second.startNode, pos->second.exitNode, ++running_id, irregular_loop_exit_edges);
									LOG_DEBUG(logger, "Returned loop to processing from: " << start << " to " << end << ".");
								}
							}

							stringstream cfg_ilp;

							if(!found_loop_head)
							{
								bool is_on_path = isNodeOnPath(target_cfg, start, end, false);
								LOG_DEBUG(logger, "Successor of actual node " << actual_cfg << " " << get(startAddrStringNProp, actual_cfg) << " (edge: " << eo << ") is no loop head. The node is " << ((!is_on_path)?("not "):("")) << "within the sequential code part");
								cfg_ilp << "w" << actual_cfg << " >= ";
								if(is_on_path)
								{
									cfg_ilp << "w" << target_cfg;
								}
								if(get(nodeTypeNProp, actual_cfg) == BasicBlock)
								{
									if(is_on_path)
									{
										cfg_ilp << " + ";
									}

									if(!conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION))
									{
										cfg_ilp << "ce" << source(eo,cfg) << "t" << target(eo, cfg);
									}
									else // conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION)
									{
										cfg_ilp << getEdgeCostConstraint(eo);
									}
								}


								cfg_ilp << ";" << endl;

								cfg_ilps.push_back(cfg_ilp.str());
								
								// checking if target node is within loop body
								if(is_on_path)
								{
									LOG_DEBUG(logger, "Pushing " << target_cfg << " " << get(startAddrStringNProp, target_cfg) << " to process list");
									processing.push_back(target_cfg);
								}
								else
								{
									LOG_DEBUG(logger, "Node " << target_cfg << " " << get(startAddrStringNProp, target_cfg) << " is not within currently processing code part (function or loop body), cannot add to process list.");
									leavingEdges.push_back(eo);
								}

							}
							else
							{
								LOG_DEBUG(logger, "Successor of actual node " << actual_cfg << " " << get(startAddrStringNProp, actual_cfg) << " (edge: " << eo << ") is loop head");
								cfg_ilp << "w" << actual_cfg << " >= wl" << loop_id;
								if(get(nodeTypeNProp, actual_cfg) == BasicBlock)
								{
									if(!conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION))
									{
										cfg_ilp << " + ce" << source(eo,cfg) << "t" << target(eo, cfg);
									}
									else // conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION)
									{
										cfg_ilp << " + " << getEdgeCostConstraint(eo);
									}
								}
								cfg_ilp << ";" <<  endl;
								cfg_ilps.push_back(cfg_ilp.str());

								for(uint32_t i = 0; i < loop_exits.size(); i++)
								{
									LOG_DEBUG(logger, "Loop exit nodes are: " << loop_exits[i]);
									for(cfgOutEdgeIter ep2 = out_edges(loop_exits[i], cfg); ep2.first != ep2.second; ++ep2.first) 
									{
										CFGEdge el = *ep2.first;
										CFGVertex post_loop_node = target(el, cfg);

										edge_type_t etype = get(edgeTypeEProp, el);
										if((etype == ForwardStep) || (etype == ForwardJump) || (etype == Meta))
										{
											stringstream tmp;
											// the wcet of the loop is the wcet of the following node + the cost of the loop + the cost of the loop out edge

											if(!conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION))
											{
												tmp << "wl" << loop_id << " >= w" << post_loop_node <<  " + cl" << loop_id << " + ce" << source(el,cfg) << "t" << target(el, cfg) << ";" << endl;
											}
											else // conf->getBool(CONF_BBSISP_WCP_SHRINK_ILP_FORMULATION)
											{
												tmp << "wl" << loop_id << " >= w" << post_loop_node <<  " + cl" << loop_id << " + " << getEdgeCostConstraint(el) << ";" << endl;
											}

											cfg_ilps.push_back(tmp.str());

											// checking if target node is within loop body
											if(isNodeOnPath(target_cfg, start, end, false))
											{
												LOG_DEBUG(logger, "Pushing post loop node " << post_loop_node << " " << get(startAddrStringNProp, post_loop_node) << " to process list");
												processing.push_back(post_loop_node);
											}
											else
											{
												LOG_DEBUG(logger, "Post loop node " << target_cfg << " " << get(startAddrStringNProp, target_cfg) << " is not on path, cannot add to process list.");
												leavingEdges.push_back(eo);
												assert(false);
											}
										}
									}

								}
								for(uint32_t i = 0; i < irregular_loop_exit_edges.size(); i++)
								{
									CFGEdge e = irregular_loop_exit_edges[i];
									LOG_DEBUG(logger, "Irregular loop exit edge: " << e);
									// checking if the target of the loop leaving edge can be found whithin the currently activw loop body
									if(isNodeOnPath(target(e, cfg), start, end, false))
									{

										stringstream tmp;
										// If a loop is unexpectively left by an edge e, the target of e may be reached by the loop body (in the worst case at the end of the loop, since the structure of the loop is hidden by the cost of the loop (clXX).
										// The cost of the irregular loop exit edge does not need to be charged here, because it is implicitely already in the cost of the loop (which is maximizes over all possible paths, including the dead end of an irregular leaving edge.
										tmp << "wl" << loop_id << " >= w" << target(e, cfg) <<  " + cl" << loop_id << ";" << endl; 
										cfg_ilps.push_back(tmp.str());
									}
									else
									{
										// The irregular loop leaving edge leaves multiple levels of loop nests. Delegate handling to next loop level.
										leavingEdges.push_back(e);
										assert(false);
									}
								}


							}

						}
					}
				}
			}
			else
			{
				LOG_DEBUG(logger, "Found end node");

				stringstream cfg_ilp;

				// The cost of the loop conserving edge (the bottom basic block) is charged in the loop cost variable: clXX = loop_bound+1 * wLoopHead + ceLoopConservingEdgeXX
				// This is because the loop body is ececuted loop_bound+1, whereas the cost of the loop conserving edge needs to be taken only loop_bound times into account, because the last iteration of the loop uses another edge, which is charged in wlXX >= wYY + clXX + ceExitEdgeOfLoopXX
				cfg_ilp << "w" << actual_cfg << " = 0;" << endl;

				cfg_ilps.push_back(cfg_ilp.str());
			}
			processed.push_back(actual_cfg);
		}
	}
	return running_id;

}