void nonlinear_constraint::build_maps() const { std::thread::id const tid = std::this_thread::get_id(); assert(m_numctr_map.find(tid) == m_numctr_map.cend()); assert(m_var_array_map.find(tid) == m_var_array_map.cend()); // Build var_array_map map<string, ibex::ExprSymbol const *> var_map = build_var_map(m_domain_vars); ibex::Array<ibex::ExprSymbol const> & var_array = m_var_array_map[tid]; var_array.resize(var_map.size()); int i = 0; for (auto const item : var_map) { var_array.set_ref(i++, *(item.second)); } // The use of unique_ptr is to free the returned exprctr* from translate_enode_to_exprctr unique_ptr<ibex::ExprCtr const> exprctr( translate_enode_to_exprctr(var_map, get_enode(), m_polarity, m_subst)); m_numctr_map[tid].reset(new ibex::NumConstraint(var_array, *exprctr)); }
// ==================================================== // Nonlinear constraint // ==================================================== nonlinear_constraint::nonlinear_constraint(Enode * const e, unordered_set<Enode*> const & var_set, lbool const p, unordered_map<Enode*, ibex::Interval> const & subst) : constraint(constraint_type::Nonlinear, e), m_is_neq(p == l_False && e->isEq()), m_numctr(nullptr), m_var_array(var_set.size()) { // Build var_map and var_array // Need to pass a fresh copy of var_array everytime it builds NumConstraint auto var_map = build_var_map(var_set); m_var_array.resize(var_map.size()); unsigned i = 0; for (auto const item : var_map) { m_var_array.set_ref(i++, item.second); } unique_ptr<ibex::ExprCtr const> exprctr(translate_enode_to_exprctr(var_map, e, p, subst)); m_numctr.reset(new ibex::NumConstraint(m_var_array, *exprctr)); DREAL_LOG_INFO << "nonlinear_constraint: "<< *this; }