void soc::SocSystem_Ors::getTargetV(arr& v_i,real& y_prec,uint i,uint t){ if(!t && vars(i)->targetType!=trajectoryTT){ v_i = vars(i)->v_target; y_prec = vars(i)->v_prec; return; } v_i = vars(i)->v_trajectory[t]; y_prec = vars(i)->v_prec_trajectory(t); }
void soc::SocSystem_Ors::getJtJ(arr& J_i,arr& tJ_i,uint i){ //vars(i)->updateJacobian(); if(!WS->Qlin.N){ J_i=vars(i)->J; tJ_i=vars(i)->tJ; }else{ J_i=vars(i)->J*WS->Qlin; transpose(tJ_i,J_i); } }
void soc::SocSystem_Ors::getTarget(arr& y_i,real& y_prec,uint i,uint t){ if(!t && vars(i)->targetType!=trajectoryTT){ TaskVariable *v=vars(i); v->updateChange(-1); y_i = v->y+v->y_change; y_prec = vars(i)->y_prec; return; } y_i = vars(i)->y_trajectory[t]; y_prec = vars(i)->y_prec_trajectory(t); }
/*** * @brief Implementation of observation DEVS function */ std::unique_ptr<vv::Value> observation( const vd::ObservationEvent& event) const override { const std::string& port = event.getPortName(); { Variables::const_iterator itf = vars().find(port); if (itf != vars().end()) { return value::Double::create(itf->second->getVal()); } } return 0; }
/** * @brief Output function that fills the value of state variables * @param time, time of the output * @param extEvtList, the list of external event */ void outputVar(const vd::Time& /*time*/, vd::ExternalEventList& extEvtList) const { Variables::const_iterator itb = vars().begin(); Variables::const_iterator ite = vars().end(); for (; itb != ite; itb++) { const Variable& v = *itb->second; if (getModel().existOutputPort(itb->first)) { extEvtList.emplace_back(itb->first); value::Double& val = extEvtList.back().addDouble(); val = v.getVal(); } } }
void ResultSet::project (ProductionVector<const POS*> const * varsV) { std::set<const POS*> vars(varsV->begin(), varsV->end()); /* List of vars to delete. * This is cheaper than walking all the bindings in a row, but assumes * that the row has no bindings which fail to appear in knownVars. */ std::set<const POS*> toDel; for (std::set<const POS*>::const_iterator knownVar = knownVars.begin(); knownVar != knownVars.end(); ++knownVar) if (vars.find(*knownVar) == vars.end()) toDel.insert(*knownVar); /* Delete those vars from each row, and from knowVars. */ for (ResultSetIterator row = results.begin(); row != results.end(); ++row) for (std::set<const POS*>::const_iterator var = toDel.begin(); var != toDel.end(); ++var) if ((*row)->find(*var) != (*row)->end()) (*row)->erase((*row)->find(*var)); /* Delete those vars from knowVars. */ for (std::set<const POS*>::const_iterator var = toDel.begin(); var != toDel.end(); ++var) knownVars.erase(*var); selectOrder = *varsV; orderedSelect = true; }
void test_vector() { std::vector<TT> vars(5); TT t; TT f; TT::variables(vars.begin(), vars.end(), t, f); TT a = vars[0]; TT b = vars[1]; assert((a & (b & ~a)) == f); assert((a & (~a)) == f); assert((a | (~a)) == t); assert((b & (~b)) == f); assert((b | (~b)) == t); assert(b.negCofactor(b) == f); assert(b.posCofactor(b) == t); assert(a.negCofactor(a) == f); assert(a.posCofactor(a) == t); TT c = a & b; assert(c.posCofactor(a) == b); TT c1 = a | b; assert(c1.negCofactor(a) == b); TT d = a & b & ~(vars[2] | vars[3]); TT e = d.posCofactor(a); assert(TT::firstVar(vars.begin(), vars.end(), e,e) == (vars.begin()+1)); }
bool SaveLoad_v6::GameHandler::loadExtra(int slot, uint8 id, int16 dataVar, int32 size, int32 offset) { if (!_reader || (_reader->getSlot() != (uint32)slot)) return false; SavePartMem mem(1); if (!_reader->readPart(2, &mem)) return false; uint8 extraSaveNumber; if (!mem.writeInto(&extraSaveNumber, 0, 1)) return false; if (extraSaveNumber != id) return false; uint32 varSize = SaveHandler::getVarSize(_vm); SavePartVars vars(_vm, varSize); if (!_reader->readPart(3, &vars)) return false; if (!vars.writeInto(0, 0, varSize)) return false; return true; }
void short_test() { std::vector<TT> vars(2); TT t; TT f; TT::variables(vars.begin(), vars.end(), t, f); TT a = vars[0]; TT b = vars[1]; assert((a & (~a)) == f); assert((a | (~a)) == t); assert((b & (~b)) == f); assert((b | (~b)) == t); assert(b.negCofactor(b) == f); assert(b.posCofactor(b) == t); assert(a.negCofactor(a) == f); assert(a.posCofactor(a) == t); TT c = a & b; assert(c.posCofactor(a) == b); TT c1 = a | b; assert(c1.negCofactor(a) == b); std::pair<TT,TT> p = c.cofactors(a); assert(p.second == b); assert(p.first == f); }
static Array HHVM_FUNCTION(xdebug_get_declared_vars) { if (RuntimeOption::RepoAuthoritative) { raise_error("xdebug_get_declared_vars unsupported in RepoAuthoritative " "mode"); } // Grab the callee function VMRegAnchor _; // Ensure consistent state for vmfp auto func = g_context->getPrevFunc(vmfp()); if (!func) { return Array::Create(); } // Add each named local to the returned array. Note that since this function // is supposed to return all _declared_ variables in scope, which includes // variables that have been unset. auto const numNames = func->numNamedLocals(); PackedArrayInit vars(numNames); for (Id i = 0; i < numNames; ++i) { assert(func->lookupVarId(func->localVarName(i)) == i); String varname(const_cast<StringData*>(func->localVarName(i))); // Skip the internal closure "0Closure" variable if (!s_closure_varname.equal(varname)) { vars.append(varname); } } return vars.toArray(); }
bool SaveLoad_v6::GameHandler::saveExtra(int slot, uint8 id, int16 dataVar, int32 size, int32 offset) { if (!_writer || (_writer->getSlot() != (uint32)slot)) return false; uint32 varSize = SaveHandler::getVarSize(_vm); SavePartMem mem(1); SavePartVars vars(_vm, varSize); if (!mem.readFrom(&id, 0, 1)) return false; if (!vars.readFrom(0, 0, varSize)) return false; if (!_writer->writePart(2, &mem)) return false; if (!_writer->writePart(3, &vars)) return false; _hasExtra = true; return true; }
// // Hoist quantifier from rule (universal) or query (existential) // unsigned rule_manager::hoist_quantifier(bool is_forall, expr_ref& fml, svector<symbol>* names) { unsigned index = var_counter().get_next_var(fml); while (is_quantifier(fml) && (is_forall == to_quantifier(fml)->is_forall())) { quantifier* q = to_quantifier(fml); index += q->get_num_decls(); if (names) { names->append(q->get_num_decls(), q->get_decl_names()); } fml = q->get_expr(); } if (!has_quantifiers(fml)) { return index; } app_ref_vector vars(m); quantifier_hoister qh(m); qh.pull_quantifier(is_forall, fml, vars); if (vars.empty()) { return index; } // replace vars by de-bruijn indices expr_substitution sub(m); for (unsigned i = 0; i < vars.size(); ++i) { app* v = vars[i].get(); if (names) { names->push_back(v->get_decl()->get_name()); } sub.insert(v, m.mk_var(index++,m.get_sort(v))); } scoped_ptr<expr_replacer> rep = mk_default_expr_replacer(m); rep->set_substitution(&sub); (*rep)(fml); return index; }
SLP *edict2slp(EDICT *edict){ uInt i; // vector<varpair> vars(edict->numRules - CHAR_SIZE + 1); vector<uInt_pair> vars(edict->numRules - CHAR_SIZE - 1); // vector<uInt_pair> vars(edict->numRules); string alphabet; cout << "read alphabet" << endl; for(i = 0; i <= CHAR_SIZE; i++){ alphabet.push_back((char)i); } cout << "read rules" << endl; for(i = CHAR_SIZE + 1; i < edict->numRules; i++){ if(edict->rule[i].left > i || edict->rule[i].right > i || edict->rule[i].left >= edict->numRules || edict->rule[i].left >= edict->numRules ){ cout << "i=" << i << " left=" << edict->rule[i].left << " right=" << edict->rule[i].left << endl; } uInt_pair v; vars[i - (CHAR_SIZE + 1)].first = (uInt)(edict->rule[i].left); vars[i - (CHAR_SIZE + 1)].second = (uInt)(edict->rule[i].right); } cout << "create SLP" << endl; return new SLP(alphabet, vars); }
Z3_ast Z3_API Z3_qe_model_project (Z3_context c, Z3_model m, unsigned num_bounds, Z3_app const bound[], Z3_ast body) { Z3_TRY; LOG_Z3_qe_model_project (c, m, num_bounds, bound, body); RESET_ERROR_CODE(); app_ref_vector vars(mk_c(c)->m ()); if (!to_apps(num_bounds, bound, vars)) { SET_ERROR_CODE (Z3_INVALID_ARG); RETURN_Z3(0); } expr_ref result (mk_c(c)->m ()); result = to_expr (body); model_ref model (to_model_ref (m)); spacer::qe_project (mk_c(c)->m (), vars, result, model); mk_c(c)->save_ast_trail (result.get ()); return of_expr (result.get ()); Z3_CATCH_RETURN(0); }
void variable_mode_controller::show_var(ttree_view_node& node) { twidget* w = node.find("name", false); if(tlabel* label = dynamic_cast<tlabel*>(w)) { model().set_data(vars()[label->label()]); } }
JBoolean GLFitDescription::Create ( istream& is, GLFitDescription** fd ) { JFileVersion version; is >> version; if (version > kCurrentSetupVersion) { return kJFalse; } int type; is >> type; JString form; is >> form; JString name; is >> name; JSize count; is >> count; JPtrArray<JString> vars(JPtrArrayT::kDeleteAll); for (JIndex i = 1; i <= count; i++) { JString* var = new JString(); assert(var != NULL); is >> *var; vars.Append(var); } if (type == kPolynomial) { GLPolyFitDescription* pfd = new GLPolyFitDescription(is); assert(pfd != NULL); *fd = pfd; } else if (type == kNonLinear) { GLNonLinearFitDescription* nfd = new GLNonLinearFitDescription(is); assert(nfd != NULL); *fd = nfd; for (JIndex i = 1; i <= count; i++) { (*fd)->itsVarList->AddVariable(*(vars.NthElement(i)), 0); } (*fd)->SetParameterCount(count); } else { return kJFalse; } vars.DeleteAll(); (*fd)->itsFnName = name; (*fd)->itsFnForm = form; return kJTrue; }
void Solver::setState(const Eigen::VectorXd& x) { int nVar = mProb->getNumVariables(); std::vector<Var *>& vars(mProb->vars()); for (int i = 0; i < nVar; i++) { vars[i]->mVal = x(i); } }
void plotPull(string ptMin, string ptMax){ TFile* file_in = new TFile(("pullOutFile_pt"+ptMin+"_"+ptMax+".root").c_str(), "READ"); TTree* tree = (TTree*)file_in->Get("tree_toys"); vector<string> vars(15); vars[0] = "CBC_mean"; vars[1] = "CBC_sigma"; vars[2] = "CBC_alphaC"; vars[3] = "CBC_alphaCB"; vars[4] = "CBC_n"; vars[5] = "cbmean"; vars[6] = "cbsigma"; vars[7] = "cbalpha_s"; vars[8] = "cbn_s"; vars[9] = "frac_s"; vars[10] = "gaussmean"; vars[11] = "gausssigma"; vars[12] = "frac_scut"; vars[13] = "N_scut"; vars[14] = "N_sig"; vector<TH1F*> histos(15); for(int i=0; i<histos.size(); i++){ histos[i] = new TH1F(("h_"+vars[i]).c_str(), ("h_"+vars[i]).c_str(), 500, -5., 5.); } vector<TH1F*> histos_err(15); for(int i=0; i<histos_err.size(); i++){ histos_err[i] = new TH1F(("h_err_"+vars[i]).c_str(), ("h_err_"+vars[i]).c_str(), 100, 0., 1.); } TCanvas c; gStyle->SetOptFit(111111); for(int i=0; i<vars.size(); i++){ tree->Draw(("(val_"+vars[i]+" - realVal_"+vars[i]+")/err_"+vars[i]+">>h(200, -5, 5").c_str()); histos[i] = (TH1F*)((TH1F*)gDirectory->Get("h"))->Clone(histos[i]->GetName()); histos[i]->Fit("gaus", "LL"); histos[i]->Draw(); c.SaveAs(("pull_"+vars[i]+"_pt"+ptMin+"_"+ptMax+".root").c_str()); c.SaveAs(("pull_"+vars[i]+"_pt"+ptMin+"_"+ptMax+".png").c_str()); c.SaveAs(("pull_"+vars[i]+"_pt"+ptMin+"_"+ptMax+".pdf").c_str()); tree->Draw(("err_"+vars[i]+"/val_"+vars[i]+">>h()").c_str()); histos_err[i] = (TH1F*)((TH1F*)gDirectory->Get("h"))->Clone(histos_err[i]->GetName()); histos_err[i]->Draw(); c.SaveAs(("err_"+vars[i]+"_pt"+ptMin+"_"+ptMax+".root").c_str()); c.SaveAs(("err_"+vars[i]+"_pt"+ptMin+"_"+ptMax+".png").c_str()); c.SaveAs(("err_"+vars[i]+"_pt"+ptMin+"_"+ptMax+".pdf").c_str()); } }
void InspectionCompressorTab::init(const QVariantMap &var_values) { Variables vars(QSqlDatabase(), Variable::Compressor); vars.initEditDialogueWidgets(this, var_values); QGridLayout *layout = new QGridLayout(this); EditInspectionDialogueLayout(&md_inputwidgets, &md_groups, layout).layout(); }
void loginfrm::loadsysvars() { QString qstr = "SELECT var, value FROM maincfg WHERE `var` = 'docfolder' OR `var` = 'templatefolder' ORDER BY var ASC;"; QSqlQuery vars(qstr); vars.next(); docfolder = vars.value(1).toString(); vars.next(); templatefolder = vars.value(1).toString(); }
PyObject * PyOCIO_AllocationTransform_getVars(PyObject * self) { OCIO_PYTRY_ENTER() ConstAllocationTransformRcPtr transform = GetConstAllocationTransform(self); std::vector<float> vars(transform->getNumVars()); if(!vars.empty()) transform->getVars(&vars[0]); return CreatePyListFromFloatVector(vars); OCIO_PYTRY_EXIT(NULL) }
void EBPoissonOp:: prolongIncrement(LevelData<EBCellFAB>& a_phiThisLevel, const LevelData<EBCellFAB>& a_correctCoar) { CH_TIME("EBPoissonOp::prolongIncrement"); Interval vars(0, 0); CH_assert(m_hasMGObjects); m_ebInterpMG.pwcInterp(a_phiThisLevel, a_correctCoar, vars); }
void QuaggaAdapter::executeCommand(int argc, char* argv[]) { std::vector<std::string> vars(argv, argv+argc); // concatenate vars std::string command = ""; std::for_each(vars.begin(), vars.end(), [&command](std::string & s){ command.append(s).append(" "); }); pipeToQuaggaShell(command); }
Eigen::VectorXd Solver::getState() { int nVar = mProb->getNumVariables(); std::vector<Var *>& vars(mProb->vars()); VectorXd x(nVar); for (int i = 0; i < nVar; i++) { x(i) = vars[i]->mVal; } return x; }
void SessionListWidget::parseQstat(QString const& qstat) { QStringList lines = qstat.split('\n'); JobDefinition *job = NULL; QMap<QString, QString> jobSpec, jobVars; QRegExp rxJobId("[0-9]+\\.pbs01"); QRegExp rxKey("[A-Za-z_\\.]+"); QString key(""), value(""); for(QStringList::const_iterator line = lines.begin(); line != lines.end(); line++) { if(line->isEmpty()) { /* empty */ } else if(line->startsWith("Job Id:")) { if(job != NULL) { job->update(jobSpec); sessions.append(*job); delete job; job = NULL; jobSpec.clear(); jobVars.clear(); } rxJobId.indexIn(*line); job = new JobDefinition(rxJobId.cap()); } else if(line->startsWith(" ")) { /* keys start with 4 spaces */ if(key == "Variable_List") { QStringList vars(jobSpec[key].split(",")); for(QStringList::const_iterator i = vars.begin(); i != vars.end(); i++) { int eq = i->indexOf('='); jobVars.insert(i->left(eq), i->mid(eq + 1)); } } rxKey.indexIn(*line); key = rxKey.cap(0); value = line->mid(line->indexOf('=') + 2); jobSpec.insert(key, value); } else if(line->at(0) == '\t') { /* append to the previous key */ jobSpec[key].append(line->mid(1)); } } if(job) { job->update(jobSpec); sessions.append(*job); } qDebug() << sessions; }
void test2() { ast_manager m; reg_decl_plugins(m); bv_util bv(m); datatype_util dtutil(m); params_ref p; datatype_decl_plugin & dt = *(static_cast<datatype_decl_plugin*>(m.get_plugin(m.get_family_id("datatype")))); sort_ref_vector new_sorts(m); constructor_decl* R = mk_constructor_decl(symbol("R"), symbol("is-R"), 0, nullptr); constructor_decl* G = mk_constructor_decl(symbol("G"), symbol("is-G"), 0, nullptr); constructor_decl* B = mk_constructor_decl(symbol("B"), symbol("is-B"), 0, nullptr); constructor_decl* constrs[3] = { R, G, B }; datatype_decl * enum_sort = mk_datatype_decl(dtutil, symbol("RGB"), 0, nullptr, 3, constrs); VERIFY(dt.mk_datatypes(1, &enum_sort, 0, nullptr, new_sorts)); sort* rgb = new_sorts[0].get(); expr_ref x = mk_const(m, "x", rgb), y = mk_const(m, "y", rgb), z = mk_const(m, "z", rgb); ptr_vector<func_decl> const& enums = *dtutil.get_datatype_constructors(rgb); expr_ref r = expr_ref(m.mk_const(enums[0]), m); expr_ref g = expr_ref(m.mk_const(enums[1]), m); expr_ref b = expr_ref(m.mk_const(enums[2]), m); ref<solver> fd_solver = mk_fd_solver(m, p); fd_solver->assert_expr(m.mk_not(m.mk_eq(x, r))); fd_solver->assert_expr(m.mk_not(m.mk_eq(x, b))); expr_ref_vector asms(m), vars(m), conseq(m); vars.push_back(x); vars.push_back(y); VERIFY(l_true == fd_solver->get_consequences(asms, vars, conseq)); std::cout << conseq << "\n"; conseq.reset(); fd_solver->push(); fd_solver->assert_expr(m.mk_not(m.mk_eq(x, g))); VERIFY(l_false == fd_solver->check_sat(0,nullptr)); fd_solver->pop(1); VERIFY(l_true == fd_solver->get_consequences(asms, vars, conseq)); std::cout << conseq << "\n"; conseq.reset(); model_ref mr; fd_solver->get_model(mr); model_smt2_pp(std::cout << "model:\n", m, *mr.get(), 0); VERIFY(l_true == fd_solver->check_sat(0,nullptr)); fd_solver->get_model(mr); ENSURE(mr.get()); model_smt2_pp(std::cout, m, *mr.get(), 0); }
void ASTAnalyzer::printScopeDeclarations (Scope* scope) { Scope::FunctionIterator fuctions(scope); while (fuctions.hasNext()) { fuctions.next()->node()->visit(this); } Scope::VarIterator vars(scope); while (vars.hasNext()) { AstVar* var = vars.next(); output << typeToName(var->type()) << " " << var->name() << ";\n"; } }
void variable_mode_controller::show_array(tree_view_node& node) { widget* w = node.find("name", false); if(label* lbl = dynamic_cast<label*>(w)) { const std::string& var = lbl->get_label(); size_t n_start = var.find_last_of('[') + 1; size_t n_len = var.size() - n_start - 1; int n = std::stoi(var.substr(n_start, n_len)); model().set_data(config_to_string(vars().child(var.substr(1, n_start - 3), n))); } }
void CPLEXSolver::add_in_constraint(LinearConstraint *con, double coef){ DBG("Creating a Gurobi representation of a constriant %s\n", ""); IloNumArray weights(*env, (IloInt)con->_coefficients.size()); IloNumVarArray vars(*env, (IloInt)con->_variables.size()); for(unsigned int i = 0; i < con->_variables.size(); ++i){ DBG("\tAdding variable to CPLEX\n%s", ""); IloNumVar var_ptr; if(con->_variables[i]->_var == NULL){ IloNumVar::Type type; if(con->_variables[i]->_continuous) type = IloNumVar::Float; // else if(con->_lower == 0 && con->_upper == 1) type = IloNumVar::Bool; else type = IloNumVar::Int; var_ptr = IloNumVar(getEnv(), con->_variables[i]->_lower, // LB con->_variables[i]->_upper, // UB type); int *var_id = new int; *var_id = variables->getSize(); variables->add(var_ptr); con->_variables[i]->_var = (void*) var_id; DBG("Created new variable with id %d. type:%c lb:%f ub:%f coef:%f\n", *var_id, type, con->_variables[i]->_lower, con->_variables[i]->_upper, coef); } else { var_ptr = (*variables)[*(int*)(con->_variables[i]->_var)]; } vars[i] = (*variables)[*(int*)(con->_variables[i]->_var)]; weights[i] = con->_coefficients[i]; } IloNumExprArg lin_expr = IloScalProd(weights, vars); if(coef < -0.1){ model->add(IloMinimize(*env, lin_expr)); } else if(coef > 0.1){ model->add(IloMaximize(*env, lin_expr)); } else { if(con->_lhs > -INFINITY && con->_rhs < INFINITY){ if(con->_lhs == con->_rhs) { model->add(lin_expr == con->_lhs); } else { model->add(IloRange(*env, con->_lhs, lin_expr, con->_rhs)); } } else if(con->_lhs > -INFINITY) model->add(lin_expr >= con->_lhs); else if(con->_rhs < INFINITY) model->add(lin_expr <= con->_rhs); } }
static void test2(char const *ex) { smt_params params; params.m_model = true; ast_manager m; reg_decl_plugins(m); arith_util a(m); expr_ref fml = parse_fml(m, ex); app_ref_vector vars(m); expr_ref_vector lits(m); vars.push_back(m.mk_const(symbol("x"), a.mk_real())); vars.push_back(m.mk_const(symbol("y"), a.mk_real())); vars.push_back(m.mk_const(symbol("z"), a.mk_real())); flatten_and(fml, lits); smt::context ctx(m, params); ctx.push(); ctx.assert_expr(fml); lbool result = ctx.check(); VERIFY(result == l_true); ref<model> md; ctx.get_model(md); ctx.pop(1); std::cout << mk_pp(fml, m) << "\n"; expr_ref pr1(m), pr2(m), fml2(m); expr_ref_vector bound(m); ptr_vector<sort> sorts; svector<symbol> names; for (unsigned i = 0; i < vars.size(); ++i) { bound.push_back(vars[i].get()); names.push_back(vars[i]->get_decl()->get_name()); sorts.push_back(m.get_sort(vars[i].get())); } expr_abstract(m, 0, bound.size(), bound.c_ptr(), fml, fml2); fml2 = m.mk_exists(bound.size(), sorts.c_ptr(), names.c_ptr(), fml2); qe::expr_quant_elim qe(m, params); for (unsigned i = 0; i < vars.size(); ++i) { VERIFY(qe::arith_project(*md, vars[i].get(), lits)); } pr1 = mk_and(lits); qe(m.mk_true(), fml2, pr2); std::cout << mk_pp(pr1, m) << "\n"; std::cout << mk_pp(pr2, m) << "\n"; expr_ref npr2(m); npr2 = m.mk_not(pr2); ctx.push(); ctx.assert_expr(pr1); ctx.assert_expr(npr2); VERIFY(l_false == ctx.check()); ctx.pop(1); }