void CEnumInfo<T>::reportProgress(const CThreadEnumerator<T> *pThreadEnum, size_t nThread) { if (nThread >= 1) { // Save already collected information const ulonglong nCanon = constrCanonical(); const ulonglong nTotal = constrTotal(); const ulonglong nrbTotal = numbSimpleDesign(); CGroupsInfo groupsInfo; groupsInfo.updateGroupInfo(this); for (size_t i = 0; i < nThread; i++, pThreadEnum++) { if (pThreadEnum->code() != t_threadRunning) continue; updateEnumInfo(pThreadEnum->enumInfo()); groupsInfo.updateGroupInfo(pThreadEnum->enumInfo()); } reportProgress(t_reportByTime, &groupsInfo); // Restore information setNumMatrOfType(nCanon, t_canonical); setNumMatrOfType(nTotal, t_totalConstr); setNumbSimpleDesign(nrbTotal); } else { updateEnumInfo(pThreadEnum->enumInfo()); reportThreadProgress(); } }
void LargeFileIterator::processLine() { start: //to avoid deep recursion atEnd=file->atEnd(); if (!atEnd) { QString line=file->readLine(); pos+=getSize(line); QStringList entries=line.split('\t'); //assert(entries.size()>valueColumn); if(entries.size()<valueColumn) { //qDebug()<<line; goto start;//return processLine(); } currValue=entries.at(valueColumn).toDouble(); if (weightColumn>=0) currWeight=entries.at(weightColumn).toDouble(); else currWeight=1; ConditionMap::iterator itr=conditions.begin(); for (;itr!=conditions.end();itr++) { int col=itr.key(); QString val=itr.value(); QString curCondVal=entries.at(col); if (curCondVal!=val) goto start;//return processLine(); } extractAdditionalInfo(entries); reportProgress(); } }
void CSysController::parseFreeBSDUpdateLine(QString line) { SProgress progress; progress.mMessage = tr("Installing system update"); reportProgress(progress); reportLogLine(line); }
void BulkImport::loadCompileEarly(const QStringList& filepaths, const QString& qspec) { Progress prog(Progress::BULK_COMPILE_EARLY); reportProcessBegin(prog); for(int i=0; i<filepaths.length() && !isAborted(); i++){ const QString& filepath = filepaths.at(i); try{ cache()->importXmlFile(filepath, qspec); reportProgress(prog(filepaths.count(), i+1, QStringList() << filepath << filepath)); }catch(std::exception& ex){ prog.setTag(filepath); emit error(ex, prog); }catch(...){ prog.setTag(filepath); emit error(std::runtime_error("Unknown error!"), prog); } } reportProcessEnd(prog(Progress::BULK_COMPILE_EARLY)); if (isAborted()){ emit aborted(); }else{ emit finished(); } }
Uploader::Uploader(QObject *parent) : QObject(parent), mProgressSent(0), mProgressTotal(0) { mImgur = new QtImgur("6920a141451d125b3e1357ce0e432409", this); connect(mImgur, SIGNAL(uploaded(QString, QString, QString)), this, SLOT(uploaded(QString, QString, QString))); connect(mImgur, SIGNAL(error(QString, QtImgur::Error)) , this, SLOT(imgurError(QString, QtImgur::Error))); connect(mImgur, SIGNAL(uploadProgress(qint64,qint64)) , this, SLOT(reportProgress(qint64, qint64))); }
LargeFileIterator::~LargeFileIterator() { reportProgress(); if (inputFile!=NULL) { inputFile->close(); delete inputFile; } if (file!=NULL) delete file; }
void onMain(void) { setInitialState(); while (!stopping()) { if (m_report_timer.overflow()) { if (m_args.progress) reportProgress(); dispatch(m_pcs); m_report_timer.reset(); } double now = Clock::get(); if ((getEntityState() == IMC::EntityState::ESTA_NORMAL) && (now - m_last_vstate >= c_vs_timeout)) { changeMode(IMC::PlanControlState::PCS_BLOCKED, DTR("vehicle state timeout")); m_last_vstate = now; } // got requests to process if (!pendingReply() && m_requests.size()) { processRequest(&m_requests.front()); m_requests.pop(); } double delta = m_vc_reply_deadline < 0 ? 1 : m_vc_reply_deadline - now; if (delta > 0) { waitForMessages(std::min(1.0, delta)); continue; } // handle reply timeout m_vc_reply_deadline = -1; changeMode(IMC::PlanControlState::PCS_READY, DTR("vehicle reply timeout")); // Popping all requests while (m_requests.size()) m_requests.pop(); // Increment local request id to prevent old replies from being processed ++m_vreq_ctr; err(DTR("cleared all requests")); } }
static cl_int runIntegral(CLInfo* ci, SeparationCLMem* cm, RunSizes* runSizes, EvaluationState* es, const CLRequest* clr, const AstronomyParameters* ap, const IntegralArea* ia) { cl_int err = CL_SUCCESS; double t1, t2, dt; double tAcc = 0.0; for (; es->nu_step < ia->nu_steps; es->nu_step++) { if (clr->enableCheckpointing && timeToCheckpointGPU(es, ia)) { err = checkpointCL(ci, cm, ia, es); if (err != CL_SUCCESS) break; } t1 = mwGetTimeMilli(); err = runNuStep(ci, ia, runSizes, es->nu_step); if (err != CL_SUCCESS) { mwPerrorCL(err, "Failed to run nu step"); return err; } t2 = mwGetTimeMilli(); dt = t2 - t1; tAcc += dt; reportProgress(ap, ia, es, es->nu_step + 1, dt); } es->nu_step = 0; mw_printf("Integration time: %f s. Average time per iteration = %f ms\n", tAcc / 1000.0, tAcc / (double) ia->nu_steps); if (err == CL_SUCCESS) { err = readKernelResults(ci, cm, es, ia); if (err != CL_SUCCESS) mw_printf("Failed to read final kernel results\n"); /* Add final episode to running totals */ addTmpCheckpointSums(es); } return err; }
/** * Listen for incoming messages from subscribed topic */ void NexusSubscriber::listen() { auto receivedDataStats = std::make_shared<ReceivedDataStats>(); m_running = true; std::string message; auto receivedData = std::make_shared<EventData>(); reportProgress(0.0); // frame numbers run from 0 to numberOfFrames-1 while (m_running) { if (!(m_subscriber->listenForMessage(message))) continue; decodeMessage(receivedData, message, receivedDataStats); if (m_futureMessages.size() > 128) { m_running = false; uint64_t smallestID = std::numeric_limits<uint64_t>::max(); for (auto messageID : m_futureMessages) { if (messageID.first < smallestID) smallestID = messageID.first; } std::string missingError = "A message is missing and 128 messages have been " "received since it was supposed to be received. Aborting " "listen. Missing message ID: "; throw std::runtime_error(missingError + std::to_string(smallestID - 1)); } } reportProgress(1.0); std::cout << std::endl << "Frames received: " << receivedDataStats->numberOfFramesReceived << std::endl << "Bytes received: " << receivedDataStats->totalBytesReceived << std::endl << "Number of messages received: " << receivedDataStats->numberOfMessagesReceived << std::endl; }
void MaemoDebugSupport::handleAdapterSetupRequested() { ASSERT_STATE(Inactive); setState(StartingRunner); showMessage(tr("Preparing remote side ...\n"), AppStuff); disconnect(m_runner, 0, this, 0); connect(m_runner, SIGNAL(error(QString)), this, SLOT(handleSshError(QString))); connect(m_runner, SIGNAL(readyForExecution()), this, SLOT(startExecution())); connect(m_runner, SIGNAL(reportProgress(QString)), this, SLOT(handleProgressReport(QString))); m_runner->start(); }
bool Integrator::nextRun() { if (mainWindow) reportProgress(); ++runNumber; bool nextOk; if (cancelled) { nextOk = false; } else if (runIterator) nextOk = runIterator->pullValue<bool>("value"); else nextOk = runNumber == 1; if (!nextOk) closeReport(); return nextOk; }
/** Fits each spectrum in the workspace to f(x) = A * sin( w * x + p) * @param ws :: [input] The workspace to fit * @param freq :: [input] Hint for the frequency (w) * @param groupName :: [input] The name of the output workspace group * @param resTab :: [output] Table workspace storing the asymmetries and phases * @param resGroup :: [output] Workspace group storing the fitting results */ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, double freq, std::string groupName, API::ITableWorkspace_sptr &resTab, API::WorkspaceGroup_sptr &resGroup) { int nhist = static_cast<int>(ws->getNumberHistograms()); // Create the fitting function f(x) = A * sin ( w * x + p ) // The same function and initial parameters are used for each fit std::string funcStr = createFittingFunction(freq, true); // Set up results table resTab->addColumn("int", "Spectrum number"); resTab->addColumn("double", "Asymmetry"); resTab->addColumn("double", "Phase"); // Loop through fitting all spectra individually const static std::string success = "success"; for (int wsIndex = 0; wsIndex < nhist; wsIndex++) { reportProgress(wsIndex, nhist); auto fit = createChildAlgorithm("Fit"); fit->initialize(); fit->setPropertyValue("Function", funcStr); fit->setProperty("InputWorkspace", ws); fit->setProperty("WorkspaceIndex", wsIndex); fit->setProperty("CreateOutput", true); fit->setPropertyValue("Output", groupName); fit->execute(); std::string status = fit->getProperty("OutputStatus"); if (!fit->isExecuted() || status != success) { std::ostringstream error; error << "Fit failed for spectrum at workspace index " << wsIndex; error << ": " << status; throw std::runtime_error(error.str()); } API::MatrixWorkspace_sptr fitOut = fit->getProperty("OutputWorkspace"); resGroup->addWorkspace(fitOut); API::ITableWorkspace_sptr tab = fit->getProperty("OutputParameters"); // Now we have our fitting results stored in tab // but we need to extract the relevant information, i.e. // the detector phases (parameter 'p') and asymmetries ('A') const auto &spectrum = ws->getSpectrum(static_cast<size_t>(wsIndex)); extractDetectorInfo(tab, resTab, spectrum.getSpectrumNo()); } }
void KisGmicUpdater::start() { QUrl url(m_url); QNetworkRequest request(url); QString userAgent("org.krita.gmic/"); QString version = QString("%0.%1.%2.%3").arg(gmic_version/1000).arg((gmic_version/100)%10).arg((gmic_version/10)%10).arg(gmic_version%10); userAgent.append(version); dbgPlugins << "userAgent" << userAgent.toLatin1(); request.setRawHeader("User-Agent", userAgent.toLatin1()); QNetworkReply * getReply = m_manager.get(request); connect(getReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(reportProgress(qint64,qint64))); connect(getReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError))); }
/** * Write the data from the message to file and record statistics such as number * of received bytes and frames * * @param receivedData - EventData object containing the received data * @param message - the message buffer, from which to get the number of received * bytes * @param receivedDataStats - struct of recorded statistics of received data */ void NexusSubscriber::processMessage( std::shared_ptr<EventData> receivedData, const std::string &message, std::shared_ptr<ReceivedDataStats> receivedDataStats) { receivedDataStats->totalBytesReceived += message.size(); receivedDataStats->numberOfFrames = receivedData->getNumberOfFrames(); receivedDataStats->frameNumber = receivedData->getFrameNumber(); if (m_filewriter) { m_filewriter->writeData(receivedData); } if (receivedData->getEndFrame()) { receivedDataStats->numberOfFramesReceived++; reportProgress(static_cast<float>(receivedDataStats->frameNumber) / static_cast<float>(receivedDataStats->numberOfFrames)); if (receivedData->getEndRun()) { m_running = false; } } receivedDataStats->numberOfMessagesReceived++; }
//========================================================================= void NodeDetailsLoaderThread::run() { QFile file(fileName); if ( !file.exists() ) file.setFileName(QString(QApplication::applicationDirPath()).append(fileName)); if( !file.open(QIODevice::ReadOnly|QIODevice::Text) ) { qDebug() << "Cannot open input file " << fileName; return; } int p = 0; QTextStream in(&file); qint32 nposition = 0; if ( type == sequence ) { gi2TaxProvider = new Gi2TaxMapBinProvider(&gi2taxmap); gi2TaxProvider->open(); } quint64 fSize = file.size(); while( !in.atEnd() && nposition < node->positions.size() ) { qint64 pos = node->positions[nposition++]; in.seek(pos); if ( in.atEnd() || must_stop ) break; QString line = in.readLine(); if ( line == NULL || line.isEmpty() ) continue; processLine(line); if ( ++p == progressCounter ) { reportProgress(((qreal)pos)/fSize); p = 0; } } file.close(); if ( !must_stop ) finishProcessing(); }
void onMain(void) { setInitialState(); while (!stopping()) { if (m_report_timer.overflow()) { if (m_args.progress) reportProgress(); dispatch(m_pcs); m_report_timer.reset(); } double now = Clock::get(); if ((getEntityState() == IMC::EntityState::ESTA_NORMAL) && (now - m_last_vstate >= c_vs_timeout)) { changeMode(IMC::PlanControlState::PCS_BLOCKED, DTR("vehicle state timeout")); m_last_vstate = now; } double delta = m_vc_reply_deadline < 0 ? 1 : m_vc_reply_deadline - now; if (delta > 0) { waitForMessages(std::min(1.0, delta)); continue; } // handle reply timeout m_vc_reply_deadline = -1; changeMode(IMC::PlanControlState::PCS_READY, DTR("vehicle reply timeout")); } }
void CPBIController::onUpdateProcessfinished(int exitCode) { SProgress progress; Q_UNUSED(exitCode); // TODO: more accurate error check QString current_app = mAppsToUpdate[mCurrentUpdate]; current_app= current_app.left(current_app.lastIndexOf("-")); // remove arch current_app= current_app.left(current_app.lastIndexOf("-")); // remove ver progress.mItemNo= mCurrentUpdate; progress.mItemsCount= mAppsToUpdate.size(); progress.mMessage=tr("[%1/%2] Preparing to install update for %3").arg(QString::number(progress.mItemNo+1), QString::number(progress.mItemsCount), current_app); if (mCurrentUpdate < (mAppsToUpdate.size() - 1)) { SProgress progress; progress.mLogMessages= QStringList()<<"==============================="; } mCurrentUpdate++; if (mCurrentUpdate >= mAppsToUpdate.size()) { mCurrentUpdate=0; check(); } else { reportProgress(progress); launchUpdate(); } }
// Execute a performance test using a file of null terminated useragent strings // as input. If calibrate is true then the file is read but no detections // are performed. void runPerformanceTest(PERFORMANCE_STATE *state) { char *input = (char*)malloc(state->pool->dataSet->header.maxUserAgentLength + 1); char *result = NULL; long valueCount; FILE *inputFilePtr; int i, v, count = 0; fiftyoneDegreesWorkset *ws = NULL; // Open the file and check it's valid. inputFilePtr = fopen(state->fileName, "r"); if (inputFilePtr == NULL) { printf("Failed to open file with null-terminating user agent strings to fiftyoneDegreesMatch against 51Degrees data file. \n"); fclose(inputFilePtr); exit(0); } // Get the first entry from the file. result = fgets(input, state->pool->dataSet->header.maxUserAgentLength, inputFilePtr); while(result != NULL && !feof(inputFilePtr)) { // Split the string at carriage returns. strtok(result, "\n"); // If detection should be performed get the result and the property values. if (state->calibrate == 0) { ws = fiftyoneDegreesWorksetPoolGet(state->pool); fiftyoneDegreesMatch(ws, input); valueCount = 0; for (i = 0; i < ws->dataSet->requiredPropertyCount; i++) { fiftyoneDegreesSetValues(ws, i); for (v = 0; v < ws->valuesCount; v++) { valueCount += (long)(ws->values[v]->nameOffset); } } fiftyoneDegreesWorksetPoolRelease(state->pool, ws); #ifndef FIFTYONEDEGREES_NO_THREADING FIFTYONEDEGREES_MUTEX_LOCK(&state->lock); #endif state->valueCount += valueCount; #ifndef FIFTYONEDEGREES_NO_THREADING FIFTYONEDEGREES_MUTEX_UNLOCK(&state->lock); #endif } count++; // Print a progress marker. if (count == state->progress) { reportProgress(state, count); count = 0; } // Get the next entry from the data file. result = fgets(input, state->pool->dataSet->header.maxUserAgentLength, inputFilePtr); } free(input); reportProgress(state, count); fclose(inputFilePtr); #ifndef FIFTYONEDEGREES_NO_THREADING FIFTYONEDEGREES_THREAD_EXIT; #endif }
bool ThresholdData::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { VERIFY(pInArgList != NULL); StepResource pStep("Execute Wizard Item", "app", "{2501975d-7cd5-49b0-a3e7-49f7106793c0}"); pStep->addProperty("Item", getName()); mpStep = pStep.get(); if (!extractInputArgs(pInArgList)) { return false; } const RasterDataDescriptor* pDesc = static_cast<const RasterDataDescriptor*>(mpInputElement->getDataDescriptor()); VERIFY(pDesc); DimensionDescriptor band; if (mDisplayBandNumber > 0) { band = pDesc->getOriginalBand(mDisplayBandNumber - 1); if (band.isValid() == false) { reportError("The specified band is invalid.", "{a529538b-5b82-425d-af10-385a2581beec}"); return false; } } else { band = pDesc->getActiveBand(mDisplayBandNumber); } FactoryResource<DataRequest> pReq; pReq->setInterleaveFormat(BSQ); pReq->setBands(band, band, 1); DataAccessor acc = mpInputElement->getDataAccessor(pReq.release()); if (!acc.isValid()) { reportError("Unable to access data element.", "{b5f1b7dd-7cf7-4cd5-b5bc-7b747d3561b9}"); return false; } // If necessary, convert region units if (mRegionUnits != RAW_VALUE) { Statistics* pStatistics = mpInputElement->getStatistics(band); if (pStatistics == NULL) { reportError("Unable to calculate data statistics.", "{61a44ced-a4aa-4423-b379-5783137eb980}"); return false; } mFirstThreshold = convertToRawUnits(pStatistics, mRegionUnits, mFirstThreshold); mSecondThreshold = convertToRawUnits(pStatistics, mRegionUnits, mSecondThreshold); } FactoryResource<BitMask> pBitmask; for (unsigned int row = 0; row < pDesc->getRowCount(); ++row) { reportProgress("Thresholding data", 100 * row / pDesc->getRowCount(), "{2fc3dbea-1307-471c-bba2-bf86032be518}"); for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col) { VERIFY(acc.isValid()); double val = ModelServices::getDataValue(pDesc->getDataType(), acc->getColumn(), 0); switch (mPassArea) { case UPPER: if (val >= mFirstThreshold) { pBitmask->setPixel(col, row, true); } break; case LOWER: if (val <= mFirstThreshold) { pBitmask->setPixel(col, row, true); } break; case MIDDLE: if (val >= mFirstThreshold && val <= mSecondThreshold) { pBitmask->setPixel(col, row, true); } break; case OUTSIDE: if (val <= mFirstThreshold || val >= mSecondThreshold) { pBitmask->setPixel(col, row, true); } break; default: reportError("Unknown or invalid pass area.", "{19c92b3b-52e9-442b-a01f-b545f819f200}"); return false; } acc->nextColumn(); } acc->nextRow(); } std::string aoiName = pDesc->getName() + "_aoi"; ModelResource<AoiElement> pAoi(aoiName, mpInputElement); if (pAoi.get() == NULL) { reportWarning("Overwriting existing AOI.", "{d953a030-dd63-43a1-98db-b0f491dee123}"); Service<ModelServices>()->destroyElement( Service<ModelServices>()->getElement(aoiName, TypeConverter::toString<AoiElement>(), mpInputElement)); pAoi = ModelResource<AoiElement>(aoiName, mpInputElement); } if (pAoi.get() == NULL) { reportError("Unable to create output AOI.", "{f76c2f4d-9a7f-4055-9383-022116cdcadb}"); return false; } pAoi->addPoints(pBitmask.get()); AoiLayer* pLayer = NULL; if (mpView != NULL) { if ((pLayer = static_cast<AoiLayer*>(mpView->createLayer(AOI_LAYER, pAoi.get()))) == NULL) { reportWarning("Unable to create AOI layer, continuing thresholding.", "{5eca6ea0-33c1-4b1a-b777-c8e1b86fd2fb}"); } } if (pOutArgList != NULL) { pOutArgList->setPlugInArgValue("Result", pAoi.get()); if (pLayer != NULL) { pOutArgList->setPlugInArgValue("Result Layer", pLayer); } } pAoi.release(); reportComplete(); return true; }
ReachabilityResult HeuristicDFS::reachable(const PetriNet& net, const MarkVal* m0, const VarVal* v0, const BoolVal *ba, PQL::Condition* query){ //Do we initially satisfy query? if(query->evaluate(PQL::EvaluationContext(m0, v0, ba))) return ReachabilityResult(ReachabilityResult::Satisfied, "A state satisfying the query was found"); StateSet states(net); StateAllocator<> allocator(net); std::list<State*> stack; State* s0 = allocator.createState(); memcpy(s0->marking(), m0, sizeof(MarkVal)*net.numberOfPlaces()); memcpy(s0->intValuation(), v0, sizeof(VarVal)*net.numberOfIntVariables()); memcpy(s0->boolValuation(), ba, sizeof(BoolVal)*net.numberOfBoolVariables()); stack.push_back(s0); states.add(s0); Structures::DistanceMatrix distanceMatrix(net); State* ns = allocator.createState(); unsigned int max = 0; int count = 0; BigInt expandedStates = 0; BigInt exploredStates = 0; BigInt transitionFired = 0; while(!stack.empty()){ // Progress reporting and abort checking if(count++ & 1<<16){ if(stack.size() > max) max = stack.size(); count = 0; // Report progress reportProgress((double)(max - stack.size())/(double)max); // Check abort if(abortRequested()) return ReachabilityResult(ReachabilityResult::Unknown, "Search was aborted."); } State* s = stack.back(); stack.pop_back(); State* succ[net.numberOfTransitions()]; double distances[net.numberOfTransitions()]; memset(succ, 0, net.numberOfTransitions()*sizeof(State*)); for(unsigned int t = 0; t < net.numberOfTransitions(); t++){ if(net.fire(t, s, ns)){ transitionFired++; if(states.add(ns)){ exploredStates++; ns->setParent(s); ns->setTransition(t); if(query->evaluate(*ns)) return ReachabilityResult(ReachabilityResult::Satisfied, "A state satisfying the query was found", expandedStates, exploredStates, transitionFired, 0, ns->pathLength(), ns->trace()); PQL::DistanceContext context(net, _distanceStrategy, ns->marking(), ns->intValuation(), ns->boolValuation(), &distanceMatrix); succ[t] = ns; distances[t] = query->distance(context); ns = allocator.createState(); } } } // Pretty bobble sort of the successors while(true){ bool foundSomething = false; unsigned int min = 0; for(unsigned int t = 0; t < net.numberOfTransitions(); t++){ if(succ[t] && (!foundSomething || distances[t] < distances[min])){ min = t; foundSomething = true; } } if(foundSomething){ stack.push_back(succ[min]); succ[min] = NULL; }else break; } expandedStates++; } return ReachabilityResult(ReachabilityResult::NotSatisfied, "No state satisfying the query exists.", expandedStates, exploredStates, transitionFired, 0); }
bool ImportHelper::importJson (const string& collectionName, const string& fileName) { _collectionName = collectionName; _firstLine = ""; _numberLines = 0; _numberOk = 0; _numberError = 0; _outputBuffer.clear(); _errorMessage = ""; _hasError = false; // read and convert int fd; int64_t totalLength; if (fileName == "-") { // we don't have a filesize totalLength = 0; fd = STDIN_FILENO; } else { // read filesize totalLength = TRI_SizeFile(fileName.c_str()); fd = TRI_OPEN(fileName.c_str(), O_RDONLY); if (fd < 0) { _errorMessage = TRI_LAST_ERROR_STR; return false; } } bool isArray = false; bool checkedFront = false; // progress display control variables int64_t totalRead = 0; double nextProgress = ProgressStep; static const int BUFFER_SIZE = 32768; while (! _hasError) { // reserve enough room to read more data if (_outputBuffer.reserve(BUFFER_SIZE) == TRI_ERROR_OUT_OF_MEMORY) { _errorMessage = TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY); if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } return false; } // read directly into string buffer ssize_t n = TRI_READ(fd, _outputBuffer.end(), BUFFER_SIZE - 1); if (n < 0) { _errorMessage = TRI_LAST_ERROR_STR; if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } return false; } else if (n == 0) { // we're done break; } // adjust size of the buffer by the size of the chunk we just read _outputBuffer.increaseLength(n); if (! checkedFront) { // detect the import file format (single lines with individual JSON objects // or a JSON array with all documents) char const* p = _outputBuffer.begin(); char const* e = _outputBuffer.end(); while (p < e && (*p == ' ' || *p == '\r' || *p == '\n' || *p == '\t' || *p == '\f' || *p == '\b')) { ++p; } isArray = (*p == '['); checkedFront = true; } totalRead += (int64_t) n; reportProgress(totalLength, totalRead, nextProgress); if (_outputBuffer.length() > _maxUploadSize) { if (isArray) { if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } _errorMessage = "import file is too big. please increase the value of --batch-size (currently " + StringUtils::itoa(_maxUploadSize) + ")"; return false; } // send all data before last '\n' char const* first = _outputBuffer.c_str(); char* pos = (char*) memrchr(first, '\n', _outputBuffer.length()); if (pos != 0) { size_t len = pos - first + 1; sendJsonBuffer(first, len, isArray); _outputBuffer.erase_front(len); } } } if (_outputBuffer.length() > 0) { sendJsonBuffer(_outputBuffer.c_str(), _outputBuffer.length(), isArray); } _numberLines = _numberError + _numberOk; if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } _outputBuffer.clear(); return ! _hasError; }
ReachabilityResult MonoBFS::reachable(const PetriNet &net, const MarkVal *m0, const VarVal *v0, const BoolVal *ba, PQL::Condition *query){ //Do we initially satisfy query? if(query->evaluate(PQL::EvaluationContext(m0, v0,ba))) return ReachabilityResult(ReachabilityResult::Satisfied, "A state satisfying the query was found"); //Create StateSet MonotonicityContext context(&net, query); context.analyze(); BFSOrderableStateSet states(net,&context); StateAllocator<1000000> allocator(net); State* s0 = allocator.createState(); memcpy(s0->marking(), m0, sizeof(MarkVal)*net.numberOfPlaces()); memcpy(s0->intValuation(), v0, sizeof(VarVal)*net.numberOfIntVariables()); memcpy(s0->boolValuation(), ba, sizeof(BoolVal)*net.numberOfBoolVariables()); states.add(s0); unsigned int max = 0; int count = 0; BigInt expandedStates = 0; BigInt exploredStates = 0; BigInt transitionFired = 0; State* ns = allocator.createState(); State* s = states.getNextState(); while(s){ // Progress reporting and abort checking if(count++ & 1<<15){ if(states.waitingSize() > max) max = states.waitingSize(); count = 0; // Report progress reportProgress((double)(max - states.waitingSize())/(double)max); // Check abort if(abortRequested()) return ReachabilityResult(ReachabilityResult::Unknown, "Search was aborted."); } for(unsigned int t = 0; t < net.numberOfTransitions(); t++){ if(net.fire(t, s, ns)){ transitionFired++; if(states.add(ns)){ exploredStates++; ns->setParent(s); ns->setTransition(t); if(query->evaluate(PQL::EvaluationContext(ns->marking(), ns->intValuation(), ns->boolValuation()))){ //ns->dumpTrace(net); return ReachabilityResult(ReachabilityResult::Satisfied, "A state satisfying the query was found", expandedStates, exploredStates, transitionFired, states.getCountRemove(), ns->pathLength(), ns->trace()); } ns = allocator.createState(); } } } s = states.getNextState(); expandedStates++; } return ReachabilityResult(ReachabilityResult::NotSatisfied, "No state satisfying the query exists.", expandedStates, exploredStates, transitionFired, states.getCountRemove()); }
bool ImportHelper::importDelimited (string const& collectionName, string const& fileName, DelimitedImportType typeImport) { _collectionName = collectionName; _firstLine = ""; _numberLines = 0; _numberOk = 0; _numberError = 0; _outputBuffer.clear(); _lineBuffer.clear(); _errorMessage = ""; _hasError = false; // read and convert int fd; int64_t totalLength; if (fileName == "-") { // we don't have a filesize totalLength = 0; fd = STDIN_FILENO; } else { // read filesize totalLength = TRI_SizeFile(fileName.c_str()); fd = TRI_OPEN(fileName.c_str(), O_RDONLY); if (fd < 0) { _errorMessage = TRI_LAST_ERROR_STR; return false; } } // progress display control variables int64_t totalRead = 0; double nextProgress = ProgressStep; size_t separatorLength; char* separator = TRI_UnescapeUtf8StringZ(TRI_UNKNOWN_MEM_ZONE, _separator.c_str(), _separator.size(), &separatorLength); if (separator == 0) { if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } _errorMessage = "out of memory"; return false; } TRI_csv_parser_t parser; TRI_InitCsvParser(&parser, TRI_UNKNOWN_MEM_ZONE, ProcessCsvBegin, ProcessCsvAdd, ProcessCsvEnd); TRI_SetSeparatorCsvParser(&parser, separator[0]); // in csv, we'll use the quote char if set // in tsv, we do not use the quote char if (typeImport == ImportHelper::CSV && _quote.size() > 0) { TRI_SetQuoteCsvParser(&parser, _quote[0], true); } else { TRI_SetQuoteCsvParser(&parser, '\0', false); } parser._dataAdd = this; _rowOffset = 0; _rowsRead = 0; char buffer[32768]; while (! _hasError) { ssize_t n = TRI_READ(fd, buffer, sizeof(buffer)); if (n < 0) { TRI_Free(TRI_UNKNOWN_MEM_ZONE, separator); TRI_DestroyCsvParser(&parser); if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } _errorMessage = TRI_LAST_ERROR_STR; return false; } else if (n == 0) { break; } totalRead += (int64_t) n; reportProgress(totalLength, totalRead, nextProgress); TRI_ParseCsvString2(&parser, buffer, n); } if (_outputBuffer.length() > 0) { sendCsvBuffer(); } TRI_DestroyCsvParser(&parser); TRI_Free(TRI_UNKNOWN_MEM_ZONE, separator); if (fd != STDIN_FILENO) { TRI_CLOSE(fd); } _outputBuffer.clear(); return !_hasError; }
void CPBIController::onReadUpdateLine(QString line) { SProgress progress; long dl_size; long dl_complete; QString dl_speed; line= line.trimmed(); QString log_message= line; //progress.mLogMessages = QStringList()<<line; progress.mItemNo= mCurrentUpdate; progress.mItemsCount= mAppsToUpdate.size(); QString current_app = mAppsToUpdate[mCurrentUpdate]; current_app= current_app.left(current_app.lastIndexOf("-")); // remove arch current_app= current_app.left(current_app.lastIndexOf("-")); // remove ver if (line.indexOf(DOWNLOADING_ERROR) ==0 ) { reportError(line.replace(DOWNLOADING_ERROR,"").trimmed()); return; } if (parseFetchOutput(line,dl_size, dl_complete, dl_speed)) { progress.misCanCancel=true; log_message.clear(); progress.mProgressMax= dl_size; progress.mProgressCurr= dl_complete; progress.mMessage= tr("[%1/%2] Downloading update for %3 (%4/%5 at %6)").arg(QString::number(progress.mItemNo+1), QString::number(progress.mItemsCount), current_app, pcbsd::Utils::bytesToHumanReadable(dl_complete), pcbsd::Utils::bytesToHumanReadable(dl_size), dl_speed); reportProgress(progress); return; } else { if (line == FETCHDONE) { //indicates beginning of instalation log_message.clear(); misWasFETCHDONE= true; } if (line.indexOf(FETCH_WORLD) == 0) { log_message = log_message.replace(FETCH_WORLD, "Downloading"); } if (misWasFETCHDONE || (line == FETCHDONE)) { //installing... progress.mMessage=tr("[%1/%2] Installing update for %3").arg(QString::number(progress.mItemNo+1), QString::number(progress.mItemsCount), current_app); progress.mSubstate= eInstall; } else { progress.mMessage=tr("[%1/%2] Preparing to install update for %3").arg(QString::number(progress.mItemNo+1), QString::number(progress.mItemsCount), current_app); } if (log_message.length()) reportLogLine(log_message); reportProgress(progress); } }
ReachabilityResult MonoDFS::reachable(const PetriNet &net, const MarkVal *m0, const VarVal *v0, const BoolVal *b0, PQL::Condition *query){ //Do we initially satisfy query? if(query->evaluate(PQL::EvaluationContext(m0, v0, b0))) return ReachabilityResult(ReachabilityResult::Satisfied, "A state satisfying the query was found"); //Create StateSet MonotonicityContext context(&net,query); context.analyze(); DFSStateSet states(net,&context, ModeNormal); StateAllocator<1000000> allocator(net); State* s0 = allocator.createState(); memcpy(s0->marking(), m0, sizeof(MarkVal)*net.numberOfPlaces()); memcpy(s0->intValuation(), v0, sizeof(VarVal)*net.numberOfIntVariables()); memcpy(s0->boolValuation(), b0, sizeof(BoolVal)*net.numberOfBoolVariables()); states.add(s0, 0); unsigned int max = 0; int count = 0; BigInt exploredStates = 0; BigInt expandedStates = 0; BigInt transitionFired = 0; State* ns = allocator.createState(); while(states.waitingSize()){ if(count++ & 1<<18){ if(states.waitingSize() > max) max = states.waitingSize(); count = 0; //report progress reportProgress((double)(max-states.waitingSize())/(double)max); //check abort if(abortRequested()) return ReachabilityResult(ReachabilityResult::Unknown, "Search was aborted."); } //Take first step of the stack Step tstep = states.getNextStep(); State* s = tstep.state; ns->setParent(s); bool foundSomething = false; for(unsigned int t = tstep.t; t < net.numberOfTransitions(); t++){ if(net.fire(t, s->marking(), s->intValuation(),s->boolValuation(), ns->marking(), ns->intValuation(), ns->boolValuation())){ transitionFired++; if(states.add(ns,t)){ ns->setTransition(t); if(query->evaluate(PQL::EvaluationContext(ns->marking(), ns->intValuation(), ns->boolValuation()))) return ReachabilityResult(ReachabilityResult::Satisfied, "A state satisfying the query was found", expandedStates, exploredStates, transitionFired, states.getCountRemove(), ns->pathLength(), ns->trace()); exploredStates++; foundSomething = true; ns = allocator.createState(); break; } } } if(!foundSomething){ states.popWating(); expandedStates++; } } //states.writeStatistics(); return ReachabilityResult(ReachabilityResult::NotSatisfied, "No state satisfying the query exists.", expandedStates, exploredStates, transitionFired, states.getCountRemove()); }
static CALresult runIntegral(const AstronomyParameters* ap, const IntegralArea* ia, EvaluationState* es, const CLRequest* clr, MWCALInfo* ci, SeparationCALMem* cm) { CALresult err; SeparationCALNames cn; double t1, t2, dt, tAcc = 0.0; SeparationCALChunks chunks; memset(&cn, 0, sizeof(SeparationCALNames)); err = getModuleNames(ci, &cn, cm->numberStreams); if (err != CAL_RESULT_OK) { cal_warn("Failed to get module names", err); return err; } err = setKernelArguments(ci, cm, &cn); if (err != CAL_RESULT_OK) { destroyModuleNames(&cn); return err; } if (findCALChunks(ap, ci, clr, ia, &chunks) != CAL_RESULT_OK) return CAL_RESULT_ERROR; for (; es->nu_step < ia->nu_steps; es->nu_step++) { if (clr->enableCheckpointing && timeToCheckpointGPU(es, ia)) { err = checkpointCAL(cm, ia, es); if (err != CAL_RESULT_OK) break; } t1 = mwGetTimeMilli(); err = runNuStep(ci, cm, ia, &chunks, clr->pollingMode, es->nu_step); if (err != CAL_RESULT_OK) break; t2 = mwGetTimeMilli(); dt = t2 - t1; tAcc += dt; reportProgress(ap, ia, es, es->nu_step + 1, dt); } es->nu_step = 0; warn("Integration time = %f s, average per iteration = %f ms\n", 1.0e-3 * tAcc, tAcc / ia->nu_steps); destroyModuleNames(&cn); freeCALChunks(&chunks); if (err == CAL_RESULT_OK) { readResults(cm, ia, es); addTmpSums(es); /* Add final episode to running totals */ } return err; }
void actionCollect(const std::string &filename, enum CollectingMode mode, StatisticsCollection &statisticsCollection, HistogramCollection &histogramCollection, bool mwaChannels, size_t flaggedTimesteps, const std::set<size_t> &flaggedAntennae) { MeasurementSet *ms = new MeasurementSet(filename); const unsigned polarizationCount = ms->PolarizationCount(); const unsigned bandCount = ms->BandCount(); const bool ignoreChannelZero = ms->IsChannelZeroRubish(); const std::string stationName = ms->GetStationName(); BandInfo *bands = new BandInfo[bandCount]; double **frequencies = new double*[bandCount]; unsigned totalChannels = 0; for(unsigned b=0;b<bandCount;++b) { bands[b] = ms->GetBandInfo(b); frequencies[b] = new double[bands[b].channels.size()]; totalChannels += bands[b].channels.size(); for(unsigned c=0;c<bands[b].channels.size();++c) { frequencies[b][c] = bands[b].channels[c].frequencyHz; } } delete ms; std::cout << "Polarizations: " << polarizationCount << '\n' << "Bands: " << bandCount << '\n' << "Channels/band: " << (totalChannels / bandCount) << '\n'; if(ignoreChannelZero) std::cout << "Channel zero will be ignored, as this looks like a LOFAR data set with bad channel 0.\n"; else std::cout << "Channel zero will be included in the statistics, as it seems that channel 0 is okay.\n"; // Initialize statisticscollection statisticsCollection.SetPolarizationCount(polarizationCount); if(mode == CollectDefault) { for(unsigned b=0;b<bandCount;++b) { if(ignoreChannelZero) statisticsCollection.InitializeBand(b, (frequencies[b]+1), bands[b].channels.size()-1); else statisticsCollection.InitializeBand(b, frequencies[b], bands[b].channels.size()); } } // Initialize Histograms collection histogramCollection.SetPolarizationCount(polarizationCount); // get columns casa::Table table(filename, casa::Table::Update); const char *dataColumnName = "DATA"; casa::ROArrayColumn<casa::Complex> dataColumn(table, dataColumnName); casa::ROArrayColumn<bool> flagColumn(table, "FLAG"); casa::ROScalarColumn<double> timeColumn(table, "TIME"); casa::ROScalarColumn<int> antenna1Column(table, "ANTENNA1"); casa::ROScalarColumn<int> antenna2Column(table, "ANTENNA2"); casa::ROScalarColumn<int> windowColumn(table, "DATA_DESC_ID"); std::cout << "Collecting statistics..." << std::endl; size_t channelCount = bands[0].channels.size(); bool *correlatorFlags = new bool[channelCount]; bool *correlatorFlagsForBadAntenna = new bool[channelCount]; for(size_t ch=0; ch!=channelCount; ++ch) { correlatorFlags[ch] = false; correlatorFlagsForBadAntenna[ch] = true; } if(mwaChannels) { if(channelCount%24 != 0) std::cout << "MWA channels requested, but nr of channels not a multiply of 24. Ignoring.\n"; else { size_t chanPerSb = channelCount/24; for(size_t x=0;x!=24;++x) { correlatorFlags[x*chanPerSb] = true; correlatorFlags[x*chanPerSb + chanPerSb/2] = true; correlatorFlags[x*chanPerSb + chanPerSb-1] = true; } } } const unsigned nrow = table.nrow(); size_t timestepIndex = (size_t) -1; double prevtime = -1.0; for(unsigned row = 0; row!=nrow; ++row) { const double time = timeColumn(row); const unsigned antenna1Index = antenna1Column(row); const unsigned antenna2Index = antenna2Column(row); const unsigned bandIndex = windowColumn(row); if(time != prevtime) { ++timestepIndex; prevtime = time; } const BandInfo &band = bands[bandIndex]; const casa::Array<casa::Complex> dataArray = dataColumn(row); const casa::Array<bool> flagArray = flagColumn(row); std::vector<std::complex<float>* > samples(polarizationCount); bool **isRFI = new bool*[polarizationCount]; for(unsigned p = 0; p < polarizationCount; ++p) { isRFI[p] = new bool[band.channels.size()]; samples[p] = new std::complex<float>[band.channels.size()]; } const bool antennaIsFlagged = flaggedAntennae.find(antenna1Index) != flaggedAntennae.end() || flaggedAntennae.find(antenna2Index) != flaggedAntennae.end(); casa::Array<casa::Complex>::const_iterator dataIter = dataArray.begin(); casa::Array<bool>::const_iterator flagIter = flagArray.begin(); const unsigned startChannel = ignoreChannelZero ? 1 : 0; if(ignoreChannelZero) { for(unsigned p = 0; p < polarizationCount; ++p) { ++dataIter; ++flagIter; } } for(unsigned channel = startChannel ; channel<band.channels.size(); ++channel) { for(unsigned p = 0; p < polarizationCount; ++p) { samples[p][channel - startChannel] = *dataIter; isRFI[p][channel - startChannel] = *flagIter; ++dataIter; ++flagIter; } } for(unsigned p = 0; p < polarizationCount; ++p) { switch(mode) { case CollectDefault: if(antennaIsFlagged || timestepIndex < flaggedTimesteps) statisticsCollection.Add(antenna1Index, antenna2Index, time, bandIndex, p, &samples[p]->real(), &samples[p]->imag(), isRFI[p], correlatorFlagsForBadAntenna, band.channels.size() - startChannel, 2, 1, 1); else statisticsCollection.Add(antenna1Index, antenna2Index, time, bandIndex, p, &samples[p]->real(), &samples[p]->imag(), isRFI[p], correlatorFlags, band.channels.size() - startChannel, 2, 1, 1); break; case CollectHistograms: histogramCollection.Add(antenna1Index, antenna2Index, p, samples[p], isRFI[p], band.channels.size() - startChannel); break; } } for(unsigned p = 0; p < polarizationCount; ++p) { delete[] isRFI[p]; delete[] samples[p]; } delete[] isRFI; reportProgress(row, nrow); } delete[] correlatorFlags; delete[] correlatorFlagsForBadAntenna; for(unsigned b=0;b<bandCount;++b) delete[] frequencies[b]; delete[] frequencies; delete[] bands; std::cout << "100\n"; }
void CSysController::parsePatchUpdateLine(QString line) { SProgress progress; static int total_steps = 0; QString dl_speed; long dl_size, dl_complete; line= line.trimmed(); if (line.indexOf(SYS_PATCH_DOWNLOADING_WORD) == 0) { reportLogLine(QString("---------------------")); reportLogLine(QString("Installing update ") + mvUpdatesToApply[mCurrentUpdate].mName); reportLogLine(line.replace(SYS_PATCH_DOWNLOADING_WORD, "Downloading")); progress.mMessage= tr("Preparing to download ") + mvUpdatesToApply[mCurrentUpdate].mName; reportProgress(progress); return; } else if (line.indexOf(SYS_PATCH_FETCH) == 0) { return; } else if (parseFetchOutput(line, dl_size, dl_complete, dl_speed)) { progress.mMessage=tr("Downloading update (%1/%2 at %3)").arg(pcbsd::Utils::bytesToHumanReadable(dl_size), pcbsd::Utils::bytesToHumanReadable(dl_complete), dl_speed); progress.mProgressMax= dl_size; progress.mProgressCurr= dl_complete; progress.mSubstate= eDownload; progress.misCanCancel= true; reportProgress(progress); return; } else if (line.indexOf(SYS_PATCH_TOTAL_STEPS) == 0) { line.replace(SYS_PATCH_TOTAL_STEPS, ""); total_steps= line.toInt(); return; } else if (line.indexOf(SYS_PATCH_SETSTEPS) == 0) { line.replace(SYS_PATCH_SETSTEPS, ""); progress.mMessage= tr("Installing update ") + mvUpdatesToApply[mCurrentUpdate].mName; progress.mProgressMax= total_steps; progress.mProgressCurr= line.toInt(); progress.mSubstate= eInstall; reportProgress(progress); return; } else if (line.indexOf(SYS_PATCH_MSG) == 0) { line.replace(SYS_PATCH_MSG, ""); reportLogLine(line); return; } else if (line.indexOf(SYS_PATCH_FINISHED) == 0) { reportLogLine(QString("Finished install: ") + mvUpdatesToApply[mCurrentUpdate].mName); return; } }
double NesterovAcceleratedGradientSolver::solve(MatrixVector& inputs, const CostAndGradientFunction& callback) { assert(!inputs.empty()); double futurePointCost = 0.0; for (size_t i = 0; i < _iterations; ++i, ++_iterationsSoFar) { // detect cold start bool coldStart = !_velocity; if(coldStart) { _velocity.reset(new MatrixVector(inputs.sizes(), inputs.front().precision())); matrix::zeros(*_velocity); _iterationsSoFar = 0; } // evaluate at future point auto futureInputs = apply(apply(*_velocity, matrix::Multiply(_momentum)), inputs, matrix::Add()); MatrixVector futurePointDerivative; futurePointCost = callback.computeCostAndGradient(futurePointDerivative, futureInputs); if(!std::isfinite(futurePointCost)) { util::log("NesterovAcceleratedGradientSolver") << "Skipping not finite update (" << futurePointCost << ").\n"; continue; } double gradNorm = std::sqrt(matrix::dotProduct(futurePointDerivative, futurePointDerivative)); // possibly clip the gradient double scale = gradNorm > _maxGradNorm ? -(_learningRate * _maxGradNorm) / gradNorm : -_learningRate; // Update parameters apply(inputs, futureInputs, apply(futurePointDerivative, matrix::Multiply(scale)), matrix::Add()); // Update velocity auto multipliedMom = apply(*_velocity, matrix::Multiply(_momentum)); auto scaledFpd = apply(futurePointDerivative, matrix::Multiply(scale)); apply(*_velocity, multipliedMom, scaledFpd, matrix::Add()); if(coldStart) { _runningExponentialCostSum = futurePointCost; } else { size_t samples = std::min(_iterationsSoFar, static_cast<size_t>(100)); double ratio = (1.0 / samples); _runningExponentialCostSum = (1.0 - ratio) * _runningExponentialCostSum + ratio * futurePointCost; } reportProgress(futurePointCost, _runningExponentialCostSum, gradNorm, scale); _learningRate = _learningRate / _annealingRate; } return futurePointCost; }
/** Fits each spectrum in the workspace to f(x) = A * sin( w * x + p) * @param ws :: [input] The workspace to fit * @param freq :: [input] Hint for the frequency (w) * @param groupName :: [input] The name of the output workspace group * @param resTab :: [output] Table workspace storing the asymmetries and phases * @param resGroup :: [output] Workspace group storing the fitting results */ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, double freq, std::string groupName, API::ITableWorkspace_sptr resTab, API::WorkspaceGroup_sptr &resGroup) { int nhist = static_cast<int>(ws->getNumberHistograms()); // Create the fitting function f(x) = A * sin ( w * x + p ) // The same function and initial parameters are used for each fit std::string funcStr = createFittingFunction(freq, true); // Set up results table resTab->addColumn("int", "Spectrum number"); resTab->addColumn("double", "Asymmetry"); resTab->addColumn("double", "Phase"); const auto &indexInfo = ws->indexInfo(); // Loop through fitting all spectra individually const static std::string success = "success"; for (int wsIndex = 0; wsIndex < nhist; wsIndex++) { reportProgress(wsIndex, nhist); const auto &yValues = ws->y(wsIndex); auto emptySpectrum = std::all_of(yValues.begin(), yValues.end(), [](double value) { return value == 0.; }); if (emptySpectrum) { g_log.warning("Spectrum " + std::to_string(wsIndex) + " is empty"); TableWorkspace_sptr tab = boost::make_shared<TableWorkspace>(); tab->addColumn("str", "Name"); tab->addColumn("double", "Value"); tab->addColumn("double", "Error"); for (int j = 0; j < 4; j++) { API::TableRow row = tab->appendRow(); if (j == PHASE_ROW) { row << "dummy" << 0.0 << 0.0; } else { row << "dummy" << ASYMM_ERROR << 0.0; } } extractDetectorInfo(*tab, *resTab, indexInfo.spectrumNumber(wsIndex)); } else { auto fit = createChildAlgorithm("Fit"); fit->initialize(); fit->setPropertyValue("Function", funcStr); fit->setProperty("InputWorkspace", ws); fit->setProperty("WorkspaceIndex", wsIndex); fit->setProperty("CreateOutput", true); fit->setPropertyValue("Output", groupName); fit->execute(); std::string status = fit->getProperty("OutputStatus"); if (!fit->isExecuted()) { std::ostringstream error; error << "Fit failed for spectrum at workspace index " << wsIndex; error << ": " << status; throw std::runtime_error(error.str()); } else if (status != success) { g_log.warning("Fit failed for spectrum at workspace index " + std::to_string(wsIndex) + ": " + status); } API::MatrixWorkspace_sptr fitOut = fit->getProperty("OutputWorkspace"); resGroup->addWorkspace(fitOut); API::ITableWorkspace_sptr tab = fit->getProperty("OutputParameters"); // Now we have our fitting results stored in tab // but we need to extract the relevant information, i.e. // the detector phases (parameter 'p') and asymmetries ('A') extractDetectorInfo(*tab, *resTab, indexInfo.spectrumNumber(wsIndex)); } } }