39 #include <qpOASES.hpp> 44 int main(
int argc,
char *argv[] )
47 #ifdef __USE_SINGLE_PRECISION__ 86 real_t maxStationarity = 0.0, maxFeasibility = 0.0, maxComplementarity = 0.0;
87 real_t avgStationarity = 0.0, avgFeasibility = 0.0, avgComplementarity = 0.0;
90 int_t nfail = 0, npass = 0;
92 struct dirent **namelist;
97 int_t expectedNumSolvedProblems = 44;
98 real_t expectedAvgStationarity = TOL;
99 real_t expectedAvgFeasibility = TOL;
100 real_t expectedAvgComplementarity = TOL;
103 if ( argv[argc-1][0] ==
'O' )
105 if ( strlen(argv[argc-1]) != 3 )
107 fprintf( stdout,
"ERROR (testbench): Invalid options passed!\n" );
111 fprintf( stdout,
"Analysing passed options: " );
112 switch ( argv[argc-1][1] )
115 fprintf( stdout,
"default options, " );
117 if ( argv[argc-1][2] ==
's' )
119 expectedNumSolvedProblems = 44;
120 expectedAvgStationarity = 1e-9;
121 expectedAvgFeasibility = 1e-9;
122 expectedAvgComplementarity = 5e-7;
126 expectedNumSolvedProblems = 44;
127 expectedAvgStationarity = 5e-10;
128 expectedAvgFeasibility = 5e-10;
129 expectedAvgComplementarity = 5e-8;
134 fprintf( stdout,
"reliable options, " );
136 if ( argv[argc-1][2] ==
's' )
138 expectedNumSolvedProblems = 44;
139 expectedAvgStationarity = 2e-9;
140 expectedAvgFeasibility = 2e-11;
141 expectedAvgComplementarity = 3e-9;
145 expectedNumSolvedProblems = 44;
146 expectedAvgStationarity = 2e-9;
147 expectedAvgFeasibility = 2e-9;
148 expectedAvgComplementarity = 3e-7;
153 fprintf( stdout,
"MPC options, " );
155 if ( argv[argc-1][2] ==
's' )
157 expectedNumSolvedProblems = 42;
158 expectedAvgStationarity = 2e-8;
159 expectedAvgFeasibility = 1e-8;
160 expectedAvgComplementarity = 2e-7;
164 expectedNumSolvedProblems = 42;
165 expectedAvgStationarity = 3e-8;
166 expectedAvgFeasibility = 1e-8;
167 expectedAvgComplementarity = 5e-8;
172 fprintf( stdout,
"ERROR (testbench): Invalid options passed!\n" );
176 switch ( argv[argc-1][2] )
179 fprintf( stdout,
"sparse QP data\n" );
184 fprintf( stdout,
"dense QP data\n" );
189 fprintf( stdout,
"ERROR (testbench): Invalid options passed!\n" );
206 nproblems = scandir(
"../testing/cpp/data/problems", &namelist, NULL, alphasort);
209 myPrintf(
"No test problems found!\n" );
221 printf(
"%10s %9s %9s %9s %6s %-12s\n",
"problem",
"stat",
222 "feas",
"compl",
"nWSR",
"result");
223 for (i = 0; i < nproblems; i++)
228 if (namelist[i]->d_name[0] ==
'.' || namelist[i]->d_name[0] ==
'c')
233 problem = namelist[i]->d_name;
240 fprintf(
stdFile,
"%-10s ", problem);
243 snprintf(oqpProblem,
MAX_STRING_LENGTH,
"../testing/cpp/data/problems/%s/", problem);
248 nWSR, maxCPUtime, maxStationarity, maxFeasibility, maxComplementarity
251 && maxStationarity < TOL
252 && maxFeasibility < TOL
253 && maxComplementarity < TOL)
257 avgStationarity += maxStationarity;
258 avgFeasibility += maxFeasibility;
259 avgComplementarity += maxComplementarity;
271 fprintf(
stdFile,
"%9.2e %9.2e %9.2e %6d %-12s\n", maxStationarity,
272 maxFeasibility, maxComplementarity, (
int)nWSR, resstr);
274 if (scannedDir) free(namelist[i]);
276 if (scannedDir) free(namelist);
278 avgStationarity /= npass;
279 avgFeasibility /= npass;
280 avgComplementarity /= npass;
285 printf(
"Testbench results:\n" );
286 printf(
"======================\n\n" );
287 printf(
"Pass: %3d\n",(
int)npass );
288 printf(
"Fail: %3d\n",(
int)nfail );
289 printf(
"Ratio: %5.1f%%\n", 100.0 * (
real_t)npass / (
real_t)(npass+nfail) );
295 printf(
"avg. stat: %e\n", avgStationarity );
296 printf(
"avg. feas: %e\n", avgFeasibility );
297 printf(
"avg. cmpl: %e\n", avgComplementarity );
#define USING_NAMESPACE_QPOASES
#define TEST_DATA_NOT_FOUND
returnValue setToDefault()
Allows to pass back messages to the calling function.
returnValue myPrintf(const char *s)
Provides a generic way to set and pass user-specified options.
#define QPOASES_TEST_FOR_TOL(x, tol)
const uint_t MAX_STRING_LENGTH
returnValue setToReliable()
#define QPOASES_TEST_FOR_TRUE(x)
int main(int argc, char *argv[])