qpOASES
3.1.1
|
00001 /* 00002 * This file is part of qpOASES. 00003 * 00004 * qpOASES -- An Implementation of the Online Active Set Strategy. 00005 * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka, 00006 * Christian Kirches et al. All rights reserved. 00007 * 00008 * qpOASES is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * qpOASES is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with qpOASES; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 */ 00023 00024 00035 #ifndef QPOASES_MESSAGEHANDLING_HPP 00036 #define QPOASES_MESSAGEHANDLING_HPP 00037 00038 00039 #include <stdio.h> 00040 #include <string.h> 00041 00042 #ifdef __DEBUG__ 00043 #include <assert.h> 00044 #endif 00045 00046 #include <qpOASES/Constants.hpp> 00047 00048 00049 BEGIN_NAMESPACE_QPOASES 00050 00051 00053 extern FILE* stdFile; 00054 00055 00064 enum returnValue 00065 { 00066 TERMINAL_LIST_ELEMENT = -1, 00067 /* miscellaneous */ 00068 SUCCESSFUL_RETURN = 0, 00069 RET_DIV_BY_ZERO, 00070 RET_INDEX_OUT_OF_BOUNDS, 00071 RET_INVALID_ARGUMENTS, 00072 RET_ERROR_UNDEFINED, 00073 RET_WARNING_UNDEFINED, 00074 RET_INFO_UNDEFINED, 00075 RET_EWI_UNDEFINED, 00076 RET_AVAILABLE_WITH_LINUX_ONLY, 00077 RET_UNKNOWN_BUG, 00078 RET_PRINTLEVEL_CHANGED, 00079 RET_NOT_YET_IMPLEMENTED, 00080 /* Indexlist */ 00081 RET_INDEXLIST_MUST_BE_REORDERD, 00082 RET_INDEXLIST_EXCEEDS_MAX_LENGTH, 00083 RET_INDEXLIST_CORRUPTED, 00084 RET_INDEXLIST_OUTOFBOUNDS, 00085 RET_INDEXLIST_ADD_FAILED, 00086 RET_INDEXLIST_INTERSECT_FAILED, 00087 /* SubjectTo / Bounds / Constraints */ 00088 RET_INDEX_ALREADY_OF_DESIRED_STATUS, 00089 RET_ADDINDEX_FAILED, 00090 RET_REMOVEINDEX_FAILED, 00091 RET_SWAPINDEX_FAILED, 00092 RET_NOTHING_TO_DO, 00093 RET_SETUP_BOUND_FAILED, 00094 RET_SETUP_CONSTRAINT_FAILED, 00095 RET_MOVING_BOUND_FAILED, 00096 RET_MOVING_CONSTRAINT_FAILED, 00097 RET_SHIFTING_FAILED, 00098 RET_ROTATING_FAILED, 00099 /* QProblem */ 00100 RET_QPOBJECT_NOT_SETUP, 00101 RET_QP_ALREADY_INITIALISED, 00102 RET_NO_INIT_WITH_STANDARD_SOLVER, 00103 RET_RESET_FAILED, 00104 RET_INIT_FAILED, 00105 RET_INIT_FAILED_TQ, 00106 RET_INIT_FAILED_CHOLESKY, 00107 RET_INIT_FAILED_HOTSTART, 00108 RET_INIT_FAILED_INFEASIBILITY, 00109 RET_INIT_FAILED_UNBOUNDEDNESS, 00110 RET_INIT_FAILED_REGULARISATION, 00111 RET_INIT_SUCCESSFUL, 00112 RET_OBTAINING_WORKINGSET_FAILED, 00113 RET_SETUP_WORKINGSET_FAILED, 00114 RET_SETUP_AUXILIARYQP_FAILED, 00115 RET_NO_CHOLESKY_WITH_INITIAL_GUESS, 00116 RET_NO_EXTERN_SOLVER, 00117 RET_QP_UNBOUNDED, 00118 RET_QP_INFEASIBLE, 00119 RET_QP_NOT_SOLVED, 00120 RET_QP_SOLVED, 00121 RET_UNABLE_TO_SOLVE_QP, 00122 RET_INITIALISATION_STARTED, 00123 RET_HOTSTART_FAILED, 00124 RET_HOTSTART_FAILED_TO_INIT, 00125 RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, 00126 RET_ITERATION_STARTED, 00127 RET_SHIFT_DETERMINATION_FAILED, 00128 RET_STEPDIRECTION_DETERMINATION_FAILED, 00129 RET_STEPLENGTH_DETERMINATION_FAILED, 00130 RET_OPTIMAL_SOLUTION_FOUND, 00131 RET_HOMOTOPY_STEP_FAILED, 00132 RET_HOTSTART_STOPPED_INFEASIBILITY, 00133 RET_HOTSTART_STOPPED_UNBOUNDEDNESS, 00134 RET_WORKINGSET_UPDATE_FAILED, 00135 RET_MAX_NWSR_REACHED, 00136 RET_CONSTRAINTS_NOT_SPECIFIED, 00137 RET_INVALID_FACTORISATION_FLAG, 00138 RET_UNABLE_TO_SAVE_QPDATA, 00139 RET_STEPDIRECTION_FAILED_TQ, 00140 RET_STEPDIRECTION_FAILED_CHOLESKY, 00141 RET_CYCLING_DETECTED, 00142 RET_CYCLING_NOT_RESOLVED, 00143 RET_CYCLING_RESOLVED, 00144 RET_STEPSIZE, 00145 RET_STEPSIZE_NONPOSITIVE, 00146 RET_SETUPSUBJECTTOTYPE_FAILED, 00147 RET_ADDCONSTRAINT_FAILED, 00148 RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, 00149 RET_ADDBOUND_FAILED, 00150 RET_ADDBOUND_FAILED_INFEASIBILITY, 00151 RET_REMOVECONSTRAINT_FAILED, 00152 RET_REMOVEBOUND_FAILED, 00153 RET_REMOVE_FROM_ACTIVESET, 00154 RET_ADD_TO_ACTIVESET, 00155 RET_REMOVE_FROM_ACTIVESET_FAILED, 00156 RET_ADD_TO_ACTIVESET_FAILED, 00157 RET_CONSTRAINT_ALREADY_ACTIVE, 00158 RET_ALL_CONSTRAINTS_ACTIVE, 00159 RET_LINEARLY_DEPENDENT, 00160 RET_LINEARLY_INDEPENDENT, 00161 RET_LI_RESOLVED, 00162 RET_ENSURELI_FAILED, 00163 RET_ENSURELI_FAILED_TQ, 00164 RET_ENSURELI_FAILED_NOINDEX, 00165 RET_ENSURELI_FAILED_CYCLING, 00166 RET_BOUND_ALREADY_ACTIVE, 00167 RET_ALL_BOUNDS_ACTIVE, 00168 RET_CONSTRAINT_NOT_ACTIVE, 00169 RET_BOUND_NOT_ACTIVE, 00170 RET_HESSIAN_NOT_SPD, 00171 RET_HESSIAN_INDEFINITE, 00172 RET_MATRIX_SHIFT_FAILED, 00173 RET_MATRIX_FACTORISATION_FAILED, 00174 RET_PRINT_ITERATION_FAILED, 00175 RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, 00176 RET_DISABLECONSTRAINTS_FAILED, 00177 RET_ENABLECONSTRAINTS_FAILED, 00178 RET_ALREADY_ENABLED, 00179 RET_ALREADY_DISABLED, 00180 RET_NO_HESSIAN_SPECIFIED, 00181 RET_USING_REGULARISATION, 00182 RET_EPS_MUST_BE_POSITVE, 00183 RET_REGSTEPS_MUST_BE_POSITVE, 00184 RET_HESSIAN_ALREADY_REGULARISED, 00185 RET_CANNOT_REGULARISE_IDENTITY, 00186 RET_CANNOT_REGULARISE_SPARSE, 00187 RET_NO_REGSTEP_NWSR, 00188 RET_FEWER_REGSTEPS_NWSR, 00189 RET_CHOLESKY_OF_ZERO_HESSIAN, 00190 RET_ZERO_HESSIAN_ASSUMED, 00191 RET_CONSTRAINTS_ARE_NOT_SCALED, 00192 RET_INITIAL_BOUNDS_STATUS_NYI, 00193 RET_ERROR_IN_CONSTRAINTPRODUCT, 00194 RET_FIX_BOUNDS_FOR_LP, 00195 RET_USE_REGULARISATION_FOR_LP, 00196 /* SQProblem */ 00197 RET_UPDATEMATRICES_FAILED, 00198 RET_UPDATEMATRICES_FAILED_AS_QP_NOT_SOLVED, 00199 /* Utils */ 00200 RET_UNABLE_TO_OPEN_FILE, 00201 RET_UNABLE_TO_WRITE_FILE, 00202 RET_UNABLE_TO_READ_FILE, 00203 RET_FILEDATA_INCONSISTENT, 00204 /* Options */ 00205 RET_OPTIONS_ADJUSTED, 00206 /* SolutionAnalysis */ 00207 RET_UNABLE_TO_ANALYSE_QPROBLEM, 00208 /* Benchmark */ 00209 RET_NWSR_SET_TO_ONE, 00210 RET_UNABLE_TO_READ_BENCHMARK, 00211 RET_BENCHMARK_ABORTED, 00212 RET_INITIAL_QP_SOLVED, 00213 RET_QP_SOLUTION_STARTED, 00214 RET_BENCHMARK_SUCCESSFUL, 00215 /* Sparse matrices */ 00216 RET_NO_DIAGONAL_AVAILABLE, 00217 RET_DIAGONAL_NOT_INITIALISED, 00218 /* Dropping of infeasible constraints */ 00219 RET_ENSURELI_DROPPED, 00220 /* Simple exitflags */ 00221 RET_SIMPLE_STATUS_P1, 00222 RET_SIMPLE_STATUS_P0, 00223 RET_SIMPLE_STATUS_M1, 00224 RET_SIMPLE_STATUS_M2, 00225 RET_SIMPLE_STATUS_M3 00226 }; 00227 00228 00239 class MessageHandling 00240 { 00241 /* 00242 * INTERNAL DATA STRUCTURES 00243 */ 00244 public: 00252 typedef struct { 00253 returnValue key; 00254 const char* data; 00255 VisibilityStatus globalVisibilityStatus; 00257 } ReturnValueList; 00258 00259 00260 /* 00261 * PUBLIC MEMBER FUNCTIONS 00262 */ 00263 public: 00265 MessageHandling( ); 00266 00268 MessageHandling( FILE* _outputFile 00269 ); 00270 00272 MessageHandling( VisibilityStatus _errorVisibility, 00273 VisibilityStatus _warningVisibility, 00274 VisibilityStatus _infoVisibility 00275 ); 00276 00278 MessageHandling( FILE* _outputFile, 00279 VisibilityStatus _errorVisibility, 00280 VisibilityStatus _warningVisibility, 00281 VisibilityStatus _infoVisibility 00282 ); 00283 00285 MessageHandling( const MessageHandling& rhs 00286 ); 00287 00289 ~MessageHandling( ); 00290 00292 MessageHandling& operator=( const MessageHandling& rhs 00293 ); 00294 00295 00302 returnValue throwError( returnValue Enumber, 00303 const char* additionaltext, 00304 const char* functionname, 00305 const char* filename, 00306 const unsigned long linenumber, 00307 VisibilityStatus localVisibilityStatus 00310 ); 00311 00316 returnValue throwWarning( returnValue Wnumber, 00317 const char* additionaltext, 00318 const char* functionname, 00319 const char* filename, 00320 const unsigned long linenumber, 00321 VisibilityStatus localVisibilityStatus 00324 ); 00325 00329 returnValue throwInfo( returnValue Inumber, 00330 const char* additionaltext, 00331 const char* functionname, 00332 const char* filename, 00333 const unsigned long linenumber, 00334 VisibilityStatus localVisibilityStatus 00337 ); 00338 00339 00342 returnValue reset( ); 00343 00344 00347 returnValue listAllMessages( ); 00348 00349 00352 inline VisibilityStatus getErrorVisibilityStatus( ) const; 00353 00356 inline VisibilityStatus getWarningVisibilityStatus( ) const; 00357 00360 inline VisibilityStatus getInfoVisibilityStatus( ) const; 00361 00364 inline FILE* getOutputFile( ) const; 00365 00368 inline int getErrorCount( ) const; 00369 00370 00372 inline void setErrorVisibilityStatus( VisibilityStatus _errorVisibility 00373 ); 00374 00376 inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility 00377 ); 00378 00380 inline void setInfoVisibilityStatus( VisibilityStatus _infoVisibility 00381 ); 00382 00384 inline void setOutputFile( FILE* _outputFile 00385 ); 00386 00390 inline returnValue setErrorCount( int _errorCount 00391 ); 00392 00395 static const char* getErrorCodeMessage( const returnValue _returnValue 00396 ); 00397 00398 00399 /* 00400 * PROTECTED MEMBER FUNCTIONS 00401 */ 00402 protected: 00406 returnValue throwMessage( 00407 returnValue RETnumber, 00408 const char* additionaltext, 00409 const char* functionname, 00410 const char* filename, 00411 const unsigned long linenumber, 00412 VisibilityStatus localVisibilityStatus, 00415 const char* RETstring 00416 ); 00417 00418 00419 /* 00420 * PROTECTED MEMBER VARIABLES 00421 */ 00422 protected: 00423 VisibilityStatus errorVisibility; 00424 VisibilityStatus warningVisibility; 00425 VisibilityStatus infoVisibility; 00427 FILE* outputFile; 00429 int errorCount; 00430 }; 00431 00432 00433 #ifndef __FILE__ 00434 00435 #define __FILE__ 0 00436 #endif 00437 00438 #ifndef __LINE__ 00439 00440 #define __LINE__ 0 00441 #endif 00442 00444 /*#define __FUNC__ 0*/ 00445 #define __FUNC__ ("(no function name provided)") 00446 /*#define __FUNC__ __func__*/ 00447 /*#define __FUNC__ __FUNCTION__*/ 00448 00449 00451 #define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) 00452 00454 #define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) 00455 00457 #define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) 00458 00459 00463 MessageHandling* getGlobalMessageHandler( ); 00464 00465 00466 END_NAMESPACE_QPOASES 00467 00468 #include <qpOASES/MessageHandling.ipp> 00469 00470 #endif /* QPOASES_MESSAGEHANDLING_HPP */ 00471 00472 00473 /* 00474 * end of file 00475 */