/* * r u n O Q P b e n c h m a r k */ returnValue runOQPbenchmark( const char* path, BooleanType isSparse, const Options& options, int& nWSR, real_t& maxCPUtime, real_t& maxStationarity, real_t& maxFeasibility, real_t& maxComplementarity ) { real_t maxNWSR = 0.0; real_t avgNWSR = 0.0; real_t avgCPUtime = 0.0; returnValue returnvalue = runOQPbenchmark( path,isSparse,BT_TRUE, options,nWSR, maxNWSR,avgNWSR,maxCPUtime,avgCPUtime, maxStationarity,maxFeasibility,maxComplementarity ); nWSR = (int)maxNWSR; return returnvalue; }
/** Example for qpOASES main function using the OQP interface. */ int main( ) { USING_NAMESPACE_QPOASES /* 1) Define benchmark arguments. */ BooleanType isSparse = BT_FALSE; BooleanType useHotstarts = BT_TRUE; int maxAllowedNWSR = 600; real_t maxNWSR, avgNWSR, maxCPUtime, avgCPUtime; real_t maxStationarity, maxFeasibility, maxComplementarity; static Options options; Options_setToMPC( &options ); options.printLevel = PL_LOW; /* 2) Run benchmark. */ if ( runOQPbenchmark( "./chain80w/", isSparse,useHotstarts, &options,maxAllowedNWSR, &maxNWSR,&avgNWSR,&maxCPUtime,&avgCPUtime, &maxStationarity,&maxFeasibility,&maxComplementarity ) != SUCCESSFUL_RETURN ) { qpOASES_myPrintf( "In order to run this example, you need to download example no. 02\nfrom the Online QP Benchmark Collection website first!\n" ); fprintf( stderr,"error\n" ); return -1; } /* 3) Print results. */ fprintf( stderr,"\n\n" ); fprintf( stderr,"OQP Benchmark Results:\n" ); fprintf( stderr,"======================\n\n" ); fprintf( stderr,"maximum stationary error: %.3e\n",maxStationarity ); fprintf( stderr,"maximum feasibility error: %.3e\n",maxFeasibility ); fprintf( stderr,"maximum complementary error: %.3e\n",maxComplementarity ); fprintf( stderr,"\n" ); fprintf( stderr,"maximum CPU time: %.3f milliseconds\n\n",1000.0*maxCPUtime ); return 0; }
/** Example for qpOASES main function using the OQP interface. */ int main( ) { USING_NAMESPACE_QPOASES /* 1) Define benchmark arguments. */ BooleanType isSparse = BT_FALSE; Options options; options.setToMPC(); // options.setToReliable(); int nWSR = 600; real_t maxCPUtime = 10.0; /* seconds */ real_t maxPrimalDeviation, maxDualDeviation, maxObjDeviation; /* 2) Run benchmark. */ if ( runOQPbenchmark( "./chain80w/", isSparse, options, nWSR, maxCPUtime, maxPrimalDeviation, maxDualDeviation, maxObjDeviation ) != SUCCESSFUL_RETURN ) { myPrintf( "In order to run this example, you need to download example no. 02\nfrom the Online QP Benchmark Collection website first!\n" ); return -1; } /* 3) Print results. */ printf( "\n\n" ); printf( "OQP Benchmark Results:\n" ); printf( "======================\n\n" ); printf( "maximum primal deviation: %.3e\n",maxPrimalDeviation ); printf( "maximum dual deviation: %.3e\n",maxDualDeviation ); printf( "maximum objective deviation: %.3e\n",maxObjDeviation ); printf( "\n" ); printf( "maximum CPU time: %.3f milliseconds\n\n",1000.0*maxCPUtime ); return 0; }
/** Try to solve a list of or all OQP examples in testing/problems */ int main(int argc, char *argv[]) { const real_t TOL = 1e-5; /* 1) Define benchmark arguments. */ BooleanType isSparse = BT_FALSE; BooleanType useHotstarts = BT_FALSE; static Options options; int maxAllowedNWSR; real_t maxNWSR, avgNWSR, maxCPUtime, avgCPUtime; real_t maxStationarity, maxFeasibility, maxComplementarity; int scannedDir = 0; int nfail = 0, npass = 0; int nproblems, i; struct dirent **namelist; char resstr[200], OQPproblem[200]; char *problem; returnValue returnvalue; Options_setToDefault( &options ); /*options.enableFlippingBounds = BT_FALSE;*/ /*Options_setToReliable( &options );*/ Options_setToMPC( &options ); /*options.printLevel = PL_DEBUG_ITER;*/ options.printLevel = PL_LOW; /*options.enableRamping = BT_FALSE;*/ /*options.enableFarBounds = BT_FALSE;*/ if (argc == 1) { /* 2a) Scan problem directory */ nproblems = scandir("../testing/c/data/problems", &namelist, NULL, alphasort); if (nproblems <= 0) { qpOASES_myPrintf( "No test problems found!\n" ); return -1; } scannedDir = 1; } else { /* 2b) Use problem list given by arguments */ nproblems = argc - 1; scannedDir = 0; } /* 3) Run benchmark. */ printf("%10s %9s %9s %9s %6s %-12s\n", "problem", "stat", "feas", "compl", "nWSR", "result"); for (i = 0; i < nproblems; i++) { if (scannedDir) { /* skip special directories and zip file cuter.*bz2 */ if (namelist[i]->d_name[0] == '.' || namelist[i]->d_name[0] == 'c') { free(namelist[i]); continue; } problem = namelist[i]->d_name; } else { problem = argv[i+1]; } fprintf(stdout, "%-10s ", problem); fflush(stdout); snprintf(OQPproblem, 199, "../testing/c/data/problems/%s/", problem); maxCPUtime = 300.0; maxAllowedNWSR = 3500; returnvalue = runOQPbenchmark( OQPproblem, isSparse,useHotstarts, &options,maxAllowedNWSR, &maxNWSR,&avgNWSR,&maxCPUtime,&avgCPUtime, &maxStationarity,&maxFeasibility,&maxComplementarity ); if (returnvalue == SUCCESSFUL_RETURN && maxStationarity < TOL && maxFeasibility < TOL && maxComplementarity < TOL) { npass++; strncpy(resstr, "pass", 199); } else { nfail++; snprintf (resstr, 199, "fail (%d)", returnvalue); } fprintf(stdout, "%9.2e %9.2e %9.2e %6d %-12s\n", maxStationarity, maxFeasibility, maxComplementarity, (int)maxNWSR, resstr); if (scannedDir) free(namelist[i]); } if (scannedDir) free(namelist); /* 4) Print results. */ printf("\n\n" ); printf("Testbench results:\n" ); printf("======================\n\n" ); printf("Pass: %3d\n", npass); printf("Fail: %3d\n", nfail); printf("Ratio: %5.1f%%\n", 100.0 * (real_t)npass / (real_t)(npass+nfail)); printf("\n" ); return 0; }
/** Run benchmark examples. */ int main( int argc, char *argv[] ) { USING_NAMESPACE_QPOASES #ifdef __USE_SINGLE_PRECISION__ const real_t TOL = 5e-2; #else const real_t TOL = 1e-5; #endif /* 1) Define benchmark arguments. */ BooleanType isSparse = BT_FALSE; //BooleanType isSparse = BT_TRUE; Options options; options.setToDefault(); //options.setToMPC(); //options.setToReliable(); options.printLevel = PL_LOW; //options.printLevel = PL_MEDIUM; //options.printLevel = PL_TABULAR; //options.enableFarBounds = BT_FALSE; // options.initialStatusBounds = ST_LOWER; //options.numRegularisationSteps = 1; //options.epsRegularisation = 1.0e3 * EPS; //options.enableFlippingBounds = BT_FALSE; //options.enableFlippingBounds = BT_FALSE; //options.enableRamping = BT_TRUE; //options.enableFarBounds = BT_FALSE; //options.enableNZCTests = BT_FALSE; //options.epsNZCTests = 1.0e4 * EPS; //options.epsFlipping = 1.0e5 * EPS; //options.enableFullLITests = BT_TRUE; //options.enableDriftCorrection = 1; //options.enableEqualities = BT_TRUE; //options.enableEqualities = BT_FALSE; //options.epsNum = -1.0e3 * EPS; //options.epsDen = 1.0e3 * EPS; int nWSR; real_t maxCPUtime; /* seconds */ real_t maxStationarity = 0.0, maxFeasibility = 0.0, maxComplementarity = 0.0; real_t avgStationarity = 0.0, avgFeasibility = 0.0, avgComplementarity = 0.0; int scannedDir = 0; int nfail = 0, npass = 0; int nproblems, i; struct dirent **namelist; char resstr[MAX_STRING_LENGTH], OQPproblem[MAX_STRING_LENGTH]; char *problem; returnValue returnvalue; int expectedNumSolvedProblems = 44; real_t expectedAvgStationarity = TOL; real_t expectedAvgavgFeasibility = TOL; real_t expectedAvgFeasibility = TOL; if ( argv[argc-1][0] == 'O' ) { if ( strlen(argv[argc-1]) != 3 ) { fprintf( stdout,"ERROR (testbench): Invalid options passed!\n" ); return TEST_DATA_NOT_FOUND; } fprintf( stdout,"Analysing passed options: " ); switch ( argv[argc-1][1] ) { case 'd': fprintf( stdout,"default options, " ); options.setToDefault(); if ( argv[argc-1][2] == 's' ) { expectedNumSolvedProblems = 44; expectedAvgStationarity = 1e-10; expectedAvgavgFeasibility = 1e-10; expectedAvgFeasibility = 5e-7; } else { expectedNumSolvedProblems = 44; expectedAvgStationarity = 5e-10; expectedAvgavgFeasibility = 5e-10; expectedAvgFeasibility = 5e-8; } break; case 'r': fprintf( stdout,"reliable options, " ); options.setToReliable(); if ( argv[argc-1][2] == 's' ) { expectedNumSolvedProblems = 44; expectedAvgStationarity = 1e-9; expectedAvgavgFeasibility = 2e-11; expectedAvgFeasibility = 2e-9; } else { expectedNumSolvedProblems = 44; expectedAvgStationarity = 2e-9; expectedAvgavgFeasibility = 1e-9; expectedAvgFeasibility = 2e-7; } break; case 'm': fprintf( stdout,"MPC options, " ); options.setToMPC(); if ( argv[argc-1][2] == 's' ) { expectedNumSolvedProblems = 42; expectedAvgStationarity = 1e-8; expectedAvgavgFeasibility = 1e-8; expectedAvgFeasibility = 1e-7; } else { expectedNumSolvedProblems = 42; expectedAvgStationarity = 2e-8; expectedAvgavgFeasibility = 1e-8; expectedAvgFeasibility = 5e-8; } break; default: fprintf( stdout,"ERROR (testbench): Invalid options passed!\n" ); return TEST_DATA_NOT_FOUND; } switch ( argv[argc-1][2] ) { case 's': fprintf( stdout,"sparse QP data\n" ); isSparse = BT_TRUE; break; case 'd': fprintf( stdout,"dense QP data\n" ); isSparse = BT_FALSE; break; default: fprintf( stdout,"ERROR (testbench): Invalid options passed!\n" ); return TEST_DATA_NOT_FOUND; } options.printLevel = PL_NONE; nproblems = argc-2; } else { nproblems = argc-1; } if (nproblems == 0) { /* 2a) Scan problem directory */ nproblems = scandir("./cpp/data/problems", &namelist, NULL, alphasort); if (nproblems <= 0) { myPrintf( "No test problems found!\n" ); return TEST_DATA_NOT_FOUND; } scannedDir = 1; } else { /* 2b) Use problem list given by arguments */ scannedDir = 0; } /* 3) Run benchmark. */ printf("%10s %9s %9s %9s %6s %-12s\n", "problem", "stat", "feas", "compl", "nWSR", "result"); for (i = 0; i < nproblems; i++) { if (scannedDir) { /* skip special directories and zip file cuter.*bz2 */ if (namelist[i]->d_name[0] == '.' || namelist[i]->d_name[0] == 'c') { free(namelist[i]); continue; } problem = namelist[i]->d_name; } else { problem = argv[i+1]; } fprintf(stdFile, "%-10s ", problem); fflush(stdFile); snprintf(OQPproblem, MAX_STRING_LENGTH, "./cpp/data/problems/%s/", problem); maxCPUtime = 300.0; nWSR = 2500; returnvalue = runOQPbenchmark( OQPproblem, isSparse, options, nWSR, maxCPUtime, maxStationarity, maxFeasibility, maxComplementarity ); if (returnvalue == SUCCESSFUL_RETURN && maxStationarity < TOL && maxFeasibility < TOL && maxComplementarity < TOL) { npass++; avgStationarity += maxStationarity; avgFeasibility += maxFeasibility; avgComplementarity += maxComplementarity; strncpy(resstr, "pass", MAX_STRING_LENGTH); } else { if ( returnvalue == RET_BENCHMARK_ABORTED ) return TEST_DATA_NOT_FOUND; nfail++; snprintf (resstr, MAX_STRING_LENGTH, "fail (%d)", returnvalue); } fprintf(stdFile, "%9.2e %9.2e %9.2e %6d %-12s\n", maxStationarity, maxFeasibility, maxComplementarity, nWSR, resstr); if (scannedDir) free(namelist[i]); } if (scannedDir) free(namelist); avgStationarity /= npass; avgFeasibility /= npass; avgComplementarity /= npass; /* 4) Print results. */ printf("\n\n" ); printf("Testbench results:\n" ); printf("======================\n\n" ); printf("Pass: %3d\n", npass); printf("Fail: %3d\n", nfail); printf("Ratio: %5.1f%%\n", 100.0 * (real_t)npass / (real_t)(npass+nfail)); printf("\n" ); QPOASES_TEST_FOR_TRUE( npass >= expectedNumSolvedProblems ); printf("avg. stat: %e\n", avgStationarity); printf("avg. feas: %e\n", avgFeasibility); printf("avg. cmpl: %e\n", avgFeasibility); QPOASES_TEST_FOR_TRUE( avgStationarity <= expectedAvgStationarity ); QPOASES_TEST_FOR_TRUE( avgFeasibility <= expectedAvgavgFeasibility ); QPOASES_TEST_FOR_TRUE( avgComplementarity <= expectedAvgFeasibility ); return 0; }