test_runAllOqpExamples.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
38 #include <qpOASES.hpp>
39 #include <qpOASES/UnitTesting.hpp>
40 
41 
43 int main( )
44 {
46 
47  /* 1) Define benchmark arguments. */
48  BooleanType isSparse = BT_FALSE;
49  BooleanType useHotstarts;
50 
52  options.setToMPC();
53  options.printLevel = PL_LOW;
54 
55  int_t maxAllowedNWSR;
56  real_t maxNWSR, avgNWSR, maxCPUtime, avgCPUtime;
57  real_t maxStationarity, maxFeasibility, maxComplementarity;
58 
59  const int_t numBenchmarks = 4; //5
60  const char *benchmarkPath[numBenchmarks];
61  benchmarkPath[0] = "../testing/cpp/data/oqp/chain80/";
62  benchmarkPath[1] = "../testing/cpp/data/oqp/chain80w/";
63  benchmarkPath[2] = "../testing/cpp/data/oqp/diesel/";
64  benchmarkPath[3] = "../testing/cpp/data/oqp/crane/";
65  //benchmarkPath[4] = "../testing/cpp/data/oqp/CDU/";
66 
67 
68  /* 2) Run all benchmarks in a loop */
69  for ( int_t ii=0; ii<2*numBenchmarks; ++ii )
70  {
71  if ( ii%2 == 0 )
72  useHotstarts = BT_FALSE;
73  else
74  useHotstarts = BT_TRUE;
75 
76  maxAllowedNWSR = 1000;
77  maxNWSR = 0.0;
78  avgNWSR = 0.0;
79  maxCPUtime = 1000.0; /* seconds */
80  avgCPUtime = 0.0; /* seconds */
81  maxStationarity = 0.0;
82  maxFeasibility = 0.0;
83  maxComplementarity = 0.0;
84 
85  if ( runOqpBenchmark( benchmarkPath[ii/2],
86  isSparse,useHotstarts,
87  options,maxAllowedNWSR,
88  maxNWSR,avgNWSR,maxCPUtime,avgCPUtime,
89  maxStationarity,maxFeasibility,maxComplementarity
90  ) != SUCCESSFUL_RETURN )
91  {
92  myPrintf( "Something went wrong when running benchmark!\n" );
93  return TEST_DATA_NOT_FOUND;
94  }
95 
96  /* 3) Print results. */
97  printf( "\n\n" );
98  if ( useHotstarts == BT_FALSE )
99  printf( "OQP Benchmark Results for %s (cold-starts):\n", benchmarkPath[ii/2] );
100  else
101  printf( "OQP Benchmark Results for %s (hot-starts):\n", benchmarkPath[ii/2] );
102 
103  printf( "===========================================================================\n\n" );
104  printf( "maximum CPU time: %.2f milliseconds\n",1000.0*maxCPUtime );
105  printf( "average CPU time: %.2f milliseconds\n",1000.0*avgCPUtime );
106  printf( "\n" );
107  printf( "maximum iterations: %.1f\n",maxNWSR );
108  printf( "average iterations: %.1f\n",avgNWSR );
109  printf( "\n" );
110  printf( "maximum violation stationarity: %.3e\n",maxStationarity );
111  printf( "maximum violation feasibility: %.3e\n",maxFeasibility );
112  printf( "maximum violation complementarity: %.3e\n",maxComplementarity );
113  printf( "\n" );
114 
115  QPOASES_TEST_FOR_TOL( maxStationarity, 1e-9 );
116  QPOASES_TEST_FOR_TOL( maxFeasibility, 1e-11 );
117  QPOASES_TEST_FOR_TOL( maxComplementarity, 1e-10 );
118 
119  switch( ii )
120  {
121  case 0:
122  /* chain80 (cold) */
123  QPOASES_TEST_FOR_TRUE( maxNWSR <= 62.5 );
124  QPOASES_TEST_FOR_TRUE( avgNWSR <= 7.5 );
125  break;
126 
127  case 1:
128  /* chain80 (hot) */
129  QPOASES_TEST_FOR_TRUE( maxNWSR <= 19.5 );
130  QPOASES_TEST_FOR_TRUE( avgNWSR <= 2.4 );
131  break;
132 
133  case 2:
134  /* chain80w (cold) */
135  QPOASES_TEST_FOR_TRUE( maxNWSR <= 84.5 );
136  QPOASES_TEST_FOR_TRUE( avgNWSR <= 10.1 );
137  break;
138 
139  case 3:
140  /* chain80w (hot) */
141  QPOASES_TEST_FOR_TRUE( maxNWSR <= 16.5 );
142  QPOASES_TEST_FOR_TRUE( avgNWSR <= 2.7 );
143  break;
144 
145  case 4:
146  /* diesel (cold) */
147  QPOASES_TEST_FOR_TRUE( maxNWSR <= 26.5 );
148  QPOASES_TEST_FOR_TRUE( avgNWSR <= 0.5 );
149  break;
150 
151  case 5:
152  /* diesel (hot) */
153  QPOASES_TEST_FOR_TRUE( maxNWSR <= 22.5 );
154  QPOASES_TEST_FOR_TRUE( avgNWSR <= 0.3 );
155  break;
156 
157  case 6:
158  /* crane (cold) */
159  QPOASES_TEST_FOR_TRUE( maxNWSR <= 64.5 );
160  QPOASES_TEST_FOR_TRUE( avgNWSR <= 44.0 );
161  break;
162 
163  case 7:
164  /* crane (hot) */
165  QPOASES_TEST_FOR_TRUE( maxNWSR <= 42.5 );
166  QPOASES_TEST_FOR_TRUE( avgNWSR <= 0.4 );
167  break;
168  }
169  }
170 
171  return TEST_PASSED;
172 }
173 
174 
175 /*
176  * end of file
177  */
#define TEST_DATA_NOT_FOUND
Definition: UnitTesting.hpp:51
int main()
returnValue myPrintf(const char *s)
Provides a generic way to set and pass user-specified options.
Definition: options.hpp:65
#define QPOASES_TEST_FOR_TOL(x, tol)
Definition: UnitTesting.hpp:61
#define PL_LOW
#define TEST_PASSED
Definition: UnitTesting.hpp:45
returnValue runOqpBenchmark(const char *path, BooleanType isSparse, const Options &options, int_t &nWSR, real_t &maxCPUtime, real_t &maxStationarity, real_t &maxFeasibility, real_t &maxComplementarity)
#define BT_TRUE
Definition: acado_types.hpp:47
returnValue setToMPC()
#define BT_FALSE
Definition: acado_types.hpp:49
double real_t
Definition: AD_test.c:10
#define QPOASES_TEST_FOR_TRUE(x)
Definition: UnitTesting.hpp:64


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:12