qpOASES
3.2.1
An Implementation of the Online Active Set Strategy
|
00001 /* 00002 * This file is part of qpOASES. 00003 * 00004 * qpOASES -- An Implementation of the Online Active Set Strategy. 00005 * Copyright (C) 2007-2017 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 /* Schur complement computations */ 00221 RET_KKT_MATRIX_SINGULAR, 00222 RET_QR_FACTORISATION_FAILED, 00223 RET_INERTIA_CORRECTION_FAILED, 00224 RET_NO_SPARSE_SOLVER, 00225 /* Simple exitflags */ 00226 RET_SIMPLE_STATUS_P1, 00227 RET_SIMPLE_STATUS_P0, 00228 RET_SIMPLE_STATUS_M1, 00229 RET_SIMPLE_STATUS_M2, 00230 RET_SIMPLE_STATUS_M3 00231 }; 00232 00233 00244 class MessageHandling 00245 { 00246 /* 00247 * INTERNAL DATA STRUCTURES 00248 */ 00249 public: 00257 typedef struct { 00258 returnValue key; 00259 const char* data; 00260 VisibilityStatus globalVisibilityStatus; 00262 } ReturnValueList; 00263 00264 00265 /* 00266 * PUBLIC MEMBER FUNCTIONS 00267 */ 00268 public: 00270 MessageHandling( ); 00271 00273 MessageHandling( FILE* _outputFile 00274 ); 00275 00277 MessageHandling( VisibilityStatus _errorVisibility, 00278 VisibilityStatus _warningVisibility, 00279 VisibilityStatus _infoVisibility 00280 ); 00281 00283 MessageHandling( FILE* _outputFile, 00284 VisibilityStatus _errorVisibility, 00285 VisibilityStatus _warningVisibility, 00286 VisibilityStatus _infoVisibility 00287 ); 00288 00290 MessageHandling( const MessageHandling& rhs 00291 ); 00292 00294 ~MessageHandling( ); 00295 00297 MessageHandling& operator=( const MessageHandling& rhs 00298 ); 00299 00300 00307 returnValue throwError( returnValue Enumber, 00308 const char* additionaltext, 00309 const char* functionname, 00310 const char* filename, 00311 const unsigned long linenumber, 00312 VisibilityStatus localVisibilityStatus 00315 ); 00316 00321 returnValue throwWarning( returnValue Wnumber, 00322 const char* additionaltext, 00323 const char* functionname, 00324 const char* filename, 00325 const unsigned long linenumber, 00326 VisibilityStatus localVisibilityStatus 00329 ); 00330 00334 returnValue throwInfo( returnValue Inumber, 00335 const char* additionaltext, 00336 const char* functionname, 00337 const char* filename, 00338 const unsigned long linenumber, 00339 VisibilityStatus localVisibilityStatus 00342 ); 00343 00344 00347 returnValue reset( ); 00348 00349 00352 returnValue listAllMessages( ); 00353 00354 00357 inline VisibilityStatus getErrorVisibilityStatus( ) const; 00358 00361 inline VisibilityStatus getWarningVisibilityStatus( ) const; 00362 00365 inline VisibilityStatus getInfoVisibilityStatus( ) const; 00366 00369 inline FILE* getOutputFile( ) const; 00370 00373 inline int_t getErrorCount( ) const; 00374 00375 00377 inline void setErrorVisibilityStatus( VisibilityStatus _errorVisibility 00378 ); 00379 00381 inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility 00382 ); 00383 00385 inline void setInfoVisibilityStatus( VisibilityStatus _infoVisibility 00386 ); 00387 00389 inline void setOutputFile( FILE* _outputFile 00390 ); 00391 00395 inline returnValue setErrorCount( int_t _errorCount 00396 ); 00397 00400 static const char* getErrorCodeMessage( const returnValue _returnValue 00401 ); 00402 00403 00404 /* 00405 * PROTECTED MEMBER FUNCTIONS 00406 */ 00407 protected: 00411 returnValue throwMessage( 00412 returnValue RETnumber, 00413 const char* additionaltext, 00414 const char* functionname, 00415 const char* filename, 00416 const unsigned long linenumber, 00417 VisibilityStatus localVisibilityStatus, 00420 const char* RETstring 00421 ); 00422 00423 00424 /* 00425 * PROTECTED MEMBER VARIABLES 00426 */ 00427 protected: 00428 VisibilityStatus errorVisibility; 00429 VisibilityStatus warningVisibility; 00430 VisibilityStatus infoVisibility; 00432 FILE* outputFile; 00434 int_t errorCount; 00435 }; 00436 00437 00438 #ifndef __FILE__ 00439 00440 #define __FILE__ 0 00441 #endif 00442 00443 #ifndef __LINE__ 00444 00445 #define __LINE__ 0 00446 #endif 00447 00449 /*#define __FUNC__ 0*/ 00450 #define __FUNC__ ("(no function name provided)") 00451 /*#define __FUNC__ __func__*/ 00452 /*#define __FUNC__ __FUNCTION__*/ 00453 00454 00456 #define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) 00457 00459 #define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) 00460 00462 #define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) ) 00463 00464 00468 MessageHandling* getGlobalMessageHandler( ); 00469 00470 00471 END_NAMESPACE_QPOASES 00472 00473 #include <qpOASES/MessageHandling.ipp> 00474 00475 #endif /* QPOASES_MESSAGEHANDLING_HPP */ 00476 00477 00478 /* 00479 * end of file 00480 */