RenderAf::RenderAf( const std::string & i_store_dir): af::Render(), AfNodeSrv( this, i_store_dir) { //printf("RenderAf::RenderAf:\n"); //printf("this = %p\n", this); // setNode( this); AFINFA("RenderAf::RenderAf(%d)", m_id); initDefaultValues(); int size; char * data = af::fileRead( getStoreFile(), &size); if( data == NULL ) return; rapidjson::Document document; char * res = af::jsonParseData( document, data, size); if( res == NULL ) { delete [] data; return; } if( jsonRead( document)) setStoredOk(); delete [] res; delete [] data; // This render came from store on server start, it can't be online or busy setOffline(); setBusy( false); }
CalibrationHelperCms::CalibrationHelperCms(boost::shared_ptr<CmsSwap> cmsSwap, boost::shared_ptr<CmsPricer> pricer, vector<long> swapLetNumbers, vector<double> margins, boost::shared_ptr<SabrRbsSmile> volCube, int undPillarIndex, long noOptPillars ) : cmsSwap_(cmsSwap), pricer_(pricer), volCube_(volCube), undPillarIndex_(undPillarIndex), useStdCube_(false) { QL_REQUIRE(swapLetNumbers.size()==margins.size(),"Swaplet numbers vector (" << swapLetNumbers.size() << ") must have same length as margins vector (" << margins.size() << ")"); optPillarTimes_ = volCube->optionPillarTimes(); if(noOptPillars>0) noOptPillars_=noOptPillars; else noOptPillars_=optPillarTimes_.size(); QL_REQUIRE(noOptPillars_ <= optPillarTimes_.size(),"Number of option pillars (" << noOptPillars_ << ") must be leq opt pillar times (" << optPillarTimes_.size() << ")"); int pos=0; for(int i=0;i<swapLetNumbers.size();i++) { pos+=swapLetNumbers[i]; swpGroupEnds_.push_back(pos); } for(int i=0;i<margins.size();i++) { marketMargins_.push_back(margins[i]); modelMargins_.push_back(0.0); } initDefaultValues(); }
CalibrationHelperCmsCorrelations::CalibrationHelperCmsCorrelations(vector<boost::shared_ptr<SingleLookSpreadOption>> singleLookSpreadOptions, boost::shared_ptr<CmsPricer> pricer, vector<double> prices, boost::shared_ptr<CorrelationTermStructure> corrTS, double lambda, bool useDiffStrike, double diffStrike, int diffFlavour) : pricer_(pricer),corrTS_(corrTS), lambda_(lambda), singleLookSpreadOptions_(singleLookSpreadOptions),marketPrices_(prices), useDiffStrike_(useDiffStrike), diffStrike_(diffStrike), diffFlavour_(diffFlavour) { useSingleLook_=true; initDefaultValues(); }
CalibrationHelperCms::CalibrationHelperCms(boost::shared_ptr<CmsSwap> cmsSwap, boost::shared_ptr<CmsPricer> pricer, vector<long> swapLetNumbers, vector<double> weights, vector<double> margins, boost::shared_ptr<SwaptionVolCube4> volCube2, Period underlying, long noOptPillars, long skipOptPillars ) : cmsSwap_(cmsSwap), pricer_(pricer), volCube2_(volCube2), underlying_(underlying), useStdCube_(true) { QL_REQUIRE(swapLetNumbers.size()==margins.size(),"Swaplet numbers vector (" << swapLetNumbers.size() << ") must have same length as margins vector (" << margins.size() << ")"); QL_REQUIRE(swapLetNumbers.size()==weights.size(),"Swaplet numbers vector (" << swapLetNumbers.size() << ") must have same length as weights vector (" << weights.size() << ")"); optPillarTimes_ = volCube2->optionTimes(); if(noOptPillars>0) noOptPillars_=noOptPillars; else noOptPillars_=optPillarTimes_.size(); skipOptPillars_=skipOptPillars; // QL_REQUIRE(noOptPillars_ <= optPillarTimes_.size(),"Number of option pillars (" << noOptPillars_ << ") must be leq opt pillar times (" << optPillarTimes_.size() << ")"); int pos=0; for(int i=0;i<swapLetNumbers.size();i++) { pos+=swapLetNumbers[i]; swpGroupEnds_.push_back(pos); } for(int i=0;i<margins.size();i++) { marketMargins_.push_back(margins[i]); modelMargins_.push_back(0.0); } // rescale weights double sumW=0.0; weights_=vector<double>(weights.size(),0.0); for(int i=0;i<weights.size();i++) { sumW+=weights[i]; } for(int i=0;i<weights.size();i++) { weights_[i] = sqrt(weights[i]/sumW); } initDefaultValues(); }
PPETask::PPETask(DjiPoint _startSprayingPosition,double _sprayingDirection, double _sprayingWidth, int _droneNum, bool _isUseCoordTransform) { if (!(_sprayingDirection <= 360 && _sprayingDirection >= 0 && _sprayingWidth>0 && _sprayingWidth<=MAX_SPRAY_WIDTH_METER)) { printLog("WaypointTask init input error", true); } if (_isUseCoordTransform) { if (!isLegalLatLong(_startSprayingPosition)) { printLog("_startSprayingPosition is illegal LatLong", true); } } if (_droneNum<1) { printLog("inupt error droneNum<1", true); } isUseCoordTransform = _isUseCoordTransform; //all the latitude_longtitude data will be transformed into plane coordinate (the unit is metre) tran = isUseCoordTransform ? CoordTransform(_startSprayingPosition) : CoordTransform(); homePoint = isUseCoordTransform ? tran.latlong2plane(_startSprayingPosition) : _startSprayingPosition; droneNum = _droneNum; forwardVec = CoordTransform::dirSouthEastFromNorthAngle(_sprayingDirection); forwardVec = forwardVec / molMat(forwardVec); //rotate clockwise 90 degree sideVec.x = forwardVec.y; sideVec.y = -forwardVec.x; sprayWidth = _sprayingWidth; printLog(" "); printPoint("startSprayingPosition: ", _startSprayingPosition); printLog("sprayingDirection: " + double2string(_sprayingDirection)); printLog("sprayingWidth: " + double2string(sprayWidth)); printLog("droneNum: " + int2string(droneNum)); initDefaultValues(); }
CalibrationHelperCmsCorrelations::CalibrationHelperCmsCorrelations(boost::shared_ptr<CmsSpreadOption> spreadOption, boost::shared_ptr<CmsPricer> pricer, long firstOptionlet, vector<long> optionLetNumbers, vector<double> prices, boost::shared_ptr<CorrelationTermStructure> corrTS, double lambda, bool useDiffStrike, double diffStrike, int diffFlavour) : spreadOption_(spreadOption), pricer_(pricer), corrTS_(corrTS), lambda_(lambda), firstOptionlet_(firstOptionlet), useDiffStrike_(useDiffStrike), diffStrike_(diffStrike), diffFlavour_(diffFlavour) { int pos=firstOptionlet_; for(int i=0;i<optionLetNumbers.size();i++) { pos+=optionLetNumbers[i]; optGroupEnds_.push_back(pos); } for(int i=0;i<prices.size();i++) { double bef=0.0; if(i>0) bef = prices[i-1]; marketPrices_.push_back(prices[i] - bef); } useSingleLook_=false; initDefaultValues(); }
PRUoutcome::PRUoutcome() { initDefaultValues(); }
PRUoutcome::PRUoutcome(xmlpp::TextReader &reader) { initDefaultValues(); if (reader.has_attributes()) { reader.move_to_first_attribute(); do { if (reader.get_name() == "id") name = reader.get_value(); else if (reader.get_name() == "p") probability = atof(reader.get_value().c_str()); } while (reader.move_to_next_attribute()); reader.move_to_element(); } while(reader.read()) { string name = reader.get_name(); if ((reader.get_node_type() == xmlpp::TextReader::EndElement) && (name == "Outcome")) break; if (reader.get_node_type() != xmlpp::TextReader::Element ) continue; if (name == "Quality") { if (reader.has_attributes()) { reader.move_to_first_attribute(); do { if (reader.get_name() == "kind") quality = reader.get_value(); else if (reader.get_name() == "param") qualityParameter = atof(reader.get_value().c_str()); else if (reader.get_name() == "const") qualityConstant = atof(reader.get_value().c_str()); } while (reader.move_to_next_attribute()); reader.move_to_element(); } } else if (name == "Duration") { if (reader.has_attributes()) { reader.move_to_first_attribute(); do { if (reader.get_name() == "kind") duration = reader.get_value(); else if (reader.get_name() == "param") durationParameter = atof(reader.get_value().c_str()); else if (reader.get_name() == "const") durationConstant = atof(reader.get_value().c_str()); } while (reader.move_to_next_attribute()); reader.move_to_element(); } } else if (name == "Observe") { if (reader.has_value()) observable = reader.get_value(); else observable = reader.read_string(); } else if (name == "SVU") { readVector(stateVariableUpdate,reader); } else if (name == "Final") { isFinal = true; if (reader.has_attributes()) { reader.move_to_first_attribute(); do { if (reader.get_name() == "label") finalLabel = reader.get_value(); } while (reader.move_to_next_attribute()); reader.move_to_element(); } } else if (name == "Next") readVector(nextModules,reader,"\n "); else std::cerr << "Unexpected tag " << name << "!" << std::endl; } // while reader.read() } // PRUoutcome(reader)
MessageGenerator::MessageGenerator(const char* path, bool keepfile, SchemaType st, IProperties* globals) : m_keepfile(keepfile), m_schemaType(st) { if(globals) m_globals = globals; m_items = globals->queryProp("items")?atoi(globals->queryProp("items")):1; m_isRoxie = globals->queryProp("roxie") ? true : false; m_genAllDatasets = globals->queryProp("alldataset") ? true : false; m_gx = globals->queryProp("gx") ? true : false; m_soapWrap = globals->queryProp("gs") ? false: true; m_ecl2esp = globals->getPropBool("ECL2ESP", false); if (m_ecl2esp) m_items = 1; if (globals->queryProp("gf")) m_gfile.set(globals->queryProp("gf")); if (globals->queryProp("cfg")) { StringBuffer cfg; if (loadFile(cfg, globals->queryProp("cfg"))) m_cfg.setown(createPTreeFromXMLString(cfg)); else ERRLOG("Can not load cfg file; ignored"); } m_logfile = stdout; if(!path || !*path) { throw MakeStringException(-1, "please provide the path of wsdl"); } m_path.append(path); if(strnicmp(path, "http:", 5) == 0 || strnicmp(path, "https:", 6) == 0) { HttpClient client(NULL, path); StringBuffer requestbuf; client.generateGetRequest(requestbuf); client.sendRequest(requestbuf, NULL, NULL, NULL, &m_schema); const char* ptr = m_schema.str(); if(ptr) { ptr = strchr(ptr, '<'); if(!ptr) { if(http_tracelevel > 0) fprintf(m_logfile, "The schema is not valid xml%s", LT); return; } else m_schema.remove(0, ptr - m_schema.str()); } } else { m_schema.loadFile(path); if(http_tracelevel >= 10) fprintf(m_logfile, "Loaded schema:\n%s\n", m_schema.str()); } if(m_schema.length() == 0) { throw MakeStringException(-1, "wsdl is empty"); } Owned<IPropertyTree> schema = createPTreeFromXMLString(m_schema.str()); if (m_isRoxie) m_roxieSchemaRoot.set(schema->queryBranch("//Result")); else m_schemaTree.set(schema); if(!m_schemaTree.get() && !m_roxieSchemaRoot.get()) throw MakeStringException(-1, "can't generate property tree from schema"); setXsdNamespace(); if (!m_isRoxie) { if(m_schemaType == WSDL) { Owned<IPropertyTreeIterator> mi = m_schemaTree->getElements("portType/operation"); if(mi.get()) { std::set<std::string> methods; for (mi->first(); mi->isValid(); mi->next()) { const char *name = mi->query().queryProp("@name"); if(!name || !*name) continue; StringBuffer xpath; xpath.clear().append("portType/operation[@name='").append(name).append("']/input/@message"); const char* input = m_schemaTree->queryProp(xpath.str()); if(!input || !*input) throw MakeStringException(-1, "can't find input message for method %s", name); if(strncmp(input, "tns:", 4) == 0) input += 4; xpath.clear().append("message[@name='").append(input).append("']/part/@element"); const char* element = m_schemaTree->queryProp(xpath.str()); if(!element || !*element) throw MakeStringException(-1, "can't find message %s\n", input); if(strncmp(element, "tns:", 4) == 0) element += 4; if(methods.find(element) == methods.end()) { methods.insert(element); m_methods.append(element); } xpath.clear().append("portType/operation[@name='").append(name).append("']/output/@message"); const char* output = m_schemaTree->queryProp(xpath.str()); if(!output || !*output) throw MakeStringException(-1, "can't find output message for method %s", name); if(strncmp(output, "tns:", 4) == 0) output += 4; xpath.clear().append("message[@name='").append(output).append("']/part/@element"); element = m_schemaTree->queryProp(xpath.str()); if(!element || !*element) throw MakeStringException(-1, "can't find message %s\n", output); if(strncmp(element, "tns:", 4) == 0) element += 4; if(methods.find(element) == methods.end()) { methods.insert(element); m_methods.append(element); } } } } else { Owned<IPropertyTreeIterator> mi = m_schemaTree->getElements(VStringBuffer("%s:element",xsdNs())); if(mi.get()) { for (mi->first(); mi->isValid(); mi->next()) { const char *name = mi->query().queryProp("@name"); if(name && *name) m_methods.append(name); } } } } initDefaultValues(); }
SettingsManager::SettingsManager() : mSettings("SPbSU", "QReal") { initDefaultValues(); load(); }
RenderAf::RenderAf( af::Msg * msg): af::Render( msg), AfNodeSrv( this) { initDefaultValues(); }