当前位置: 首页>>代码示例>>C++>>正文


C++ Enode::getCar方法代码示例

本文整理汇总了C++中Enode::getCar方法的典型用法代码示例。如果您正苦于以下问题:C++ Enode::getCar方法的具体用法?C++ Enode::getCar怎么用?C++ Enode::getCar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Enode的用法示例。


在下文中一共展示了Enode::getCar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: display

ostream& display(ostream& out, box const & b, bool const exact, bool const old_style) {
    std::streamsize ss = out.precision();
    out.precision(16);
    if (old_style) {
        out << "delta-sat with the following box:" << endl;
        unsigned const s = b.size();
        for (unsigned i = 0; i < s; i++) {
            Enode * e = b.m_vars[i];
            string const & name = e->getCar()->getName();
            ibex::Interval const & v = b.m_values[i];
            out << "\t" << name << " : " << v;
            if (i != (s - 1)) {
                out << ";";
            }
            out << endl;
        }
    } else {
        unsigned const s = b.size();
        for (unsigned i = 0; i < s; i++) {
            Enode * e = b.m_vars[i];
            ibex::Interval const & v = b.m_values[i];
            ibex::Interval const & d = b.m_domains[i];
            out << e->getCar()->getName()
                << " : ";
            display(out, d, exact);
            out << " = ";
            display(out, v, exact);
            out << endl;
        }
    }
    out.precision(ss);
    return out;
}
开发者ID:kquine,项目名称:dreal3,代码行数:33,代码来源:box.cpp

示例2: expEnqueueArguments

void Egraph::expEnqueueArguments( Enode * x, Enode * y )
{
    assert( x->isTerm( ) );
    assert( y->isTerm( ) );
    assert( x->getArity( ) == y->getArity( ) );
    // No explanation needed if they are the same
    if ( x == y )
        return;

    // Simple explanation if they are arity 0 terms
    if ( x->getArity( ) == 0 )
    {
        exp_pending.push_back( x );
        exp_pending.push_back( y );
        return;
    }
    // Otherwise they are the same function symbol
    // Recursively enqueue the explanations for the args
    assert( x->getCar( ) == y->getCar( ) );
    Enode * xptr = x->getCdr( );
    Enode * yptr = y->getCdr( );
    while ( !xptr->isEnil( ) )
    {
        exp_pending.push_back( xptr->getCar( ) );
        exp_pending.push_back( yptr->getCar( ) );
        xptr = xptr->getCdr( );
        yptr = yptr->getCdr( );
    }
    // Check both lists have the same length
    assert( yptr->isEnil( ) );
}
开发者ID:patere,项目名称:dReal,代码行数:31,代码来源:EgraphExplain.C

示例3: extract_invariants

IVector ode_solver::extract_invariants() {
    map<Enode*, pair<double, double>> inv_map;
    for (auto inv : m_invs) {
        Enode * p = inv->getCdr()->getCdr()->getCdr()->getCdr()->getCar();
        Enode * op = p->getCar();
        bool pos = true;

        // Handle Negation
        if (op->getId() == ENODE_ID_NOT) {
            p = p->getCdr()->getCar();
            op = p->getCar();
            pos = false;
        }
        switch (op->getId()) {
        case ENODE_ID_GEQ:
        case ENODE_ID_GT:
            // Handle >= & >
            pos = !pos;
        case ENODE_ID_LEQ:
        case ENODE_ID_LT: {
            // Handle <= & <
            Enode * lhs = pos ? p->getCdr()->getCar() : p->getCdr()->getCdr()->getCar();
            Enode * rhs = pos ? p->getCdr()->getCdr()->getCar() : p->getCdr()->getCar();
            if (lhs->isVar() && rhs->isConstant()) {
                if (inv_map.find(lhs) != inv_map.end()) {
                    inv_map[lhs].second = rhs->getValue();
                } else {
                    inv_map.emplace(lhs, make_pair(lhs->getLowerBound(), rhs->getValue()));
                }
            } else if (lhs->isConstant() && rhs->isVar()) {
                if (inv_map.find(rhs) != inv_map.end()) {
                    inv_map[rhs].first = lhs->getValue();
                } else {
                    inv_map.emplace(rhs, make_pair(lhs->getValue(), rhs->getUpperBound()));
                }
            } else {
                cerr << "ode_solver::extract_invariant: error:" << p << endl;
            }
        }
            break;
        default:
            cerr << "ode_solver::extract_invariant: error" << p << endl;
        }
    }
    IVector ret (m_t_vars.size());
    unsigned i = 0;
    for (auto const & m_t_var : m_t_vars) {
        if (inv_map.find(m_t_var) != inv_map.end()) {
            auto inv = interval(inv_map[m_t_var].first, inv_map[m_t_var].second);
            DREAL_LOG_INFO << "Invariant extracted from  " << m_t_var << " = " << inv;
            ret[i++] = inv;
        } else {
            auto inv = interval(m_t_var->getLowerBound(), m_t_var->getUpperBound());
            DREAL_LOG_INFO << "Default Invariant set for " << m_t_var << " = " << inv;
            ret[i++] = inv;
        }
    }
    return ret;
}
开发者ID:rachelwang,项目名称:dreal,代码行数:59,代码来源:ode_solver.cpp

