当前位置: 首页>>代码示例>>C++>>正文


C++ Analysis类代码示例

本文整理汇总了C++中Analysis的典型用法代码示例。如果您正苦于以下问题:C++ Analysis类的具体用法?C++ Analysis怎么用?C++ Analysis使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Analysis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST_F

TEST_F(AnalysisFixture, DataPoint_JSONSerialization_PreRun_Roundtrip) {
  Analysis analysis = analysis1(PreRun);

  // Retrieve data point
  ASSERT_FALSE(analysis.dataPoints().empty());
  DataPoint dataPoint = analysis.dataPoints()[0];

  // Serialize data point
  std::string json = dataPoint.toJSON();
  EXPECT_FALSE(json.empty());

  // Deserialize and check results
  AnalysisJSONLoadResult loadResult = loadJSON(json);
  ASSERT_TRUE(loadResult.analysisObject);
  ASSERT_TRUE(loadResult.analysisObject->optionalCast<DataPoint>());
  DataPoint copy = loadResult.analysisObject->cast<DataPoint>();
  EXPECT_EQ(json,copy.toJSON());

  // Save data point
  openstudio::path p = toPath("AnalysisFixtureData/data_point_pre_run.json");
  EXPECT_TRUE(dataPoint.saveJSON(p,true));

  // Load and check results
  loadResult = loadJSON(json);
  ASSERT_TRUE(loadResult.analysisObject);
  ASSERT_TRUE(loadResult.analysisObject->optionalCast<DataPoint>());
  copy = loadResult.analysisObject->cast<DataPoint>();
  EXPECT_EQ(json,copy.toJSON());
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:29,代码来源:DataPoint_GTest.cpp

示例2: strlen

list<Analysis *> * HfstAnalyzer::analyze(const char * word, bool fullMorphology) {
	//cerr << "HfstAnalyzer::analyze (" << string(word) << ")" << endl;
	size_t wlen = strlen(word);
	if (wlen > LIBVOIKKO_MAX_WORD_CHARS) {
		return new list<Analysis *>();
	}
	list<Analysis *> * analysisList = new list<Analysis *>();

	/* I know this is the wrong thing, but going to do it anyway */
	std::string str(word);
	char * writable = new char[str.size() + 1];
	std::copy(str.begin(), str.end(), writable);
	writable[str.size()] = '\0';

	hfst_ospell::AnalysisQueue q = t->lookup(writable);

	while(q.size() > 0) {
		hfst_ospell::StringWeightPair pair = q.top();
		string analysis = pair.first;
		string tags = analysis.substr(analysis.find("+"),analysis.length()-1);
		Analysis * a = new Analysis();
		if (fullMorphology) {
			string lemma = analysis.substr(0,analysis.find("+"));
			a->addAttribute(Analysis::Key::BASEFORM,  StringUtils::ucs4FromUtf8(lemma.c_str()));
		}
		a->addAttribute(Analysis::Key::FSTOUTPUT,  StringUtils::ucs4FromUtf8(tags.c_str()));
		analysisList->push_back(a);
		q.pop();
	}

	return analysisList;
}
开发者ID:voikko,项目名称:corevoikko,代码行数:32,代码来源:HfstAnalyzer.cpp

示例3: bzero

void UdpAnalysis::analyzeProtocol(ProtocolStack &pstack, size_t *bytes)
{
	if(_bufsize < sizeof(_udphdr))
	{
		bzero(&_udphdr, sizeof(_udphdr));
		return;
	}
	
	memcpy(&_udphdr, _buffer, sizeof(_udphdr));
	_udphdr.source = ntohs(_udphdr.source);
	_udphdr.dest = ntohs(_udphdr.dest);
	_udphdr.len = ntohs(_udphdr.len);
	_udphdr.check = ntohs(_udphdr.check);

	if(bytes != NULL)
		*bytes += _udphdr.len;
	pstack.push_back(this);

	int port = _udphdr.source < _udphdr.dest ? _udphdr.source:_udphdr.dest;
	Analysis *child = _getChild(port);
	if(child != NULL)
	{
		child->setBuffer(_buffer + 8, _bufsize - 8);
		child->analyzeProtocol(pstack, NULL);
	}
}
开发者ID:ljianhui,项目名称:NetworkSniffer,代码行数:26,代码来源:udpanalysis.cpp

示例4: fq

void MainWindow::saveSelected(const QString &filename)
{
	if (_analyses->count() > 0)
	{
		QWebElement element =  ui->webViewResults->page()->mainFrame()->documentElement();
		QString qHTML = element.toOuterXml();
		_package->analysesHTML = fq(qHTML);

		Json::Value analysesData = Json::arrayValue;
		for (Analyses::iterator itr = _analyses->begin(); itr != _analyses->end(); itr++)
		{
			Analysis *analysis = *itr;
			if (analysis != NULL && analysis->visible())
			{
				Json::Value analysisData = analysis->asJSON();
				analysisData["options"] = analysis->options()->asJSON();
				analysesData.append(analysisData);
			}
		}

		_package->analysesData = analysesData;
		_package->hasAnalyses = true;
	}

	_loader.save(filename, _package);
	_alert->show();
}
开发者ID:MaxG87,项目名称:jasp-desktop,代码行数:27,代码来源:mainwindow.cpp

示例5: if

void Engine::receiveMessages(int timeout)
{
	string data;

	if (_channel->receive(data, timeout))
	{
		Value jsonRequest;
		Reader r;
		r.parse(data, jsonRequest, false);

		string analysisName = jsonRequest.get("name", nullValue).asString();
		int id = jsonRequest.get("id", -1).asInt();
		bool run = jsonRequest.get("perform", "run").asString() == "run";
		Value jsonOptions = jsonRequest.get("options", nullValue);

		if (_currentAnalysis != NULL && _currentAnalysis->id() == id)
		{
			_currentAnalysis->options()->set(jsonOptions);
			if (run)
				_currentAnalysis->setStatus(Analysis::Running);
			else
				_currentAnalysis->setStatus(Analysis::Empty);
		}
		else if (_nextAnalysis != NULL && _nextAnalysis->id() == id)
		{
			_nextAnalysis->options()->set(jsonOptions);
			if (run)
				_nextAnalysis->setStatus(Analysis::Running);
			else
				_nextAnalysis->setStatus(Analysis::Empty);
		}
		else
		{
			Analysis *analysis = AnalysisLoader::load(id, analysisName);
			analysis->options()->set(jsonOptions);
			if (run)
				analysis->setStatus(Analysis::Running);

			if (_dataSet == NULL)
			{
				managed_shared_memory *mem = SharedMemory::get();
				_dataSet = mem->find<DataSet>(boost::interprocess::unique_instance).first;
				_R.setDataSet(_dataSet);
			}

			analysis->setDataSet(_dataSet);
			analysis->setRInterface(&_R);
			analysis->resultsChanged.connect(boost::bind(&Engine::analysisResultsChanged, this, _1));

			if (_nextAnalysis != NULL)
				delete _nextAnalysis;

			_nextAnalysis = analysis;

			if (_currentAnalysis != NULL)
				_currentAnalysis->setStatus(Analysis::Aborted);
		}
	}
}
开发者ID:AlexanderLyNL,项目名称:jasp-desktop,代码行数:59,代码来源:engine.cpp

示例6: clear

void Analyses::clear()
{
	for (Analyses::iterator itr = this->begin(); itr != this->end(); itr++)
	{
		Analysis *analysis = *itr;
		if (analysis->status() != Analysis::Complete)
			analysis->setStatus(Analysis::Aborted);
	}
}
开发者ID:AlexanderLyNL,项目名称:jasp-desktop,代码行数:9,代码来源:analyses.cpp

示例7: main

int main( int argc, char **argv )
{
  Analysis *scmanal = new Analysis( 1, 0, 3, "AMPLITUDE DURATION RATE", argc, argv );
  double amplitude = atof( argv[ 2 ] );
  double duration = atof( argv[ 3 ] );
  double rate = atof( argv[ 4 ] );

  char output_comment[ 256 ];
  snprintf( output_comment, 256, "(%f) * noise", amplitude );
  scmanal->set_comment( 0, output_comment );

  scmanal->set_type( 0, TIME_DOMAIN );
  scmanal->set_begin( 0, 0 );
  scmanal->set_end( 0, duration );
  scmanal->set_compl_begin( 0, 0 );
  scmanal->set_compl_end( 0, rate / 2 );

  size_t length = int(duration * rate);

  scmanal->make_outputs( length );
  double *output = scmanal->get_file( 0 );

  for ( uint i = 0; i < length; i++ ) {
    output[ i ] = 2*amplitude*((rand()/(RAND_MAX+1.0))-.5);
  }

  delete scmanal;
}
开发者ID:keithw,项目名称:Audio-Analysis,代码行数:28,代码来源:noisegen.cpp

示例8: TEST_F

TEST_F(AnalysisDriverFixture,RuntimeBehavior_StopAndRestartDakotaAnalysis) {

  // RETRIEVE PROBLEM
  Problem problem = retrieveProblem("SimpleHistogramBinUQ",true,false);

  // DEFINE SEED
  Model model = model::exampleModel();
  openstudio::path p = toPath("./example.osm");
  model.save(p,true);
  FileReference seedModel(p);

  // CREATE ANALYSIS
  SamplingAlgorithmOptions algOptions;
  algOptions.setSamples(10);
  Analysis analysis("Stop and Restart Dakota Analysis",
                    problem,
                    SamplingAlgorithm(algOptions),
                    seedModel);

  // RUN ANALYSIS
  if (!dakotaExePath().empty()) {
    ProjectDatabase database = getCleanDatabase("StopAndRestartDakotaAnalysis");
    AnalysisDriver analysisDriver(database);
    AnalysisRunOptions runOptions = standardRunOptions(analysisDriver.database().path().parent_path());
    StopWatcher watcher(analysisDriver);
    watcher.watch(analysis.uuid());
    CurrentAnalysis currentAnalysis = analysisDriver.run(analysis,runOptions);
    analysisDriver.waitForFinished();
    EXPECT_FALSE(analysisDriver.isRunning());

    // check conditions afterward
    boost::optional<runmanager::JobErrors> jobErrors = currentAnalysis.dakotaJobErrors();
    ASSERT_TRUE(jobErrors);
    EXPECT_FALSE(jobErrors->errors().empty());
    EXPECT_FALSE(currentAnalysis.analysis().dataPoints().empty());
    EXPECT_FALSE(currentAnalysis.analysis().dataPointsToQueue().empty());
    EXPECT_FALSE(currentAnalysis.analysis().completeDataPoints().empty());
    EXPECT_FALSE(currentAnalysis.analysis().successfulDataPoints().empty());
    EXPECT_TRUE(currentAnalysis.analysis().failedDataPoints().empty());
    EXPECT_FALSE(currentAnalysis.analysis().algorithm()->isComplete());
    EXPECT_FALSE(currentAnalysis.analysis().algorithm()->failed());
    EXPECT_EQ(0u,analysisDriver.currentAnalyses().size());
    LOG(Debug,"After initial stop, there are " << currentAnalysis.analysis().dataPoints().size()
        << " data points, of which " << currentAnalysis.analysis().completeDataPoints().size()
        << " are complete.");

    // try to restart from database contents
    Analysis analysis = AnalysisRecord::getAnalysisRecords(database)[0].analysis();
    ASSERT_TRUE(analysis.algorithm());
    EXPECT_FALSE(analysis.algorithm()->isComplete());
    EXPECT_FALSE(analysis.algorithm()->failed());
    currentAnalysis = analysisDriver.run(analysis,runOptions);
    analysisDriver.waitForFinished();
    EXPECT_EQ(10u,analysis.dataPoints().size());
    EXPECT_EQ(0u,analysis.dataPointsToQueue().size());
    EXPECT_EQ(10u,analysis.completeDataPoints().size());
    EXPECT_EQ(10u,analysis.successfulDataPoints().size());
    EXPECT_EQ(0u,analysis.failedDataPoints().size());
  }
}
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:60,代码来源:RuntimeBehavior_GTest.cpp

示例9: Equals

	bool Analysis::operator==(const Analysis &analysis) const
	{
		if (GetState()!=analysis.GetState())
			return false;
		if (m_negated!=analysis.m_negated)
			return false;
		if (GetType()!=analysis.GetType())
			return false;
		else
			return Equals(&analysis);
	}
开发者ID:MarkVanPeteghem,项目名称:RichBooleans,代码行数:11,代码来源:analysis.cpp

示例10: sendToProcess

void EngineSync::sendMessages()
{
#ifdef QT_DEBUG
	std::cout << "send messages\n";
	std::cout.flush();
#endif

	for (int i = 0; i < _analysesInProgress.size(); i++)
	{
		Analysis *analysis = _analysesInProgress[i];
		if (analysis != NULL && analysis->status() == Analysis::Empty)
			sendToProcess(i, analysis);
	}

	for (Analyses::iterator itr = _analyses->begin(); itr != _analyses->end(); itr++)
	{
		Analysis *analysis = *itr;

		if (analysis->status() == Analysis::Empty)
		{
			bool sent = false;

			for (int i = 0; i < _analysesInProgress.size(); i++)
			{
				if (_analysesInProgress[i] == NULL)
				{
					sendToProcess(i, analysis);
					sent = true;
					break;
				}
			}

			if (sent == false)  // no free processes left
				return;
		}
		else if (analysis->status() == Analysis::Inited)
		{
#ifndef QT_DEBUG
			for (int i = 1; i < _analysesInProgress.size(); i++) // don't perform 'runs' on process 0, only inits.
#else
			for (int i = 0; i < _analysesInProgress.size(); i++)
#endif
			{
				if (_analysesInProgress[i] == NULL)
				{
					sendToProcess(i, analysis);
					break;
				}
			}
		}
	}

}
开发者ID:HelenSteingroever,项目名称:jasp-desktop,代码行数:53,代码来源:enginesync.cpp

示例11: TEST_F

TEST_F(ProjectFixture,Profile_ProblemSave) {
  Analysis analysis = getAnalysisToRun(100,0);

  // time the process of saving to database
  ptime start = microsec_clock::local_time();
  ProjectDatabase db = getCleanDatabase(toPath("./ProblemSave"));
  ASSERT_TRUE(db.startTransaction());
  ProblemRecord record = ProblemRecord::factoryFromProblem(analysis.problem(),db);
  db.save();
  ASSERT_TRUE(db.commitTransaction());
  time_duration saveTime = microsec_clock::local_time() - start;

  std::cout << "Time: " << to_simple_string(saveTime) << std::endl;
}
开发者ID:NREL,项目名称:OpenStudio-resources,代码行数:14,代码来源:ProjectDatabaseProfiling_GTest.cpp

示例12: runPixelTreeMaker

void runPixelTreeMaker(Bool_t doMC         = 0,
                       const char *files   = 0,
                       const char *outfile = 0,
                       UInt_t nev          = 0,
		       Float_t SDRelFrac   = 1.)
{
  gDebugMask  = Debug::kAnalysis;
  gDebugLevel = 1;
  gErrorIgnoreLevel = kInfo;

  // setup analysis object
  Analysis *ana = new Analysis;
  ana->SetUseHLT(1);
  if (nev>0)
    ana->SetProcessNEvents(nev);
  TString ofname(gSystem->Getenv("MIT_OUTPUTFILE"));
  if (!ofname.IsNull()) 
    ana->SetOutputName(ofname);

  if (files) {
    TString dummy(files);
    TString suffix(dummy(dummy.Length()-4,dummy.Length()));
    if (suffix.CompareTo("root")==0)
      ana->AddFile(files);
    else
      ana->AddFiles(files);
  }

  HLTMod *hmod = new HLTMod;
  hmod->SetPrintTable(1);
  ana->AddSuperModule(hmod);

  // setup modules
  PixelsMakerMod *mod = new PixelsMakerMod;
  mod->SetIsMC(doMC);
  mod->AddVertexName("Pixel3Vertexes");
  mod->AddVertexName("TrackletVertexes");
  mod->AddVertexName("ClusterVertexes");
  mod->AddVertexName("PixelVertexes");
  mod->AddVertexName("PrimaryVertexes");
  mod->AddVertexName("PrimaryVertexesBeamSpot");
  // - diffractive study -
  mod->SetUseHfOnly(true);
  mod->SetSDRelFrac(SDRelFrac);

  if (outfile)
    mod->SetFileName(Form("%s_SDRelFrac%.1f.root",outfile,SDRelFrac));
  else
    mod->SetFileName("pixeltree.root");

  ana->AddSuperModule(mod);
  
  // run the analysis after successful initialisation
  ana->Run(!gROOT->IsBatch());
}
开发者ID:CmsHI,项目名称:CVS_SavedFMa,代码行数:55,代码来源:runPixelTreeMaker.C

示例13: getJpsiPars

Str2VarMap getJpsiPars(TString type, TCut cut, TFile * file)
{
	string datafilename = "/afs/cern.ch/work/p/pluca/weighted/Lmumu/candLb.root";
	string candfilename = "/afs/cern.ch/work/p/pluca/weighted/Lmumu/candLb_MC.root";
	TFile * MCFile = TFile::Open(candfilename.c_str());
	TTree * BdJpsiKSTree = (TTree *)MCFile->Get("candBdJpsiKS");

	file->cd();
	RooRealVar * vMuMu = new RooRealVar("Lb_MassConsLambda","Lb_MassConsLambda",5620.,5350.,6000.);
	Analysis * anaLbMuMu_MC = new Analysis("Lb2Lmumu_"+type+"_MC","Lb","candLb2Lmumu",candfilename,vMuMu,&CutsDef::cutMuMu);
	RooRealVar * vJpsi = new RooRealVar("Lb_MassConsJpsiLambda","Lb_MassConsJpsiLambda",5620.,5250.,6000.);
	Analysis * anaLbJpsi_default = new Analysis("Jpsi_default","Lb","candLb2JpsiL",datafilename,vJpsi,&CutsDef::cutJpsi);

	string model = "DCB_Sn";
	string optionsjpsi = "-ANDpulls-log-stdAxis-quiet-XM(#Lambda#mu#mu) (MeV/c^{2})-noCost-nochi2";
	string optionsmumu = "-stdAxis-quiet-XM(#Lambda#mu#mu) (MeV/c^{2})-noCost-nochi2";

	anaLbMuMu_MC->SetSignal((model+"-s[9]-s2[30]").c_str());
	anaLbMuMu_MC->Initialize("");
	anaLbMuMu_MC->Fit(5400.,5750.,200,true,"-stdAxis-XM(#Lambda#mu#mu) (MeV/c^{2})-noCost-nochi2",CutsDef::mumuTrueID+cut);
	Str2VarMap MCpars = anaLbMuMu_MC->GetSigParams();

	Analysis * KS = new Analysis("KS_bkg","Lb",BdJpsiKSTree,vJpsi,"DCB_OST","","-namepar");
	KS->Fit(5300.,6000.,150,true,"-noPlot-quiet");
	Str2VarMap pars = KS->GetSigParams();
	RooRealVar * m_shift = new RooRealVar("m_shift","shift",0.,-5.,5.);
	setConstant(&pars);
	ModifyPars(&pars,"m",m_shift,"-shift");

	string jpsimodel = model+"-Xn"+Form("[%f]",MCpars["n"]->getVal());
	jpsimodel += (string)"-s[7,1,12]";//+Form("[%f]",MCpars["s"]->getVal());
	jpsimodel += (string)"-s2[15,8,30]";//+Form("[%f,]",MCpars["s2"]->getVal());
	jpsimodel += (string)"-a"+Form("[%f]",MCpars["a"]->getVal());
	jpsimodel += (string)"-a2"+Form("[%f]",MCpars["a2"]->getVal());
	jpsimodel += (string)"-f"+Form("[%f]",MCpars["f"]->getVal());

	anaLbJpsi_default->SetSignal(jpsimodel.c_str());
	RooRealVar * nKSjpsi = new RooRealVar("nKSjpsi","nKSjpsi",2.e3,0,1.e4);
	anaLbJpsi_default->addBkgComponent("JpsiKS","DCB_OST",nKSjpsi,"",pars);
	//anaLbJpsi_default->addBkgComponent("BuKst",BuKstmumuTree,350.);
	anaLbJpsi_default->Initialize();
	anaLbJpsi_default->Fit(5300.,6000.,200,true,optionsjpsi,cut);
	
	Str2VarMap jpsiSigpars = anaLbJpsi_default->GetSigParams();
	setConstant(&jpsiSigpars);
	RooRealVar * factor = new RooRealVar("factor","factor",1.,0.5,3.);
	ModifyPars(&jpsiSigpars,"s",factor);
	ModifyPars(&jpsiSigpars,"s2",factor);
	return jpsiSigpars;
}
开发者ID:lucapescatore88,项目名称:Lmumu,代码行数:50,代码来源:angBkgParSys.cpp

示例14: sendMessages

void EngineSync::process()
{
	for (int i = 0; i < _channels.size(); i++)
	{
		Analysis *analysis = _analysesInProgress[i];

		if (analysis == NULL)
			continue;

		IPCChannel *channel = _channels[i];
		string data;

		if (channel->receive(data))
		{
#ifdef QT_DEBUG
			std::cout << "message received\n";
            std::cout << data << "\n";
			std::cout.flush();
#endif

			Json::Reader reader;
			Json::Value json;
			reader.parse(data, json);

			//int id = json.get("id", -1).asInt();
			//bool init = json.get("perform", "init").asString() == "init";
			Json::Value results = json.get("results", Json::nullValue);
			string status = json.get("status", "error").asString();

			if (analysis->status() == Analysis::Initing)
			{
				analysis->setStatus(Analysis::Inited);
				analysis->setResults(results);
				_analysesInProgress[i] = NULL;
				sendMessages();
			}
			else if (analysis->status() == Analysis::Running)
			{
				if (status == "complete")
				{
					analysis->setStatus(Analysis::Complete);
					analysis->setResults(results);
					_analysesInProgress[i] = NULL;
					sendMessages();
				}
				else
				{
					analysis->setResults(results);
				}
			}
			else
			{
				sendMessages();
			}
		}

	}
}
开发者ID:HelenSteingroever,项目名称:jasp-desktop,代码行数:58,代码来源:enginesync.cpp

示例15: nextCommand

string AsteroidTracker::nextCommand(double currentTime) {    
    Analysis a;
    string the_big_answer;
    vector<_link> links, rankedLinks;
    vector<int> targetList;
    vector<double> timesToRelocate;
    int commandListSize;
    
    nextCommandTime = currentTime;
    while ((!commandDeckLoaded) && (nextCommandTime < SIMULATION_TIME)) {
        links.clear();
        rankedLinks.clear();
        targetList.clear();
        timesToRelocate.clear();
        
        links = generateLinks(nextCommandTime);
        rankedLinks = rankLinks(links);
        targetList = generateTargetLinks(rankedLinks);
        timesToRelocate = generateTimesToRelocate(targetList, nextCommandTime);
        double maxRelocateTime = a.max(timesToRelocate);
        relocateAntennas(targetList, maxRelocateTime, nextCommandTime);
        double beamTime = activateAntennas(nextCommandTime);
        monitorAsteroids(beamTime, nextCommandTime);
    }
    commandDeckLoaded = true;
    
    if (!antennasRetired) { // set a trap to prevent the deck from being overloaded
        retireAntennas();
        antennasRetired = true;
        commandListSize = commandList.size();
    }

    // fill the output returned with the command note.
    if (commandDeckLoaded) { // Added to v2
        if (commandNumber < commandListSize) {
            the_big_answer = commandList.at(commandNumber).commandNote;
        }
        commandNumber++;
    }

    // evaluate all links to determine the best candidate

    cout << "Number of Antennas: " << numberOfAntennas << endl;    
    cout << "Number of Asteroids: " << numberOfAsteroids << endl;
    cout << "Number of Commands: " << commandList.size() << endl;
    
    return the_big_answer;
}
开发者ID:RigelFive,项目名称:TopCoder,代码行数:48,代码来源:AsteroidTracker.cpp


注:本文中的Analysis类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。