/** * \brief CalculatePerformance controls when the performance of a bot is calculated and also helps with when the next levels should be used. */ void PerformanceStats::CalculatePerformance() { // if the test type and ranking make sense. if (!_unrecognisedData) { if (_botID.compare("") == 0) { // if the bot has no ID then put the folder name as today's date. auto time = std::chrono::system_clock::now(); auto time_t = chrono::system_clock::to_time_t(time); stringstream dateString; dateString << put_time(std::localtime(&time_t), "%d-%m-%y"); _botID = dateString.str(); } bool error = false; _testNumber++; error = CheckFolderState(); if (!error) { if (_testType.compare("TESTMAPS") == 0) { TestMaps(); } else if (_testType.compare("MARATHON") == 0) { Marathon(); } } } else { cout << "The test type or ranking you have chosen is unrecongnised. Please modify and restart Spelunky." << endl; } }
//============================================================================== int Komplex_LinearProblem::ProcessValues(double c0r, double c0i, const Epetra_RowMatrix & A0, double c1r, double c1i, const Epetra_RowMatrix & A1, const Epetra_MultiVector & Xr, const Epetra_MultiVector & Xi, const Epetra_MultiVector & Br, const Epetra_MultiVector & Bi, bool firstTime) { TEUCHOS_TEST_FOR_EXCEPT(TestMaps(A0, A1, Xr, Xi, Br, Bi)!=0); TEUCHOS_TEST_FOR_EXCEPT(InitMatrixAccess(A0, A1)!=0); TEUCHOS_TEST_FOR_EXCEPT(ConstructKomplexMaps(A0.OperatorDomainMap(), A0.OperatorRangeMap(), A0.RowMatrixRowMap())!=0); if (firstTime) { KomplexMatrix_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy,*KomplexMatrixRowMap_,0)); KomplexLHS_ = Teuchos::rcp(new Epetra_MultiVector(*KomplexMatrixDomainMap_, Xr.NumVectors())); KomplexRHS_ = Teuchos::rcp(new Epetra_MultiVector(*KomplexMatrixRangeMap_, Xr.NumVectors())); } int NumMyRows = A0.NumMyRows(); // Process X and B values for (int j=0; j<Xr.NumVectors(); j++) { double *localKX = &((*KomplexLHS_)[j][0]); double *localKB = &((*KomplexRHS_)[j][0]); for (int i=0; i< NumMyRows; i++) { localKX[2*i] = Xr[j][i]; localKX[2*i+1] = Xi[j][i]; localKB[2*i] = Br[j][i]; localKB[2*i+1] = Bi[j][i]; } } int NumIndices0; int NumIndices1; int * Indices0; int * Indices1; double * Values0; double * Values1; std::vector<int> KIndices0(MaxNumMyEntries0_); std::vector<double> KValues0(MaxNumMyEntries0_); std::vector<int> KIndices1(MaxNumMyEntries1_); std::vector<double> KValues1(MaxNumMyEntries1_); int * A0_ColGids = A0.RowMatrixColMap().MyGlobalElements(); int * A1_ColGids = A1.RowMatrixColMap().MyGlobalElements(); // For each row of A0 and A1 find the real and imag parts and place entries: // A_r -A_i // A_i A_r for ( int i=0; i<NumMyRows; i++) { // Get ith row TEUCHOS_TEST_FOR_EXCEPT(GetRow(i, A0, A1, NumIndices0, Values0, Indices0, NumIndices1, Values1, Indices1)<0); int globalRow = A0.RowMatrixRowMap().GID(i); // Process real part due to c0r*A0 if (c0r!=0.0) { // Upper Left for (int j=0; j<NumIndices0; j++) { KIndices0[j] = 2*A0_ColGids[Indices0[j]]; KValues0[j] = c0r*Values0[j]; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow, NumIndices0, &KValues0[0], &KIndices0[0], firstTime)<0); // Lower Right for (int j=0; j<NumIndices0; j++) { KIndices0[j]++; // KValues0[j] = c0r*Values0[j]; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow+1, NumIndices0, &KValues0[0], &KIndices0[0], firstTime)<0); } // Process imag part due to c0i*A0 if (c0i!=0.0) { // Upper Right (negate values) for (int j=0; j<NumIndices0; j++) { KIndices0[j] = 2*A0_ColGids[Indices0[j]]+1; KValues0[j] = - c0i*Values0[j]; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow, NumIndices0, &KValues0[0], &KIndices0[0], firstTime)<0); // Lower Left for (int j=0; j<NumIndices0; j++) { KIndices0[j]--; KValues0[j] *= -1.0; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow+1, NumIndices0, &KValues0[0], &KIndices0[0], firstTime)<0); } // Process real part due to c1r*A1 if (c1r!=0.0) { // Upper Left for (int j=0; j<NumIndices1; j++) { KIndices1[j] = 2*A1_ColGids[Indices1[j]]; KValues1[j] = c1r*Values1[j]; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow, NumIndices1, &KValues1[0], &KIndices1[0], firstTime)<0); // Lower Right for (int j=0; j<NumIndices1; j++) { KIndices1[j]++; //KValues1[j] = c1r*Values1[j]; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow+1, NumIndices1, &KValues1[0], &KIndices1[0], firstTime)<0); } // Process imag part due to c1i*A1 if (c1i!=0.0) { // Upper Right (negate values) for (int j=0; j<NumIndices1; j++) { KIndices1[j] = 2*A1_ColGids[Indices1[j]]+1; KValues1[j] = - c1i*Values1[j]; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow, NumIndices1, &KValues1[0], &KIndices1[0], firstTime)<0); // Lower Left for (int j=0; j<NumIndices1; j++) { KIndices1[j]--; KValues1[j] *= -1.0; } TEUCHOS_TEST_FOR_EXCEPT(PutRow(2*globalRow+1, NumIndices1, &KValues1[0], &KIndices1[0], firstTime)<0); } } return(0); }