ex get_M_0_sq_ob_Xpression(ParameterMap &pm,bool withFS){ static ex xi_0 = M0_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_M0 = gtilde1( sqrt( M0_sq ) * L ); static ex log_M0_L3 = log( M0_sq / pow( Lambda3 , 2 ) ) ; static ex xi_pm = Mpm_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_Mpm = gtilde1( sqrt( Mpm_sq ) * L ); static ex log_Mpm_L3 = log( Mpm_sq / pow( Lambda3 , 2 ) ) ; static ex log_M0_X3 = log( M0_sq / pow( Xi3 , 2 ) ) ; static ex X_FSE = Mpm_sq * ( 1. +2.*xi_pm * ( log_Mpm_L3 + fse_log_corr_Mpm ) - xi_0 * ( log_M0_L3 + fse_log_corr_M0 )) + 2 * c2 *( 1 - 4. * xi_0 * ( log_M0_X3 + fse_log_corr_M0) + CM0); static ex X = Mpm_sq * ( 1. +2.*xi_pm * log_Mpm_L3 - xi_0 * log_M0_L3 ) + 2 * c2 *( 1 - 4. * xi_0 * log_M0_X3 + CM0); pm.add( B ); pm.add( f ); pm.add( c2 ); pm.add( Lambda3 ); pm.add( Xi3 ); pm.add( CM0 ); if( withFS ) return X_FSE; else return X; }
void ConfigFileWriter::writeRouterModelFile(std::string filename, NodeSet& ns) { std::fstream out; std::set<std::string>::iterator it = ns.modelsUsed().begin(); if (it != ns.modelsUsed().end()) { out.open(filename.c_str(), std::fstream::out | std::fstream::trunc); } while (it != ns.modelsUsed().end()) { ParameterMap* parameters = Config::instance().getModelParameterList(*it); const Parameter& model = parameters->getParameter("ROUTER-MODEL"); if (model != Parameter::unknownParameter) { out << model << std::endl; ParameterMap::iterator pit = parameters->begin(); while (pit != parameters->end()) { if (pit->first != "ROUTER-MODEL") out << pit->second << std::endl; pit++; } out << std::endl; } it++; } }
bool CSVWriter::init(const ParameterMap& params, const Ports<StreamInfo>& inp) { assert(inp.size()==1); const StreamInfo& in = inp[0].data; string outputFile = getStringParam("File", params); m_precision = getIntParam("Precision",params); if (m_precision > (BUFSIZE-10)) { cerr << "WARNING: precision is too large ! use precision " << BUFSIZE - 10 << endl; m_precision = BUFSIZE - 10; } int res = preparedirs(outputFile.c_str()); if (res!=0) return false; m_fout.open(outputFile.c_str(), ios_base::trunc); if (!m_fout.is_open() || m_fout.bad()) return false; if (getStringParam("Metadata",params)=="True") { // write metadata at the beginnig of the file string paramStr = getStringParam("Attrs",params); map<string,string> params = decodeAttributeStr(paramStr); ostringstream oss; for (map<string,string>::const_iterator it=params.begin();it!=params.end();it++) oss << "% " << it->first << "=" << it->second << endl; m_fout.write(oss.str().c_str(),oss.str().size()); } return true; }
bool SpecificWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { printf("<<< setParametersAndPossibleActivation\n"); // We didn't reactivate the component reactivated = false; // Update parameters params.clear(); for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { printf("param:%s value:%s\n", it->first.c_str(), it->second.value.c_str()); params[it->first] = it->second; } printf("----\n"); try { action = ""; for (uint i=0; i<params["action"].value.size(); i++) { action += params["action"].value[i]; if (i+2<params["action"].value.size()) { if (params["action"].value[i+1] == '_' and params["action"].value[i+2] == '_') break; } } std::transform(action.begin(), action.end(), action.begin(), ::tolower); // // action = params["action"].value; if (action == "graspobject") { active = true; } else { active = true; } } catch (...) { printf("exception in setParametersAndPossibleActivation %d\n", __LINE__); return false; } // Check if we should reactivate the component if (active) { active = true; reactivated = true; } printf("setParametersAndPossibleActivation >>>\n"); return true; }
ForceIdentityDistance::ForceIdentityDistance(const PointLayout& layout, const ParameterMap& params) : DistanceFunction(layout, params) { validParams = QStringList() << "distance" << "params"; _dist = MetricFactory::create(params.value("distance"), layout, params.value("params", ParameterMap()).toParameterMap()); }
ParameterMap parseOptions(int argc, char* argv[]) { if (argc < 3) { usage(); } QStringList args; for (int i=0; i<argc; i++) args << argv[i]; ParameterMap options; options.insert("inputFiles", args[1]); options.insert("dataset", args[2]); // this is ugly, but works... for (int i=0; i<args.size(); i++) { if (args[i].startsWith("--select=")) { descs_select = args[i].mid(9).split(","); args.removeAt(i); i--; } if (args[i].startsWith("--exclude=")) { descs_exclude = args[i].mid(10).split(","); args.removeAt(i); i--; } if (args[i].startsWith("--reflayout=")) { layout = new PointLayout(); Point refp; refp.load(args[i].mid(12)); *layout = refp.layout(); args.removeAt(i); i--; } if (args[i].startsWith("--nthreads=")) { QThreadPool::globalInstance()->setMaxThreadCount(args[i].mid(11).toInt()); args.removeAt(i); i--; } } int start = 0, end = 10000000; if (args.size() > 3) start = args[3].toInt(); if (args.size() > 4) end = args[4].toInt(); if (args.size() > 5) usage(); options.insert("start", start); options.insert("end", end); return options; }
int Scenario::loadMapBuf(string mapn) { mapname=mapn; ifstream mapfile; string tmpline; string loadfile=config.datadir+mapname; mapfile.open(loadfile.c_str()); if (mapfile) { cout << "Loading new map: " << loadfile << endl; } else { cout << "Map loading failed: " << loadfile << " not found!\n"; return 2; } mapbuf.clear(); /* We parse the parameters to add a name if it was missing This whole file reading looks much more complicated because of this (otherwise there would only be mapbuf.push_back(tmpline) */ string cname; Uint16 x,y; ParameterMap parameters; bool header=true; std::map<string,Uint16> namecount; while (getline(mapfile,tmpline)) { if (header) { mapbuf.push_back(tmpline); std::istringstream tmpstream(tmpline); tmpstream >> cname; if (cname[0]=='#') { if (cname=="#ENDHEADER") header=false; continue; } } else { cname.erase(); x=y=0; std::istringstream tmpstream(tmpline); tmpstream >> cname >> x >> y; if (cname.empty() || cname[0]=='#') { mapbuf.push_back(tmpline); continue; } else { namecount[cname]++; } string parameterlist((istreambuf_iterator<char>(tmpstream)), istreambuf_iterator<char>()); parameters=getParameters(parameterlist); if (!hasParam(parameters,"name")) { if (parameters.empty()) tmpline+=" name="+cname+itos(namecount[cname]); else tmpline+=", name="+cname+itos(namecount[cname]); } mapbuf.push_back(tmpline); } }
// Called to parse a RCSS keyword declaration. bool PropertyParserKeyword::ParseValue(Property& property, const String& value, const ParameterMap& parameters) const { ParameterMap::const_iterator iterator = parameters.find(value); if (iterator == parameters.end()) return false; property.value = Variant((*iterator).second); property.unit = Property::KEYWORD; return true; }
ex get_M_pm_sq_ob_FSE_Xpression(ParameterMap & pm ){ static ex X_FSE = Mpm_sq * M0_sq / pow( 4. * Pi * f , 2 ) * gtilde1( sqrt( M0_sq ) * L ) ; pm.add( B ); pm.add( f ); pm.add( c2 ); return X_FSE; }
ParameterMap Driver::parameters() { if(!isValid()) { return ParameterMap(); } ParameterMap parameterMap; const JSList *parameters = jackctl_driver_get_parameters(_jackDriver); while(parameters) { Parameter p = Parameter((jackctl_parameter_t*)parameters->data); parameterMap.insert(p.name(), p); parameters = parameters->next; } return parameterMap; }
ex get_f_pm_ob_FSE_Xpression(ParameterMap & pm ){ static ex xi_pm = Mpm_sq/ pow( 4. * Pi * f , 2 ); static ex xi_0 = M0_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_Mpm = gtilde1( sqrt( Mpm_sq ) * L ); static ex fse_log_corr_M0 = gtilde1( sqrt( M0_sq ) * L ); static ex X_FSE = f * ( - ( xi_pm * fse_log_corr_Mpm + xi_0 * fse_log_corr_M0 ) ) ; pm.add( B ); pm.add( f ); pm.add( c2 ); return X_FSE; }
DeleteMessageResponse* SQSConnection::deleteMessage(const std::string &aQueueUrl, const std::string &aReceiptHandle) { ParameterMap lMap; lMap.insert ( ParameterPair ( "ReceiptHandle", aReceiptHandle ) ); DeleteMessageHandler lHandler; makeQueryRequest ( aQueueUrl, "DeleteMessage", &lMap, &lHandler ); if (lHandler.isSuccessful()) { setCommons(lHandler, lHandler.theDeleteMessageResponse); return lHandler.theDeleteMessageResponse; } else { throw DeleteMessageException( lHandler.getQueryErrorResponse() ); } }
ex get_M_0_sq_ob_FSE_Xpression(ParameterMap & pm ){ static ex xi_0 = M0_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_M0 = gtilde1( sqrt( M0_sq ) * L ); static ex xi_pm = Mpm_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_Mpm = gtilde1( sqrt( Mpm_sq ) * L ); static ex X_FSE = Mpm_sq * ( 2.*xi_pm * fse_log_corr_Mpm - xi_0 * fse_log_corr_M0 ) + 2 * c2 *( - 4. * xi_0 * fse_log_corr_M0 ); pm.add( B ); pm.add( f ); pm.add( c2 ); return X_FSE; }
/** * Add/modify an entry in the parameter map for the given component * to update its rotation. The component is const * as the move doesn't actually change the object * @param comp A reference to the component to move * @param pmap A reference to the ParameterMap that will hold the new position * @param rot The rotation quaternion * @param rotType Defines how the given rotation should be interpreted @see * TransformType enumeration */ void rotateComponent(const IComponent &comp, ParameterMap &pmap, const Kernel::Quat &rot, const TransformType rotType) { // // This behaviour was copied from how RotateInstrumentComponent worked // Quat newRot = rot; if (rotType == Absolute) { // Find the corresponding relative position auto parent = comp.getParent(); if (parent) { Quat rot0 = parent->getRelativeRot(); rot0.inverse(); newRot = rot * rot0; } } else if (rotType == Relative) { const Quat &Rot0 = comp.getRelativeRot(); newRot = Rot0 * rot; } else { throw std::invalid_argument("rotateComponent - Unknown rotType: " + boost::lexical_cast<std::string>(rotType)); } // Add a parameter for the new rotation pmap.addQuat(comp.getComponentID(), "rot", newRot); }
void OutputFormat::setParameters(const std::string& outDir, const ParameterMap& formatParams) { m_outDir = outDir; m_params.clear(); ParameterDescriptorList pList = getParameters(); for (ParameterDescriptorList::iterator it=pList.begin(); it!=pList.end(); it++) { ParameterMap::const_iterator pIt = formatParams.find(it->m_identifier); if (pIt!=formatParams.end()) { m_params[it->m_identifier] = pIt->second; } else { m_params[it->m_identifier] = it->m_defaultValue; } } }
ListQueuesResponse* SQSConnection::listQueues(const std::string &aQueueNamePrefix) { ParameterMap lMap; if (aQueueNamePrefix != "") { lMap.insert ( ParameterPair ( "QueueNamePrefix", aQueueNamePrefix ) ); } ListQueuesHandler lHandler; makeQueryRequest ( "ListQueues", &lMap, &lHandler ); if (lHandler.isSuccessful()) { setCommons(lHandler, lHandler.theListQueuesResponse); return lHandler.theListQueuesResponse; } else { throw ListQueuesException( lHandler.getQueryErrorResponse() ); } }
/** * Add/modify an entry in the parameter map for the given component * to update its position. The component is const * as the move doesn't actually change the object * @param comp A reference to the component to move * @param pmap A reference to the ParameterMap that will hold the new position * @param pos The new position * @param positionType Defines how the given position should be interpreted @see * TransformType enumeration */ void moveComponent(const IComponent &comp, ParameterMap &pmap, const Kernel::V3D &pos, const TransformType positionType) { // // This behaviour was copied from how MoveInstrumentComponent worked // // First set it to the new absolute position V3D newPos = pos; switch (positionType) { case Absolute: // Do nothing break; case Relative: newPos += comp.getPos(); break; default: throw std::invalid_argument("moveComponent - Unknown positionType: " + boost::lexical_cast<std::string>(positionType)); } // Then find the corresponding relative position auto parent = comp.getParent(); if (parent) { newPos -= parent->getPos(); Quat rot = parent->getRotation(); rot.inverse(); rot.rotate(newPos); } // Add a parameter for the new position pmap.addV3D(comp.getComponentID(), "pos", newPos); }
Epic::AudioParameter& operator [] (Epic::StringHash id) { auto it = m_Params.find(id); if (it == std::end(m_Params)) return s_NullParameter; return *(*it).second; }
ParameterMap parseOptions(int argc, char* argv[]) { if (argc < 2) { G_ERROR("not enough arguments...\n\n" "Usage: " << argv[0] << " [-v] dataset_file"); } ParameterMap options; options.insert("verbose", false); if (argc >= 3) { if (QString(argv[1]) == "-v") { options.insert("verbose", true); options.insert("dataset", argv[2]); } else if (QString(argv[2]) == "-v") { options.insert("verbose", true); options.insert("dataset", argv[1]); } } else { options.insert("dataset", argv[1]); } return options; }
SendMessageResponse* SQSConnection::sendMessage(const std::string &aQueueUrl, const std::string &aMessageBody, bool aEncode) { ParameterMap lMap; long lBody64Len; std::string enc; if (aEncode) enc = AWSConnection::base64Encode(aMessageBody.c_str(), aMessageBody.size(), lBody64Len); else enc = aMessageBody; if (enc.size() > 32768) { std::stringstream lTmp; lTmp << "Message larger than 32kB : " << enc.size() / 1024 << " kb"; throw SendMessageException( QueryErrorResponse("1", lTmp.str(), "", "") ); } lMap.insert ( ParameterPair ( "MessageBody", enc ) ); return sendMessage(aQueueUrl, lMap); }
bool SpecificWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { printf("<<< setParametersAndPossibleActivation\n"); // We didn't reactivate the component reactivated = false; // Update parameters params.clear(); for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { params[it->first] = it->second; } try { action = params["action"].value; std::transform(action.begin(), action.end(), action.begin(), ::tolower); //TYPE YOUR ACTION NAME if (action == "actionname") { active = true; } else { active = true; } } catch (...) { printf("exception in setParametersAndPossibleActivation %d\n", __LINE__); return false; } // Check if we should reactivate the component if (active) { active = true; reactivated = true; } printf("setParametersAndPossibleActivation >>>\n"); return true; }
bool GenericWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { // We didn't reactivate the component reactivated = false; // Update parameters for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { params[it->first] = it->second; } try { // Action p.action = createAction(params["action"].value); // Fill received plan p.plan.clear(); QStringList actionList = QString::fromStdString(params["plan"].value).split(QRegExp("[()]+"), QString::SkipEmptyParts); for (int32_t actionString=0; actionString<actionList.size(); actionString++) { std::vector<string> elementsVec; QStringList elements = actionList[actionString].remove(QChar('\n')).split(QRegExp("\\s+"), QString::SkipEmptyParts); for (int32_t elem=0; elem<elements.size(); elem++) { elementsVec.push_back(elements[elem].toStdString()); } p.plan.push_back(elementsVec); } } catch (...) { return false; } // Check if we should reactivate the component if (isActive()) { activate(p); reactivated = true; } return true; }
ReceiveMessageResponse* SQSConnection::receiveMessage (const std::string &aQueueUrl, int aNumberOfMessages, int aVisibilityTimeout, bool aDecode) { ParameterMap lMap; if (aNumberOfMessages != 0) { std::stringstream s; s << aNumberOfMessages; lMap.insert (ParameterPair ("MaxNumberOfMessages", s.str())); } if (aVisibilityTimeout > -1) { std::stringstream s; s << aVisibilityTimeout; lMap.insert (ParameterPair ("VisibilityTimeout", s.str())); } return receiveMessage (aQueueUrl, lMap, aDecode); }
std::string Component::getStringParam(const std::string& id, const ParameterMap& params) { ParameterMap::const_iterator it=params.find(id); if (it!=params.end()) { if (it->second.size()==0) { cerr << "ERROR: parameter " << id << " is empty !" << endl; return EMPTY_STRING; } return it->second; } ParameterDescriptorList pList = getParameterDescriptorList(); for (ParameterDescriptorList::const_iterator descIt=pList.begin(); descIt!=pList.end(); descIt++) { if (descIt->m_identifier==id) return descIt->m_defaultValue; } cerr << "ERROR: no parameter " << id << " for component " << getIdentifier() << " !" << endl; return EMPTY_STRING; }
bool SpecificWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { // We didn't reactivate the component reactivated = false; // Update parameters params.clear(); for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { params[it->first] = it->second; } try { action = params["action"].value; std::transform(action.begin(), action.end(), action.begin(), ::tolower); if (action == "findobjectvisually") { active = true; } else { active = true; } } catch (...) { return false; } // Check if we should reactivate the component if (active) { active = true; reactivated = true; } return true; }
CreateQueueResponse* SQSConnection::createQueue ( const std::string &aQueueName, int aDefaultVisibilityTimeout) { ParameterMap lMap; lMap.insert ( ParameterPair ( "QueueName", aQueueName ) ); if (aDefaultVisibilityTimeout > -1 ) { std::stringstream s; s << aDefaultVisibilityTimeout; lMap.insert ( ParameterPair ( "DefaultVisibilityTimeout", s.str() ) ); } CreateQueueHandler lHandler; makeQueryRequest ( "CreateQueue", &lMap, &lHandler ); if (lHandler.isSuccessful()) { setCommons(lHandler, lHandler.theCreateQueueResponse); return lHandler.theCreateQueueResponse; } else { throw CreateQueueException( lHandler.getQueryErrorResponse() ); } }
ex get_M_pm_sq_ob_Xpression(ParameterMap & pm , bool withFS /* =true */ ){ static ex xi_0 = M0_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_M0 = gtilde1( sqrt( M0_sq ) * L ); static ex log_M0_L3 = log( M0_sq / pow( Lambda3 , 2 ) ) ; static ex X_FSE = ( Mpm_sq * ( 1. + xi_0 * ( log_M0_L3 + fse_log_corr_M0 )+ CMpm ) ) ; static ex X = ( Mpm_sq * ( 1. + xi_0 * log_M0_L3 + CMpm ) ) ; pm.add( B ); pm.add( f ); pm.add( c2 ); pm.add( Lambda3 ); pm.add( CMpm ); if(withFS) return X_FSE; else return X; }
int LuaBinding::ActorAdd() { const char* actorAlias = NULL; Vector2i actorPosition; if (!Peek(1, &actorAlias) || !Peek(2, &actorPosition)) { return ERROR_TYPE_PARAMETER; } const char* actorName = NULL; Peek(3, &actorName); ParameterMap parameters; Peek(4, ¶meters); IWorldContext* worldContext = System::QueryWorldContext(); if (worldContext == NULL) { return ERROR_TYPE_STATE; } const boost::shared_ptr<Actor> actor = worldContext->AddActor(actorAlias, actorPosition, actorName).lock(); if (!actor) { return ERROR_TYPE_STATE; } const boost::shared_ptr<ActorPropertyScript> property = actor->GetProperty<ActorPropertyScript>().lock(); if (property) { for (ParameterMap::iterator iter = parameters.begin(); iter != parameters.end(); ++iter) { property->SetParameter(iter->first.c_str(), iter->second); } } Push(actor->GetId()); return 1; }
int main(int argc, char* argv[]) { QCoreApplication app(argc, argv); gaia2::verbose = true; // get command-line options ParameterMap options = parseOptions(argc, argv); yaml::Node filelist = yaml::loadFromFile(options.value("inputFiles")); const yaml::Mapping& tracks = filelist.mapping(); // convert our yaml::Map to a QMap we can give to mergeFiles QMap<QString, QString> sigfiles; yaml::Mapping::const_iterator it = tracks.constBegin(); for (; it != tracks.constEnd(); ++it) { sigfiles.insert(it.key().toString(), it.value().toString()); } //qDebug() << "Found" << tracks.size() << "in filelist"; // do the actual merging DataSet* dataset = DataSet::mergeFiles(sigfiles, descs_select, descs_exclude, options.value("start").toInt(), options.value("end").toInt(), layout); // save dataset & clean up stuff qDebug() << "Saving dataset..."; dataset->save(options.value("dataset")); qDebug() << "Dataset successfully saved!"; // let the OS reclaim the memory itself, much faster than deleting the dataset here... //delete dataset; return 0; }
ex get_f_pm_ob_Xpression(ParameterMap &pm,bool withFS){ static ex xi_pm = Mpm_sq/ pow( 4. * Pi * f , 2 ); static ex xi_0 = M0_sq/ pow( 4. * Pi * f , 2 ); static ex fse_log_corr_Mpm = gtilde1( sqrt( Mpm_sq ) * L ); static ex fse_log_corr_M0 = gtilde1( sqrt( M0_sq ) * L ); static ex log_M0_L4 = log( M0_sq / pow( Lambda4 , 2 ) ); static ex log_Mpm_L4 = log( Mpm_sq / pow( Lambda4 , 2 ) ); static ex X_FSE = f * ( 1. - ( xi_pm * ( log_Mpm_L4 + fse_log_corr_Mpm ) + xi_0 * ( log_M0_L4 + fse_log_corr_M0 ) ) + Cf ) ; static ex X = f * ( 1. - ( xi_pm * log_Mpm_L4 + xi_0 * log_M0_L4 ) + Cf ) ; pm.add( B ); pm.add( f ); pm.add( c2 ); pm.add( Lambda4 ); pm.add( Cf ); if( withFS ) return X_FSE; else return X; }