void CRUDupElimLogScanner::Fetch() { // Start the cyclic shift ... pPrevRec_ = pCurrentRec_; if (TRUE == pResultSet_->Next()) { // End the cyclic shift ... pCurrentRec_ = inputBuf_[inputBufIndex_]; // ... and retrieve the new data pCurrentRec_->Build(*pResultSet_, ckStartColumn_); // Move the pointer inside the buffer inputBufIndex_ = (inputBufIndex_+1) % IB_SIZE; if (NULL == pPrevRec_ || pCurrentRec_->GetCKTuple() != pPrevRec_->GetCKTuple()) { // A new distinct CK value has been encountered ckTag_++; } pCurrentRec_->SetCKTag(ckTag_); UpdateStatistics(); } else { // End of input reached ! isEntireDeltaScanned_ = TRUE; pCurrentStmt_->Close(); } }
void CChangedDlg::OnBnClickedShowUnmodified() { UpdateData(); m_FileListCtrl.Show(UpdateShowFlags()); m_regAddBeforeCommit = m_bShowUnversioned; UpdateStatistics(); }
void Game::Run() { sf::Clock clock; sf::Time timeSinceLastUpdate = sf::Time::Zero; while (m_window.isOpen()) { sf::Time elapsedTime = clock.restart(); timeSinceLastUpdate += elapsedTime; while (timeSinceLastUpdate > TimePerFrame) { timeSinceLastUpdate -= TimePerFrame; ProcessInput(); Update(TimePerFrame); // Check inside this loop, because stack might be empty before Update() call. if (m_stateStack.IsEmpty()) { std::cout << "In Game: Stack empty, closing window.\n"; m_window.close(); } } UpdateStatistics(elapsedTime); Render(); } }
int CBaseParser::ReadAmrData(ONDEMANDPARAM *pOndemand, BYTE *szBuffer, int nRetryState, int nSuccState) { int readLen=0, nError; pOndemand->stat.nCount ++; pOndemand->stat.nSendCount ++; pOndemand->stat.nSend += sizeof(ENDI_AMRREAD_PAYLOAD) + sizeof(CODI_HEADER) + sizeof(EUI64) + sizeof(CODI_TAIL); gettimeofday((struct timeval *)&pOndemand->tmSend, NULL); nError = endiReadAmr(pOndemand->endi, (BYTE *)szBuffer, &readLen, GetReplyTimeout()); if (nError != CODIERR_NOERROR) { pOndemand->stat.nError ++; if (pOndemand->nRetry < GetRetryCount()) // 3회 이상 연속 실패시 종료 { pOndemand->nRetry++; return nRetryState; }else { pOndemand->nRetry = 0; return STATE_ERROR; } } pOndemand->nRetry = 0; UpdateStatistics(pOndemand, (BYTE *)szBuffer, readLen); pOndemand->stat.nCount ++; pOndemand->stat.nRecvCount ++; return nSuccState; }
void Frame::RunQuery(const wxString& query, bool empty_results) { wxStopWatch sw; const wxString query_lower = query.Lower(); // Query functions supported by ODBC // $SQLTables, $SQLColumns, etc. // $SQLTables $1:'%' // allow you to get database schema. if (query_lower.StartsWith("select") || query_lower.StartsWith("describe") || query_lower.StartsWith("show") || query_lower.StartsWith("explain") || query_lower.StartsWith("$sql")) { long rpc; if (m_Results->IsShown()) { rpc = m_otl.Query(query, m_Results, m_Stopped, empty_results); } else { rpc = m_otl.Query(query, m_Shell, m_Stopped); } sw.Pause(); UpdateStatistics(sw.Time(), rpc); } else { const auto rpc = m_otl.Query(query); sw.Pause(); UpdateStatistics(sw.Time(), rpc); } m_Shell->DocumentEnd(); }
UINT CChangedDlg::ChangedStatusThread() { InterlockedExchange(&m_bBlock, TRUE); g_Git.RefreshGitIndex(); m_bCanceled = false; SetDlgItemText(IDOK, CString(MAKEINTRESOURCE(IDS_MSGBOX_CANCEL))); DialogEnableWindow(IDC_REFRESH, FALSE); DialogEnableWindow(IDC_SHOWUNVERSIONED, FALSE); DialogEnableWindow(IDC_SHOWUNMODIFIED, FALSE); DialogEnableWindow(IDC_SHOWIGNORED, FALSE); DialogEnableWindow(IDC_SHOWUSERPROPS, FALSE); CString temp; m_FileListCtrl.Clear(); if (!m_FileListCtrl.GetStatus(&m_pathList, m_bRemote, m_bShowIgnored != FALSE, m_bShowUnversioned != FALSE)) { if (!m_FileListCtrl.GetLastErrorMessage().IsEmpty()) m_FileListCtrl.SetEmptyString(m_FileListCtrl.GetLastErrorMessage()); } unsigned int dwShow = GITSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS | GITSLC_SHOWLOCKS | GITSLC_SHOWSWITCHED | GITSLC_SHOWINCHANGELIST; dwShow |= m_bShowUnversioned ? GITSLC_SHOWUNVERSIONED : 0; dwShow |= m_iShowUnmodified ? GITSLC_SHOWNORMAL : 0; dwShow |= m_bShowIgnored ? GITSLC_SHOWIGNORED : 0; dwShow |= m_bShowExternals ? GITSLC_SHOWEXTERNAL | GITSLC_SHOWINEXTERNALS | GITSLC_SHOWEXTERNALFROMDIFFERENTREPO : 0; m_FileListCtrl.Show(dwShow); UpdateStatistics(); bool bIsDirectory = false; CTGitPath commonDir = m_FileListCtrl.GetCommonDirectory(false); if (m_pathList.GetCount() == 1) { if (m_pathList[0].IsEmpty()) CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, m_sTitle); else CAppUtils::SetWindowTitle(m_hWnd, (g_Git.m_CurrentDir + _T("\\") + m_pathList[0].GetWinPathString()).TrimRight('\\'), m_sTitle); bIsDirectory = m_pathList[0].IsDirectory() || m_pathList[0].IsEmpty(); // if it is empty it is g_Git.m_CurrentDir which is a directory } else CAppUtils::SetWindowTitle(m_hWnd, commonDir.GetWinPathString(), m_sTitle); SetDlgItemText(IDOK, CString(MAKEINTRESOURCE(IDS_MSGBOX_OK))); DialogEnableWindow(IDC_REFRESH, TRUE); DialogEnableWindow(IDC_SHOWUNVERSIONED, bIsDirectory); //DialogEnableWindow(IDC_SHOWUNMODIFIED, bIsDirectory); DialogEnableWindow(IDC_SHOWIGNORED, bIsDirectory); DialogEnableWindow(IDC_SHOWUSERPROPS, TRUE); InterlockedExchange(&m_bBlock, FALSE); // revert the remote flag back to the default m_bRemote = !!(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\CheckRepo"), FALSE); RefreshCursor(); return 0; }
void CChangedDlg::OnBnClickedShowlocalchangesignored() { UpdateData(); if (m_FileListCtrl.m_FileLoaded & CGitStatusListCtrl::FILELIST_LOCALCHANGESIGNORED) m_FileListCtrl.Show(UpdateShowFlags()); else if (m_bShowLocalChangesIgnored) { if (!AfxBeginThread(ChangedStatusThreadEntry, this)) CMessageBox::Show(GetSafeHwnd(), IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); } UpdateStatistics(); }
void CChangedDlg::OnBnClickedShowignored() { UpdateData(); if (m_FileListCtrl.m_FileLoaded & CGitStatusListCtrl::FILELIST_IGNORE) m_FileListCtrl.Show(UpdateShowFlags()); else if (m_bShowIgnored) { if (AfxBeginThread(ChangedStatusThreadEntry, this) == nullptr) CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); } UpdateStatistics(); }
bool StatisticalProfiler::IsDone() const { if (mSamples.size() >= mLastCalculationSize + mSamplesPerCalculation) UpdateStatistics(); if (mSamples.size() >= mMaxSamples) return true; if (mSamples.size() < mMinSamples) return false; return mStdDev <= mTargetStdDev * mMean; }
UINT CChangedDlg::ChangedStatusThread() { InterlockedExchange(&m_bBlock, TRUE); m_bCanceled = false; SetDlgItemText(IDOK, CString(MAKEINTRESOURCE(IDS_MSGBOX_CANCEL))); DialogEnableWindow(IDC_REFRESH, FALSE); DialogEnableWindow(IDC_CHECKREPO, FALSE); DialogEnableWindow(IDC_SHOWUNVERSIONED, FALSE); DialogEnableWindow(IDC_SHOWUNMODIFIED, FALSE); DialogEnableWindow(IDC_SHOWIGNORED, FALSE); DialogEnableWindow(IDC_SHOWUSERPROPS, FALSE); CString temp; if (!m_FileListCtrl.GetStatus(&m_pathList, m_bRemote, m_bShowIgnored != FALSE, m_bShowUnversioned,m_bShowUserProps != FALSE)) { if (!m_FileListCtrl.GetLastErrorMessage().IsEmpty()) m_FileListCtrl.SetEmptyString(m_FileListCtrl.GetLastErrorMessage()); } DWORD dwShow = SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS | SVNSLC_SHOWLOCKS | SVNSLC_SHOWSWITCHED | SVNSLC_SHOWINCHANGELIST; dwShow |= m_bShowUnversioned ? SVNSLC_SHOWUNVERSIONED : 0; dwShow |= m_iShowUnmodified ? SVNSLC_SHOWNORMAL : 0; dwShow |= m_bShowIgnored ? SVNSLC_SHOWIGNORED : 0; dwShow |= m_bShowExternals ? SVNSLC_SHOWEXTERNAL | SVNSLC_SHOWINEXTERNALS | SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO : 0; m_FileListCtrl.Show(dwShow); UpdateStatistics(); CTGitPath commonDir = m_FileListCtrl.GetCommonDirectory(false); bool bSingleFile = ((m_pathList.GetCount()==1)&&(!m_pathList[0].IsDirectory())); if (bSingleFile) SetWindowText(m_sTitle + _T(" - ") + m_pathList[0].GetWinPathString()); else SetWindowText(m_sTitle + _T(" - ") + commonDir.GetWinPathString()); SetDlgItemText(IDOK, CString(MAKEINTRESOURCE(IDS_MSGBOX_OK))); DialogEnableWindow(IDC_REFRESH, TRUE); DialogEnableWindow(IDC_CHECKREPO, TRUE); DialogEnableWindow(IDC_SHOWUNVERSIONED, !bSingleFile); DialogEnableWindow(IDC_SHOWUNMODIFIED, !bSingleFile); DialogEnableWindow(IDC_SHOWIGNORED, !bSingleFile); DialogEnableWindow(IDC_SHOWUSERPROPS, TRUE); InterlockedExchange(&m_bBlock, FALSE); // revert the remote flag back to the default m_bRemote = !!(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\CheckRepo"), FALSE); RefreshCursor(); return 0; }
UINT CChangedDlg::ChangedStatusThread() { InterlockedExchange(&m_bBlock, TRUE); g_Git.RefreshGitIndex(); m_bCanceled = false; SetDlgItemText(IDOK, CString(MAKEINTRESOURCE(IDS_MSGBOX_CANCEL))); DialogEnableWindow(IDC_REFRESH, FALSE); DialogEnableWindow(IDC_SHOWUNVERSIONED, FALSE); DialogEnableWindow(IDC_SHOWUNMODIFIED, FALSE); DialogEnableWindow(IDC_SHOWIGNORED, FALSE); DialogEnableWindow(IDC_SHOWLOCALCHANGESIGNORED, FALSE); CString temp; m_FileListCtrl.Clear(); if (!m_FileListCtrl.GetStatus(m_bWholeProject ? nullptr : &m_pathList, m_bRemote, m_bShowIgnored != FALSE, m_bShowUnversioned != FALSE, m_bShowLocalChangesIgnored != FALSE)) { if (!m_FileListCtrl.GetLastErrorMessage().IsEmpty()) m_FileListCtrl.SetEmptyString(m_FileListCtrl.GetLastErrorMessage()); } unsigned int dwShow = GITSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS | GITSLC_SHOWLOCKS | GITSLC_SHOWSWITCHED | GITSLC_SHOWINCHANGELIST; dwShow |= m_bShowUnversioned ? GITSLC_SHOWUNVERSIONED : 0; dwShow |= m_iShowUnmodified ? GITSLC_SHOWNORMAL : 0; dwShow |= m_bShowIgnored ? GITSLC_SHOWIGNORED : 0; dwShow |= m_bShowLocalChangesIgnored ? GITSLC_SHOWASSUMEVALID | GITSLC_SHOWSKIPWORKTREE : 0; m_FileListCtrl.Show(dwShow); UpdateStatistics(); SetDlgTitle(); bool bIsDirectory = false; if (m_pathList.GetCount() == 1) bIsDirectory = m_pathList[0].IsDirectory() || m_pathList[0].IsEmpty(); // if it is empty it is g_Git.m_CurrentDir which is a directory SetDlgItemText(IDOK, CString(MAKEINTRESOURCE(IDS_MSGBOX_OK))); DialogEnableWindow(IDC_REFRESH, TRUE); DialogEnableWindow(IDC_SHOWUNVERSIONED, bIsDirectory); //DialogEnableWindow(IDC_SHOWUNMODIFIED, bIsDirectory); DialogEnableWindow(IDC_SHOWIGNORED, bIsDirectory); DialogEnableWindow(IDC_SHOWLOCALCHANGESIGNORED, TRUE); InterlockedExchange(&m_bBlock, FALSE); // revert the remote flag back to the default m_bRemote = !!(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\CheckRepo"), FALSE); RefreshCursor(); return 0; }
void CChangedDlg::OnBnClickedShowunversioned() { UpdateData(); m_regAddBeforeCommit = m_bShowUnversioned; if(m_FileListCtrl.m_FileLoaded & CGitStatusListCtrl::FILELIST_UNVER) { m_FileListCtrl.Show(UpdateShowFlags()); } else { if(m_bShowUnversioned) { if (!AfxBeginThread(ChangedStatusThreadEntry, this)) { CMessageBox::Show(GetSafeHwnd(), IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); } } } UpdateStatistics(); }
void Game::Run() { sf::Clock clock; sf::Time timeSinceLastUpdate = sf::Time::Zero; while (mWindow.isOpen()) { sf::Time elapsedTime = clock.restart(); timeSinceLastUpdate += elapsedTime; while (timeSinceLastUpdate > TimePerFrame) { timeSinceLastUpdate -= TimePerFrame; ProcessEvents(); Update(TimePerFrame); } UpdateStatistics(elapsedTime); Render(); } }
int CBaseParser::ReadRomMap(WORD addr, int len, ONDEMANDPARAM *pOndemand, BYTE *szBuffer, int nRetryState, int nSuccState) { int readLen=0, nError; pOndemand->stat.nCount ++; pOndemand->stat.nSendCount ++; pOndemand->stat.nSend += sizeof(ENDI_ROMREAD_PAYLOAD) + sizeof(CODI_HEADER) + sizeof(EUI64) + sizeof(CODI_TAIL); gettimeofday((struct timeval *)&pOndemand->tmSend, NULL); nError = endiReadRom(pOndemand->endi, addr, len, (BYTE *)szBuffer, &readLen, GetReplyTimeout()); if (nError != CODIERR_NOERROR) { pOndemand->stat.nError ++; if (pOndemand->nRetry < GetRetryCount()) // 3회 이상 연속 실패시 종료 { pOndemand->nRetry++; return nRetryState; }else { pOndemand->nRetry = 0; return STATE_ERROR; } } if (readLen != len) { XDEBUG(ANSI_COLOR_RED " ****** PARSER: Invalid ROM DATA Length ******\r\n" ANSI_NORMAL); XDEBUG(ANSI_COLOR_RED " Request Size = %d, Read Size = %d\r\n" ANSI_NORMAL, len, readLen); pOndemand->nRetry++; return nRetryState; } pOndemand->nRetry = 0; UpdateStatistics(pOndemand, (BYTE *)szBuffer, readLen); pOndemand->stat.nCount ++; pOndemand->stat.nRecvCount ++; return nSuccState; }
double StatisticalProfiler::GetMedian() const { UpdateStatistics(); return mMedian; }
double StatisticalProfiler::GetMax() const { UpdateStatistics(); return mMax; }
float32 b2ParticleGroup::GetMass() const { UpdateStatistics(); return m_mass; }
int SolveSubproblem(int CurrentSubproblem, int Subproblems, GainType * GlobalBestCost) { Node *FirstNodeSaved = FirstNode, *N, *Next, *Last = 0; GainType OptimumSaved = Optimum, Cost, Improvement, GlobalCost; double LastTime, Time, ExcessSaved = Excess; int NewDimension = 0, OldDimension = 0, Number, i, InitialTourEdges = 0, AscentCandidatesSaved = AscentCandidates, InitialPeriodSaved = InitialPeriod, MaxTrialsSaved = MaxTrials; BestCost = PLUS_INFINITY; FirstNode = 0; N = FirstNodeSaved; do { if (N->Subproblem == CurrentSubproblem) { if (SubproblemsCompressed && (((N->SubproblemPred == N->SubBestPred || FixedOrCommon(N, N->SubproblemPred) || (N->SubBestPred && (N->FixedTo1Saved == N->SubBestPred || N->FixedTo2Saved == N->SubBestPred))) && (N->SubproblemSuc == N->SubBestSuc || FixedOrCommon(N, N->SubproblemSuc) || (N->SubBestSuc && (N->FixedTo1Saved == N->SubBestSuc || N->FixedTo2Saved == N->SubBestSuc)))) || ((N->SubproblemPred == N->SubBestSuc || FixedOrCommon(N, N->SubproblemPred) || (N->SubBestSuc && (N->FixedTo1Saved == N->SubBestSuc || N->FixedTo2Saved == N->SubBestSuc))) && (N->SubproblemSuc == N->SubBestPred || FixedOrCommon(N, N->SubproblemSuc) || (N->SubBestPred && (N->FixedTo1Saved == N->SubBestPred || N->FixedTo2Saved == N->SubBestPred)))))) N->Subproblem = -CurrentSubproblem; else { if (!FirstNode) FirstNode = N; NewDimension++; } N->Head = N->Tail = 0; if (N->SubBestSuc) OldDimension++; } N->SubBestPred = N->SubBestSuc = 0; N->FixedTo1Saved = N->FixedTo1; N->FixedTo2Saved = N->FixedTo2; } while ((N = N->SubproblemSuc) != FirstNodeSaved); if ((Number = CurrentSubproblem % Subproblems) == 0) Number = Subproblems; if (NewDimension <= 3 || NewDimension == OldDimension) { if (TraceLevel >= 1 && NewDimension <= 3) printff ("\nSubproblem %d of %d: Dimension = %d (too small)\n", Number, Subproblems, NewDimension); FirstNode = FirstNodeSaved; return 0; } if (AscentCandidates > NewDimension - 1) AscentCandidates = NewDimension - 1; if (InitialPeriod < 0) { InitialPeriod = NewDimension / 2; if (InitialPeriod < 100) InitialPeriod = 100; } if (Excess < 0) Excess = 1.0 / NewDimension; if (MaxTrials == -1) MaxTrials = NewDimension; N = FirstNode; do { Next = N->SubproblemSuc; if (N->Subproblem == CurrentSubproblem) { N->Pred = N->Suc = N; if (N != FirstNode) Follow(N, Last); Last = N; } else if (Next->Subproblem == CurrentSubproblem && !Fixed(Last, Next)) { if (!Last->FixedTo1 || Last->FixedTo1->Subproblem != CurrentSubproblem) Last->FixedTo1 = Next; else Last->FixedTo2 = Next; if (!Next->FixedTo1 || Next->FixedTo1->Subproblem != CurrentSubproblem) Next->FixedTo1 = Last; else Next->FixedTo2 = Last; if (C == C_EXPLICIT) { if (Last->Id > Next->Id) Last->C[Next->Id] = 0; else Next->C[Last->Id] = 0; } } } while ((N = Next) != FirstNode); Dimension = NewDimension; AllocateSegments(); InitializeStatistics(); if (CacheSig) for (i = 0; i <= CacheMask; i++) CacheSig[i] = 0; OptimumSaved = Optimum; Optimum = 0; N = FirstNode; do { if (N->SubproblemSuc == N->InitialSuc || N->SubproblemPred == N->InitialSuc) InitialTourEdges++; if (!Fixed(N, N->Suc)) Optimum += Distance(N, N->Suc); if (N->FixedTo1 && N->Subproblem != N->FixedTo1->Subproblem) eprintf("Illegal fixed edge (%d,%d)", N->Id, N->FixedTo1->Id); if (N->FixedTo2 && N->Subproblem != N->FixedTo2->Subproblem) eprintf("Illegal fixed edge (%d,%d)", N->Id, N->FixedTo2->Id); } while ((N = N->Suc) != FirstNode); if (TraceLevel >= 1) printff ("\nSubproblem %d of %d: Dimension = %d, Upper bound = " GainFormat "\n", Number, Subproblems, Dimension, Optimum); FreeCandidateSets(); CreateCandidateSet(); for (Run = 1; Run <= Runs; Run++) { LastTime = GetTime(); Cost = Norm != 0 ? FindTour() : Optimum; /* Merge with subproblem tour */ Last = 0; N = FirstNode; do { if (N->Subproblem == CurrentSubproblem) { if (Last) Last->Next = N; Last = N; } } while ((N = N->SubproblemSuc) != FirstNode); Last->Next = FirstNode; Cost = MergeWithTour(); if (MaxPopulationSize > 1) { /* Genetic algorithm */ for (i = 0; i < PopulationSize; i++) Cost = MergeTourWithIndividual(i); if (!HasFitness(Cost)) { if (PopulationSize < MaxPopulationSize) { AddToPopulation(Cost); if (TraceLevel >= 1) PrintPopulation(); } else if (Cost < Fitness[PopulationSize - 1]) { ReplaceIndividualWithTour(PopulationSize - 1, Cost); if (TraceLevel >= 1) PrintPopulation(); } } } if (Cost < BestCost) { N = FirstNode; do { N->SubBestPred = N->Pred; N->SubBestSuc = N->Suc; } while ((N = N->Suc) != FirstNode); BestCost = Cost; } if (Cost < Optimum || (Cost != Optimum && OutputTourFileName)) { Improvement = Optimum - Cost; if (Improvement > 0) { BestCost = GlobalCost = *GlobalBestCost -= Improvement; Optimum = Cost; } else GlobalCost = *GlobalBestCost - Improvement; N = FirstNode; do N->Mark = 0; while ((N = N->SubproblemSuc) != FirstNode); do { N->Mark = N; if (!N->SubproblemSuc->Mark && (N->Subproblem != CurrentSubproblem || N->SubproblemSuc->Subproblem != CurrentSubproblem)) N->BestSuc = N->SubproblemSuc; else if (!N->SubproblemPred->Mark && (N->Subproblem != CurrentSubproblem || N->SubproblemPred->Subproblem != CurrentSubproblem)) N->BestSuc = N->SubproblemPred; else if (!N->Suc->Mark) N->BestSuc = N->Suc; else if (!N->Pred->Mark) N->BestSuc = N->Pred; else N->BestSuc = FirstNode; } while ((N = N->BestSuc) != FirstNode); Dimension = DimensionSaved; i = 0; do { if (ProblemType != ATSP) BetterTour[++i] = N->Id; else if (N->Id <= Dimension / 2) { i++; if (N->BestSuc->Id != N->Id + Dimension / 2) BetterTour[i] = N->Id; else BetterTour[Dimension / 2 - i + 1] = N->Id; } } while ((N = N->BestSuc) != FirstNode); BetterTour[0] = BetterTour[ProblemType != ATSP ? Dimension : Dimension / 2]; WriteTour(OutputTourFileName, BetterTour, GlobalCost); if (Improvement > 0) { do if (N->Subproblem != CurrentSubproblem) break; while ((N = N->SubproblemPred) != FirstNode); if (N->SubproblemSuc == N->BestSuc) { N = FirstNode; do { N->BestSuc->SubproblemPred = N; N = N->SubproblemSuc = N->BestSuc; } while (N != FirstNode); } else { N = FirstNode; do (N->SubproblemPred = N->BestSuc)->SubproblemSuc = N; while ((N = N->BestSuc) != FirstNode); } RecordBestTour(); WriteTour(TourFileName, BestTour, GlobalCost); } Dimension = NewDimension; if (TraceLevel >= 1) { printff("*** %d: Cost = " GainFormat, Number, GlobalCost); if (OptimumSaved != MINUS_INFINITY && OptimumSaved != 0) printff(", Gap = %04f%%", 100.0 * (GlobalCost - OptimumSaved) / OptimumSaved); printff(", Time = %0.2f sec. %s\n", fabs(GetTime() - LastTime), GlobalCost < OptimumSaved ? "<" : GlobalCost == OptimumSaved ? "=" : ""); } } Time = fabs(GetTime() - LastTime); UpdateStatistics(Cost, Time); if (TraceLevel >= 1 && Cost != PLUS_INFINITY) printff("Run %d: Cost = " GainFormat ", Time = %0.2f sec.\n\n", Run, Cost, Time); if (PopulationSize >= 2 && (PopulationSize == MaxPopulationSize || Run >= 2 * MaxPopulationSize) && Run < Runs) { Node *N; int Parent1, Parent2; Parent1 = LinearSelection(PopulationSize, 1.25); do Parent2 = LinearSelection(PopulationSize, 1.25); while (Parent1 == Parent2); ApplyCrossover(Parent1, Parent2); N = FirstNode; do { int d = C(N, N->Suc); AddCandidate(N, N->Suc, d, INT_MAX); AddCandidate(N->Suc, N, d, INT_MAX); N = N->InitialSuc = N->Suc; } while (N != FirstNode); } SRandom(++Seed); if (Norm == 0) break; } if (TraceLevel >= 1) PrintStatistics(); if (C == C_EXPLICIT) { N = FirstNode; do { for (i = 1; i < N->Id; i++) { N->C[i] -= N->Pi + NodeSet[i].Pi; N->C[i] /= Precision; } if (N->FixedTo1 && N->FixedTo1 != N->FixedTo1Saved) { if (N->Id > N->FixedTo1->Id) N->C[N->FixedTo1->Id] = Distance(N, N->FixedTo1); else N->FixedTo1->C[N->Id] = Distance(N, N->FixedTo1); } if (N->FixedTo2 && N->FixedTo2 != N->FixedTo2Saved) { if (N->Id > N->FixedTo2->Id) N->C[N->FixedTo2->Id] = Distance(N, N->FixedTo2); else N->FixedTo2->C[N->Id] = Distance(N, N->FixedTo2); } } while ((N = N->Suc) != FirstNode); } FreeSegments(); FreeCandidateSets(); FreePopulation(); if (InitialTourEdges == Dimension) { do N->InitialSuc = N->SubproblemSuc; while ((N = N->SubproblemSuc) != FirstNode); } else { do N->InitialSuc = 0; while ((N = N->SubproblemSuc) != FirstNode); } Dimension = ProblemType != ATSP ? DimensionSaved : 2 * DimensionSaved; N = FirstNode = FirstNodeSaved; do { N->Suc = N->BestSuc = N->SubproblemSuc; N->Suc->Pred = N; Next = N->FixedTo1; N->FixedTo1 = N->FixedTo1Saved; N->FixedTo1Saved = Next; Next = N->FixedTo2; N->FixedTo2 = N->FixedTo2Saved; N->FixedTo2Saved = Next; } while ((N = N->Suc) != FirstNode); Optimum = OptimumSaved; Excess = ExcessSaved; AscentCandidates = AscentCandidatesSaved; InitialPeriod = InitialPeriodSaved; MaxTrials = MaxTrialsSaved; return 1; }
float32 b2ParticleGroup::GetInertia() const { UpdateStatistics(); return m_inertia; }
b2Vec2 b2ParticleGroup::GetCenter() const { UpdateStatistics(); return m_center; }
QgsMssqlProvider::QgsMssqlProvider( QString uri ) : QgsVectorDataProvider( uri ) , mCrs() , mWkbType( QGis::WKBUnknown ) { QgsDataSourceURI anUri = QgsDataSourceURI( uri ); if ( !anUri.srid().isEmpty() ) mSRId = anUri.srid().toInt(); else mSRId = -1; mWkbType = anUri.wkbType(); mValid = true; mUseWkb = false; mSkipFailures = false; mUseEstimatedMetadata = anUri.useEstimatedMetadata(); mSqlWhereClause = anUri.sql(); mDatabase = GetDatabase( anUri.service(), anUri.host(), anUri.database(), anUri.username(), anUri.password() ); if ( !OpenDatabase( mDatabase ) ) { setLastError( mDatabase.lastError( ).text( ) ); mValid = false; return; } // Create a query for default connection mQuery = QSqlQuery( mDatabase ); // Database successfully opened; we can now issue SQL commands. if ( !anUri.schema().isEmpty() ) mSchemaName = anUri.schema(); else mSchemaName = "dbo"; if ( !anUri.table().isEmpty() ) { // the layer name has been specified mTableName = anUri.table(); QStringList sl = mTableName.split( '.' ); if ( sl.length() == 2 ) { mSchemaName = sl[0]; mTableName = sl[1]; } mTables = QStringList( mTableName ); } else { // Get a list of table mTables = mDatabase.tables( QSql::Tables ); if ( mTables.count() > 0 ) mTableName = mTables[0]; else mValid = false; } if ( mValid ) { if ( !anUri.keyColumn().isEmpty() ) mFidColName = anUri.keyColumn(); if ( !anUri.geometryColumn().isEmpty() ) mGeometryColName = anUri.geometryColumn(); if ( mSRId < 0 || mWkbType == QGis::WKBUnknown || mGeometryColName.isEmpty() ) loadMetadata(); loadFields(); UpdateStatistics( mUseEstimatedMetadata ); if ( mGeometryColName.isEmpty() ) { // table contains no geometries mWkbType = QGis::WKBNoGeometry; mSRId = 0; } } //fill type names into sets mNativeTypes // integer types << QgsVectorDataProvider::NativeType( tr( "8 Bytes integer" ), "bigint", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "4 Bytes integer" ), "int", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "2 Bytes integer" ), "smallint", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "1 Bytes integer" ), "tinyint", QVariant::Int ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 ) // floating point << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "float", QVariant::Double ) // string types << QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 255 ) << QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255 ) << QgsVectorDataProvider::NativeType( tr( "Text, fixed length unicode (nchar)" ), "nchar", QVariant::String, 1, 255 ) << QgsVectorDataProvider::NativeType( tr( "Text, limited variable length unicode (nvarchar)" ), "nvarchar", QVariant::String, 1, 255 ) << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String ) << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length unicode (ntext)" ), "text", QVariant::String ) ; }
LRESULT CChangedDlg::OnSVNStatusListCtrlItemCountChanged(WPARAM, LPARAM) { UpdateStatistics(); return 0; }
void QmitkImageStatisticsView::IgnoreZerosCheckboxClicked( ) { UpdateStatistics(); }
b2Vec2 b2ParticleGroup::GetLinearVelocity() const { UpdateStatistics(); return m_linearVelocity; }
float32 b2ParticleGroup::GetAngularVelocity() const { UpdateStatistics(); return m_angularVelocity; }
ReturnFlag LKH::LKHAlg::run_() { GainType Cost, OldOptimum; double Time, LastTime = GetTime(); if (SubproblemSize > 0) { if (DelaunayPartitioning) SolveDelaunaySubproblems(); else if (KarpPartitioning) SolveKarpSubproblems(); else if (KCenterPartitioning) SolveKCenterSubproblems(); else if (KMeansPartitioning) SolveKMeansSubproblems(); else if (RohePartitioning) SolveRoheSubproblems(); else if (MoorePartitioning || SierpinskiPartitioning) SolveSFCSubproblems(); else SolveTourSegmentSubproblems(); } AllocateStructures(); CreateCandidateSet(); InitializeStatistics(); if (Norm != 0) BestCost = PLUS_INFINITY; else { /* The ascent has solved the problem! */ Optimum = BestCost = (GainType) LowerBound; UpdateStatistics(Optimum, GetTime() - LastTime); RecordBetterTour(); RecordBestTour(); WriteTour(OutputTourFileName, BestTour, BestCost); WriteTour(TourFileName, BestTour, BestCost); Runs = 0; } /* Find a specified number (Runs) of local optima */ for (Run = 1; Run <= Runs; Run++) { LastTime = GetTime(); Cost = FindTour(); /* using the Lin-Kernighan heuristic */ if (*MaxPopulationSize > 1) { /* Genetic algorithm */ int i; for (i = 0; i < *PopulationSize; i++) { GainType OldCost = Cost; Cost = MergeTourWithIndividual(i,this); if (TraceLevel >= 1 && Cost < OldCost) { printff(" Merged with %d: Cost = " GainFormat, i + 1, Cost); if (Optimum != MINUS_INFINITY && Optimum != 0) printff(", Gap = %0.4f%%", 100.0 * (Cost - Optimum) / Optimum); printff("\n"); } } if (!HasFitness(Cost)) { if (*PopulationSize < *MaxPopulationSize) { AddToPopulation(Cost,this); if (TraceLevel >= 1) PrintPopulation(this); } else if (Cost < Fitness.get()[*PopulationSize - 1]) { i = ReplacementIndividual(Cost,this); ReplaceIndividualWithTour(i, Cost,this); if (TraceLevel >= 1) PrintPopulation(this); } } } else if (Run > 1) Cost = MergeBetterTourWithBestTour(); if (Cost < BestCost) { BestCost = Cost; RecordBetterTour(); RecordBestTour(); WriteTour(OutputTourFileName, BestTour, BestCost); WriteTour(TourFileName, BestTour, BestCost); } OldOptimum = Optimum; if (Cost < Optimum) { if (FirstNode->InputSuc) { Node *N = FirstNode; while ((N = N->InputSuc = N->Suc) != FirstNode); } Optimum = Cost; printff("*** New optimum = " GainFormat " ***\n\n", Optimum); } Time = fabs(GetTime() - LastTime); UpdateStatistics(Cost, Time); if (TraceLevel >= 1 && Cost != PLUS_INFINITY) { printff("Run %d: Cost = " GainFormat, Global::msp_global->m_runId, Cost); if (Optimum != MINUS_INFINITY && Optimum != 0) printff(", Gap = %0.4f%%", 100.0 * (Cost - Optimum) / Optimum); // printff(", Time = %0.2f sec. %s\n\n", Time, // Cost < Optimum ? "<" : Cost == Optimum ? "=" : ""); printff(", Time = %0.2f sec. \n", Time); } if (StopAtOptimum && Cost == OldOptimum && *MaxPopulationSize >= 1) { Runs = Run; break; } if (*PopulationSize >= 2 && (*PopulationSize == *MaxPopulationSize || Run >= 2 * *MaxPopulationSize) && Run < Runs) { Node *N; int Parent1, Parent2; Parent1 = LinearSelection(*PopulationSize, 1.25,this); do Parent2 = LinearSelection(*PopulationSize, 1.25,this); while (Parent2 == Parent1); ApplyCrossover(Parent1, Parent2,this); N = FirstNode; do { int d = (this->*C)(N, N->Suc); AddCandidate(N, N->Suc, d, INT_MAX); AddCandidate(N->Suc, N, d, INT_MAX); N = N->InitialSuc = N->Suc; } while (N != FirstNode); } mv_cost[Global::msp_global->m_runId]=Cost; SRandom(++Seed); } // PrintStatistics(); freeAll(); FreeStructures(); return Return_Terminate; }
double StatisticalProfiler::GetRawMean() const { UpdateStatistics(); return mRawMean; }
int main(int argc, char *argv[]) { GainType Cost; double Time, LastTime = GetTime(); /* Read the specification of the problem */ if (argc >= 2) ParameterFileName = argv[1]; ReadParameters(); MaxMatrixDimension = 10000; ReadProblem(); if (SubproblemSize > 0) { if (DelaunayPartitioning) SolveDelaunaySubproblems(); else if (KarpPartitioning) SolveKarpSubproblems(); else if (KCenterPartitioning) SolveKCenterSubproblems(); else if (KMeansPartitioning) SolveKMeansSubproblems(); else if (RohePartitioning) SolveRoheSubproblems(); else if (MoorePartitioning || SierpinskiPartitioning) SolveSFCSubproblems(); else SolveTourSegmentSubproblems(); return EXIT_SUCCESS; } AllocateStructures(); CreateCandidateSet(); InitializeStatistics(); if (Norm != 0) BestCost = PLUS_INFINITY; else { /* The ascent has solved the problem! */ Optimum = BestCost = (GainType) LowerBound; UpdateStatistics(Optimum, GetTime() - LastTime); RecordBetterTour(); RecordBestTour(); WriteTour(OutputTourFileName, BestTour, BestCost); WriteTour(TourFileName, BestTour, BestCost); Runs = 0; } /* Find a specified number (Runs) of local optima */ for (Run = 1; Run <= Runs; Run++) { LastTime = GetTime(); Cost = FindTour(); /* using the Lin-Kernighan heuristic */ if (MaxPopulationSize > 1) { /* Genetic algorithm */ int i; for (i = 0; i < PopulationSize; i++) { GainType OldCost = Cost; Cost = MergeTourWithIndividual(i); if (TraceLevel >= 1 && Cost < OldCost) { printff(" Merged with %d: Cost = " GainFormat, i + 1, Cost); if (Optimum != MINUS_INFINITY && Optimum != 0) printff(", Gap = %0.4f%%", 100.0 * (Cost - Optimum) / Optimum); printff("\n"); } } if (!HasFitness(Cost)) { if (PopulationSize < MaxPopulationSize) { AddToPopulation(Cost); if (TraceLevel >= 1) PrintPopulation(); } else if (Cost < Fitness[PopulationSize - 1]) { i = ReplacementIndividual(Cost); ReplaceIndividualWithTour(i, Cost); if (TraceLevel >= 1) PrintPopulation(); } } } else if (Run > 1) Cost = MergeBetterTourWithBestTour(); if (Cost < BestCost) { BestCost = Cost; RecordBetterTour(); RecordBestTour(); WriteTour(OutputTourFileName, BestTour, BestCost); WriteTour(TourFileName, BestTour, BestCost); } if (Cost < Optimum) { if (FirstNode->InputSuc) { Node *N = FirstNode; while ((N = N->InputSuc = N->Suc) != FirstNode); } Optimum = Cost; printff("*** New optimum = " GainFormat " ***\n\n", Optimum); } Time = fabs(GetTime() - LastTime); UpdateStatistics(Cost, Time); if (TraceLevel >= 1 && Cost != PLUS_INFINITY) { printff("Run %d: Cost = " GainFormat, Run, Cost); if (Optimum != MINUS_INFINITY && Optimum != 0) printff(", Gap = %0.4f%%", 100.0 * (Cost - Optimum) / Optimum); printff(", Time = %0.2f sec. %s\n\n", Time, Cost < Optimum ? "<" : Cost == Optimum ? "=" : ""); } if (PopulationSize >= 2 && (PopulationSize == MaxPopulationSize || Run >= 2 * MaxPopulationSize) && Run < Runs) { Node *N; int Parent1, Parent2; Parent1 = LinearSelection(PopulationSize, 1.25); do Parent2 = LinearSelection(PopulationSize, 1.25); while (Parent2 == Parent1); ApplyCrossover(Parent1, Parent2); N = FirstNode; do { int d = C(N, N->Suc); AddCandidate(N, N->Suc, d, INT_MAX); AddCandidate(N->Suc, N, d, INT_MAX); N = N->InitialSuc = N->Suc; } while (N != FirstNode); } SRandom(++Seed); } PrintStatistics(); return EXIT_SUCCESS; }
double StatisticalProfiler::GetRawStdDev() const { UpdateStatistics(); return mRawStdDev; }
int tsp_lkh() { GainType Cost, OldOptimum; double Time, LastTime = GetTime(); /* Read the specification of the problem */ ReadParameters(); MaxMatrixDimension = 10000; init(); AllocateStructures(); CreateCandidateSet(); InitializeStatistics(); BestCost = PLUS_INFINITY; for (Run = 1; Run <= Runs; Run++) { LastTime = GetTime(); Cost = FindTour(); /* using the Lin-Kernighan heuristic */ if (MaxPopulationSize > 1) { /* Genetic algorithm */ int i; for (i = 0; i < PopulationSize; i++) { GainType OldCost = Cost; Cost = MergeTourWithIndividual(i); if (TraceLevel >= 1 && Cost < OldCost) { // printff(" Merged with %d: Cost = " GainFormat, i + 1, /// Cost); // if (Optimum != MINUS_INFINITY && Optimum != 0) // printff(", Gap = %0.4f%%", // 100.0 * (Cost - Optimum) / Optimum); //printff("\n"); } } if (!HasFitness(Cost)) { if (PopulationSize < MaxPopulationSize) { AddToPopulation(Cost); if (TraceLevel >= 1) PrintPopulation(); } else if (Cost < Fitness[PopulationSize - 1]) { i = ReplacementIndividual(Cost); ReplaceIndividualWithTour(i, Cost); if (TraceLevel >= 1) PrintPopulation(); } } } else if (Run > 1) Cost = MergeTourWithBestTour(); if (Cost < BestCost) { BestCost = Cost; RecordBetterTour(); RecordBestTour(); } OldOptimum = Optimum; if (Cost < Optimum) { if (FirstNode->InputSuc) { Node *N = FirstNode; while ((N = N->InputSuc = N->Suc) != FirstNode); } Optimum = Cost; //printff("*** New optimum = " GainFormat " ***\n\n", Optimum); } Time = fabs(GetTime() - LastTime); UpdateStatistics(Cost, Time); /* if (TraceLevel >= 1 && Cost != PLUS_INFINITY) { printff("Run %d: Cost = " GainFormat, Run, Cost); if (Optimum != MINUS_INFINITY && Optimum != 0) printff(", Gap = %0.4f%%", 100.0 * (Cost - Optimum) / Optimum); printff(", Time = %0.2f sec. %s\n\n", Time, Cost < Optimum ? "<" : Cost == Optimum ? "=" : ""); }*/ if (StopAtOptimum && Cost == OldOptimum && MaxPopulationSize >= 1) { Runs = Run; break; } if (PopulationSize >= 2 && (PopulationSize == MaxPopulationSize || Run >= 2 * MaxPopulationSize) && Run < Runs) { Node *N; int Parent1, Parent2; Parent1 = LinearSelection(PopulationSize, 1.25); do Parent2 = LinearSelection(PopulationSize, 1.25); while (Parent2 == Parent1); ApplyCrossover(Parent1, Parent2); N = FirstNode; do { if (ProblemType != HCP && ProblemType != HPP) { int d = C(N, N->Suc); AddCandidate(N, N->Suc, d, INT_MAX); AddCandidate(N->Suc, N, d, INT_MAX); } N = N->InitialSuc = N->Suc; } while (N != FirstNode); } SRandom(++Seed); } // PrintStatistics(); for (int i = 0; i < TSP_N; i++) { TSP_RESULT[i] = BestTour[i] - 1; } // printf("%d -¡·",BestTour[i]-1); return BestCost; }