本文整理汇总了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());
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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);
}
示例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;
}
}
}
}
}
示例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;
}
示例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());
}
示例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;
}
示例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();
}
}
}
}
示例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;
}