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


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

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


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

示例1: stoi

ode_solver::ode_solver(SMTConfig& c,
                       Egraph & e,
                       Enode * l_int,
                       vector<Enode*> invs,
                       unordered_map<Enode*, int>& enode_to_rp_id) :
    m_config(c),
    m_egraph(e),
    m_int(l_int),
    m_invs(invs),
    m_enode_to_rp_id(enode_to_rp_id),
    m_stepControl(c.nra_ODE_step),
    m_time(nullptr) {
    // Pick the right flow_map (var |-> ODE) using current mode
    m_mode = l_int->getCdr()->getCar()->getValue();
    map<string, Enode *> & flow_map = m_egraph.flow_maps[string("flow_") + to_string(m_mode)];
    m_time = l_int->getCdr()->getCdr()->getCdr()->getCar();
    string time_str = m_time->getCar()->getName();                       // i.e. "time_1"
    m_step = stoi(time_str.substr(time_str.find_last_of("_") + 1));      // i.e. 1
    Enode * var_list = l_int->getCdr()->getCdr()->getCdr()->getCdr();

    // Collect _0, _t variables from variable list in integral literal
    while (!var_list->isEnil()) {
        string name = var_list->getCar()->getCar()->getName();
        size_t second_ = name.find_last_of("_");
        size_t first_ = name.find_last_of("_", second_ - 1);
        string name_prefix, name_postfix;
        if (first_ == string::npos) {
            name_prefix = name.substr(0, second_);
            name_postfix = name.substr(second_);
        } else {
            name_prefix = name.substr(0, first_);
            name_postfix = name.substr(first_);
        }
        if (flow_map.find(name_prefix) == flow_map.end()) {
            cerr << name_prefix << " is not found in flow_map." << endl;
            assert(flow_map.find(name_prefix) != flow_map.end());
        }

        Enode * rhs = flow_map[name_prefix];
        stringstream ss;
        rhs->print_infix(ss, true, name_postfix);
        if (rhs->isConstant() && rhs->getValue() == 0.0) {
            // If RHS of ODE == 0.0, we treat it as a parameter in CAPD
            m_pars.push_back(var_list->getCar());
            m_par_list.push_back(name);
        } else {
            // Otherwise, we treat it as an ODE variable.
            m_0_vars.push_back(var_list->getCar());
            m_t_vars.push_back(var_list->getCdr()->getCar());
            m_var_list.push_back(name);
            m_ode_list.push_back(ss.str());
        }
        var_list = var_list->getCdr()->getCdr();
    }

    // join var_list to make diff_var, ode_list to diff_fun_forward
    string diff_var = "";
    if (!m_var_list.empty()) {
        diff_var = "var:" + join(m_var_list, ", ") + ";";
    }
    string diff_fun_forward = "";
    string diff_fun_backward = "";
    if (!m_ode_list.empty()) {
        diff_fun_forward = "fun:" + join(m_ode_list, ", ") + ";";
        diff_fun_backward = "fun: -" + join(m_ode_list, ", -") + ";";
    }
    // construct diff_sys_forward (string to CAPD)
    string diff_par;
    if (m_par_list.size() > 0) {
        diff_par = "par:" + join(m_par_list, ", ") + ";";
        m_diff_sys_forward = diff_par;
        m_diff_sys_backward = diff_par;
    }
    m_diff_sys_forward  += diff_var + diff_fun_forward;
    m_diff_sys_backward += diff_var + diff_fun_backward;
    DREAL_LOG_INFO << "diff_par          : " << diff_par;
    DREAL_LOG_INFO << "diff_var          : " << diff_var;
    DREAL_LOG_INFO << "diff_fun_forward  : " << diff_fun_forward;
    DREAL_LOG_INFO << "diff_fun_backward : " << diff_fun_backward;
    DREAL_LOG_INFO << "diff_sys_forward  : " << m_diff_sys_forward;
    DREAL_LOG_INFO << "diff_sys_backward : " << m_diff_sys_backward;
    for (auto ode_str : m_ode_list) {
        string const func_str = diff_par + diff_var + "fun:" + ode_str + ";";
        m_funcs.push_back(IFunction(func_str));
    };
    m_inv = extract_invariants();
    }
开发者ID:rachelwang,项目名称:dreal,代码行数:87,代码来源:ode_solver.cpp


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