/** \brief return the complement of variables that are currently assigned. */ void theory_wmaxsat::get_assignment(svector<bool>& result) { result.reset(); if (!m_found_optimal) { for (unsigned i = 0; i < m_vars.size(); ++i) { result.push_back(false); } } else { std::sort(m_cost_save.begin(), m_cost_save.end()); for (unsigned i = 0,j = 0; i < m_vars.size(); ++i) { if (j < m_cost_save.size() && m_cost_save[j] == static_cast<theory_var>(i)) { result.push_back(false); ++j; } else { result.push_back(true); } } } TRACE("opt", tout << "cost save: "; for (unsigned i = 0; i < m_cost_save.size(); ++i) { tout << m_cost_save[i] << " "; } tout << "\nvars: "; for (unsigned i = 0; i < m_vars.size(); ++i) { tout << mk_pp(m_vars[i].get(), get_manager()) << " "; } tout << "\nassignment: "; for (unsigned i = 0; i < result.size(); ++i) { tout << result[i] << " "; } tout << "\n";);
void proof_checker::hyp_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) { if (logic == symbol::null) { op_names.push_back(builtin_name("cons", OP_CONS)); op_names.push_back(builtin_name("atom", OP_ATOM)); op_names.push_back(builtin_name("nil", OP_NIL)); } }
void special_relations_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) { if (logic == symbol::null) { op_names.push_back(builtin_name(m_po.bare_str(), OP_SPECIAL_RELATION_PO)); op_names.push_back(builtin_name(m_po_ao.bare_str(), OP_SPECIAL_RELATION_PO_AO)); op_names.push_back(builtin_name(m_lo.bare_str(), OP_SPECIAL_RELATION_LO)); op_names.push_back(builtin_name(m_plo.bare_str(), OP_SPECIAL_RELATION_PLO)); op_names.push_back(builtin_name(m_to.bare_str(), OP_SPECIAL_RELATION_TO)); } }
void pb_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) { if (logic == symbol::null) { op_names.push_back(builtin_name(m_at_most_sym.bare_str(), OP_AT_MOST_K)); op_names.push_back(builtin_name(m_at_least_sym.bare_str(), OP_AT_LEAST_K)); op_names.push_back(builtin_name(m_pble_sym.bare_str(), OP_PB_LE)); op_names.push_back(builtin_name(m_pbge_sym.bare_str(), OP_PB_GE)); op_names.push_back(builtin_name(m_pbeq_sym.bare_str(), OP_PB_EQ)); } }
void float_decl_plugin::get_sort_names(svector<builtin_name> & sort_names, symbol const & logic) { sort_names.push_back(builtin_name("FloatingPoint", FLOAT_SORT)); sort_names.push_back(builtin_name("RoundingMode", ROUNDING_MODE_SORT)); // The final theory supports three common FloatingPoint sorts sort_names.push_back(builtin_name("Float16", FLOAT16_SORT)); sort_names.push_back(builtin_name("Float32", FLOAT32_SORT)); sort_names.push_back(builtin_name("Float64", FLOAT64_SORT)); sort_names.push_back(builtin_name("Float128", FLOAT128_SORT)); }
void prepare(svector<iovec>& v, void* ptr, const int sender=-1) { Task<Image> * task = (Task<Image> *) ptr; Blob* blob = task->getBlob(); task->get()->magick("BMP"); task->get()->write(blob); struct iovec iov={const_cast<void*>(blob->data()),blob->length()}; v.push_back(iov); setCallbackArg(ptr); const char * imagename = task->name().c_str(); struct iovec iov2={const_cast<char*>(imagename),strlen(imagename)+1}; v.push_back(iov2); setCallbackArg(nullptr); }
void rule_manager::mk_negations(app_ref_vector& body, svector<bool>& is_negated) { for (unsigned i = 0; i < body.size(); ++i) { expr* e = body[i].get(), *e1; if (m.is_not(e, e1) && m_ctx.is_predicate(e1)) { check_app(e1); body[i] = to_app(e1); is_negated.push_back(true); } else { is_negated.push_back(false); } } }
void visit(expr * n, unsigned delta, bool & visited) { expr_delta_pair e(n, delta); if (!m_cache.contains(e)) { m_todo.push_back(e); visited = false; } }
void set_value_p(app* e, expr* v) { SASSERT(e->get_num_args() == 0); SASSERT(is_uninterp_const(e)); m_const.push_back(std::make_pair(e, v)); m_refs.push_back(e); m_refs.push_back(v); }
void set_next_arg(cmd_context & ctx, symbol const & s) override { cmd * c = ctx.find_cmd(s); if (c == nullptr) { std::string err_msg("unknown command '"); err_msg = err_msg + s.bare_str() + "'"; throw cmd_exception(std::move(err_msg)); } m_cmds.push_back(s); }
virtual void set_next_arg(cmd_context & ctx, symbol const & s) { cmd * c = ctx.find_cmd(s); if (c == 0) { std::string err_msg("unknown command '"); err_msg = err_msg + s.bare_str() + "'"; throw cmd_exception(err_msg); } m_cmds.push_back(s); }
virtual void set_next_arg(cmd_context & ctx, symbol const & s) { if(m_arg_idx==0) { m_rel_name = s; } else { SASSERT(m_arg_idx>1); m_kinds.push_back(s); } m_arg_idx++; }
void insert(symbol const & name, param_kind k, char const * descr) { SASSERT(!name.is_numerical()); info i; if (m_info.find(name, i)) { SASSERT(i.first == k); return; } m_info.insert(name, info(k, descr)); m_names.push_back(name); }
void SArtefactActivation::Load() { for(int i=0; i<(int)eMax; ++i) m_activation_states.push_back(SStateDef()); LPCSTR activation_seq = pSettings->r_string(*m_af->cNameSect(),"artefact_activation_seq"); m_activation_states[(int)eStarting].Load(activation_seq, "starting"); m_activation_states[(int)eFlying].Load(activation_seq, "flying"); m_activation_states[(int)eBeforeSpawn].Load(activation_seq, "idle_before_spawning"); m_activation_states[(int)eSpawnZone].Load(activation_seq, "spawning"); }
// return true if n contains a variable in the range [begin, end] bool operator()(expr * n, unsigned begin = 0, unsigned end = UINT_MAX) { m_contains = false; m_window = end - begin; m_todo.reset(); m_cache.reset(); m_todo.push_back(expr_delta_pair(n, begin)); while (!m_todo.empty()) { expr_delta_pair e = m_todo.back(); if (visit_children(e.m_node, e.m_delta)) { m_cache.insert(e); m_todo.pop_back(); } if (m_contains) { return true; } } SASSERT(!m_contains); return false; }
BOOL CreateNode(Fvector& vAt, vertex& N) { // *** Query and cache polygons for ray-casting Fvector PointUp; PointUp.set(vAt); PointUp.y += RCAST_Depth; SnapXZ (PointUp); Fvector PointDown; PointDown.set(vAt); PointDown.y -= RCAST_Depth; SnapXZ (PointDown); Fbox BB; BB.set (PointUp,PointUp); BB.grow(g_params.fPatchSize/2); // box 1 Fbox B2; B2.set (PointDown,PointDown); B2.grow(g_params.fPatchSize/2); // box 2 BB.merge(B2 ); BoxQuery(BB,false ); u32 dwCount = XRC.r_count(); if (dwCount==0) { // Log("chasm1"); return FALSE; // chasm? } // *** Transfer triangles and compute sector R_ASSERT(dwCount<RCAST_MaxTris); static svector<tri,RCAST_MaxTris> tris; tris.clear(); for (u32 i=0; i<dwCount; i++) { tri& D = tris.last(); CDB::RESULT &rp = XRC.r_begin()[i]; CDB::TRI& T = *(Level.get_tris()+rp.id); D.v[0].set (rp.verts[0]); D.v[1].set (rp.verts[1]); D.v[2].set (rp.verts[2]); D.sector = T.sector; D.N.mknormal(D.v[0],D.v[1],D.v[2]); if (D.N.y<=0) continue; tris.inc (); } if (tris.size()==0) { // Log("chasm2"); return FALSE; // chasm? } // *** Perform ray-casts and calculate sector WORD Sector = 0xfffe; // mark as first time static svector<Fvector,RCAST_Total> points; points.clear(); static svector<Fvector,RCAST_Total> normals; normals.clear(); Fvector P,D; D.set(0,-1,0); float coeff = 0.5f*g_params.fPatchSize/float(RCAST_Count); for (int x=-RCAST_Count; x<=RCAST_Count; x++) { P.x = vAt.x + coeff*float(x); for (int z=-RCAST_Count; z<=RCAST_Count; z++) { P.z = vAt.z + coeff*float(z); P.y = vAt.y + 10.f; float tri_min_range = flt_max; int tri_selected = -1; float range,u,v; for (i=0; i<u32(tris.size()); i++) { if (CDB::TestRayTri(P,D,tris[i].v,u,v,range,false)) { if (range<tri_min_range) { tri_min_range = range; tri_selected = i; } } } if (tri_selected>=0) { P.y -= tri_min_range; points.push_back(P); normals.push_back(tris[tri_selected].N); WORD TS = WORD(tris[tri_selected].sector); if (Sector==0xfffe) Sector = TS; else if (Sector!=TS) Sector=InvalidSector; } } } if (points.size()<3) { // Msg ("Failed to create node at [%f,%f,%f].",vAt.x,vAt.y,vAt.z); return FALSE; } if (float(points.size())/float(RCAST_Total) < 0.7f) { // Msg ("Partial chasm at [%f,%f,%f].",vAt.x,vAt.y,vAt.z); return FALSE; } // *** Calc normal Fvector vNorm; vNorm.set(0,0,0); for (u32 n=0; n<normals.size(); n++) vNorm.add(normals[n]); vNorm.div(float(normals.size())); vNorm.normalize(); /* { // second algorithm (Magic) Fvector N,O; N.set(vNorm); O.set(points[0]); Mgc::OrthogonalPlaneFit( points.size(),(Mgc::Vector3*)points.begin(), *((Mgc::Vector3*)&O), *((Mgc::Vector3*)&N) ); if (N.y<0) N.invert(); N.normalize(); vNorm.lerp(vNorm,N,.3f); vNorm.normalize(); } */ // *** Align plane Fvector vOffs; vOffs.set(0,-1000,0); Fplane PL; PL.build(vOffs,vNorm); for (u32 p=0; p<points.size(); p++) { float dist = PL.classify(points[p]); if (dist>0) { vOffs = points[p]; PL.build(vOffs,vNorm); } } // *** Create node and register it N.Sector =Sector; // sector N.Plane.build (vOffs,vNorm); // build plane D.set (0,1,0); N.Plane.intersectRayPoint(PointDown,D,N.Pos); // "project" position // *** Validate results vNorm.set(0,1,0); if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f))) return FALSE; float y_old = vAt.y; float y_new = N.Pos.y; if (y_old>y_new) { // down if (y_old-y_new > g_params.fCanDOWN ) return FALSE; } else { // up if (y_new-y_old > g_params.fCanUP ) return FALSE; } // *** Validate plane { Fvector PLP; D.set(0,-1,0); int num_successed_rays = 0; for (int x=-RCAST_Count; x<=RCAST_Count; x++) { P.x = N.Pos.x + coeff*float(x); for (int z=-RCAST_Count; z<=RCAST_Count; z++) { P.z = N.Pos.z + coeff*float(z); P.y = N.Pos.y; N.Plane.intersectRayPoint(P,D,PLP); // "project" position P.y = PLP.y+RCAST_VALID*0.01f; float tri_min_range = flt_max; int tri_selected = -1; float range,u,v; for (i=0; i<float(tris.size()); i++) { if (CDB::TestRayTri(P,D,tris[i].v,u,v,range,false)) { if (range<tri_min_range) { tri_min_range = range; tri_selected = i; } } } if (tri_selected>=0) { if (tri_min_range<RCAST_VALID) num_successed_rays++; } } } float perc = float(num_successed_rays)/float(RCAST_Total); if (perc < 0.5f) { // Msg ("Floating node."); return FALSE; } } // *** Mask check // ??? return TRUE; }
// Used to prepare (non contiguous) output messages virtual void prepare(svector<iovec>& v, void* ptr, const int sender=-1) { struct iovec iov={ptr,sizeof(void*)}; v.push_back(iov); setCallbackArg(NULL); }
void float_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) { op_names.push_back(builtin_name("plusInfinity", OP_FLOAT_PLUS_INF)); op_names.push_back(builtin_name("minusInfinity", OP_FLOAT_MINUS_INF)); op_names.push_back(builtin_name("NaN", OP_FLOAT_NAN)); op_names.push_back(builtin_name("roundNearestTiesToEven", OP_RM_NEAREST_TIES_TO_EVEN)); op_names.push_back(builtin_name("roundNearestTiesToAway", OP_RM_NEAREST_TIES_TO_AWAY)); op_names.push_back(builtin_name("roundTowardPositive", OP_RM_TOWARD_POSITIVE)); op_names.push_back(builtin_name("roundTowardNegative", OP_RM_TOWARD_NEGATIVE)); op_names.push_back(builtin_name("roundTowardZero", OP_RM_TOWARD_ZERO)); op_names.push_back(builtin_name("+", OP_FLOAT_ADD)); op_names.push_back(builtin_name("-", OP_FLOAT_SUB)); op_names.push_back(builtin_name("/", OP_FLOAT_DIV)); op_names.push_back(builtin_name("*", OP_FLOAT_MUL)); op_names.push_back(builtin_name("abs", OP_FLOAT_ABS)); op_names.push_back(builtin_name("remainder", OP_FLOAT_REM)); op_names.push_back(builtin_name("fusedMA", OP_FLOAT_FUSED_MA)); op_names.push_back(builtin_name("squareRoot", OP_FLOAT_SQRT)); op_names.push_back(builtin_name("roundToIntegral", OP_FLOAT_ROUND_TO_INTEGRAL)); op_names.push_back(builtin_name("==", OP_FLOAT_EQ)); op_names.push_back(builtin_name("<", OP_FLOAT_LT)); op_names.push_back(builtin_name(">", OP_FLOAT_GT)); op_names.push_back(builtin_name("<=", OP_FLOAT_LE)); op_names.push_back(builtin_name(">=", OP_FLOAT_GE)); op_names.push_back(builtin_name("isZero", OP_FLOAT_IS_ZERO)); op_names.push_back(builtin_name("isNZero", OP_FLOAT_IS_NZERO)); op_names.push_back(builtin_name("isPZero", OP_FLOAT_IS_PZERO)); op_names.push_back(builtin_name("isSignMinus", OP_FLOAT_IS_SIGN_MINUS)); op_names.push_back(builtin_name("min", OP_FLOAT_MIN)); op_names.push_back(builtin_name("max", OP_FLOAT_MAX)); op_names.push_back(builtin_name("asFloat", OP_TO_FLOAT)); }
void float_decl_plugin::get_sort_names(svector<builtin_name> & sort_names, symbol const & logic) { sort_names.push_back(builtin_name("FP", FLOAT_SORT)); sort_names.push_back(builtin_name("RoundingMode", ROUNDING_MODE_SORT)); }
int parseFormat(string ffname, ivector & tvec, svector & dnames, svector & delims, int *grpsize) { ifstream ifstr(ffname.c_str(), ios::in); if (ifstr.fail() || ifstr.eof()) { cerr << "couldnt open format file" << endl; throw; } char *next, *third, *newstr, *linebuf = new char[80]; while (!ifstr.bad() && !ifstr.eof()) { ifstr.getline(linebuf, 80); if (strlen(linebuf) > 1) { next = strchr(linebuf, ' '); *next++ = 0; third = strchr(next, ' '); if (third) *third++ = 0; dnames.push_back(next); if (strncmp(linebuf, "int", 3) == 0) { tvec.push_back(ftype_int); delims.push_back(""); } else if (strncmp(linebuf, "dint", 4) == 0) { tvec.push_back(ftype_dint); delims.push_back(""); } else if (strncmp(linebuf, "qhex", 4) == 0) { tvec.push_back(ftype_qhex); delims.push_back(""); } else if (strncmp(linebuf, "float", 5) == 0) { tvec.push_back(ftype_float); delims.push_back(""); } else if (strncmp(linebuf, "double", 6) == 0) { tvec.push_back(ftype_double); delims.push_back(""); } else if (strncmp(linebuf, "word", 4) == 0) { tvec.push_back(ftype_word); delims.push_back(""); } else if (strncmp(linebuf, "string", 6) == 0) { tvec.push_back(ftype_string); ifstr.getline(linebuf, 80); newstr = new char[strlen(linebuf)+1]; strcpy(newstr, linebuf); delims.push_back(newstr); } else if (strncmp(linebuf, "date", 4) == 0) { tvec.push_back(ftype_date); delims.push_back(""); } else if (strncmp(linebuf, "mdate", 5) == 0) { tvec.push_back(ftype_mdate); delims.push_back(""); } else if (strncmp(linebuf, "cmdate", 6) == 0) { tvec.push_back(ftype_cmdate); delims.push_back(""); } else if (strncmp(linebuf, "dt", 2) == 0) { tvec.push_back(ftype_dt); delims.push_back(""); } else if (strncmp(linebuf, "mdt", 3) == 0) { tvec.push_back(ftype_mdt); delims.push_back(""); } else if (strncmp(linebuf, "group", 5) == 0) { sscanf(third, "%d", grpsize); tvec.push_back(ftype_group); delims.push_back(""); } else if (strncmp(linebuf, "igroup", 6) == 0) { sscanf(third, "%d", grpsize); tvec.push_back(ftype_igroup); ifstr.getline(linebuf, 80); delims.push_back(linebuf); } else if (strncmp(linebuf, "digroup", 7) == 0) { sscanf(third, "%d", grpsize); tvec.push_back(ftype_digroup); ifstr.getline(linebuf, 80); delims.push_back(linebuf); } else { cerr << "couldnt parse format file line " << tvec.size()+1 << endl; throw; } } } return tvec.size(); delete [] linebuf; }
void prepare(svector<iovec>& v, void* ptr, const int sender=-1) { // just send the data not the message struct iovec iov={((COMM::TransportImpl::msg_t*)ptr)->getData(),size}; v.push_back(iov); setCallbackArg(ptr); // set the pointer for the callback }
void proof_checker::hyp_decl_plugin::get_sort_names(svector<builtin_name> & sort_names, symbol const & logic) { if (logic == symbol::null) { sort_names.push_back(builtin_name("cell", CELL_SORT)); } }
void float_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) { // These are the operators from the final draft of the SMT FloatingPoint standard op_names.push_back(builtin_name("+oo", OP_FLOAT_PLUS_INF)); op_names.push_back(builtin_name("-oo", OP_FLOAT_MINUS_INF)); op_names.push_back(builtin_name("+zero", OP_FLOAT_PLUS_ZERO)); op_names.push_back(builtin_name("-zero", OP_FLOAT_MINUS_ZERO)); op_names.push_back(builtin_name("NaN", OP_FLOAT_NAN)); op_names.push_back(builtin_name("roundNearestTiesToEven", OP_RM_NEAREST_TIES_TO_EVEN)); op_names.push_back(builtin_name("roundNearestTiesToAway", OP_RM_NEAREST_TIES_TO_AWAY)); op_names.push_back(builtin_name("roundTowardPositive", OP_RM_TOWARD_POSITIVE)); op_names.push_back(builtin_name("roundTowardNegative", OP_RM_TOWARD_NEGATIVE)); op_names.push_back(builtin_name("roundTowardZero", OP_RM_TOWARD_ZERO)); op_names.push_back(builtin_name("RNE", OP_RM_NEAREST_TIES_TO_EVEN)); op_names.push_back(builtin_name("RNA", OP_RM_NEAREST_TIES_TO_AWAY)); op_names.push_back(builtin_name("RTP", OP_RM_TOWARD_POSITIVE)); op_names.push_back(builtin_name("RTN", OP_RM_TOWARD_NEGATIVE)); op_names.push_back(builtin_name("RTZ", OP_RM_TOWARD_ZERO)); op_names.push_back(builtin_name("fp.abs", OP_FLOAT_ABS)); op_names.push_back(builtin_name("fp.neg", OP_FLOAT_NEG)); op_names.push_back(builtin_name("fp.add", OP_FLOAT_ADD)); op_names.push_back(builtin_name("fp.sub", OP_FLOAT_SUB)); op_names.push_back(builtin_name("fp.mul", OP_FLOAT_MUL)); op_names.push_back(builtin_name("fp.div", OP_FLOAT_DIV)); op_names.push_back(builtin_name("fp.fma", OP_FLOAT_FMA)); op_names.push_back(builtin_name("fp.sqrt", OP_FLOAT_SQRT)); op_names.push_back(builtin_name("fp.rem", OP_FLOAT_REM)); op_names.push_back(builtin_name("fp.roundToIntegral", OP_FLOAT_ROUND_TO_INTEGRAL)); op_names.push_back(builtin_name("fp.min", OP_FLOAT_MIN)); op_names.push_back(builtin_name("fp.max", OP_FLOAT_MAX)); op_names.push_back(builtin_name("fp.leq", OP_FLOAT_LE)); op_names.push_back(builtin_name("fp.lt", OP_FLOAT_LT)); op_names.push_back(builtin_name("fp.geq", OP_FLOAT_GE)); op_names.push_back(builtin_name("fp.gt", OP_FLOAT_GT)); op_names.push_back(builtin_name("fp.eq", OP_FLOAT_EQ)); op_names.push_back(builtin_name("fp.isNormal", OP_FLOAT_IS_NORMAL)); op_names.push_back(builtin_name("fp.isSubnormal", OP_FLOAT_IS_SUBNORMAL)); op_names.push_back(builtin_name("fp.isZero", OP_FLOAT_IS_ZERO)); op_names.push_back(builtin_name("fp.isInfinite", OP_FLOAT_IS_INF)); op_names.push_back(builtin_name("fp.isNaN", OP_FLOAT_IS_NAN)); op_names.push_back(builtin_name("fp.isNegative", OP_FLOAT_IS_NEGATIVE)); op_names.push_back(builtin_name("fp.isPositive", OP_FLOAT_IS_POSITIVE)); op_names.push_back(builtin_name("fp", OP_FLOAT_FP)); op_names.push_back(builtin_name("fp.to_ubv", OP_FLOAT_TO_UBV)); op_names.push_back(builtin_name("fp.to_sbv", OP_FLOAT_TO_SBV)); op_names.push_back(builtin_name("to_fp", OP_TO_FLOAT)); }
void prepare(svector<iovec>& v, void* ptr, const int sender=-1) { struct iovec iov={((ff_task_t*)ptr)->getData(),taskSize*taskSize*sizeof(double)}; v.push_back(iov); setCallbackArg(ptr); }
void prepare(svector<iovec>& v, void* ptr, const int sender=-1) { struct iovec iov={ptr,taskSize*taskSize*sizeof(double)}; v.push_back(iov); setCallbackArg(NULL); }