示例4: assert

//
// Merge collected arguments for nodes
//
Enode * Cnfizer::mergeEnodeArgs( Enode * e
                               , map< enodeid_t, Enode * > & cache
                               , map< enodeid_t, int > & enodeid_to_incoming_edges )
{
  assert( e->isAnd( ) || e->isOr( ) );

  Enode * e_symb = e->getCar( );
  vector< Enode * > new_args;

  for ( Enode * list = e->getCdr( ) ;
        !list->isEnil( ) ;
        list = list->getCdr( ) )
  {
    Enode * arg = list->getCar( );
    Enode * sub_arg = cache[ arg->getId( ) ];
    Enode * sym = arg->getCar( );

    if ( sym->getId( ) != e_symb->getId( ) )
    {
      new_args.push_back( sub_arg );
      continue;
    }

    assert( enodeid_to_incoming_edges.find( arg->getId( ) ) != enodeid_to_incoming_edges.end( ) );
    assert( enodeid_to_incoming_edges[ arg->getId( ) ] >= 1 );

    if ( enodeid_to_incoming_edges[ arg->getId( ) ] > 1 )
    {
      new_args.push_back( sub_arg );
      continue;
    }

    for ( Enode * sub_arg_list = sub_arg->getCdr( ) ;
          !sub_arg_list->isEnil( ) ;
          sub_arg_list = sub_arg_list->getCdr( ) )
      new_args.push_back( sub_arg_list->getCar( ) );
  }

  Enode * new_list = const_cast< Enode * >(egraph.enil);

  while ( !new_args.empty( ) )
  {
    new_list = egraph.cons( new_args.back( ), new_list );
    new_args.pop_back( );
  }

  return egraph.cons( e_symb, new_list );
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:51,代码来源:Cnfizer.C

示例5: checkClause

//
// Check if a formula is a clause
//
bool Cnfizer::checkClause( Enode * e, set< enodeid_t > & check_cache )
{
  assert( e );

  if ( e->isLit( ) )
  {
    check_cache.insert( e->getId( ) );                           // Don't check again
    return true;
  }

  if ( !e->isOr( ) )
    return false;

  if ( check_cache.find( e->getId( ) ) != check_cache.end( ) )   // Already visited term
    return true;

  bool is_clause = true;
  for ( Enode * list = e->getCdr( ) ;
        list != egraph.enil && is_clause ;
        list = list->getCdr( ) )
    is_clause = checkClause( list->getCar( ), check_cache );

  if ( !is_clause )
    return false;

  check_cache.insert( e->getId( ) );                             // Don't check again

  return true;
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:32,代码来源:Cnfizer.C

示例6: checkPureConj

//
// Check if its a pure conjunction of literals
//
bool Cnfizer::checkPureConj( Enode * e, set< enodeid_t > & check_cache )
{
  if ( check_cache.find( e->getId( ) ) != check_cache.end( ) )
    return true;

  if ( e->isLit( ) )
  {
    check_cache.insert( e->getId( ) );
    return true;
  }

  if ( !e->isAnd( ) )
    return false;

  bool is_pure_conj = true;
  for ( Enode * list = e->getCdr( ) ;
        list != egraph.enil && is_pure_conj ;
        list = list->getCdr( ) )
    is_pure_conj = checkPureConj( list->getCar( ), check_cache );

  if ( !is_pure_conj )
   return false;

  check_cache.insert( e->getId( ) );

  return true;
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:30,代码来源:Cnfizer.C

示例7: expExplainAlongPath

//
// Subroutine of explain
// A step of explanation for x and y
//
void Egraph::expExplainAlongPath ( Enode * x, Enode * y )
{
    Enode * v  = expHighestNode( x );
    Enode * to = expHighestNode( y );

    while ( v != to )
    {
        Enode * p = v->getExpParent( );
        assert( p != NULL );
        Enode * r = v->getExpReason( );

        // If it is not a congruence edge
        if ( r != NULL )
        {
            if ( !isDup1( r ) )
            {
                assert( r->isTerm( ) );
                explanation.push_back( r );
                storeDup1( r );
            }
        }
        // Otherwise it is a congruence edge
        // This means that the edge is linking nodes
        // like (v)f(a1,...,an) (p)f(b1,...,bn), and that
        // a1,...,an = b1,...bn. For each pair ai,bi
        // we have therefore to compute the reasons
        else
        {
            assert( v->getCar( ) == p->getCar( ) );
            assert( v->getArity( ) == p->getArity( ) );
            expEnqueueArguments( v, p );
        }

#ifdef PRODUCE_PROOF
        if ( config.produce_inter > 0
                && config.logic != QF_AX )
        {
            cgraph.addCNode( v );
            cgraph.addCNode( p );
            cgraph.addCEdge( v, p, r );
        }
#endif

        expUnion( v, p );
        v = expHighestNode( p );
    }
}
开发者ID:patere,项目名称:dReal,代码行数:51,代码来源:EgraphExplain.C

示例8: retrieveTopLevelFormulae

//
// Retrieve the formulae at the top-level
//
void Cnfizer::retrieveTopLevelFormulae( Enode * f, vector< Enode * > & top_level_formulae )
{
  if ( f->isAnd( ) )
    for ( Enode * list = f->getCdr( ) ;
          list != egraph.enil ;
          list = list->getCdr( ) )
      retrieveTopLevelFormulae( list->getCar( ), top_level_formulae );
  else
    top_level_formulae.push_back( f );
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:13,代码来源:Cnfizer.C

示例9: printExtModel

void CoreSMTSolver::printExtModel( ostream & out )
{
  for (Var v = 2; v < model.size(); v++)
  {
    Enode * e = theory_handler->varToEnode( v );
    int tmp1, tmp2;
    if( sscanf( (e->getCar( )->getName( )).c_str( ), CNF_STR, &tmp1, &tmp2 ) != 1 )
      if ( model[ v ] != l_Undef )
        out << ( model[ v ] == l_True ? "" : "(not " ) << e << ( model[ v ] == l_True ? "" : ")" ) << endl;
  }
}
开发者ID:dpsanders,项目名称:dreal3-1,代码行数:11,代码来源:Debug.C

示例10: opensmt_define_ode

void opensmt_define_ode( opensmt_context c, const char * flowname, opensmt_expr * vars, opensmt_expr * rhses, unsigned n)
{
  assert( c );
  OpenSMTContext * c_ = static_cast< OpenSMTContext * >( c );
  OpenSMTContext & context = *c_;
  vector<pair<string, Enode *> *> odes;
  for (unsigned i = 0; i < n; i++) {
      Enode * var = static_cast<Enode *>(vars[i]);
      Enode * rhs = static_cast<Enode *>(rhses[i]);
      odes.push_back(new pair<string, Enode*>(var->getCar()->getName(), rhs));
  }
  context.DefineODE(flowname, &odes);
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:13,代码来源:opensmt_c.C

示例11: assert

ostream & print_infix_op(ostream & out, Enode * const e, string const & op,
                         std::function<ostream &(ostream &, Enode * const)> const & f) {
    assert(e->getArity() >= 2);
    out << "(";
    f(out, e->get1st());
    Enode * tmp = e->getCdr()->getCdr();
    while (!tmp->isEnil()) {
        out << " " << op << " ";
        f(out, tmp->getCar());
        tmp = tmp->getCdr();
    }
    out << ")";
    return out;
}
开发者ID:clhuang,项目名称:dreal3,代码行数:14,代码来源:print.cpp

示例12: dreal_mk_forall

dreal_expr dreal_mk_forall(dreal_context c, dreal_expr * varlist, unsigned n, dreal_expr body) {
  assert(c);
  OpenSMTContext * c_ = static_cast<OpenSMTContext *>(c);
  OpenSMTContext & context = *c_;
  vector<pair<string, Snode *>> sorted_var_list;
  for (unsigned i = 0; i <n; ++i) {
      dreal_expr var = varlist[i];
      Enode * e = static_cast<Enode*>(var);
      Snode * sort = e->getSort();
      string name = e->getCar()->getNameFull();
      sorted_var_list.push_back(make_pair(name, sort));
  }
  Enode * e_body = static_cast<Enode*>(body);
  Enode * res = context.mkForall(sorted_var_list, e_body);
  return static_cast<void *>(res);
}
开发者ID:scungao,项目名称:dreal3,代码行数:16,代码来源:dreal.C

示例13: retrieveConjuncts

//
// Retrieve conjuncts
//
void Cnfizer::retrieveConjuncts( Enode * f, vector< Enode * > & conjuncts )
{
  assert( f->isLit( ) || f->isAnd( ) );

  if ( f->isLit( ) )
  {
    conjuncts.push_back( f );
  }
  else if ( f->isAnd( ) )
  {
    for ( Enode * list = f->getCdr( ) ;
          list != egraph.enil ;
          list = list->getCdr( ) )
      retrieveConjuncts( list->getCar( ), conjuncts );
  }
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:19,代码来源:Cnfizer.C

示例14: retrieveClause

//
// Retrieve a clause
//
void Cnfizer::retrieveClause( Enode * f, vector< Enode * > & clause )
{
  assert( f->isLit( ) || f->isOr( ) );

  if ( f->isLit( ) )
  {
    clause.push_back( f );
  }
  else if ( f->isOr( ) )
  {
    for ( Enode * list = f->getCdr( ) ;
          list != egraph.enil ;
          list = list->getCdr( ) )
      retrieveClause( list->getCar( ), clause );
  }
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:19,代码来源:Cnfizer.C

示例15: opensmt_mk_forall

opensmt_expr opensmt_mk_forall( opensmt_context c, opensmt_expr * varlist, unsigned n, opensmt_expr body ) {
  assert( c );
  OpenSMTContext * c_ = static_cast< OpenSMTContext * >( c );
  OpenSMTContext & context = *c_;
  vector<pair<string, Snode *>*>* sorted_var_list = new vector<pair<string, Snode *>*>();
  for (unsigned i = 0; i < n; ++i) {
      opensmt_expr var = varlist[i];
      Enode * e = static_cast<Enode*>(var);
      Snode * sort = e->getSort();
      string name = e->getCar()->getName();
      sorted_var_list->push_back(new pair<string, Snode *>(name, sort));
  }
  Enode * e_body = static_cast<Enode*>(body);
  Enode * res = context.mkForall(sorted_var_list, e_body);
  delete sorted_var_list;
  return static_cast< void * >( res );
}
开发者ID:4lex4nder,项目名称:dreal3,代码行数:17,代码来源:opensmt_c.C


注:本文中的Enode::getCar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。