From 4394f83601eef50653609b1462906262560598be Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 29 Sep 2021 11:07:18 -0700 Subject: [PATCH] remove qpOASES (#22377) --- phonelibs/qpoases/EXAMPLES/example1.cpp | 74 - phonelibs/qpoases/EXAMPLES/example1b.cpp | 69 - phonelibs/qpoases/INCLUDE/Bounds.hpp | 189 - phonelibs/qpoases/INCLUDE/Constants.hpp | 108 - phonelibs/qpoases/INCLUDE/Constraints.hpp | 181 - phonelibs/qpoases/INCLUDE/CyclingManager.hpp | 126 - .../INCLUDE/EXTRAS/SolutionAnalysis.hpp | 107 - phonelibs/qpoases/INCLUDE/Indexlist.hpp | 154 - phonelibs/qpoases/INCLUDE/MessageHandling.hpp | 415 -- phonelibs/qpoases/INCLUDE/QProblem.hpp | 666 --- phonelibs/qpoases/INCLUDE/QProblemB.hpp | 628 --- phonelibs/qpoases/INCLUDE/SubjectTo.hpp | 178 - phonelibs/qpoases/INCLUDE/Types.hpp | 131 - phonelibs/qpoases/INCLUDE/Utils.hpp | 197 - phonelibs/qpoases/LICENSE.txt | 504 --- phonelibs/qpoases/README.txt | 92 - phonelibs/qpoases/SConscript | 16 - phonelibs/qpoases/SRC/Bounds.cpp | 252 -- phonelibs/qpoases/SRC/Bounds.ipp | 144 - phonelibs/qpoases/SRC/Constraints.cpp | 248 -- phonelibs/qpoases/SRC/Constraints.ipp | 144 - phonelibs/qpoases/SRC/CyclingManager.cpp | 188 - phonelibs/qpoases/SRC/CyclingManager.ipp | 51 - .../qpoases/SRC/EXTRAS/SolutionAnalysis.cpp | 434 -- phonelibs/qpoases/SRC/Indexlist.cpp | 342 -- phonelibs/qpoases/SRC/Indexlist.ipp | 85 - phonelibs/qpoases/SRC/MessageHandling.cpp | 529 --- phonelibs/qpoases/SRC/MessageHandling.ipp | 137 - phonelibs/qpoases/SRC/QProblem.cpp | 3867 ----------------- phonelibs/qpoases/SRC/QProblem.ipp | 299 -- phonelibs/qpoases/SRC/QProblemB.cpp | 2151 --------- phonelibs/qpoases/SRC/QProblemB.ipp | 425 -- phonelibs/qpoases/SRC/SubjectTo.cpp | 200 - phonelibs/qpoases/SRC/SubjectTo.ipp | 132 - phonelibs/qpoases/SRC/Utils.cpp | 471 -- phonelibs/qpoases/SRC/Utils.ipp | 51 - phonelibs/qpoases/VERSIONS.txt | 87 - release/files_common | 2 - 38 files changed, 14074 deletions(-) delete mode 100644 phonelibs/qpoases/EXAMPLES/example1.cpp delete mode 100644 phonelibs/qpoases/EXAMPLES/example1b.cpp delete mode 100644 phonelibs/qpoases/INCLUDE/Bounds.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/Constants.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/Constraints.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/CyclingManager.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/Indexlist.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/MessageHandling.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/QProblem.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/QProblemB.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/SubjectTo.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/Types.hpp delete mode 100644 phonelibs/qpoases/INCLUDE/Utils.hpp delete mode 100644 phonelibs/qpoases/LICENSE.txt delete mode 100644 phonelibs/qpoases/README.txt delete mode 100644 phonelibs/qpoases/SConscript delete mode 100644 phonelibs/qpoases/SRC/Bounds.cpp delete mode 100644 phonelibs/qpoases/SRC/Bounds.ipp delete mode 100644 phonelibs/qpoases/SRC/Constraints.cpp delete mode 100644 phonelibs/qpoases/SRC/Constraints.ipp delete mode 100644 phonelibs/qpoases/SRC/CyclingManager.cpp delete mode 100644 phonelibs/qpoases/SRC/CyclingManager.ipp delete mode 100644 phonelibs/qpoases/SRC/EXTRAS/SolutionAnalysis.cpp delete mode 100644 phonelibs/qpoases/SRC/Indexlist.cpp delete mode 100644 phonelibs/qpoases/SRC/Indexlist.ipp delete mode 100644 phonelibs/qpoases/SRC/MessageHandling.cpp delete mode 100644 phonelibs/qpoases/SRC/MessageHandling.ipp delete mode 100644 phonelibs/qpoases/SRC/QProblem.cpp delete mode 100644 phonelibs/qpoases/SRC/QProblem.ipp delete mode 100644 phonelibs/qpoases/SRC/QProblemB.cpp delete mode 100644 phonelibs/qpoases/SRC/QProblemB.ipp delete mode 100644 phonelibs/qpoases/SRC/SubjectTo.cpp delete mode 100644 phonelibs/qpoases/SRC/SubjectTo.ipp delete mode 100644 phonelibs/qpoases/SRC/Utils.cpp delete mode 100644 phonelibs/qpoases/SRC/Utils.ipp delete mode 100644 phonelibs/qpoases/VERSIONS.txt diff --git a/phonelibs/qpoases/EXAMPLES/example1.cpp b/phonelibs/qpoases/EXAMPLES/example1.cpp deleted file mode 100644 index 92b47fc93..000000000 --- a/phonelibs/qpoases/EXAMPLES/example1.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file EXAMPLES/example1.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Very simple example for testing qpOASES (using QProblem class). - */ - - -#include - - -/** Example for qpOASES main function using the QProblem class. */ -int main( ) -{ - /* Setup data of first QP. */ - real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; - real_t A[1*2] = { 1.0, 1.0 }; - real_t g[2] = { 1.5, 1.0 }; - real_t lb[2] = { 0.5, -2.0 }; - real_t ub[2] = { 5.0, 2.0 }; - real_t lbA[1] = { -1.0 }; - real_t ubA[1] = { 2.0 }; - - /* Setup data of second QP. */ - real_t g_new[2] = { 1.0, 1.5 }; - real_t lb_new[2] = { 0.0, -1.0 }; - real_t ub_new[2] = { 5.0, -0.5 }; - real_t lbA_new[1] = { -2.0 }; - real_t ubA_new[1] = { 1.0 }; - - - /* Setting up QProblem object. */ - QProblem example( 2,1 ); - - /* Solve first QP. */ - int nWSR = 10; - example.init( H,g,A,lb,ub,lbA,ubA, nWSR,0 ); - - /* Solve second QP. */ - nWSR = 10; - example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR,0 ); - - return 0; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/EXAMPLES/example1b.cpp b/phonelibs/qpoases/EXAMPLES/example1b.cpp deleted file mode 100644 index 331f19d8d..000000000 --- a/phonelibs/qpoases/EXAMPLES/example1b.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file EXAMPLES/example1b.cpp - * \author Hans Joachim Ferreau - * \version 1.3 - * \date 2007-2008 - * - * Very simple example for testing qpOASES using the QProblemB class. - */ - - -#include - - -/** Example for qpOASES main function using the QProblemB class. */ -int main( ) -{ - /* Setup data of first QP. */ - real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; - real_t g[2] = { 1.5, 1.0 }; - real_t lb[2] = { 0.5, -2.0 }; - real_t ub[2] = { 5.0, 2.0 }; - - /* Setup data of second QP. */ - real_t g_new[2] = { 1.0, 1.5 }; - real_t lb_new[2] = { 0.0, -1.0 }; - real_t ub_new[2] = { 5.0, -0.5 }; - - - /* Setting up QProblemB object. */ - QProblemB example( 2 ); - - /* Solve first QP. */ - int nWSR = 10; - example.init( H,g,lb,ub, nWSR,0 ); - - /* Solve second QP. */ - nWSR = 10; - example.hotstart( g_new,lb_new,ub_new, nWSR,0 ); - - return 0; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/Bounds.hpp b/phonelibs/qpoases/INCLUDE/Bounds.hpp deleted file mode 100644 index 7260756da..000000000 --- a/phonelibs/qpoases/INCLUDE/Bounds.hpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Bounds.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the Bounds class designed to manage working sets of - * bounds within a QProblem. - */ - - -#ifndef QPOASES_BOUNDS_HPP -#define QPOASES_BOUNDS_HPP - - -#include - - - -/** This class manages working sets of bounds by storing - * index sets and other status information. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class Bounds : public SubjectTo -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - Bounds( ); - - /** Copy constructor (deep copy). */ - Bounds( const Bounds& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~Bounds( ); - - /** Assignment operator (deep copy). */ - Bounds& operator=( const Bounds& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor takes the number of bounds. - * \return SUCCESSFUL_RETURN */ - returnValue init( int n /**< Number of bounds. */ - ); - - - /** Initially adds number of a new (i.e. not yet in the list) bound to - * given index set. - * \return SUCCESSFUL_RETURN \n - RET_SETUP_BOUND_FAILED \n - RET_INDEX_OUT_OF_BOUNDS \n - RET_INVALID_ARGUMENTS */ - returnValue setupBound( int _number, /**< Number of new bound. */ - SubjectToStatus _status /**< Status of new bound. */ - ); - - /** Initially adds all numbers of new (i.e. not yet in the list) bounds to - * to the index set of free bounds; the order depends on the SujectToType - * of each index. - * \return SUCCESSFUL_RETURN \n - RET_SETUP_BOUND_FAILED */ - returnValue setupAllFree( ); - - - /** Moves index of a bound from index list of fixed to that of free bounds. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_BOUND_FAILED \n - RET_INDEX_OUT_OF_BOUNDS */ - returnValue moveFixedToFree( int _number /**< Number of bound to be freed. */ - ); - - /** Moves index of a bound from index list of free to that of fixed bounds. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_BOUND_FAILED \n - RET_INDEX_OUT_OF_BOUNDS */ - returnValue moveFreeToFixed( int _number, /**< Number of bound to be fixed. */ - SubjectToStatus _status /**< Status of bound to be fixed. */ - ); - - /** Swaps the indices of two free bounds within the index set. - * \return SUCCESSFUL_RETURN \n - RET_SWAPINDEX_FAILED */ - returnValue swapFree( int number1, /**< Number of first constraint or bound. */ - int number2 /**< Number of second constraint or bound. */ - ); - - - /** Returns number of variables. - * \return Number of variables. */ - inline int getNV( ) const; - - /** Returns number of implicitly fixed variables. - * \return Number of implicitly fixed variables. */ - inline int getNFV( ) const; - - /** Returns number of bounded (but possibly free) variables. - * \return Number of bounded (but possibly free) variables. */ - inline int getNBV( ) const; - - /** Returns number of unbounded variables. - * \return Number of unbounded variables. */ - inline int getNUV( ) const; - - - /** Sets number of implicitly fixed variables. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNFV( int n /**< Number of implicitly fixed variables. */ - ); - - /** Sets number of bounded (but possibly free) variables. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNBV( int n /**< Number of bounded (but possibly free) variables. */ - ); - - /** Sets number of unbounded variables. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNUV( int n /**< Number of unbounded variables */ - ); - - - /** Returns number of free variables. - * \return Number of free variables. */ - inline int getNFR( ); - - /** Returns number of fixed variables. - * \return Number of fixed variables. */ - inline int getNFX( ); - - - /** Returns a pointer to free variables index list. - * \return Pointer to free variables index list. */ - inline Indexlist* getFree( ); - - /** Returns a pointer to fixed variables index list. - * \return Pointer to fixed variables index list. */ - inline Indexlist* getFixed( ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int nV; /**< Number of variables (nV = nFV + nBV + nUV). */ - int nFV; /**< Number of implicitly fixed variables. */ - int nBV; /**< Number of bounded (but possibly free) variables. */ - int nUV; /**< Number of unbounded variables. */ - - Indexlist free; /**< Index list of free variables. */ - Indexlist fixed; /**< Index list of fixed variables. */ -}; - -#include - -#endif /* QPOASES_BOUNDS_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/Constants.hpp b/phonelibs/qpoases/INCLUDE/Constants.hpp deleted file mode 100644 index 92ee81229..000000000 --- a/phonelibs/qpoases/INCLUDE/Constants.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Constants.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2008 - * - * Definition of all global constants. - */ - - -#ifndef QPOASES_CONSTANTS_HPP -#define QPOASES_CONSTANTS_HPP - -#ifndef QPOASES_CUSTOM_INTERFACE -#include "acado_qpoases_interface.hpp" -#else - #define XSTR(x) #x - #define STR(x) XSTR(x) - #include STR(QPOASES_CUSTOM_INTERFACE) -#endif - -/** Maximum number of variables within a QP formulation. - Note: this value has to be positive! */ -const int NVMAX = QPOASES_NVMAX; - -/** Maximum number of constraints within a QP formulation. - Note: this value has to be positive! */ -const int NCMAX = QPOASES_NCMAX; - -/** Redefinition of NCMAX used for memory allocation, to avoid zero sized arrays - and compiler errors. */ -const int NCMAX_ALLOC = (NCMAX == 0) ? 1 : NCMAX; - -/**< Maximum number of working set recalculations. - Note: this value has to be positive! */ -const int NWSRMAX = QPOASES_NWSRMAX; - -/** Desired KKT tolerance of QP solution; a warning RET_INACCURATE_SOLUTION is - * issued if this tolerance is not met. - * Note: this value has to be positive! */ -const real_t DESIREDACCURACY = (real_t) 1.0e-3; - -/** Critical KKT tolerance of QP solution; an error is issued if this - * tolerance is not met. - * Note: this value has to be positive! */ -const real_t CRITICALACCURACY = (real_t) 1.0e-2; - - - -/** Numerical value of machine precision (min eps, s.t. 1+eps > 1). - Note: this value has to be positive! */ -const real_t EPS = (real_t) QPOASES_EPS; - -/** Numerical value of zero (for situations in which it would be - * unreasonable to compare with 0.0). - * Note: this value has to be positive! */ -const real_t ZERO = (real_t) 1.0e-50; - -/** Numerical value of infinity (e.g. for non-existing bounds). - * Note: this value has to be positive! */ -const real_t INFTY = (real_t) 1.0e12; - - -/** Lower/upper (constraints') bound tolerance (an inequality constraint - * whose lower and upper bound differ by less than BOUNDTOL is regarded - * to be an equality constraint). - * Note: this value has to be positive! */ -const real_t BOUNDTOL = (real_t) 1.0e-10; - -/** Offset for relaxing (constraints') bounds at beginning of an initial homotopy. - * Note: this value has to be positive! */ -const real_t BOUNDRELAXATION = (real_t) 1.0e3; - - -/** Factor that determines physical lengths of index lists. - * Note: this value has to be greater than 1! */ -const int INDEXLISTFACTOR = 5; - - -#endif /* QPOASES_CONSTANTS_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/Constraints.hpp b/phonelibs/qpoases/INCLUDE/Constraints.hpp deleted file mode 100644 index 899167942..000000000 --- a/phonelibs/qpoases/INCLUDE/Constraints.hpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Constraints.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the Constraints class designed to manage working sets of - * constraints within a QProblem. - */ - - -#ifndef QPOASES_CONSTRAINTS_HPP -#define QPOASES_CONSTRAINTS_HPP - - -#include - - - -/** This class manages working sets of constraints by storing - * index sets and other status information. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class Constraints : public SubjectTo -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - Constraints( ); - - /** Copy constructor (deep copy). */ - Constraints( const Constraints& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~Constraints( ); - - /** Assignment operator (deep copy). */ - Constraints& operator=( const Constraints& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor takes the number of constraints. - * \return SUCCESSFUL_RETURN */ - returnValue init( int n /**< Number of constraints. */ - ); - - - /** Initially adds number of a new (i.e. not yet in the list) constraint to - * a given index set. - * \return SUCCESSFUL_RETURN \n - RET_SETUP_CONSTRAINT_FAILED \n - RET_INDEX_OUT_OF_BOUNDS \n - RET_INVALID_ARGUMENTS */ - returnValue setupConstraint( int _number, /**< Number of new constraint. */ - SubjectToStatus _status /**< Status of new constraint. */ - ); - - /** Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to - * to the index set of inactive constraints; the order depends on the SujectToType - * of each index. Only disabled constraints are added to index set of disabled constraints! - * \return SUCCESSFUL_RETURN \n - RET_SETUP_CONSTRAINT_FAILED */ - returnValue setupAllInactive( ); - - - /** Moves index of a constraint from index list of active to that of inactive constraints. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_CONSTRAINT_FAILED */ - returnValue moveActiveToInactive( int _number /**< Number of constraint to become inactive. */ - ); - - /** Moves index of a constraint from index list of inactive to that of active constraints. - * \return SUCCESSFUL_RETURN \n - RET_MOVING_CONSTRAINT_FAILED */ - returnValue moveInactiveToActive( int _number, /**< Number of constraint to become active. */ - SubjectToStatus _status /**< Status of constraint to become active. */ - ); - - - /** Returns the number of constraints. - * \return Number of constraints. */ - inline int getNC( ) const; - - /** Returns the number of implicit equality constraints. - * \return Number of implicit equality constraints. */ - inline int getNEC( ) const; - - /** Returns the number of "real" inequality constraints. - * \return Number of "real" inequality constraints. */ - inline int getNIC( ) const; - - /** Returns the number of unbounded constraints (i.e. without any bounds). - * \return Number of unbounded constraints (i.e. without any bounds). */ - inline int getNUC( ) const; - - - /** Sets number of implicit equality constraints. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNEC( int n /**< Number of implicit equality constraints. */ - ); - - /** Sets number of "real" inequality constraints. - * \return SUCCESSFUL_RETURN */ - inline returnValue setNIC( int n /**< Number of "real" inequality constraints. */ - ); - - /** Sets number of unbounded constraints (i.e. without any bounds). - * \return SUCCESSFUL_RETURN */ - inline returnValue setNUC( int n /**< Number of unbounded constraints (i.e. without any bounds). */ - ); - - - /** Returns the number of active constraints. - * \return Number of constraints. */ - inline int getNAC( ); - - /** Returns the number of inactive constraints. - * \return Number of constraints. */ - inline int getNIAC( ); - - - /** Returns a pointer to active constraints index list. - * \return Pointer to active constraints index list. */ - inline Indexlist* getActive( ); - - /** Returns a pointer to inactive constraints index list. - * \return Pointer to inactive constraints index list. */ - inline Indexlist* getInactive( ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int nC; /**< Number of constraints (nC = nEC + nIC + nUC). */ - int nEC; /**< Number of implicit equality constraints. */ - int nIC; /**< Number of "real" inequality constraints. */ - int nUC; /**< Number of unbounded constraints (i.e. without any bounds). */ - - Indexlist active; /**< Index list of active constraints. */ - Indexlist inactive; /**< Index list of inactive constraints. */ -}; - - -#include - -#endif /* QPOASES_CONSTRAINTS_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/CyclingManager.hpp b/phonelibs/qpoases/INCLUDE/CyclingManager.hpp deleted file mode 100644 index b4410b106..000000000 --- a/phonelibs/qpoases/INCLUDE/CyclingManager.hpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/CyclingManager.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the CyclingManager class designed to detect - * and handle possible cycling during QP iterations. - */ - - -#ifndef QPOASES_CYCLINGMANAGER_HPP -#define QPOASES_CYCLINGMANAGER_HPP - - -#include - - - -/** This class is intended to detect and handle possible cycling during QP iterations. - * As cycling seems to occur quite rarely, this class is NOT FULLY IMPLEMENTED YET! - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class CyclingManager -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - CyclingManager( ); - - /** Copy constructor (deep copy). */ - CyclingManager( const CyclingManager& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~CyclingManager( ); - - /** Copy asingment operator (deep copy). */ - CyclingManager& operator=( const CyclingManager& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor which takes the number of bounds/constraints. - * \return SUCCESSFUL_RETURN */ - returnValue init( int _nV, /**< Number of bounds to be managed. */ - int _nC /**< Number of constraints to be managed. */ - ); - - - /** Stores index of a bound/constraint that might cause cycling. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - returnValue setCyclingStatus( int number, /**< Number of bound/constraint. */ - BooleanType isBound, /**< Flag that indicates if given number corresponds to a - * bound (BT_TRUE) or a constraint (BT_FALSE). */ - CyclingStatus _status /**< Cycling status of bound/constraint. */ - ); - - /** Returns if bound/constraint might cause cycling. - * \return BT_TRUE: bound/constraint might cause cycling \n - BT_FALSE: otherwise */ - CyclingStatus getCyclingStatus( int number, /**< Number of bound/constraint. */ - BooleanType isBound /**< Flag that indicates if given number corresponds to - * a bound (BT_TRUE) or a constraint (BT_FALSE). */ - ) const; - - - /** Clears all previous cycling information. - * \return SUCCESSFUL_RETURN */ - returnValue clearCyclingData( ); - - - /** Returns if cycling was detected. - * \return BT_TRUE iff cycling was detected. */ - inline BooleanType isCyclingDetected( ) const; - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int nV; /**< Number of managed bounds. */ - int nC; /**< Number of managed constraints. */ - - CyclingStatus status[NVMAX+NCMAX]; /**< Array to store cycling status of all bounds/constraints. */ - - BooleanType cyclingDetected; /**< Flag if cycling was detected. */ -}; - - -#include - -#endif /* QPOASES_CYCLINGMANAGER_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp b/phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp deleted file mode 100644 index 056bb26f0..000000000 --- a/phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/EXTRAS/SolutionAnalysis.hpp - * \author Milan Vukov, Boris Houska, Hans Joachim Ferreau - * \version 1.3embedded - * \date 2012 - * - * Solution analysis class, based on a class in the standard version of the qpOASES - */ - - -// - -#ifndef QPOASES_SOLUTIONANALYSIS_HPP -#define QPOASES_SOLUTIONANALYSIS_HPP - -#include - -/** Enables the computation of variance as is in the standard version of qpOASES */ -#define QPOASES_USE_OLD_VERSION 0 - -#if QPOASES_USE_OLD_VERSION -#define KKT_DIM (2 * NVMAX + NCMAX) -#endif - -class SolutionAnalysis -{ -public: - - /** Default constructor. */ - SolutionAnalysis( ); - - /** Copy constructor (deep copy). */ - SolutionAnalysis( const SolutionAnalysis& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~SolutionAnalysis( ); - - /** Copy asingment operator (deep copy). */ - SolutionAnalysis& operator=( const SolutionAnalysis& rhs /**< Rhs object. */ - ); - - /** A routine for computation of inverse of the Hessian matrix. */ - returnValue getHessianInverse( - QProblem* qp, /** QP */ - real_t* hessianInverse /** Inverse of the Hessian matrix*/ - ); - - /** A routine for computation of inverse of the Hessian matrix. */ - returnValue getHessianInverse( QProblemB* qp, /** QP */ - real_t* hessianInverse /** Inverse of the Hessian matrix*/ - ); - -#if QPOASES_USE_OLD_VERSION - returnValue getVarianceCovariance( - QProblem* qp, - real_t* g_b_bA_VAR, - real_t* Primal_Dual_VAR - ); -#endif - -private: - - real_t delta_g_cov[ NVMAX ]; /** A covariance-vector of g */ - real_t delta_lb_cov[ NVMAX ]; /** A covariance-vector of lb */ - real_t delta_ub_cov[ NVMAX ]; /** A covariance-vector of ub */ - real_t delta_lbA_cov[ NCMAX_ALLOC ]; /** A covariance-vector of lbA */ - real_t delta_ubA_cov[ NCMAX_ALLOC ]; /** A covariance-vector of ubA */ - -#if QPOASES_USE_OLD_VERSION - real_t K[KKT_DIM * KKT_DIM]; /** A matrix to store an intermediate result */ -#endif - - int FR_idx[ NVMAX ]; /** Index array for free variables */ - int FX_idx[ NVMAX ]; /** Index array for fixed variables */ - int AC_idx[ NCMAX_ALLOC ]; /** Index array for active constraints */ - - real_t delta_xFR[ NVMAX ]; /** QP reaction, primal, w.r.t. free */ - real_t delta_xFX[ NVMAX ]; /** QP reaction, primal, w.r.t. fixed */ - real_t delta_yAC[ NVMAX ]; /** QP reaction, dual, w.r.t. active */ - real_t delta_yFX[ NVMAX ]; /** QP reaction, dual, w.r.t. fixed*/ -}; - -#endif // QPOASES_SOLUTIONANALYSIS_HPP diff --git a/phonelibs/qpoases/INCLUDE/Indexlist.hpp b/phonelibs/qpoases/INCLUDE/Indexlist.hpp deleted file mode 100644 index 21c31ddb9..000000000 --- a/phonelibs/qpoases/INCLUDE/Indexlist.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Indexlist.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the Indexlist class designed to manage index lists of - * constraints and bounds within a SubjectTo object. - */ - - -#ifndef QPOASES_INDEXLIST_HPP -#define QPOASES_INDEXLIST_HPP - - -#include - - -/** This class manages index lists. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class Indexlist -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - Indexlist( ); - - /** Copy constructor (deep copy). */ - Indexlist( const Indexlist& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~Indexlist( ); - - /** Assingment operator (deep copy). */ - Indexlist& operator=( const Indexlist& rhs /**< Rhs object. */ - ); - - /** Pseudo-constructor. - * \return SUCCESSFUL_RETURN */ - returnValue init( ); - - - /** Creates an array of all numbers within the index set in correct order. - * \return SUCCESSFUL_RETURN \n - RET_INDEXLIST_CORRUPTED */ - returnValue getNumberArray( int* const numberarray /**< Output: Array of numbers (NULL on error). */ - ) const; - - - /** Determines the index within the index list at with a given number is stored. - * \return >= 0: Index of given number. \n - -1: Number not found. */ - int getIndex( int givennumber /**< Number whose index shall be determined. */ - ) const; - - /** Determines the physical index within the index list at with a given number is stored. - * \return >= 0: Index of given number. \n - -1: Number not found. */ - int getPhysicalIndex( int givennumber /**< Number whose physical index shall be determined. */ - ) const; - - /** Returns the number stored at a given physical index. - * \return >= 0: Number stored at given physical index. \n - -RET_INDEXLIST_OUTOFBOUNDS */ - int getNumber( int physicalindex /**< Physical index of the number to be returned. */ - ) const; - - - /** Returns the current length of the index list. - * \return Current length of the index list. */ - inline int getLength( ); - - /** Returns last number within the index list. - * \return Last number within the index list. */ - inline int getLastNumber( ) const; - - - /** Adds number to index list. - * \return SUCCESSFUL_RETURN \n - RET_INDEXLIST_MUST_BE_REORDERD \n - RET_INDEXLIST_EXCEEDS_MAX_LENGTH */ - returnValue addNumber( int addnumber /**< Number to be added. */ - ); - - /** Removes number from index list. - * \return SUCCESSFUL_RETURN */ - returnValue removeNumber( int removenumber /**< Number to be removed. */ - ); - - /** Swaps two numbers within index list. - * \return SUCCESSFUL_RETURN */ - returnValue swapNumbers( int number1,/**< First number for swapping. */ - int number2 /**< Second number for swapping. */ - ); - - /** Determines if a given number is contained in the index set. - * \return BT_TRUE iff number is contain in the index set */ - inline BooleanType isMember( int _number /**< Number to be tested for membership. */ - ) const; - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - int number[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store numbers of constraints or bounds. */ - int next[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of successor. */ - int previous[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of predecossor. */ - int length; /**< Length of index list. */ - int first; /**< Physical index of first element. */ - int last; /**< Physical index of last element. */ - int lastusedindex; /**< Physical index of last entry in index list. */ - int physicallength; /**< Physical length of index list. */ -}; - - -#include - -#endif /* QPOASES_INDEXLIST_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/MessageHandling.hpp b/phonelibs/qpoases/INCLUDE/MessageHandling.hpp deleted file mode 100644 index 3d17498ad..000000000 --- a/phonelibs/qpoases/INCLUDE/MessageHandling.hpp +++ /dev/null @@ -1,415 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/MessageHandling.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the MessageHandling class including global return values. - */ - - -#ifndef QPOASES_MESSAGEHANDLING_HPP -#define QPOASES_MESSAGEHANDLING_HPP - -// #define PC_DEBUG - -#ifdef PC_DEBUG - #include - - /** Defines an alias for FILE from stdio.h. */ - #define myFILE FILE - /** Defines an alias for stderr from stdio.h. */ - #define myStderr stderr - /** Defines an alias for stdout from stdio.h. */ - #define myStdout stdout -#else - /** Defines an alias for FILE from stdio.h. */ - #define myFILE int - /** Defines an alias for stderr from stdio.h. */ - #define myStderr 0 - /** Defines an alias for stdout from stdio.h. */ - #define myStdout 0 -#endif - - -#include -#include - - -/** Defines symbols for global return values. \n - * Important: All return values are assumed to be nonnegative! */ -enum returnValue -{ -TERMINAL_LIST_ELEMENT = -1, /**< Terminal list element, internal usage only! */ -/* miscellaneous */ -SUCCESSFUL_RETURN = 0, /**< Successful return. */ -RET_DIV_BY_ZERO, /**< Division by zero. */ -RET_INDEX_OUT_OF_BOUNDS, /**< Index out of bounds. */ -RET_INVALID_ARGUMENTS, /**< At least one of the arguments is invalid. */ -RET_ERROR_UNDEFINED, /**< Error number undefined. */ -RET_WARNING_UNDEFINED, /**< Warning number undefined. */ -RET_INFO_UNDEFINED, /**< Info number undefined. */ -RET_EWI_UNDEFINED, /**< Error/warning/info number undefined. */ -RET_AVAILABLE_WITH_LINUX_ONLY, /**< This function is available under Linux only. */ -RET_UNKNOWN_BUG, /**< The error occured is not yet known. */ -RET_PRINTLEVEL_CHANGED, /**< 10 Print level changed. */ -RET_NOT_YET_IMPLEMENTED, /**< Requested function is not yet implemented in this version of qpOASES. */ -/* Indexlist */ -RET_INDEXLIST_MUST_BE_REORDERD, /**< Index list has to be reordered. */ -RET_INDEXLIST_EXCEEDS_MAX_LENGTH, /**< Index list exceeds its maximal physical length. */ -RET_INDEXLIST_CORRUPTED, /**< Index list corrupted. */ -RET_INDEXLIST_OUTOFBOUNDS, /**< Physical index is out of bounds. */ -RET_INDEXLIST_ADD_FAILED, /**< Adding indices from another index set failed. */ -RET_INDEXLIST_INTERSECT_FAILED, /**< Intersection with another index set failed. */ -/* SubjectTo / Bounds / Constraints */ -RET_INDEX_ALREADY_OF_DESIRED_STATUS, /**< Index is already of desired status. */ -RET_ADDINDEX_FAILED, /**< Cannot swap between different indexsets. */ -RET_SWAPINDEX_FAILED, /**< 20 Adding index to index set failed. */ -RET_NOTHING_TO_DO, /**< Nothing to do. */ -RET_SETUP_BOUND_FAILED, /**< Setting up bound index failed. */ -RET_SETUP_CONSTRAINT_FAILED, /**< Setting up constraint index failed. */ -RET_MOVING_BOUND_FAILED, /**< Moving bound between index sets failed. */ -RET_MOVING_CONSTRAINT_FAILED, /**< Moving constraint between index sets failed. */ -/* QProblem */ -RET_QP_ALREADY_INITIALISED, /**< QProblem has already been initialised. */ -RET_NO_INIT_WITH_STANDARD_SOLVER, /**< Initialisation via extern QP solver is not yet implemented. */ -RET_RESET_FAILED, /**< Reset failed. */ -RET_INIT_FAILED, /**< Initialisation failed. */ -RET_INIT_FAILED_TQ, /**< 30 Initialisation failed due to TQ factorisation. */ -RET_INIT_FAILED_CHOLESKY, /**< Initialisation failed due to Cholesky decomposition. */ -RET_INIT_FAILED_HOTSTART, /**< Initialisation failed! QP could not be solved! */ -RET_INIT_FAILED_INFEASIBILITY, /**< Initial QP could not be solved due to infeasibility! */ -RET_INIT_FAILED_UNBOUNDEDNESS, /**< Initial QP could not be solved due to unboundedness! */ -RET_INIT_SUCCESSFUL, /**< Initialisation done. */ -RET_OBTAINING_WORKINGSET_FAILED, /**< Failed to obtain working set for auxiliary QP. */ -RET_SETUP_WORKINGSET_FAILED, /**< Failed to setup working set for auxiliary QP. */ -RET_SETUP_AUXILIARYQP_FAILED, /**< Failed to setup auxiliary QP for initialised homotopy. */ -RET_NO_EXTERN_SOLVER, /**< No extern QP solver available. */ -RET_QP_UNBOUNDED, /**< 40 QP is unbounded. */ -RET_QP_INFEASIBLE, /**< QP is infeasible. */ -RET_QP_NOT_SOLVED, /**< Problems occured while solving QP with standard solver. */ -RET_QP_SOLVED, /**< QP successfully solved. */ -RET_UNABLE_TO_SOLVE_QP, /**< Problems occured while solving QP. */ -RET_INITIALISATION_STARTED, /**< Starting problem initialisation. */ -RET_HOTSTART_FAILED, /**< Unable to perform homotopy due to internal error. */ -RET_HOTSTART_FAILED_TO_INIT, /**< Unable to initialise problem. */ -RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, /**< Unable to perform homotopy as previous QP is not solved. */ -RET_ITERATION_STARTED, /**< Iteration... */ -RET_SHIFT_DETERMINATION_FAILED, /**< 50 Determination of shift of the QP data failed. */ -RET_STEPDIRECTION_DETERMINATION_FAILED, /**< Determination of step direction failed. */ -RET_STEPLENGTH_DETERMINATION_FAILED, /**< Determination of step direction failed. */ -RET_OPTIMAL_SOLUTION_FOUND, /**< Optimal solution of neighbouring QP found. */ -RET_HOMOTOPY_STEP_FAILED, /**< Unable to perform homotopy step. */ -RET_HOTSTART_STOPPED_INFEASIBILITY, /**< Premature homotopy termination because QP is infeasible. */ -RET_HOTSTART_STOPPED_UNBOUNDEDNESS, /**< Premature homotopy termination because QP is unbounded. */ -RET_WORKINGSET_UPDATE_FAILED, /**< Unable to update working sets according to initial guesses. */ -RET_MAX_NWSR_REACHED, /**< Maximum number of working set recalculations performed. */ -RET_CONSTRAINTS_NOT_SPECIFIED, /**< Problem does comprise constraints! You also have to specify new constraints' bounds. */ -RET_INVALID_FACTORISATION_FLAG, /**< 60 Invalid factorisation flag. */ -RET_UNABLE_TO_SAVE_QPDATA, /**< Unable to save QP data. */ -RET_STEPDIRECTION_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ -RET_STEPDIRECTION_FAILED_CHOLESKY, /**< Abnormal termination due to Cholesky factorisation. */ -RET_CYCLING_DETECTED, /**< Cycling detected. */ -RET_CYCLING_NOT_RESOLVED, /**< Cycling cannot be resolved, QP probably infeasible. */ -RET_CYCLING_RESOLVED, /**< Cycling probably resolved. */ -RET_STEPSIZE, /**< For displaying performed stepsize. */ -RET_STEPSIZE_NONPOSITIVE, /**< For displaying non-positive stepsize. */ -RET_SETUPSUBJECTTOTYPE_FAILED, /**< Setup of SubjectToTypes failed. */ -RET_ADDCONSTRAINT_FAILED, /**< 70 Addition of constraint to working set failed. */ -RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, /**< Addition of constraint to working set failed (due to QP infeasibility). */ -RET_ADDBOUND_FAILED, /**< Addition of bound to working set failed. */ -RET_ADDBOUND_FAILED_INFEASIBILITY, /**< Addition of bound to working set failed (due to QP infeasibility). */ -RET_REMOVECONSTRAINT_FAILED, /**< Removal of constraint from working set failed. */ -RET_REMOVEBOUND_FAILED, /**< Removal of bound from working set failed. */ -RET_REMOVE_FROM_ACTIVESET, /**< Removing from active set... */ -RET_ADD_TO_ACTIVESET, /**< Adding to active set... */ -RET_REMOVE_FROM_ACTIVESET_FAILED, /**< Removing from active set failed. */ -RET_ADD_TO_ACTIVESET_FAILED, /**< Adding to active set failed. */ -RET_CONSTRAINT_ALREADY_ACTIVE, /**< 80 Constraint is already active. */ -RET_ALL_CONSTRAINTS_ACTIVE, /**< All constraints are active, no further constraint can be added. */ -RET_LINEARLY_DEPENDENT, /**< New bound/constraint is linearly dependent. */ -RET_LINEARLY_INDEPENDENT, /**< New bound/constraint is linearly independent. */ -RET_LI_RESOLVED, /**< Linear independence of active contraint matrix successfully resolved. */ -RET_ENSURELI_FAILED, /**< Failed to ensure linear indepence of active contraint matrix. */ -RET_ENSURELI_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ -RET_ENSURELI_FAILED_NOINDEX, /**< No index found, QP probably infeasible. */ -RET_ENSURELI_FAILED_CYCLING, /**< Cycling detected, QP probably infeasible. */ -RET_BOUND_ALREADY_ACTIVE, /**< Bound is already active. */ -RET_ALL_BOUNDS_ACTIVE, /**< 90 All bounds are active, no further bound can be added. */ -RET_CONSTRAINT_NOT_ACTIVE, /**< Constraint is not active. */ -RET_BOUND_NOT_ACTIVE, /**< Bound is not active. */ -RET_HESSIAN_NOT_SPD, /**< Projected Hessian matrix not positive definite. */ -RET_MATRIX_SHIFT_FAILED, /**< Unable to update matrices or to transform vectors. */ -RET_MATRIX_FACTORISATION_FAILED, /**< Unable to calculate new matrix factorisations. */ -RET_PRINT_ITERATION_FAILED, /**< Unable to print information on current iteration. */ -RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, /**< No global message output file initialised. */ -/* Utils */ -RET_UNABLE_TO_OPEN_FILE, /**< Unable to open file. */ -RET_UNABLE_TO_WRITE_FILE, /**< Unable to write into file. */ -RET_UNABLE_TO_READ_FILE, /**< 100 Unable to read from file. */ -RET_FILEDATA_INCONSISTENT, /**< File contains inconsistent data. */ -/* SolutionAnalysis */ -RET_NO_SOLUTION, /**< QP solution does not satisfy KKT optimality conditions. */ -RET_INACCURATE_SOLUTION /**< KKT optimality conditions not satisfied to sufficient accuracy. */ -}; - - - -/** This class handles all kinds of messages (errors, warnings, infos) initiated - * by qpOASES modules and stores the correspoding global preferences. - * - * \author Hans Joachim Ferreau (special thanks to Leonard Wirsching) - * \version 1.3embedded - * \date 2007-2008 - */ -class MessageHandling -{ - /* - * INTERNAL DATA STRUCTURES - */ - public: - /** Data structure for entries in global message list. */ - typedef struct { - returnValue key; /**< Global return value. */ - const char* data; /**< Corresponding message. */ - VisibilityStatus globalVisibilityStatus; /**< Determines if message can be printed. - * If this value is set to VS_HIDDEN, no message is printed! */ - } ReturnValueList; - - - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - MessageHandling( ); - - /** Constructor which takes the desired output file. */ - MessageHandling( myFILE* _outputFile /**< Output file. */ - ); - - /** Constructor which takes the desired visibility states. */ - MessageHandling( VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ - VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ - VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ - ); - - /** Constructor which takes the desired output file and desired visibility states. */ - MessageHandling( myFILE* _outputFile, /**< Output file. */ - VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ - VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ - VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ - ); - - /** Copy constructor (deep copy). */ - MessageHandling( const MessageHandling& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~MessageHandling( ); - - /** Assignment operator (deep copy). */ - MessageHandling& operator=( const MessageHandling& rhs /**< Rhs object. */ - ); - - - /** Prints an error message(a simplified macro THROWERROR is also provided). \n - * Errors are definied as abnormal events which cause an immediate termination of the current (sub) function. - * Errors of a sub function should be commented by the calling function by means of a warning message - * (if this error does not cause an error of the calling function, either)! - * \return Error number returned by sub function call - */ - returnValue throwError( - returnValue Enumber, /**< Error number returned by sub function call. */ - const char* additionaltext, /**< Additional error text (0, if none). */ - const char* functionname, /**< Name of function which caused the error. */ - const char* filename, /**< Name of file which caused the error. */ - const unsigned long linenumber, /**< Number of line which caused the error.incompatible binary file */ - VisibilityStatus localVisibilityStatus /**< Determines (locally) if error message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - ); - - /** Prints a warning message (a simplified macro THROWWARNING is also provided). - * Warnings are definied as abnormal events which does NOT cause an immediate termination of the current (sub) function. - * \return Warning number returned by sub function call - */ - returnValue throwWarning( - returnValue Wnumber, /**< Warning number returned by sub function call. */ - const char* additionaltext, /**< Additional warning text (0, if none). */ - const char* functionname, /**< Name of function which caused the warning. */ - const char* filename, /**< Name of file which caused the warning. */ - const unsigned long linenumber, /**< Number of line which caused the warning. */ - VisibilityStatus localVisibilityStatus /**< Determines (locally) if warning message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - ); - - /** Prints a info message (a simplified macro THROWINFO is also provided). - * \return Info number returned by sub function call - */ - returnValue throwInfo( - returnValue Inumber, /**< Info number returned by sub function call. */ - const char* additionaltext, /**< Additional warning text (0, if none). */ - const char* functionname, /**< Name of function which submitted the info. */ - const char* filename, /**< Name of file which submitted the info. */ - const unsigned long linenumber, /**< Number of line which submitted the info. */ - VisibilityStatus localVisibilityStatus /**< Determines (locally) if info message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - ); - - - /** Resets all preferences to default values. - * \return SUCCESSFUL_RETURN */ - returnValue reset( ); - - - /** Prints a complete list of all messages to output file. - * \return SUCCESSFUL_RETURN */ - returnValue listAllMessages( ); - - - /** Returns visibility status for error messages. - * \return Visibility status for error messages. */ - inline VisibilityStatus getErrorVisibilityStatus( ) const; - - /** Returns visibility status for warning messages. - * \return Visibility status for warning messages. */ - inline VisibilityStatus getWarningVisibilityStatus( ) const; - - /** Returns visibility status for info messages. - * \return Visibility status for info messages. */ - inline VisibilityStatus getInfoVisibilityStatus( ) const; - - /** Returns pointer to output file. - * \return Pointer to output file. */ - inline myFILE* getOutputFile( ) const; - - /** Returns error count value. - * \return Error count value. */ - inline int getErrorCount( ) const; - - - /** Changes visibility status for error messages. */ - inline void setErrorVisibilityStatus( VisibilityStatus _errorVisibility /**< New visibility status for error messages. */ - ); - - /** Changes visibility status for warning messages. */ - inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility /**< New visibility status for warning messages. */ - ); - - /** Changes visibility status for info messages. */ - inline void setInfoVisibilityStatus( VisibilityStatus _infoVisibility /**< New visibility status for info messages. */ - ); - - /** Changes output file for messages. */ - inline void setOutputFile( myFILE* _outputFile /**< New output file for messages. */ - ); - - /** Changes error count. - * \return SUCCESSFUL_RETURN \n - * RET_INVALID_ARGUMENT */ - inline returnValue setErrorCount( int _errorCount /**< New error count value. */ - ); - - /** Return the error code string. */ - static const char* getErrorString(int error); - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Prints a info message to myStderr (auxiliary function). - * \return Error/warning/info number returned by sub function call - */ - returnValue throwMessage( - returnValue RETnumber, /**< Error/warning/info number returned by sub function call. */ - const char* additionaltext, /**< Additional warning text (0, if none). */ - const char* functionname, /**< Name of function which caused the error/warning/info. */ - const char* filename, /**< Name of file which caused the error/warning/info. */ - const unsigned long linenumber, /**< Number of line which caused the error/warning/info. */ - VisibilityStatus localVisibilityStatus, /**< Determines (locally) if info message can be printed to myStderr. - * If GLOBAL visibility status of the message is set to VS_HIDDEN, - * no message is printed, anyway! */ - const char* RETstring /**< Leading string of error/warning/info message. */ - ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - VisibilityStatus errorVisibility; /**< Error messages visible? */ - VisibilityStatus warningVisibility; /**< Warning messages visible? */ - VisibilityStatus infoVisibility; /**< Info messages visible? */ - - myFILE* outputFile; /**< Output file for messages. */ - - int errorCount; /**< Counts number of errors (for nicer output only). */ -}; - - -#ifndef __FUNCTION__ - /** Ensures that __FUNCTION__ macro is defined. */ - #define __FUNCTION__ 0 -#endif - -#ifndef __FILE__ - /** Ensures that __FILE__ macro is defined. */ - #define __FILE__ 0 -#endif - -#ifndef __LINE__ - /** Ensures that __LINE__ macro is defined. */ - #define __LINE__ 0 -#endif - - -/** Short version of throwError with default values, only returnValue is needed */ -#define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) - -/** Short version of throwWarning with default values, only returnValue is needed */ -#define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) - -/** Short version of throwInfo with default values, only returnValue is needed */ -#define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) - - -/** Returns a pointer to global message handler. - * \return Pointer to global message handler. - */ -MessageHandling* getGlobalMessageHandler( ); - - -#include - -#endif /* QPOASES_MESSAGEHANDLING_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/QProblem.hpp b/phonelibs/qpoases/INCLUDE/QProblem.hpp deleted file mode 100644 index 91dc43417..000000000 --- a/phonelibs/qpoases/INCLUDE/QProblem.hpp +++ /dev/null @@ -1,666 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/QProblem.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the QProblem class which is able to use the newly - * developed online active set strategy for parametric quadratic programming. - */ - - - -#ifndef QPOASES_QPROBLEM_HPP -#define QPOASES_QPROBLEM_HPP - - -#include -#include -#include - - -/** A class for setting up and solving quadratic programs. The main feature is - * the possibily to use the newly developed online active set strategy for - * parametric quadratic programming. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class QProblem : public QProblemB -{ - /* allow SolutionAnalysis class to access private members */ - friend class SolutionAnalysis; - - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - QProblem( ); - - /** Constructor which takes the QP dimensions only. */ - QProblem( int _nV, /**< Number of variables. */ - int _nC /**< Number of constraints. */ - ); - - /** Copy constructor (deep copy). */ - QProblem( const QProblem& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~QProblem( ); - - /** Assignment operator (deep copy). */ - QProblem& operator=( const QProblem& rhs /**< Rhs object. */ - ); - - - /** Clears all data structures of QProblemB except for QP data. - * \return SUCCESSFUL_RETURN \n - RET_RESET_FAILED */ - returnValue reset( ); - - - /** Initialises a QProblem with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_TQ \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _A, /**< Constraint matrix. */ - const real_t* const _lb, /**< Lower bound vector (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bound vector (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const _lbA, /**< Lower constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const _ubA, /**< Upper constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Initialises a QProblem with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_TQ \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _A, /**< Constraint matrix. */ - const real_t* const _lb, /**< Lower bound vector (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bound vector (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const _lbA, /**< Lower constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const _ubA, /**< Upper constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Solves QProblem using online active set strategy. - * \return SUCCESSFUL_RETURN \n - RET_MAX_NWSR_REACHED \n - RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n - RET_HOTSTART_FAILED \n - RET_SHIFT_DETERMINATION_FAILED \n - RET_STEPDIRECTION_DETERMINATION_FAILED \n - RET_STEPLENGTH_DETERMINATION_FAILED \n - RET_HOMOTOPY_STEP_FAILED \n - RET_HOTSTART_STOPPED_INFEASIBILITY \n - RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ - const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const lbA_new, /**< Lower constraints' bounds of neighbouring QP to be solved. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const ubA_new, /**< Upper constraints' bounds of neighbouring QP to be solved. \n - If no upper constraints' bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - - /** Returns constraint matrix of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getA( real_t* const _A /**< Array of appropriate dimension for copying constraint matrix.*/ - ) const; - - /** Returns a single row of constraint matrix of the QP (deep copy). - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getA( int number, /**< Number of entry to be returned. */ - real_t* const row /**< Array of appropriate dimension for copying (number)th constraint. */ - ) const; - - /** Returns lower constraints' bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getLBA( real_t* const _lbA /**< Array of appropriate dimension for copying lower constraints' bound vector.*/ - ) const; - - /** Returns single entry of lower constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getLBA( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: lbA[number].*/ - ) const; - - /** Returns upper constraints' bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getUBA( real_t* const _ubA /**< Array of appropriate dimension for copying upper constraints' bound vector.*/ - ) const; - - /** Returns single entry of upper constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getUBA( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: ubA[number].*/ - ) const; - - - /** Returns current constraints object of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getConstraints( Constraints* const _constraints /** Output: Constraints object. */ - ) const; - - - /** Returns the number of constraints. - * \return Number of constraints. */ - inline int getNC( ) const; - - /** Returns the number of (implicitly defined) equality constraints. - * \return Number of (implicitly defined) equality constraints. */ - inline int getNEC( ) const; - - /** Returns the number of active constraints. - * \return Number of active constraints. */ - inline int getNAC( ); - - /** Returns the number of inactive constraints. - * \return Number of inactive constraints. */ - inline int getNIAC( ); - - /** Returns the dimension of null space. - * \return Dimension of null space. */ - int getNZ( ); - - - /** Returns the dual solution vector (deep copy). - * \return SUCCESSFUL_RETURN \n - RET_QP_NOT_SOLVED */ - returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ - ) const; - - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). - * \return SUCCESSFUL_RETURN \n - RET_SETUPSUBJECTTOTYPE_FAILED */ - returnValue setupSubjectToType( ); - - /** Computes the Cholesky decomposition R of the projected Hessian (i.e. R^T*R = Z^T*H*Z). - * \return SUCCESSFUL_RETURN \n - * RET_INDEXLIST_CORRUPTED */ - returnValue setupCholeskyDecompositionProjected( ); - - /** Initialises TQ factorisation of A (i.e. A*Q = [0 T]) if NO constraint is active. - * \return SUCCESSFUL_RETURN \n - RET_INDEXLIST_CORRUPTED */ - returnValue setupTQfactorisation( ); - - - /** Solves a QProblem whose QP data is assumed to be stored in the member variables. - * A guess for its primal/dual optimal solution vectors and the corresponding - * working sets of bounds and constraints can be provided. - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_TQ \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED */ - returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. - * A NULL pointer can be passed. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * A NULL pointer can be passed. */ - const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). - * A NULL pointer can be passed. */ - const Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). - * A NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - * Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - /** Obtains the desired working set for the auxiliary initial QP in - * accordance with the user specifications - * (assumes that member AX has already been initialised!) - * \return SUCCESSFUL_RETURN \n - RET_OBTAINING_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS */ - returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). */ - const Constraints* const guessedConstraints, /**< Guessed working set for solution (xOpt,yOpt). */ - Bounds* auxiliaryBounds, /**< Input: Allocated bound object. \n - * Ouput: Working set of constraints for auxiliary QP. */ - Constraints* auxiliaryConstraints /**< Input: Allocated bound object. \n - * Ouput: Working set for auxiliary QP. */ - ) const; - - /** Setups bound and constraints data structures according to auxiliaryBounds/Constraints. - * (If the working set shall be setup afresh, make sure that - * bounds and constraints data structure have been resetted - * and the TQ factorisation has been initialised!) - * \return SUCCESSFUL_RETURN \n - RET_SETUP_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ - const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ - BooleanType setupAfresh /**< Flag indicating if given working set shall be - * setup afresh or by updating the current one. */ - ); - - /** Setups the optimal primal/dual solution of the auxiliary initial QP. - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - const real_t* const yOpt /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - ); - - /** Setups gradient of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPgradient( ); - - /** Setups (constraints') bounds of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). - * \return SUCCESSFUL_RETURN \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryQPbounds( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ - const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ - BooleanType useRelaxation /**< Flag indicating if inactive (constraints') bounds shall be relaxed. */ - ); - - - /** Adds a constraint to active set. - * \return SUCCESSFUL_RETURN \n - RET_ADDCONSTRAINT_FAILED \n - RET_ADDCONSTRAINT_FAILED_INFEASIBILITY \n - RET_ENSURELI_FAILED */ - returnValue addConstraint( int number, /**< Number of constraint to be added to active set. */ - SubjectToStatus C_status, /**< Status of new active constraint. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Checks if new active constraint to be added is linearly dependent from - * from row of the active constraints matrix. - * \return RET_LINEARLY_DEPENDENT \n - RET_LINEARLY_INDEPENDENT \n - RET_INDEXLIST_CORRUPTED */ - returnValue addConstraint_checkLI( int number /**< Number of constraint to be added to active set. */ - ); - - /** Ensures linear independence of constraint matrix when a new constraint is added. - * To this end a bound or constraint is removed simultaneously if necessary. - * \return SUCCESSFUL_RETURN \n - RET_LI_RESOLVED \n - RET_ENSURELI_FAILED \n - RET_ENSURELI_FAILED_TQ \n - RET_ENSURELI_FAILED_NOINDEX \n - RET_REMOVE_FROM_ACTIVESET */ - returnValue addConstraint_ensureLI( int number, /**< Number of constraint to be added to active set. */ - SubjectToStatus C_status /**< Status of new active bound. */ - ); - - /** Adds a bound to active set. - * \return SUCCESSFUL_RETURN \n - RET_ADDBOUND_FAILED \n - RET_ADDBOUND_FAILED_INFEASIBILITY \n - RET_ENSURELI_FAILED */ - returnValue addBound( int number, /**< Number of bound to be added to active set. */ - SubjectToStatus B_status, /**< Status of new active bound. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Checks if new active bound to be added is linearly dependent from - * from row of the active constraints matrix. - * \return RET_LINEARLY_DEPENDENT \n - RET_LINEARLY_INDEPENDENT */ - returnValue addBound_checkLI( int number /**< Number of bound to be added to active set. */ - ); - - /** Ensures linear independence of constraint matrix when a new bound is added. - * To this end a bound or constraint is removed simultaneously if necessary. - * \return SUCCESSFUL_RETURN \n - RET_LI_RESOLVED \n - RET_ENSURELI_FAILED \n - RET_ENSURELI_FAILED_TQ \n - RET_ENSURELI_FAILED_NOINDEX \n - RET_REMOVE_FROM_ACTIVESET */ - returnValue addBound_ensureLI( int number, /**< Number of bound to be added to active set. */ - SubjectToStatus B_status /**< Status of new active bound. */ - ); - - /** Removes a constraint from active set. - * \return SUCCESSFUL_RETURN \n - RET_CONSTRAINT_NOT_ACTIVE \n - RET_REMOVECONSTRAINT_FAILED \n - RET_HESSIAN_NOT_SPD */ - returnValue removeConstraint( int number, /**< Number of constraint to be removed from active set. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Removes a bounds from active set. - * \return SUCCESSFUL_RETURN \n - RET_BOUND_NOT_ACTIVE \n - RET_HESSIAN_NOT_SPD \n - RET_REMOVEBOUND_FAILED */ - returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - real_t* const a /**< Output: Solution vector */ - ); - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n - * Special variant for the case that this function is called from within "removeBound()". - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ - real_t* const a /**< Output: Solution vector */ - ); - - - /** Solves the system Ta = b or T^Ta = b where T is a reverse upper triangular matrix. - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveT( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - real_t* const a /**< Output: Solution vector */ - ); - - - /** Determines step direction of the shift of the QP data. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const real_t* const g_new, /**< New gradient vector. */ - const real_t* const lbA_new,/**< New lower constraints' bounds. */ - const real_t* const ubA_new,/**< New upper constraints' bounds. */ - const real_t* const lb_new, /**< New lower bounds. */ - const real_t* const ub_new, /**< New upper bounds. */ - real_t* const delta_g, /**< Output: Step direction of gradient vector. */ - real_t* const delta_lbA, /**< Output: Step direction of lower constraints' bounds. */ - real_t* const delta_ubA, /**< Output: Step direction of upper constraints' bounds. */ - real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ - real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ - BooleanType& Delta_bC_isZero,/**< Output: Indicates if active constraints' bounds are to be shifted. */ - BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ - ); - - /** Determines step direction of the homotopy path. - * \return SUCCESSFUL_RETURN \n - RET_STEPDIRECTION_FAILED_TQ \n - RET_STEPDIRECTION_FAILED_CHOLESKY */ - returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - BooleanType Delta_bC_isZero, /**< Indicates if active constraints' bounds are to be shifted. */ - BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ - real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ - real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ - real_t* const delta_yAC, /**< Output: Dual homotopy step direction of active constraints' multiplier. */ - real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ - ); - - /** Determines the maximum possible step length along the homotopy path. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const int* const IAC_idx, /**< Index array of inactive constraints. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - real_t* const delta_Ax, /**< Output: Step in vector Ax. */ - int& BC_idx, /**< Output: Index of blocking constraint. */ - SubjectToStatus& BC_status, /**< Output: Status of blocking constraint. */ - BooleanType& BC_isBound /**< Output: Indicates if blocking constraint is a bound. */ - ); - - /** Performs a step along the homotopy path (and updates active set). - * \return SUCCESSFUL_RETURN \n - RET_OPTIMAL_SOLUTION_FOUND \n - RET_REMOVE_FROM_ACTIVESET_FAILED \n - RET_ADD_TO_ACTIVESET_FAILED \n - RET_QP_INFEASIBLE */ - returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const int* const AC_idx, /**< Index array of active constraints. */ - const int* const IAC_idx, /**< Index array of inactive constraints. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - const real_t* const delta_Ax, /**< Step in vector Ax. */ - int BC_idx, /**< Index of blocking constraint. */ - SubjectToStatus BC_status, /**< Status of blocking constraint. */ - BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ - ); - - - /** Checks if lower/upper (constraints') bounds remain consistent - * (i.e. if lb <= ub and lbA <= ubA ) during the current step. - * \return BT_TRUE iff (constraints") bounds remain consistent - */ - BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ - const real_t* const delta_ubA /**< Step direction of upper constraints' bounds. */ - ) const; - - - /** Setups internal QP data. - * \return SUCCESSFUL_RETURN \n - RET_INVALID_ARGUMENTS */ - returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _A, /**< Constraint matrix. */ - const real_t* const _lb, /**< Lower bound vector (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bound vector (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - const real_t* const _lbA, /**< Lower constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - const real_t* const _ubA /**< Upper constraints' bound vector. \n - If no lower constraints' bounds exist, a NULL pointer can be passed. */ - ); - - - #ifdef PC_DEBUG /* Define print functions only for debugging! */ - - /** Prints concise information on the current iteration. - * \return SUCCESSFUL_RETURN \n */ - returnValue printIteration( int iteration, /**< Number of current iteration. */ - int BC_idx, /**< Index of blocking constraint. */ - SubjectToStatus BC_status, /**< Status of blocking constraint. */ - BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ - ); - - /** Prints concise information on the current iteration. - * NOTE: ONLY DEFINED FOR SUPPRESSING A COMPILER WARNING!! - * \return SUCCESSFUL_RETURN \n */ - returnValue printIteration( int iteration, /**< Number of current iteration. */ - int BC_idx, /**< Index of blocking bound. */ - SubjectToStatus BC_status /**< Status of blocking bound. */ - ); - - #endif /* PC_DEBUG */ - - - /** Determines the maximum violation of the KKT optimality conditions - * of the current iterate within the QProblem object. - * \return SUCCESSFUL_RETURN \n - * RET_INACCURATE_SOLUTION \n - * RET_NO_SOLUTION */ - returnValue checkKKTconditions( ); - - - /** Sets constraint matrix of the QP. \n - (Remark: Also internal vector Ax is recomputed!) - * \return SUCCESSFUL_RETURN */ - inline returnValue setA( const real_t* const A_new /**< New constraint matrix (with correct dimension!). */ - ); - - /** Changes single row of constraint matrix of the QP. \n - (Remark: Also correponding component of internal vector Ax is recomputed!) - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setA( int number, /**< Number of row to be changed. */ - const real_t* const value /**< New (number)th constraint (with correct dimension!). */ - ); - - - /** Sets constraints' lower bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setLBA( const real_t* const lbA_new /**< New constraints' lower bound vector (with correct dimension!). */ - ); - - /** Changes single entry of lower constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setLBA( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of lower constraints' bound vector (with correct dimension!). */ - ); - - /** Sets constraints' upper bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setUBA( const real_t* const ubA_new /**< New constraints' upper bound vector (with correct dimension!). */ - ); - - /** Changes single entry of upper constraints' bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setUBA( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of upper constraints' bound vector (with correct dimension!). */ - ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - real_t A[NCMAX_ALLOC*NVMAX]; /**< Constraint matrix. */ - real_t lbA[NCMAX_ALLOC]; /**< Lower constraints' bound vector. */ - real_t ubA[NCMAX_ALLOC]; /**< Upper constraints' bound vector. */ - - Constraints constraints; /**< Data structure for problem's constraints. */ - - real_t T[NVMAX*NVMAX]; /**< Reverse triangular matrix, A = [0 T]*Q'. */ - real_t Q[NVMAX*NVMAX]; /**< Orthonormal quadratic matrix, A = [0 T]*Q'. */ - int sizeT; /**< Matrix T is stored in a (sizeT x sizeT) array. */ - - real_t Ax[NCMAX_ALLOC]; /**< Stores the current product A*x (for increased efficiency only). */ - - CyclingManager cyclingManager; /**< Data structure for storing (possible) cycling information (NOT YET IMPLEMENTED!). */ -}; - - -#include - -#endif /* QPOASES_QPROBLEM_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/QProblemB.hpp b/phonelibs/qpoases/INCLUDE/QProblemB.hpp deleted file mode 100644 index 49ace9ef9..000000000 --- a/phonelibs/qpoases/INCLUDE/QProblemB.hpp +++ /dev/null @@ -1,628 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/QProblemB.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the QProblemB class which is able to use the newly - * developed online active set strategy for parametric quadratic programming - * for problems with (simple) bounds only. - */ - - - -#ifndef QPOASES_QPROBLEMB_HPP -#define QPOASES_QPROBLEMB_HPP - - -#include - - - -class SolutionAnalysis; - -/** Class for setting up and solving quadratic programs with (simple) bounds only. - * The main feature is the possibily to use the newly developed online active set strategy - * for parametric quadratic programming. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class QProblemB -{ - /* allow SolutionAnalysis class to access private members */ - friend class SolutionAnalysis; - - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - QProblemB( ); - - /** Constructor which takes the QP dimension only. */ - QProblemB( int _nV /**< Number of variables. */ - ); - - /** Copy constructor (deep copy). */ - QProblemB( const QProblemB& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~QProblemB( ); - - /** Assignment operator (deep copy). */ - QProblemB& operator=( const QProblemB& rhs /**< Rhs object. */ - ); - - - /** Clears all data structures of QProblemB except for QP data. - * \return SUCCESSFUL_RETURN \n - RET_RESET_FAILED */ - returnValue reset( ); - - - /** Initialises a QProblemB with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _lb, /**< Lower bounds (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bounds (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Initialises a QProblemB with given QP data and solves it - * using an initial homotopy with empty working set (at most nWSR iterations). - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED \n - RET_INVALID_ARGUMENTS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue init( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _lb, /**< Lower bounds (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub, /**< Upper bounds (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n - Output: Number of performed working set recalculations. */ - const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ - real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ - ); - - - /** Solves an initialised QProblemB using online active set strategy. - * \return SUCCESSFUL_RETURN \n - RET_MAX_NWSR_REACHED \n - RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n - RET_HOTSTART_FAILED \n - RET_SHIFT_DETERMINATION_FAILED \n - RET_STEPDIRECTION_DETERMINATION_FAILED \n - RET_STEPLENGTH_DETERMINATION_FAILED \n - RET_HOMOTOPY_STEP_FAILED \n - RET_HOTSTART_STOPPED_INFEASIBILITY \n - RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n - RET_INACCURATE_SOLUTION \n - RET_NO_SOLUTION */ - returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ - const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n - If no upper bounds exist, a NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - - /** Returns Hessian matrix of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getH( real_t* const _H /**< Array of appropriate dimension for copying Hessian matrix.*/ - ) const; - - /** Returns gradient vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getG( real_t* const _g /**< Array of appropriate dimension for copying gradient vector.*/ - ) const; - - /** Returns lower bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getLB( real_t* const _lb /**< Array of appropriate dimension for copying lower bound vector.*/ - ) const; - - /** Returns single entry of lower bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getLB( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: lb[number].*/ - ) const; - - /** Returns upper bound vector of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getUB( real_t* const _ub /**< Array of appropriate dimension for copying upper bound vector.*/ - ) const; - - /** Returns single entry of upper bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue getUB( int number, /**< Number of entry to be returned. */ - real_t& value /**< Output: ub[number].*/ - ) const; - - - /** Returns current bounds object of the QP (deep copy). - * \return SUCCESSFUL_RETURN */ - inline returnValue getBounds( Bounds* const _bounds /** Output: Bounds object. */ - ) const; - - - /** Returns the number of variables. - * \return Number of variables. */ - inline int getNV( ) const; - - /** Returns the number of free variables. - * \return Number of free variables. */ - inline int getNFR( ); - - /** Returns the number of fixed variables. - * \return Number of fixed variables. */ - inline int getNFX( ); - - /** Returns the number of implicitly fixed variables. - * \return Number of implicitly fixed variables. */ - inline int getNFV( ) const; - - /** Returns the dimension of null space. - * \return Dimension of null space. */ - int getNZ( ); - - - /** Returns the optimal objective function value. - * \return finite value: Optimal objective function value (QP was solved) \n - +infinity: QP was not yet solved */ - real_t getObjVal( ) const; - - /** Returns the objective function value at an arbitrary point x. - * \return Objective function value at point x */ - real_t getObjVal( const real_t* const _x /**< Point at which the objective function shall be evaluated. */ - ) const; - - /** Returns the primal solution vector. - * \return SUCCESSFUL_RETURN \n - RET_QP_NOT_SOLVED */ - returnValue getPrimalSolution( real_t* const xOpt /**< Output: Primal solution vector (if QP has been solved). */ - ) const; - - /** Returns the dual solution vector. - * \return SUCCESSFUL_RETURN \n - RET_QP_NOT_SOLVED */ - returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ - ) const; - - - /** Returns status of the solution process. - * \return Status of solution process. */ - inline QProblemStatus getStatus( ) const; - - - /** Returns if the QProblem object is initialised. - * \return BT_TRUE: QProblemB initialised \n - BT_FALSE: QProblemB not initialised */ - inline BooleanType isInitialised( ) const; - - /** Returns if the QP has been solved. - * \return BT_TRUE: QProblemB solved \n - BT_FALSE: QProblemB not solved */ - inline BooleanType isSolved( ) const; - - /** Returns if the QP is infeasible. - * \return BT_TRUE: QP infeasible \n - BT_FALSE: QP feasible (or not known to be infeasible!) */ - inline BooleanType isInfeasible( ) const; - - /** Returns if the QP is unbounded. - * \return BT_TRUE: QP unbounded \n - BT_FALSE: QP unbounded (or not known to be unbounded!) */ - inline BooleanType isUnbounded( ) const; - - - /** Returns the print level. - * \return Print level. */ - inline PrintLevel getPrintLevel( ) const; - - /** Changes the print level. - * \return SUCCESSFUL_RETURN */ - returnValue setPrintLevel( PrintLevel _printlevel /**< New print level. */ - ); - - - /** Returns Hessian type flag (type is not determined due to this call!). - * \return Hessian type. */ - inline HessianType getHessianType( ) const; - - /** Changes the print level. - * \return SUCCESSFUL_RETURN */ - inline returnValue setHessianType( HessianType _hessianType /**< New Hessian type. */ - ); - - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Checks if Hessian happens to be the identity matrix, - * and sets corresponding status flag (otherwise the flag remains unaltered!). - * \return SUCCESSFUL_RETURN */ - returnValue checkForIdentityHessian( ); - - /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). - * \return SUCCESSFUL_RETURN \n - RET_SETUPSUBJECTTOTYPE_FAILED */ - returnValue setupSubjectToType( ); - - /** Computes the Cholesky decomposition R of the (simply projected) Hessian (i.e. R^T*R = Z^T*H*Z). - * It only works in the case where Z is a simple projection matrix! - * \return SUCCESSFUL_RETURN \n - * RET_INDEXLIST_CORRUPTED */ - returnValue setupCholeskyDecomposition( ); - - - /** Solves a QProblemB whose QP data is assumed to be stored in the member variables. - * A guess for its primal/dual optimal solution vectors and the corresponding - * optimal working set can be provided. - * \return SUCCESSFUL_RETURN \n - RET_INIT_FAILED \n - RET_INIT_FAILED_CHOLESKY \n - RET_INIT_FAILED_HOTSTART \n - RET_INIT_FAILED_INFEASIBILITY \n - RET_INIT_FAILED_UNBOUNDEDNESS \n - RET_MAX_NWSR_REACHED */ - returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. - * A NULL pointer can be passed. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * A NULL pointer can be passed. */ - const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). - * A NULL pointer can be passed. */ - int& nWSR, /**< Input: Maximum number of working set recalculations; \n - * Output: Number of performed working set recalculations. */ - real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ - ); - - - /** Obtains the desired working set for the auxiliary initial QP in - * accordance with the user specifications - * \return SUCCESSFUL_RETURN \n - RET_OBTAINING_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS */ - returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const real_t* const yOpt, /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are assumed to be zero. */ - const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). */ - Bounds* auxiliaryBounds /**< Input: Allocated bound object. \n - * Ouput: Working set for auxiliary QP. */ - ) const; - - /** Setups bound data structure according to auxiliaryBounds. - * (If the working set shall be setup afresh, make sure that - * bounds data structure has been resetted!) - * \return SUCCESSFUL_RETURN \n - RET_SETUP_WORKINGSET_FAILED \n - RET_INVALID_ARGUMENTS \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set for auxiliary QP. */ - BooleanType setupAfresh /**< Flag indicating if given working set shall be - * setup afresh or by updating the current one. */ - ); - - /** Setups the optimal primal/dual solution of the auxiliary initial QP. - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - const real_t* const yOpt /**< Optimal dual solution vector. - * If a NULL pointer is passed, all entries are set to zero. */ - ); - - /** Setups gradient of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS have already been initialised!). - * \return SUCCESSFUL_RETURN */ - returnValue setupAuxiliaryQPgradient( ); - - /** Setups bounds of the auxiliary initial QP for given - * optimal primal/dual solution and given initial working set - * (assumes that members X, Y and BOUNDS have already been initialised!). - * \return SUCCESSFUL_RETURN \n - RET_UNKNOWN BUG */ - returnValue setupAuxiliaryQPbounds( BooleanType useRelaxation /**< Flag indicating if inactive bounds shall be relaxed. */ - ); - - - /** Adds a bound to active set (specialised version for the case where no constraints exist). - * \return SUCCESSFUL_RETURN \n - RET_ADDBOUND_FAILED */ - returnValue addBound( int number, /**< Number of bound to be added to active set. */ - SubjectToStatus B_status, /**< Status of new active bound. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - /** Removes a bounds from active set (specialised version for the case where no constraints exist). - * \return SUCCESSFUL_RETURN \n - RET_HESSIAN_NOT_SPD \n - RET_REMOVEBOUND_FAILED */ - returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ - BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ - ); - - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - real_t* const a /**< Output: Solution vector */ - ); - - /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n - * Special variant for the case that this function is called from within "removeBound()". - * \return SUCCESSFUL_RETURN \n - RET_DIV_BY_ZERO */ - returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ - BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ - BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ - real_t* const a /**< Output: Solution vector */ - ); - - - /** Determines step direction of the shift of the QP data. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const g_new, /**< New gradient vector. */ - const real_t* const lb_new, /**< New lower bounds. */ - const real_t* const ub_new, /**< New upper bounds. */ - real_t* const delta_g, /**< Output: Step direction of gradient vector. */ - real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ - real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ - BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ - ); - - - /** Checks if lower/upper bounds remain consistent - * (i.e. if lb <= ub) during the current step. - * \return BT_TRUE iff bounds remain consistent - */ - BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub /**< Step direction of upper bounds. */ - ) const; - - - /** Setups internal QP data. - * \return SUCCESSFUL_RETURN \n - RET_INVALID_ARGUMENTS */ - returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ - const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ - const real_t* const _g, /**< Gradient vector. */ - const real_t* const _lb, /**< Lower bounds (on variables). \n - If no lower bounds exist, a NULL pointer can be passed. */ - const real_t* const _ub /**< Upper bounds (on variables). \n - If no upper bounds exist, a NULL pointer can be passed. */ - ); - - - /** Sets Hessian matrix of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setH( const real_t* const H_new /**< New Hessian matrix (with correct dimension!). */ - ); - - /** Changes gradient vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setG( const real_t* const g_new /**< New gradient vector (with correct dimension!). */ - ); - - /** Changes lower bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setLB( const real_t* const lb_new /**< New lower bound vector (with correct dimension!). */ - ); - - /** Changes single entry of lower bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setLB( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of lower bound vector. */ - ); - - /** Changes upper bound vector of the QP. - * \return SUCCESSFUL_RETURN */ - inline returnValue setUB( const real_t* const ub_new /**< New upper bound vector (with correct dimension!). */ - ); - - /** Changes single entry of upper bound vector of the QP. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setUB( int number, /**< Number of entry to be changed. */ - real_t value /**< New value for entry of upper bound vector. */ - ); - - - /** Computes parameters for the Givens matrix G for which [x,y]*G = [z,0] - * \return SUCCESSFUL_RETURN */ - inline void computeGivens( real_t xold, /**< Matrix entry to be normalised. */ - real_t yold, /**< Matrix entry to be annihilated. */ - real_t& xnew, /**< Output: Normalised matrix entry. */ - real_t& ynew, /**< Output: Annihilated matrix entry. */ - real_t& c, /**< Output: Cosine entry of Givens matrix. */ - real_t& s /**< Output: Sine entry of Givens matrix. */ - ) const; - - /** Applies Givens matrix determined by c and s (cf. computeGivens). - * \return SUCCESSFUL_RETURN */ - inline void applyGivens( real_t c, /**< Cosine entry of Givens matrix. */ - real_t s, /**< Sine entry of Givens matrix. */ - real_t xold, /**< Matrix entry to be transformed corresponding to - * the normalised entry of the original matrix. */ - real_t yold, /**< Matrix entry to be transformed corresponding to - * the annihilated entry of the original matrix. */ - real_t& xnew, /**< Output: Transformed matrix entry corresponding to - * the normalised entry of the original matrix. */ - real_t& ynew /**< Output: Transformed matrix entry corresponding to - * the annihilated entry of the original matrix. */ - ) const; - - - /* - * PRIVATE MEMBER FUNCTIONS - */ - private: - /** Determines step direction of the homotopy path. - * \return SUCCESSFUL_RETURN \n - RET_STEPDIRECTION_FAILED_CHOLESKY */ - returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ - real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ - real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ - real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ - ); - - /** Determines the maximum possible step length along the homotopy path. - * \return SUCCESSFUL_RETURN */ - returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - int& BC_idx, /**< Output: Index of blocking constraint. */ - SubjectToStatus& BC_status /**< Output: Status of blocking constraint. */ - ); - - /** Performs a step along the homotopy path (and updates active set). - * \return SUCCESSFUL_RETURN \n - RET_OPTIMAL_SOLUTION_FOUND \n - RET_REMOVE_FROM_ACTIVESET_FAILED \n - RET_ADD_TO_ACTIVESET_FAILED \n - RET_QP_INFEASIBLE */ - returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ - const int* const FX_idx, /**< Index array of fixed variables. */ - const real_t* const delta_g, /**< Step direction of gradient vector. */ - const real_t* const delta_lb, /**< Step direction of lower bounds. */ - const real_t* const delta_ub, /**< Step direction of upper bounds. */ - const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ - const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ - const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ - int BC_idx, /**< Index of blocking constraint. */ - SubjectToStatus BC_status /**< Status of blocking constraint. */ - ); - - - #ifdef PC_DEBUG /* Define print functions only for debugging! */ - - /** Prints concise information on the current iteration. - * \return SUCCESSFUL_RETURN \n */ - returnValue printIteration( int iteration, /**< Number of current iteration. */ - int BC_idx, /**< Index of blocking bound. */ - SubjectToStatus BC_status /**< Status of blocking bound. */ - ); - - #endif /* PC_DEBUG */ - - - /** Determines the maximum violation of the KKT optimality conditions - * of the current iterate within the QProblemB object. - * \return SUCCESSFUL_RETURN \n - * RET_INACCURATE_SOLUTION \n - * RET_NO_SOLUTION */ - returnValue checkKKTconditions( ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - real_t H[NVMAX*NVMAX]; /**< Hessian matrix. */ - BooleanType hasHessian; /**< Flag indicating whether H contains Hessian or corresponding Cholesky factor R; \sa init. */ - - real_t g[NVMAX]; /**< Gradient. */ - real_t lb[NVMAX]; /**< Lower bound vector (on variables). */ - real_t ub[NVMAX]; /**< Upper bound vector (on variables). */ - - Bounds bounds; /**< Data structure for problem's bounds. */ - - real_t R[NVMAX*NVMAX]; /**< Cholesky decomposition of H (i.e. H = R^T*R). */ - BooleanType hasCholesky; /**< Flag indicating whether Cholesky decomposition has already been setup. */ - - real_t x[NVMAX]; /**< Primal solution vector. */ - real_t y[NVMAX+NCMAX]; /**< Dual solution vector. */ - - real_t tau; /**< Last homotopy step length. */ - - QProblemStatus status; /**< Current status of the solution process. */ - - BooleanType infeasible; /**< QP infeasible? */ - BooleanType unbounded; /**< QP unbounded? */ - - HessianType hessianType; /**< Type of Hessian matrix. */ - - PrintLevel printlevel; /**< Print level. */ - - int count; /**< Counts the number of hotstart function calls (internal usage only!). */ -}; - - -#include - -#endif /* QPOASES_QPROBLEMB_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/SubjectTo.hpp b/phonelibs/qpoases/INCLUDE/SubjectTo.hpp deleted file mode 100644 index e07bf0421..000000000 --- a/phonelibs/qpoases/INCLUDE/SubjectTo.hpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/SubjectTo.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of the SubjectTo class designed to manage working sets of - * constraints and bounds within a QProblem. - */ - - -#ifndef QPOASES_SUBJECTTO_HPP -#define QPOASES_SUBJECTTO_HPP - - -#include - - - -/** This class manages working sets of constraints and bounds by storing - * index sets and other status information. - * - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - */ -class SubjectTo -{ - /* - * PUBLIC MEMBER FUNCTIONS - */ - public: - /** Default constructor. */ - SubjectTo( ); - - /** Copy constructor (deep copy). */ - SubjectTo( const SubjectTo& rhs /**< Rhs object. */ - ); - - /** Destructor. */ - ~SubjectTo( ); - - /** Assignment operator (deep copy). */ - SubjectTo& operator=( const SubjectTo& rhs /**< Rhs object. */ - ); - - - /** Pseudo-constructor takes the number of constraints or bounds. - * \return SUCCESSFUL_RETURN */ - returnValue init( int n /**< Number of constraints or bounds. */ - ); - - - /** Returns type of (constraints') bound. - * \return Type of (constraints') bound \n - RET_INDEX_OUT_OF_BOUNDS */ - inline SubjectToType getType( int i /**< Number of (constraints') bound. */ - ) const ; - - /** Returns status of (constraints') bound. - * \return Status of (constraints') bound \n - ST_UNDEFINED */ - inline SubjectToStatus getStatus( int i /**< Number of (constraints') bound. */ - ) const; - - - /** Sets type of (constraints') bound. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setType( int i, /**< Number of (constraints') bound. */ - SubjectToType value /**< Type of (constraints') bound. */ - ); - - /** Sets status of (constraints') bound. - * \return SUCCESSFUL_RETURN \n - RET_INDEX_OUT_OF_BOUNDS */ - inline returnValue setStatus( int i, /**< Number of (constraints') bound. */ - SubjectToStatus value /**< Status of (constraints') bound. */ - ); - - - /** Sets status of lower (constraints') bounds. */ - inline void setNoLower( BooleanType _status /**< Status of lower (constraints') bounds. */ - ); - - /** Sets status of upper (constraints') bounds. */ - inline void setNoUpper( BooleanType _status /**< Status of upper (constraints') bounds. */ - ); - - - /** Returns status of lower (constraints') bounds. - * \return BT_TRUE if there is no lower (constraints') bound on any variable. */ - inline BooleanType isNoLower( ) const; - - /** Returns status of upper bounds. - * \return BT_TRUE if there is no upper (constraints') bound on any variable. */ - inline BooleanType isNoUpper( ) const; - - - /* - * PROTECTED MEMBER FUNCTIONS - */ - protected: - /** Adds the index of a new constraint or bound to index set. - * \return SUCCESSFUL_RETURN \n - RET_ADDINDEX_FAILED */ - returnValue addIndex( Indexlist* const indexlist, /**< Index list to which the new index shall be added. */ - int newnumber, /**< Number of new constraint or bound. */ - SubjectToStatus newstatus /**< Status of new constraint or bound. */ - ); - - /** Removes the index of a constraint or bound from index set. - * \return SUCCESSFUL_RETURN \n - RET_UNKNOWN_BUG */ - returnValue removeIndex( Indexlist* const indexlist, /**< Index list from which the new index shall be removed. */ - int removenumber /**< Number of constraint or bound to be removed. */ - ); - - /** Swaps the indices of two constraints or bounds within the index set. - * \return SUCCESSFUL_RETURN \n - RET_SWAPINDEX_FAILED */ - returnValue swapIndex( Indexlist* const indexlist, /**< Index list in which the indices shold be swapped. */ - int number1, /**< Number of first constraint or bound. */ - int number2 /**< Number of second constraint or bound. */ - ); - - - /* - * PROTECTED MEMBER VARIABLES - */ - protected: - SubjectToType type[NVMAX+NCMAX]; /**< Type of constraints/bounds. */ - SubjectToStatus status[NVMAX+NCMAX]; /**< Status of constraints/bounds. */ - - BooleanType noLower; /**< This flag indicates if there is no lower bound on any variable. */ - BooleanType noUpper; /**< This flag indicates if there is no upper bound on any variable. */ - - - /* - * PRIVATE MEMBER VARIABLES - */ - private: - int size; -}; - - - -#include - -#endif /* QPOASES_SUBJECTTO_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/Types.hpp b/phonelibs/qpoases/INCLUDE/Types.hpp deleted file mode 100644 index 5b873ad07..000000000 --- a/phonelibs/qpoases/INCLUDE/Types.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Types.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2008 - * - * Declaration of all non-built-in types (except for classes). - */ - - -#ifndef QPOASES_TYPES_HPP -#define QPOASES_TYPES_HPP - - - -/** Define real_t for facilitating switching between double and float. */ -// typedef double real_t; - - -/** Summarises all possible logical values. */ -enum BooleanType -{ - BT_FALSE, /**< Logical value for "false". */ - BT_TRUE /**< Logical value for "true". */ -}; - - -/** Summarises all possible print levels. Print levels are used to describe - * the desired amount of output during runtime of qpOASES. */ -enum PrintLevel -{ - PL_NONE, /**< No output. */ - PL_LOW, /**< Print error messages only. */ - PL_MEDIUM, /**< Print error and warning messages as well as concise info messages. */ - PL_HIGH /**< Print all messages with full details. */ -}; - - -/** Defines visibility status of a message. */ -enum VisibilityStatus -{ - VS_VISIBLE, /**< Message visible. */ - VS_HIDDEN /**< Message not visible. */ -}; - - -/** Summarises all possible states of the (S)QProblem(B) object during the -solution process of a QP sequence. */ -enum QProblemStatus -{ - QPS_NOTINITIALISED, /**< QProblem object is freshly instantiated or reset. */ - QPS_PREPARINGAUXILIARYQP, /**< An auxiliary problem is currently setup, either at the very beginning - * via an initial homotopy or after changing the QP matrices. */ - QPS_AUXILIARYQPSOLVED, /**< An auxilary problem was solved, either at the very beginning - * via an initial homotopy or after changing the QP matrices. */ - QPS_PERFORMINGHOMOTOPY, /**< A homotopy according to the main idea of the online active - * set strategy is performed. */ - QPS_HOMOTOPYQPSOLVED, /**< An intermediate QP along the homotopy path was solved. */ - QPS_SOLVED /**< The solution of the actual QP was found. */ -}; - - -/** Summarises all possible types of bounds and constraints. */ -enum SubjectToType -{ - ST_UNBOUNDED, /**< Bound/constraint is unbounded. */ - ST_BOUNDED, /**< Bound/constraint is bounded but not fixed. */ - ST_EQUALITY, /**< Bound/constraint is fixed (implicit equality bound/constraint). */ - ST_UNKNOWN /**< Type of bound/constraint unknown. */ -}; - - -/** Summarises all possible states of bounds and constraints. */ -enum SubjectToStatus -{ - ST_INACTIVE, /**< Bound/constraint is inactive. */ - ST_LOWER, /**< Bound/constraint is at its lower bound. */ - ST_UPPER, /**< Bound/constraint is at its upper bound. */ - ST_UNDEFINED /**< Status of bound/constraint undefined. */ -}; - - -/** Summarises all possible cycling states of bounds and constraints. */ -enum CyclingStatus -{ - CYC_NOT_INVOLVED, /**< Bound/constraint is not involved in current cycling. */ - CYC_PREV_ADDED, /**< Bound/constraint has previously been added during the current cycling. */ - CYC_PREV_REMOVED /**< Bound/constraint has previously been removed during the current cycling. */ -}; - - -/** Summarises all possible types of the QP's Hessian matrix. */ -enum HessianType -{ - HST_SEMIDEF, /**< Hessian is positive semi-definite. */ - HST_POSDEF_NULLSPACE, /**< Hessian is positive definite on null space of active bounds/constraints. */ - HST_POSDEF, /**< Hessian is (strictly) positive definite. */ - HST_IDENTITY /**< Hessian is identity matrix. */ -}; - - - -#endif /* QPOASES_TYPES_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/INCLUDE/Utils.hpp b/phonelibs/qpoases/INCLUDE/Utils.hpp deleted file mode 100644 index a91ee78cc..000000000 --- a/phonelibs/qpoases/INCLUDE/Utils.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file INCLUDE/Utils.hpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of global utility functions for working with qpOASES. - */ - - -#ifndef QPOASES_UTILS_HPP -#define QPOASES_UTILS_HPP - - -#include - - -#ifdef PC_DEBUG /* Define print functions only for debugging! */ - -/** Prints a vector. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const v, /**< Vector to be printed. */ - int n /**< Length of vector. */ - ); - -/** Prints a permuted vector. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const v, /**< Vector to be printed. */ - int n, /**< Length of vector. */ - const int* const V_idx /**< Pemutation vector. */ - ); - -/** Prints a named vector. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const v, /**< Vector to be printed. */ - int n, /**< Length of vector. */ - const char* name /** Name of vector. */ - ); - -/** Prints a matrix. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const M, /**< Matrix to be printed. */ - int nrow, /**< Row number of matrix. */ - int ncol /**< Column number of matrix. */ - ); - -/** Prints a permuted matrix. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const M, /**< Matrix to be printed. */ - int nrow, /**< Row number of matrix. */ - int ncol , /**< Column number of matrix. */ - const int* const ROW_idx, /**< Row pemutation vector. */ - const int* const COL_idx /**< Column pemutation vector. */ - ); - -/** Prints a named matrix. - * \return SUCCESSFUL_RETURN */ -returnValue print( const real_t* const M, /**< Matrix to be printed. */ - int nrow, /**< Row number of matrix. */ - int ncol, /**< Column number of matrix. */ - const char* name /** Name of matrix. */ - ); - -/** Prints an index array. - * \return SUCCESSFUL_RETURN */ -returnValue print( const int* const index, /**< Index array to be printed. */ - int n /**< Length of index array. */ - ); - -/** Prints a named index array. - * \return SUCCESSFUL_RETURN */ -returnValue print( const int* const index, /**< Index array to be printed. */ - int n, /**< Length of index array. */ - const char* name /**< Name of index array. */ - ); - - -/** Prints a string to desired output target (useful also for MATLAB output!). - * \return SUCCESSFUL_RETURN */ -returnValue myPrintf( const char* s /**< String to be written. */ - ); - - -/** Prints qpOASES copyright notice. - * \return SUCCESSFUL_RETURN */ -returnValue printCopyrightNotice( ); - - -/** Reads a real_t matrix from file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE \n - RET_UNABLE_TO_READ_FILE */ -returnValue readFromFile( real_t* data, /**< Matrix to be read from file. */ - int nrow, /**< Row number of matrix. */ - int ncol, /**< Column number of matrix. */ - const char* datafilename /**< Data file name. */ - ); - -/** Reads a real_t vector from file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE \n - RET_UNABLE_TO_READ_FILE */ -returnValue readFromFile( real_t* data, /**< Vector to be read from file. */ - int n, /**< Length of vector. */ - const char* datafilename /**< Data file name. */ - ); - -/** Reads an integer (column) vector from file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE \n - RET_UNABLE_TO_READ_FILE */ -returnValue readFromFile( int* data, /**< Vector to be read from file. */ - int n, /**< Length of vector. */ - const char* datafilename /**< Data file name. */ - ); - - -/** Writes a real_t matrix into a file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE */ -returnValue writeIntoFile( const real_t* const data, /**< Matrix to be written into file. */ - int nrow, /**< Row number of matrix. */ - int ncol, /**< Column number of matrix. */ - const char* datafilename, /**< Data file name. */ - BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ - ); - -/** Writes a real_t vector into a file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE */ -returnValue writeIntoFile( const real_t* const data, /**< Vector to be written into file. */ - int n, /**< Length of vector. */ - const char* datafilename, /**< Data file name. */ - BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ - ); - -/** Writes an integer (column) vector into a file. - * \return SUCCESSFUL_RETURN \n - RET_UNABLE_TO_OPEN_FILE */ -returnValue writeIntoFile( const int* const integer, /**< Integer vector to be written into file. */ - int n, /**< Length of vector. */ - const char* datafilename, /**< Data file name. */ - BooleanType append /**< Indicates if integer shall be appended if the file already exists (otherwise it is overwritten). */ - ); - -#endif /* PC_DEBUG */ - - -/** Returns the current system time. - * \return current system time */ -real_t getCPUtime( ); - - -/** Returns the Euclidean norm of a vector. - * \return 0: successful */ -real_t getNorm( const real_t* const v, /**< Vector. */ - int n /**< Vector's dimension. */ - ); - -/** Returns the absolute value of a real_t. - * \return Absolute value of a real_t */ -inline real_t getAbs( real_t x /**< Input argument. */ - ); - - - -#include - -#endif /* QPOASES_UTILS_HPP */ - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/LICENSE.txt b/phonelibs/qpoases/LICENSE.txt deleted file mode 100644 index 5ab7695ab..000000000 --- a/phonelibs/qpoases/LICENSE.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/phonelibs/qpoases/README.txt b/phonelibs/qpoases/README.txt deleted file mode 100644 index 53fc2ab4f..000000000 --- a/phonelibs/qpoases/README.txt +++ /dev/null @@ -1,92 +0,0 @@ -## -## qpOASES -- An Implementation of the Online Active Set Strategy. -## Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. -## -## qpOASES is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## qpOASES is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with qpOASES; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -## - - - -INTRODUCTION -============= - -qpOASES is an open-source C++ implementation of the recently proposed -online active set strategy (see [1], [2]), which was inspired by important -observations from the field of parametric quadratic programming. It has -several theoretical features that make it particularly suited for model -predictive control (MPC) applications. - -The software package qpOASES implements these ideas and has already been -successfully used for closed-loop control of a real-world Diesel engine [3]. - - -References: - -[1] H.J. Ferreau. An Online Active Set Strategy for Fast Solution of -Parametric Quadratic Programs with Applications to Predictive Engine Control. -Diplom thesis, University of Heidelberg, 2006. - -[2] H.J. Ferreau, H.G. Bock, M. Diehl. An online active set strategy to -overcome the limitations of explicit MPC. International Journal of Robust -and Nonlinear Control, 18 (8), pp. 816-830, 2008. - -[3] H.J. Ferreau, P. Ortner, P. Langthaler, L. del Re, M. Diehl. Predictive -Control of a Real-World Diesel Engine using an Extended Online Active Set -Strategy. Annual Reviews in Control, 31 (2), pp. 293-301, 2007. - - - -GETTING STARTED -================ - -1. For installation, usage and additional information on this software package - see the qpOASES User's Manual located at ./DOC/manual.pdf! - - -2. The file ./LICENSE.txt contains a copy of the GNU Lesser General Public - License. Please read it carefully before using qpOASES! - - -3. The whole software package can be downloaded from - - http://homes.esat.kuleuven.be/~optec/software/qpOASES/ - - On this webpage you will also find a list of frequently asked questions. - - - -CONTACT THE AUTHORS -==================== - -If you have got questions, remarks or comments on qpOASES -please contact the main author: - - Hans Joachim Ferreau - Katholieke Universiteit Leuven - Department of Electrical Engineering (ESAT) - Kasteelpark Arenberg 10, bus 2446 - B-3001 Leuven-Heverlee, Belgium - - Phone: +32 16 32 03 63 - E-mail: joachim.ferreau@esat.kuleuven.be - qpOASES@esat.kuleuven.be - -Also bug reports and source code extensions are most welcome! - - - -## -## end of file -## diff --git a/phonelibs/qpoases/SConscript b/phonelibs/qpoases/SConscript deleted file mode 100644 index 932dbc700..000000000 --- a/phonelibs/qpoases/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -Import('env', 'interface_dir') - -qp_files = [ - Glob("SRC/*.cpp"), - Glob("SRC/EXTRAS/*.cpp"), -] - -cpp_path = [ - ".", - "INCLUDE", - "INCLUDE/EXTRAS", - "SRC/", - interface_dir, -] - -env.Library('qpoases', qp_files, CPPPATH=cpp_path) diff --git a/phonelibs/qpoases/SRC/Bounds.cpp b/phonelibs/qpoases/SRC/Bounds.cpp deleted file mode 100644 index cf8ed6989..000000000 --- a/phonelibs/qpoases/SRC/Bounds.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Bounds.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the Bounds class designed to manage working sets of - * bounds within a QProblem. - */ - - -#include - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * B o u n d s - */ -Bounds::Bounds( ) : SubjectTo( ), - nV( 0 ), - nFV( 0 ), - nBV( 0 ), - nUV( 0 ) -{ -} - - -/* - * B o u n d s - */ -Bounds::Bounds( const Bounds& rhs ) : SubjectTo( rhs ), - nV( rhs.nV ), - nFV( rhs.nFV ), - nBV( rhs.nBV ), - nUV( rhs.nUV ) -{ - free = rhs.free; - fixed = rhs.fixed; -} - - -/* - * ~ B o u n d s - */ -Bounds::~Bounds( ) -{ -} - - -/* - * o p e r a t o r = - */ -Bounds& Bounds::operator=( const Bounds& rhs ) -{ - if ( this != &rhs ) - { - SubjectTo::operator=( rhs ); - - nV = rhs.nV; - nFV = rhs.nFV; - nBV = rhs.nBV; - nUV = rhs.nUV; - - free = rhs.free; - fixed = rhs.fixed; - } - - return *this; -} - - -/* - * i n i t - */ -returnValue Bounds::init( int n ) -{ - nV = n; - nFV = 0; - nBV = 0; - nUV = 0; - - free.init( ); - fixed.init( ); - - return SubjectTo::init( n ); -} - - -/* - * s e t u p B o u n d - */ -returnValue Bounds::setupBound( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Add bound index to respective index list. */ - switch ( _status ) - { - case ST_INACTIVE: - if ( this->addIndex( this->getFree( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_BOUND_FAILED ); - break; - - case ST_LOWER: - if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_BOUND_FAILED ); - break; - - case ST_UPPER: - if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_BOUND_FAILED ); - break; - - default: - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A l l F r e e - */ -returnValue Bounds::setupAllFree( ) -{ - int i; - - /* 1) Place unbounded variables at the beginning of the index list of free variables. */ - for( i=0; i= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of fixed variables to that of free ones. */ - if ( this->removeIndex( this->getFixed( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getFree( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * m o v e F r e e T o F i x e d - */ -returnValue Bounds::moveFreeToFixed( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of free variables to that of fixed ones. */ - if ( this->removeIndex( this->getFree( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * s w a p F r e e - */ -returnValue Bounds::swapFree( int number1, int number2 - ) -{ - /* consistency check */ - if ( ( number1 < 0 ) || ( number1 >= getNV( ) ) || ( number2 < 0 ) || ( number2 >= getNV( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Swap index within indexlist of free variables. */ - return this->swapIndex( this->getFree( ),number1,number2 ); -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/Bounds.ipp b/phonelibs/qpoases/SRC/Bounds.ipp deleted file mode 100644 index d2ab1ba2d..000000000 --- a/phonelibs/qpoases/SRC/Bounds.ipp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Bounds.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the Bounds class designed - * to manage working sets of bounds within a QProblem. - */ - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t N V - */ -inline int Bounds::getNV( ) const -{ - return nV; -} - - -/* - * g e t N F X - */ -inline int Bounds::getNFV( ) const -{ - return nFV; -} - - -/* - * g e t N B V - */ -inline int Bounds::getNBV( ) const -{ - return nBV; -} - - -/* - * g e t N U V - */ -inline int Bounds::getNUV( ) const -{ - return nUV; -} - - - -/* - * s e t N F X - */ -inline returnValue Bounds::setNFV( int n ) -{ - nFV = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N B V - */ -inline returnValue Bounds::setNBV( int n ) -{ - nBV = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N U V - */ -inline returnValue Bounds::setNUV( int n ) -{ - nUV = n; - return SUCCESSFUL_RETURN; -} - - -/* - * g e t N F R - */ -inline int Bounds::getNFR( ) -{ - return free.getLength( ); -} - - -/* - * g e t N F X - */ -inline int Bounds::getNFX( ) -{ - return fixed.getLength( ); -} - - -/* - * g e t F r e e - */ -inline Indexlist* Bounds::getFree( ) -{ - return &free; -} - - -/* - * g e t F i x e d - */ -inline Indexlist* Bounds::getFixed( ) -{ - return &fixed; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/Constraints.cpp b/phonelibs/qpoases/SRC/Constraints.cpp deleted file mode 100644 index b2ad5bd11..000000000 --- a/phonelibs/qpoases/SRC/Constraints.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Constraints.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the Constraints class designed to manage working sets of - * constraints within a QProblem. - */ - - -#include - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * C o n s t r a i n t s - */ -Constraints::Constraints( ) : SubjectTo( ), - nC( 0 ), - nEC( 0 ), - nIC( 0 ), - nUC( 0 ) -{ -} - - -/* - * C o n s t r a i n t s - */ -Constraints::Constraints( const Constraints& rhs ) : SubjectTo( rhs ), - nC( rhs.nC ), - nEC( rhs.nEC ), - nIC( rhs.nIC ), - nUC( rhs.nUC ) -{ - active = rhs.active; - inactive = rhs.inactive; -} - - -/* - * ~ C o n s t r a i n t s - */ -Constraints::~Constraints( ) -{ -} - - -/* - * o p e r a t o r = - */ -Constraints& Constraints::operator=( const Constraints& rhs ) -{ - if ( this != &rhs ) - { - SubjectTo::operator=( rhs ); - - nC = rhs.nC; - nEC = rhs.nEC; - nIC = rhs.nIC; - nUC = rhs.nUC; - - active = rhs.active; - inactive = rhs.inactive; - } - - return *this; -} - - -/* - * i n i t - */ -returnValue Constraints::init( int n ) -{ - nC = n; - nEC = 0; - nIC = 0; - nUC = 0; - - active.init( ); - inactive.init( ); - - return SubjectTo::init( n ); -} - - -/* - * s e t u p C o n s t r a i n t - */ -returnValue Constraints::setupConstraint( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Add constraint index to respective index list. */ - switch ( _status ) - { - case ST_INACTIVE: - if ( this->addIndex( this->getInactive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); - break; - - case ST_LOWER: - if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); - break; - - case ST_UPPER: - if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); - break; - - default: - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A l l I n a c t i v e - */ -returnValue Constraints::setupAllInactive( ) -{ - int i; - - - /* 1) Place unbounded constraints at the beginning of the index list of inactive constraints. */ - for( i=0; i= getNC( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of active constraints to that of inactive ones. */ - if ( this->removeIndex( this->getActive( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getInactive( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * m o v e I n a c t i v e T o A c t i v e - */ -returnValue Constraints::moveInactiveToActive( int _number, SubjectToStatus _status - ) -{ - /* consistency check */ - if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - - /* Move index from indexlist of inactive constraints to that of active ones. */ - if ( this->removeIndex( this->getInactive( ),_number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_MOVING_BOUND_FAILED ); - - return SUCCESSFUL_RETURN; -} - - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/Constraints.ipp b/phonelibs/qpoases/SRC/Constraints.ipp deleted file mode 100644 index 1b874ef3c..000000000 --- a/phonelibs/qpoases/SRC/Constraints.ipp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Constraints.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Declaration of inlined member functions of the Constraints class designed - * to manage working sets of constraints within a QProblem. - */ - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t N C - */ -inline int Constraints::getNC( ) const -{ - return nC; -} - - -/* - * g e t N E C - */ -inline int Constraints::getNEC( ) const -{ - return nEC; -} - - -/* - * g e t N I C - */ -inline int Constraints::getNIC( ) const -{ - return nIC; -} - - -/* - * g e t N U C - */ -inline int Constraints::getNUC( ) const -{ - return nUC; -} - - -/* - * s e t N E C - */ -inline returnValue Constraints::setNEC( int n ) -{ - nEC = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N I C - */ -inline returnValue Constraints::setNIC( int n ) -{ - nIC = n; - return SUCCESSFUL_RETURN; -} - - -/* - * s e t N U C - */ -inline returnValue Constraints::setNUC( int n ) -{ - nUC = n; - return SUCCESSFUL_RETURN; -} - - -/* - * g e t N A C - */ -inline int Constraints::getNAC( ) -{ - return active.getLength( ); -} - - -/* - * g e t N I A C - */ -inline int Constraints::getNIAC( ) -{ - return inactive.getLength( ); -} - - -/* - * g e t A c t i v e - */ -inline Indexlist* Constraints::getActive( ) -{ - return &active; -} - - -/* - * g e t I n a c t i v e - */ -inline Indexlist* Constraints::getInactive( ) -{ - return &inactive; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/CyclingManager.cpp b/phonelibs/qpoases/SRC/CyclingManager.cpp deleted file mode 100644 index 27c2996ef..000000000 --- a/phonelibs/qpoases/SRC/CyclingManager.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/CyclingManager.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the CyclingManager class designed to detect - * and handle possible cycling during QP iterations. - * - */ - - -#include - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * C y c l i n g M a n a g e r - */ -CyclingManager::CyclingManager( ) : nV( 0 ), - nC( 0 ) -{ - cyclingDetected = BT_FALSE; -} - - -/* - * C y c l i n g M a n a g e r - */ -CyclingManager::CyclingManager( const CyclingManager& rhs ) : nV( rhs.nV ), - nC( rhs.nC ), - cyclingDetected( rhs.cyclingDetected ) -{ - int i; - - for( i=0; i= 0 ) && ( number < nV ) ) - { - status[number] = _status; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } - else - { - /* Set cycling status of a constraint. */ - if ( ( number >= 0 ) && ( number < nC ) ) - { - status[nV+number] = _status; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * g e t C y c l i n g S t a t u s - */ -CyclingStatus CyclingManager::getCyclingStatus( int number, BooleanType isBound ) const -{ - if ( isBound == BT_TRUE ) - { - /* Return cycling status of a bound. */ - if ( ( number >= 0 ) && ( number < nV ) ) - return status[number]; - } - else - { - /* Return cycling status of a constraint. */ - if ( ( number >= 0 ) && ( number < nC ) ) - return status[nV+number]; - } - - return CYC_NOT_INVOLVED; -} - - -/* - * c l e a r C y c l i n g D a t a - */ -returnValue CyclingManager::clearCyclingData( ) -{ - int i; - - /* Reset all status values ... */ - for( i=0; i - -/* - * S o l u t i o n A n a l y s i s - */ -SolutionAnalysis::SolutionAnalysis( ) -{ - -} - -/* - * S o l u t i o n A n a l y s i s - */ -SolutionAnalysis::SolutionAnalysis( const SolutionAnalysis& rhs ) -{ - -} - -/* - * ~ S o l u t i o n A n a l y s i s - */ -SolutionAnalysis::~SolutionAnalysis( ) -{ - -} - -/* - * o p e r a t o r = - */ -SolutionAnalysis& SolutionAnalysis::operator=( const SolutionAnalysis& rhs ) -{ - if ( this != &rhs ) - { - - } - - return *this; -} - -/* - * g e t H e s s i a n I n v e r s e - */ -returnValue SolutionAnalysis::getHessianInverse( QProblem* qp, real_t* hessianInverse ) -{ - returnValue returnvalue; /* the return value */ - BooleanType Delta_bC_isZero = BT_FALSE; /* (just use FALSE here) */ - BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ - - register int run1, run2, run3; - - register int nFR, nFX; - - /* Ask for the number of free and fixed variables, assumes that active set - * is constant for the covariance evaluation */ - nFR = qp->getNFR( ); - nFX = qp->getNFX( ); - - /* Ask for the corresponding index arrays: */ - if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* Initialization: */ - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_g_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_lb_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_ub_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NCMAX; run1++ ) - delta_lbA_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NCMAX; run1++ ) - delta_ubA_cov[ run1 ] = 0.0; - - /* The following loop solves the following: - * - * KKT * x = - * [delta_g_cov', delta_lbA_cov', delta_ubA_cov', delta_lb_cov', delta_ub_cov]' - * - * for the first NVMAX (negative) elementary vectors in order to get - * transposed inverse of the Hessian. Assuming that the Hessian is - * symmetric, the function will return transposed inverse, instead of the - * true inverse. - * - * Note, that we use negative elementary vectors due because internal - * implementation of the function hotstart_determineStepDirection requires - * so. - * - * */ - - for( run3 = 0; run3 < NVMAX; run3++ ) - { - /* Line wise loading of the corresponding (negative) elementary vector: */ - delta_g_cov[ run3 ] = -1.0; - - /* Evaluation of the step: */ - returnvalue = qp->hotstart_determineStepDirection( - FR_idx, FX_idx, AC_idx, - delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, - Delta_bC_isZero, Delta_bB_isZero, - delta_xFX, delta_xFR, delta_yAC, delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* Line wise storage of the QP reaction: */ - for( run1 = 0; run1 < nFR; run1++ ) - { - run2 = FR_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFR[ run1 ]; - } - - for( run1 = 0; run1 < nFX; run1++ ) - { - run2 = FX_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFX[ run1 ]; - } - - /* Prepare for the next iteration */ - delta_g_cov[ run3 ] = 0.0; - } - - // TODO: Perform the transpose of the inverse of the Hessian matrix - - return SUCCESSFUL_RETURN; -} - -/* - * g e t H e s s i a n I n v e r s e - */ -returnValue SolutionAnalysis::getHessianInverse( QProblemB* qp, real_t* hessianInverse ) -{ - returnValue returnvalue; /* the return value */ - BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ - - register int run1, run2, run3; - - register int nFR, nFX; - - /* Ask for the number of free and fixed variables, assumes that active set - * is constant for the covariance evaluation */ - nFR = qp->getNFR( ); - nFX = qp->getNFX( ); - - /* Ask for the corresponding index arrays: */ - if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* Initialization: */ - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_g_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_lb_cov[ run1 ] = 0.0; - - for( run1 = 0; run1 < NVMAX; run1++ ) - delta_ub_cov[ run1 ] = 0.0; - - /* The following loop solves the following: - * - * KKT * x = - * [delta_g_cov', delta_lb_cov', delta_ub_cov']' - * - * for the first NVMAX (negative) elementary vectors in order to get - * transposed inverse of the Hessian. Assuming that the Hessian is - * symmetric, the function will return transposed inverse, instead of the - * true inverse. - * - * Note, that we use negative elementary vectors due because internal - * implementation of the function hotstart_determineStepDirection requires - * so. - * - * */ - - for( run3 = 0; run3 < NVMAX; run3++ ) - { - /* Line wise loading of the corresponding (negative) elementary vector: */ - delta_g_cov[ run3 ] = -1.0; - - /* Evaluation of the step: */ - returnvalue = qp->hotstart_determineStepDirection( - FR_idx, FX_idx, - delta_g_cov, delta_lb_cov, delta_ub_cov, - Delta_bB_isZero, - delta_xFX, delta_xFR, delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* Line wise storage of the QP reaction: */ - for( run1 = 0; run1 < nFR; run1++ ) - { - run2 = FR_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFR[ run1 ]; - } - - for( run1 = 0; run1 < nFX; run1++ ) - { - run2 = FX_idx[ run1 ]; - - hessianInverse[run3 * NVMAX + run2] = delta_xFX[ run1 ]; - } - - /* Prepare for the next iteration */ - delta_g_cov[ run3 ] = 0.0; - } - - // TODO: Perform the transpose of the inverse of the Hessian matrix - - return SUCCESSFUL_RETURN; -} - -/* - * g e t V a r i a n c e C o v a r i a n c e - */ - -#if QPOASES_USE_OLD_VERSION - -returnValue SolutionAnalysis::getVarianceCovariance( QProblem* qp, real_t* g_b_bA_VAR, real_t* Primal_Dual_VAR ) -{ - int run1, run2, run3; /* simple run variables (for loops). */ - - returnValue returnvalue; /* the return value */ - BooleanType Delta_bC_isZero = BT_FALSE; /* (just use FALSE here) */ - BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ - - /* ASK FOR THE NUMBER OF FREE AND FIXED VARIABLES: - * (ASSUMES THAT ACTIVE SET IS CONSTANT FOR THE - * VARIANCE-COVARIANCE EVALUATION) - * ----------------------------------------------- */ - int nFR, nFX, nAC; - - nFR = qp->getNFR( ); - nFX = qp->getNFX( ); - nAC = qp->getNAC( ); - - if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( qp->constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* SOME INITIALIZATIONS: - * --------------------- */ - for( run1 = 0; run1 < KKT_DIM * KKT_DIM; run1++ ) - { - K [run1] = 0.0; - Primal_Dual_VAR[run1] = 0.0; - } - - /* ================================================================= */ - - /* FIRST MATRIX MULTIPLICATION (OBTAINS THE INTERMEDIATE RESULT - * K := [ ("ACTIVE" KKT-MATRIX OF THE QP)^(-1) * g_b_bA_VAR ]^T ) - * THE EVALUATION OF THE INVERSE OF THE KKT-MATRIX OF THE QP - * WITH RESPECT TO THE CURRENT ACTIVE SET - * USES THE EXISTING CHOLESKY AND TQ-DECOMPOSITIONS. FOR DETAILS - * cf. THE (protected) FUNCTION determineStepDirection. */ - - for( run3 = 0; run3 < KKT_DIM; run3++ ) - { - - for( run1 = 0; run1 < NVMAX; run1++ ) - { - delta_g_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+run1]; - delta_lb_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+NVMAX+run1]; /* LINE-WISE LOADING OF THE INPUT */ - delta_ub_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+NVMAX+run1]; /* VARIANCE-COVARIANCE */ - } - for( run1 = 0; run1 < NCMAX; run1++ ) - { - delta_lbA_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+2*NVMAX+run1]; - delta_ubA_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+2*NVMAX+run1]; - } - - /* EVALUATION OF THE STEP: - * ------------------------------------------------------------------------------ */ - - returnvalue = qp->hotstart_determineStepDirection( - FR_idx, FX_idx, AC_idx, - delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, - Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR, - delta_yAC,delta_yFX ); - - /* ------------------------------------------------------------------------------ */ - - /* STOP THE ALGORITHM IN THE CASE OF NO SUCCESFUL RETURN: - * ------------------------------------------------------ */ - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* LINE WISE */ - /* STORAGE OF THE QP-REACTION */ - /* (uses the index list) */ - - for( run1=0; run1hotstart_determineStepDirection( - FR_idx, FX_idx, AC_idx, - delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, - Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR, - delta_yAC,delta_yFX ); - - /* ------------------------------------------------------------------------------ */ - - /* STOP THE ALGORITHM IN THE CASE OF NO SUCCESFUL RETURN: - * ------------------------------------------------------ */ - if ( returnvalue != SUCCESSFUL_RETURN ) - { - return returnvalue; - } - - /* ROW-WISE STORAGE */ - /* OF THE RESULT. */ - - for( run1=0; run1 - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * I n d e x l i s t - */ -Indexlist::Indexlist( ) : length( 0 ), - first( -1 ), - last( -1 ), - lastusedindex( -1 ), - physicallength( INDEXLISTFACTOR*(NVMAX+NCMAX) ) -{ - int i; - - for( i=0; i= 0 ) && ( number[n] >= 0 ) ) - numberarray[i] = number[n]; - else - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - n = next[n]; - } - - return SUCCESSFUL_RETURN; -} - - -/* - * g e t I n d e x - */ -int Indexlist::getIndex( int givennumber ) const -{ - int i; - int n = first; - int index = -1; /* return -1 by default */ - - /* Run trough indexlist until number is found, if so return it index. */ - for ( i=0; i length ) ) - return -RET_INDEXLIST_OUTOFBOUNDS; - - return number[physicalindex]; -} - - -/* - * g e t L e n g t h - */ -inline int Indexlist::getLength( ) -{ - return length; -} - - -/* - * g e t L a s t N u m b e r - */ -inline int Indexlist::getLastNumber( ) const -{ - return number[last]; -} - - -/* - * g e t L a s t N u m b e r - */ -inline BooleanType Indexlist::isMember( int _number ) const -{ - if ( getIndex( _number ) >= 0 ) - return BT_TRUE; - else - return BT_FALSE; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/MessageHandling.cpp b/phonelibs/qpoases/SRC/MessageHandling.cpp deleted file mode 100644 index 18a7654a1..000000000 --- a/phonelibs/qpoases/SRC/MessageHandling.cpp +++ /dev/null @@ -1,529 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/MessageHandling.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the MessageHandling class including global return values. - * - */ - - - -#include -#include - - - - -/** Defines pairs of global return values and messages. */ -MessageHandling::ReturnValueList returnValueList[] = -{ -/* miscellaneous */ -{ SUCCESSFUL_RETURN, "Successful return", VS_VISIBLE }, -{ RET_DIV_BY_ZERO, "Division by zero", VS_VISIBLE }, -{ RET_INDEX_OUT_OF_BOUNDS, "Index out of bounds", VS_VISIBLE }, -{ RET_INVALID_ARGUMENTS, "At least one of the arguments is invalid", VS_VISIBLE }, -{ RET_ERROR_UNDEFINED, "Error number undefined", VS_VISIBLE }, -{ RET_WARNING_UNDEFINED, "Warning number undefined", VS_VISIBLE }, -{ RET_INFO_UNDEFINED, "Info number undefined", VS_VISIBLE }, -{ RET_EWI_UNDEFINED, "Error/warning/info number undefined", VS_VISIBLE }, -{ RET_AVAILABLE_WITH_LINUX_ONLY, "This function is available under Linux only", VS_HIDDEN }, -{ RET_UNKNOWN_BUG, "The error occured is not yet known", VS_VISIBLE }, -{ RET_PRINTLEVEL_CHANGED, "Print level changed", VS_VISIBLE }, -{ RET_NOT_YET_IMPLEMENTED, "Requested function is not yet implemented.", VS_VISIBLE }, -/* Indexlist */ -{ RET_INDEXLIST_MUST_BE_REORDERD, "Index list has to be reordered", VS_VISIBLE }, -{ RET_INDEXLIST_EXCEEDS_MAX_LENGTH, "Index list exceeds its maximal physical length", VS_VISIBLE }, -{ RET_INDEXLIST_CORRUPTED, "Index list corrupted", VS_VISIBLE }, -{ RET_INDEXLIST_OUTOFBOUNDS, "Physical index is out of bounds", VS_VISIBLE }, -{ RET_INDEXLIST_ADD_FAILED, "Adding indices from another index set failed", VS_VISIBLE }, -{ RET_INDEXLIST_INTERSECT_FAILED, "Intersection with another index set failed", VS_VISIBLE }, -/* SubjectTo / Bounds / Constraints */ -{ RET_INDEX_ALREADY_OF_DESIRED_STATUS, "Index is already of desired status", VS_VISIBLE }, -{ RET_SWAPINDEX_FAILED, "Cannot swap between different indexsets", VS_VISIBLE }, -{ RET_ADDINDEX_FAILED, "Adding index to index set failed", VS_VISIBLE }, -{ RET_NOTHING_TO_DO, "Nothing to do", VS_VISIBLE }, -{ RET_SETUP_BOUND_FAILED, "Setting up bound index failed", VS_VISIBLE }, -{ RET_SETUP_CONSTRAINT_FAILED, "Setting up constraint index failed", VS_VISIBLE }, -{ RET_MOVING_BOUND_FAILED, "Moving bound between index sets failed", VS_VISIBLE }, -{ RET_MOVING_CONSTRAINT_FAILED, "Moving constraint between index sets failed", VS_VISIBLE }, -/* QProblem */ -{ RET_QP_ALREADY_INITIALISED, "QProblem has already been initialised", VS_VISIBLE }, -{ RET_NO_INIT_WITH_STANDARD_SOLVER, "Initialisation via extern QP solver is not yet implemented", VS_VISIBLE }, -{ RET_RESET_FAILED, "Reset failed", VS_VISIBLE }, -{ RET_INIT_FAILED, "Initialisation failed", VS_VISIBLE }, -{ RET_INIT_FAILED_TQ, "Initialisation failed due to TQ factorisation", VS_VISIBLE }, -{ RET_INIT_FAILED_CHOLESKY, "Initialisation failed due to Cholesky decomposition", VS_VISIBLE }, -{ RET_INIT_FAILED_HOTSTART, "Initialisation failed! QP could not be solved!", VS_VISIBLE }, -{ RET_INIT_FAILED_INFEASIBILITY, "Initial QP could not be solved due to infeasibility!", VS_VISIBLE }, -{ RET_INIT_FAILED_UNBOUNDEDNESS, "Initial QP could not be solved due to unboundedness!", VS_VISIBLE }, -{ RET_INIT_SUCCESSFUL, "Initialisation done", VS_VISIBLE }, -{ RET_OBTAINING_WORKINGSET_FAILED, "Failed to obtain working set for auxiliary QP", VS_VISIBLE }, -{ RET_SETUP_WORKINGSET_FAILED, "Failed to setup working set for auxiliary QP", VS_VISIBLE }, -{ RET_SETUP_AUXILIARYQP_FAILED, "Failed to setup auxiliary QP for initialised homotopy", VS_VISIBLE }, -{ RET_NO_EXTERN_SOLVER, "No extern QP solver available", VS_VISIBLE }, -{ RET_QP_UNBOUNDED, "QP is unbounded", VS_VISIBLE }, -{ RET_QP_INFEASIBLE, "QP is infeasible", VS_VISIBLE }, -{ RET_QP_NOT_SOLVED, "Problems occured while solving QP with standard solver", VS_VISIBLE }, -{ RET_QP_SOLVED, "QP successfully solved", VS_VISIBLE }, -{ RET_UNABLE_TO_SOLVE_QP, "Problems occured while solving QP", VS_VISIBLE }, -{ RET_INITIALISATION_STARTED, "Starting problem initialisation...", VS_VISIBLE }, -{ RET_HOTSTART_FAILED, "Unable to perform homotopy due to internal error", VS_VISIBLE }, -{ RET_HOTSTART_FAILED_TO_INIT, "Unable to initialise problem", VS_VISIBLE }, -{ RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, "Unable to perform homotopy as previous QP is not solved", VS_VISIBLE }, -{ RET_ITERATION_STARTED, "Iteration", VS_VISIBLE }, -{ RET_SHIFT_DETERMINATION_FAILED, "Determination of shift of the QP data failed", VS_VISIBLE }, -{ RET_STEPDIRECTION_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, -{ RET_STEPLENGTH_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, -{ RET_OPTIMAL_SOLUTION_FOUND, "Optimal solution of neighbouring QP found", VS_VISIBLE }, -{ RET_HOMOTOPY_STEP_FAILED, "Unable to perform homotopy step", VS_VISIBLE }, -{ RET_HOTSTART_STOPPED_INFEASIBILITY, "Premature homotopy termination because QP is infeasible", VS_VISIBLE }, -{ RET_HOTSTART_STOPPED_UNBOUNDEDNESS, "Premature homotopy termination because QP is unbounded", VS_VISIBLE }, -{ RET_WORKINGSET_UPDATE_FAILED, "Unable to update working sets according to initial guesses", VS_VISIBLE }, -{ RET_MAX_NWSR_REACHED, "Maximum number of working set recalculations performed", VS_VISIBLE }, -{ RET_CONSTRAINTS_NOT_SPECIFIED, "Problem does comprise constraints! You have to specify new constraints' bounds", VS_VISIBLE }, -{ RET_INVALID_FACTORISATION_FLAG, "Invalid factorisation flag", VS_VISIBLE }, -{ RET_UNABLE_TO_SAVE_QPDATA, "Unable to save QP data", VS_VISIBLE }, -{ RET_STEPDIRECTION_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, -{ RET_STEPDIRECTION_FAILED_CHOLESKY, "Abnormal termination due to Cholesky factorisation", VS_VISIBLE }, -{ RET_CYCLING_DETECTED, "Cycling detected", VS_VISIBLE }, -{ RET_CYCLING_NOT_RESOLVED, "Cycling cannot be resolved, QP is probably infeasible", VS_VISIBLE }, -{ RET_CYCLING_RESOLVED, "Cycling probably resolved", VS_VISIBLE }, -{ RET_STEPSIZE, "", VS_VISIBLE }, -{ RET_STEPSIZE_NONPOSITIVE, "", VS_VISIBLE }, -{ RET_SETUPSUBJECTTOTYPE_FAILED, "Setup of SubjectToTypes failed", VS_VISIBLE }, -{ RET_ADDCONSTRAINT_FAILED, "Addition of constraint to working set failed", VS_VISIBLE }, -{ RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, "Addition of constraint to working set failed", VS_VISIBLE }, -{ RET_ADDBOUND_FAILED, "Addition of bound to working set failed", VS_VISIBLE }, -{ RET_ADDBOUND_FAILED_INFEASIBILITY, "Addition of bound to working set failed", VS_VISIBLE }, -{ RET_REMOVECONSTRAINT_FAILED, "Removal of constraint from working set failed", VS_VISIBLE }, -{ RET_REMOVEBOUND_FAILED, "Removal of bound from working set failed", VS_VISIBLE }, -{ RET_REMOVE_FROM_ACTIVESET, "Removing from active set:", VS_VISIBLE }, -{ RET_ADD_TO_ACTIVESET, "Adding to active set:", VS_VISIBLE }, -{ RET_REMOVE_FROM_ACTIVESET_FAILED, "Removing from active set failed", VS_VISIBLE }, -{ RET_ADD_TO_ACTIVESET_FAILED, "Adding to active set failed", VS_VISIBLE }, -{ RET_CONSTRAINT_ALREADY_ACTIVE, "Constraint is already active", VS_VISIBLE }, -{ RET_ALL_CONSTRAINTS_ACTIVE, "All constraints are active, no further constraint can be added", VS_VISIBLE }, -{ RET_LINEARLY_DEPENDENT, "New bound/constraint is linearly dependent", VS_VISIBLE }, -{ RET_LINEARLY_INDEPENDENT, "New bound/constraint is linearly independent", VS_VISIBLE }, -{ RET_LI_RESOLVED, "Linear independence of active contraint matrix successfully resolved", VS_VISIBLE }, -{ RET_ENSURELI_FAILED, "Failed to ensure linear indepence of active contraint matrix", VS_VISIBLE }, -{ RET_ENSURELI_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, -{ RET_ENSURELI_FAILED_NOINDEX, "No index found, QP is probably infeasible", VS_VISIBLE }, -{ RET_ENSURELI_FAILED_CYCLING, "Cycling detected, QP is probably infeasible", VS_VISIBLE }, -{ RET_BOUND_ALREADY_ACTIVE, "Bound is already active", VS_VISIBLE }, -{ RET_ALL_BOUNDS_ACTIVE, "All bounds are active, no further bound can be added", VS_VISIBLE }, -{ RET_CONSTRAINT_NOT_ACTIVE, "Constraint is not active", VS_VISIBLE }, -{ RET_BOUND_NOT_ACTIVE, "Bound is not active", VS_VISIBLE }, -{ RET_HESSIAN_NOT_SPD, "Projected Hessian matrix not positive definite", VS_VISIBLE }, -{ RET_MATRIX_SHIFT_FAILED, "Unable to update matrices or to transform vectors", VS_VISIBLE }, -{ RET_MATRIX_FACTORISATION_FAILED, "Unable to calculate new matrix factorisations", VS_VISIBLE }, -{ RET_PRINT_ITERATION_FAILED, "Unable to print information on current iteration", VS_VISIBLE }, -{ RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, "No global message output file initialised", VS_VISIBLE }, -/* Utils */ -{ RET_UNABLE_TO_OPEN_FILE, "Unable to open file", VS_VISIBLE }, -{ RET_UNABLE_TO_WRITE_FILE, "Unable to write into file", VS_VISIBLE }, -{ RET_UNABLE_TO_READ_FILE, "Unable to read from file", VS_VISIBLE }, -{ RET_FILEDATA_INCONSISTENT, "File contains inconsistent data", VS_VISIBLE }, -/* SolutionAnalysis */ -{ RET_NO_SOLUTION, "QP solution does not satisfy KKT optimality conditions", VS_VISIBLE }, -{ RET_INACCURATE_SOLUTION, "KKT optimality conditions not satisfied to sufficient accuracy", VS_VISIBLE }, -{ TERMINAL_LIST_ELEMENT, "", VS_HIDDEN } /* IMPORTANT: Terminal list element! */ -}; - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( ) : errorVisibility( VS_VISIBLE ), - warningVisibility( VS_VISIBLE ), - infoVisibility( VS_VISIBLE ), - outputFile( myStdout ), - errorCount( 0 ) -{ -} - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( myFILE* _outputFile ) : - errorVisibility( VS_VISIBLE ), - warningVisibility( VS_VISIBLE ), - infoVisibility( VS_VISIBLE ), - outputFile( _outputFile ), - errorCount( 0 ) -{ -} - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( VisibilityStatus _errorVisibility, - VisibilityStatus _warningVisibility, - VisibilityStatus _infoVisibility - ) : - errorVisibility( _errorVisibility ), - warningVisibility( _warningVisibility ), - infoVisibility( _infoVisibility ), - outputFile( myStderr ), - errorCount( 0 ) -{ -} - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( myFILE* _outputFile, - VisibilityStatus _errorVisibility, - VisibilityStatus _warningVisibility, - VisibilityStatus _infoVisibility - ) : - errorVisibility( _errorVisibility ), - warningVisibility( _warningVisibility ), - infoVisibility( _infoVisibility ), - outputFile( _outputFile ), - errorCount( 0 ) -{ -} - - - -/* - * M e s s a g e H a n d l i n g - */ -MessageHandling::MessageHandling( const MessageHandling& rhs ) : - errorVisibility( rhs.errorVisibility ), - warningVisibility( rhs.warningVisibility ), - infoVisibility( rhs.infoVisibility ), - outputFile( rhs.outputFile ), - errorCount( rhs.errorCount ) -{ -} - - -/* - * ~ M e s s a g e H a n d l i n g - */ -MessageHandling::~MessageHandling( ) -{ - #ifdef PC_DEBUG - if ( outputFile != 0 ) - fclose( outputFile ); - #endif -} - - -/* - * o p e r a t o r = - */ -MessageHandling& MessageHandling::operator=( const MessageHandling& rhs ) -{ - if ( this != &rhs ) - { - errorVisibility = rhs.errorVisibility; - warningVisibility = rhs.warningVisibility; - infoVisibility = rhs.infoVisibility; - outputFile = rhs.outputFile; - errorCount = rhs.errorCount; - } - - return *this; -} - - -/* - * t h r o w E r r o r - */ -returnValue MessageHandling::throwError( - returnValue Enumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus - ) -{ - /* consistency check */ - if ( Enumber <= SUCCESSFUL_RETURN ) - return throwError( RET_ERROR_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - - /* Call to common throwMessage function if error shall be displayed. */ - if ( errorVisibility == VS_VISIBLE ) - return throwMessage( Enumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"ERROR" ); - else - return Enumber; -} - - -/* - * t h r o w W a r n i n g - */ -returnValue MessageHandling::throwWarning( - returnValue Wnumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus - ) -{ - /* consistency check */ - if ( Wnumber <= SUCCESSFUL_RETURN ) - return throwError( RET_WARNING_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - - /* Call to common throwMessage function if warning shall be displayed. */ - if ( warningVisibility == VS_VISIBLE ) - return throwMessage( Wnumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"WARNING" ); - else - return Wnumber; -} - - -/* - * t h r o w I n f o - */ -returnValue MessageHandling::throwInfo( - returnValue Inumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus - ) -{ - /* consistency check */ - if ( Inumber < SUCCESSFUL_RETURN ) - return throwError( RET_INFO_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - - /* Call to common throwMessage function if info shall be displayed. */ - if ( infoVisibility == VS_VISIBLE ) - return throwMessage( Inumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"INFO" ); - else - return Inumber; -} - - -/* - * r e s e t - */ -returnValue MessageHandling::reset( ) -{ - setErrorVisibilityStatus( VS_VISIBLE ); - setWarningVisibilityStatus( VS_VISIBLE ); - setInfoVisibilityStatus( VS_VISIBLE ); - - setOutputFile( myStderr ); - setErrorCount( 0 ); - - return SUCCESSFUL_RETURN; -} - - -/* - * l i s t A l l M e s s a g e s - */ -returnValue MessageHandling::listAllMessages( ) -{ - #ifdef PC_DEBUG - int keypos = 0; - char myPrintfString[160]; - - /* Run through whole returnValueList and print each item. */ - while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT ) - { - sprintf( myPrintfString," %d - %s \n",keypos,returnValueList[keypos].data ); - myPrintf( myPrintfString ); - - ++keypos; - } - #endif - - return SUCCESSFUL_RETURN; -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - - -#ifdef PC_DEBUG /* Re-define throwMessage function for embedded code! */ - -/* - * t h r o w M e s s a g e - */ -returnValue MessageHandling::throwMessage( - returnValue RETnumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus, - const char* RETstring - ) -{ - int i; - - int keypos = 0; - char myPrintfString[160]; - - /* 1) Determine number of whitespace for output. */ - char whitespaces[41]; - int numberOfWhitespaces = (errorCount-1)*2; - - if ( numberOfWhitespaces < 0 ) - numberOfWhitespaces = 0; - - if ( numberOfWhitespaces > 40 ) - numberOfWhitespaces = 40; - - for( i=0; i 0 ) - { - sprintf( myPrintfString,"%s->", whitespaces ); - myPrintf( myPrintfString ); - } - - if ( additionaltext == 0 ) - { - sprintf( myPrintfString,"%s (%s, %s:%d): \t%s\n", - RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data - ); - myPrintf( myPrintfString ); - } - else - { - sprintf( myPrintfString,"%s (%s, %s:%d): \t%s %s\n", - RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data,additionaltext - ); - myPrintf( myPrintfString ); - } - - /* take care of proper indention for subsequent error messages */ - if ( RETstring[0] == 'E' ) - { - ++errorCount; - } - else - { - if ( errorCount > 0 ) - myPrintf( "\n" ); - errorCount = 0; - } - } - - return RETnumber; -} - -#else /* = PC_DEBUG not defined */ - -/* - * t h r o w M e s s a g e - */ -returnValue MessageHandling::throwMessage( - returnValue RETnumber, - const char* additionaltext, - const char* functionname, - const char* filename, - const unsigned long linenumber, - VisibilityStatus localVisibilityStatus, - const char* RETstring - ) -{ - /* DUMMY CODE FOR PRETENDING USE OF ARGUMENTS - * FOR SUPPRESSING COMPILER WARNINGS! */ - int i = 0; - if ( additionaltext == 0 ) i++; - if ( functionname == 0 ) i++; - if ( filename == 0 ) i++; - if ( linenumber == 0 ) i++; - if ( localVisibilityStatus == VS_VISIBLE ) i++; - if ( RETstring == 0 ) i++; - /* END OF DUMMY CODE */ - - return RETnumber; -} - -#endif /* PC_DEBUG */ - - - -/***************************************************************************** - * G L O B A L M E S S A G E H A N D L E R * - *****************************************************************************/ - - -/** Global message handler for all qpOASES modules.*/ -MessageHandling globalMessageHandler( myStderr,VS_VISIBLE,VS_VISIBLE,VS_VISIBLE ); - - -/* - * g e t G l o b a l M e s s a g e H a n d l e r - */ -MessageHandling* getGlobalMessageHandler( ) -{ - return &globalMessageHandler; -} - -const char* MessageHandling::getErrorString(int error) -{ - return returnValueList[ error ].data; -} - - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/MessageHandling.ipp b/phonelibs/qpoases/SRC/MessageHandling.ipp deleted file mode 100644 index 033957b28..000000000 --- a/phonelibs/qpoases/SRC/MessageHandling.ipp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/MessageHandling.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the MessageHandling class. - */ - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t E r r o r V i s i b i l i t y S t a t u s - */ -inline VisibilityStatus MessageHandling::getErrorVisibilityStatus( ) const -{ - return errorVisibility; -} - - -/* - * g e t W a r n i n g V i s i b i l i t y S t a t u s - */ -inline VisibilityStatus MessageHandling::getWarningVisibilityStatus( ) const -{ - return warningVisibility; -} - - -/* - * g e t I n f o V i s i b i l i t y S t a t u s - */ -inline VisibilityStatus MessageHandling::getInfoVisibilityStatus( ) const -{ - return infoVisibility; -} - - -/* - * g e t O u t p u t F i l e - */ -inline myFILE* MessageHandling::getOutputFile( ) const -{ - return outputFile; -} - - -/* - * g e t E r r o r C o u n t - */ -inline int MessageHandling::getErrorCount( ) const -{ - return errorCount; -} - - -/* - * s e t E r r o r V i s i b i l i t y S t a t u s - */ -inline void MessageHandling::setErrorVisibilityStatus( VisibilityStatus _errorVisibility ) -{ - errorVisibility = _errorVisibility; -} - - -/* - * s e t W a r n i n g V i s i b i l i t y S t a t u s - */ -inline void MessageHandling::setWarningVisibilityStatus( VisibilityStatus _warningVisibility ) -{ - warningVisibility = _warningVisibility; -} - - -/* - * s e t I n f o V i s i b i l i t y S t a t u s - */ -inline void MessageHandling::setInfoVisibilityStatus( VisibilityStatus _infoVisibility ) -{ - infoVisibility = _infoVisibility; -} - - -/* - * s e t O u t p u t F i l e - */ -inline void MessageHandling::setOutputFile( myFILE* _outputFile ) -{ - outputFile = _outputFile; -} - - -/* - * s e t E r r o r C o u n t - */ -inline returnValue MessageHandling::setErrorCount( int _errorCount ) -{ - if ( _errorCount >= 0 ) - { - errorCount = _errorCount; - return SUCCESSFUL_RETURN; - } - else - return RET_INVALID_ARGUMENTS; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/QProblem.cpp b/phonelibs/qpoases/SRC/QProblem.cpp deleted file mode 100644 index 75e2f324d..000000000 --- a/phonelibs/qpoases/SRC/QProblem.cpp +++ /dev/null @@ -1,3867 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblem.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the QProblem class which is able to use the newly - * developed online active set strategy for parametric quadratic programming. - */ - - -#include - -#include - -void printmatrix2(char *name, double *A, int m, int n) { - int i, j; - - printf("%s = [...\n", name); - for (i = 0; i < m; i++) { - for (j = 0; j < n; j++) - printf(" % 9.4f", A[i*n+j]); - printf(",\n"); - } - printf("];\n"); -} - -//#define __PERFORM_KKT_TEST__ - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * Q P r o b l e m - */ -QProblem::QProblem( ) : QProblemB( ) -{ - constraints.init( 0 ); - - sizeT = 0; - - cyclingManager.init( 0,0 ); -} - - -/* - * Q P r o b l e m - */ -QProblem::QProblem( int _nV, int _nC ) : QProblemB( _nV ) -{ - /* consistency checks */ - if ( _nV <= 0 ) - _nV = 1; - - if ( _nC < 0 ) - { - _nC = 0; - THROWERROR( RET_INVALID_ARGUMENTS ); - } - - constraints.init( _nC ); - - - sizeT = _nC; - if ( _nC > _nV ) - sizeT = _nV; - - cyclingManager.init( _nV,_nC ); -} - - -/* - * Q P r o b l e m - */ -QProblem::QProblem( const QProblem& rhs ) : QProblemB( rhs ) -{ - int i, j; - - int _nV = rhs.bounds.getNV( ); - int _nC = rhs.constraints.getNC( ); - - for( i=0; i<_nC; ++i ) - for( j=0; j<_nV; ++j ) - A[i*NVMAX + j] = rhs.A[i*NVMAX + j]; - - for( i=0; i<_nC; ++i ) - lbA[i] = rhs.lbA[i]; - - for( i=0; i<_nC; ++i ) - ubA[i] = rhs.ubA[i]; - - constraints = rhs.constraints; - - for( i=0; i<(_nV+_nC); ++i ) - y[i] = rhs.y[i]; - - - sizeT = rhs.sizeT; - - for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* 1) Setup index arrays. */ - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( constraints.getInactive( )->getNumberArray( IAC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* 2) Detemination of shift direction of the gradient and the (constraints') bounds. */ - returnvalue = hotstart_determineDataShift( FX_idx, AC_idx, - g_new,lbA_new,ubA_new,lb_new,ub_new, - delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, - Delta_bC_isZero, Delta_bB_isZero ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 3) Determination of step direction of X and Y. */ - returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx,AC_idx, - delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, - Delta_bC_isZero, Delta_bB_isZero, - delta_xFX,delta_xFR,delta_yAC,delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 4) Determination of step length TAU. */ - returnvalue = hotstart_determineStepLength( FR_idx,FX_idx,AC_idx,IAC_idx, - delta_lbA,delta_ubA,delta_lb,delta_ub, - delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, - BC_idx,BC_status,BC_isBound - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 5) Realisation of the homotopy step. */ - returnvalue = hotstart_performStep( FR_idx,FX_idx,AC_idx,IAC_idx, - delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, - delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, - BC_idx,BC_status,BC_isBound - ); - - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - /* optimal solution found? */ - if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) - { - status = QPS_SOLVED; - - if ( printlevel == PL_HIGH ) - THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - - /* check KKT optimality conditions */ - return checkKKTconditions( ); - } - else - { - /* checks for infeasibility... */ - if ( isInfeasible( ) == BT_TRUE ) - { - status = QPS_HOMOTOPYQPSOLVED; - return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); - } - - /* ...unboundedness... */ - if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ - return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); - - /* ... and throw unspecific error otherwise */ - THROWERROR( RET_HOMOTOPY_STEP_FAILED ); - return returnvalue; - } - } - - /* 6) Output information of successful QP iteration. */ - status = QPS_HOMOTOPYQPSOLVED; - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - } - - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - - /* if programm gets to here, output information that QP could not be solved - * within the given maximum numbers of working set changes */ - if ( printlevel == PL_HIGH ) - { - #ifdef PC_DEBUG - sprintf( messageString,"(nWSR = %d)",nWSR ); - return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* Finally check KKT optimality conditions. */ - returnValue returnvalueKKTcheck = checkKKTconditions( ); - - if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) - return returnvalueKKTcheck; - else - return RET_MAX_NWSR_REACHED; -} - - -/* - * g e t N Z - */ -int QProblem::getNZ( ) -{ - /* nZ = nFR - nAC */ - return bounds.getFree( )->getLength( ) - constraints.getActive( )->getLength( ); -} - - -/* - * g e t D u a l S o l u t i o n - */ -returnValue QProblem::getDualSolution( real_t* const yOpt ) const -{ - int i; - - /* return optimal dual solution vector - * only if current QP has been solved */ - if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - for( i=0; i -INFTY ) - { - constraints.setNoLower( BT_FALSE ); - break; - } - } - - /* 2) Check if upper constraints' bounds are present. */ - constraints.setNoUpper( BT_TRUE ); - for( i=0; i INFTY - BOUNDTOL ) ) - { - constraints.setType( i,ST_UNBOUNDED ); - ++nUC; - } - else - { - if ( lbA[i] > ubA[i] - BOUNDTOL ) - { - constraints.setType( i,ST_EQUALITY ); - ++nEC; - } - else - { - constraints.setType( i,ST_BOUNDED ); - } - } - } - - /* 4) Set dimensions of constraints structure. */ - constraints.setNEC( nEC ); - constraints.setNUC( nUC ); - constraints.setNIC( nC - nEC - nUC ); - - return SUCCESSFUL_RETURN; -} - - -/* - * c h o l e s k y D e c o m p o s i t i o n P r o j e c t e d - */ -returnValue QProblem::setupCholeskyDecompositionProjected( ) -{ - int i, j, k, ii, kk; - int nV = getNV( ); - int nFR = getNFR( ); - int nZ = getNZ( ); - - /* 1) Initialises R with all zeros. */ - for( i=0; i 0 ) - { - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - -#if 0 - real_t HZ[NVMAX*NVMAX]; - real_t ZHZ[NVMAX*NVMAX]; - - /* calculate H*Z */ - for ( i=0; i=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; - - if ( sum > 0.0 ) - { - R[i*NVMAX + i] = sqrt( sum ); - inv = 1.0 / R[i * NVMAX + i]; - } - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - for( j=(i+1); j=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; - - R[i*NVMAX + j] = sum * inv; - } - } -#else - real_t HZ[NVMAX]; - real_t ZHZ[NVMAX]; - - real_t sum, inv; - for (j = 0; j < nZ; ++j) - { - /* Cache one column of Z. */ - for (i = 0; i < NVMAX; ++i) - ZHZ[i] = Q[i * NVMAX + j]; - - /* Create one column of the product H * Z. */ - for (i = 0; i < nFR; ++i) - { - ii = FR_idx[i]; - - sum = 0.0; - for (k = 0; k < nFR; ++k) - { - kk = FR_idx[k]; - sum += H[ii * NVMAX + kk] * ZHZ[kk]; - } - HZ[ii] = sum; - } - - /* Create one column of the product Z^T * H * Z. */ - for (i = j; i < nZ; ++i) - ZHZ[ i ] = 0.0; - - for (k = 0; k < nFR; ++k) - { - kk = FR_idx[k]; - real_t q = HZ[kk]; - for (i = j; i < nZ; ++i) - { - ZHZ[i] += Q[kk * NVMAX + i] * q; - } - } - - /* Use the computed column to update the factorization. */ - /* j == i */ - sum = ZHZ[j]; - - for (k = (j - 1); k >= 0; --k) - sum -= R[k * NVMAX + j] * R[k * NVMAX + j]; - - if (sum > 0.0) - { - R[j * NVMAX + j] = sqrt(sum); - inv = 1.0 / R[j * NVMAX + j]; - } - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - for (i = (j + 1); i < nZ; ++i) - { - sum = ZHZ[i]; - - for (k = (j - 1); k >= 0; --k) - sum -= R[k * NVMAX + j] * R[k * NVMAX + i]; - - R[j * NVMAX + i] = sum * inv; - } - } -#endif - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p T Q f a c t o r i s a t i o n - */ -returnValue QProblem::setupTQfactorisation( ) -{ - int i, j, ii; - int nV = getNV( ); - int nFR = getNFR( ); - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - /* 1) Set Q to unity matrix. */ - for( i=0; igetStatus( i ); - - if ( constraints.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,guessedStatus ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - else /* No initial working set specified. */ - { - /* Obtain initial working set by "clipping". */ - if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) - { - for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( Ax[i] >= ubA[i] - BOUNDTOL ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all equality constraints if specified. */ - if ( constraints.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - /* Obtain initial working set in accordance to sign of dual solution vector. */ - if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) - { - for( i=0; i ZERO ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( yOpt[nV+i] < -ZERO ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all equality constraints if specified. */ - if ( constraints.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - /* If xOpt and yOpt are null pointer and no initial working is specified, - * start with empty working set (or implicitly fixed bounds and equality constraints only) - * for auxiliary QP. */ - if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) - { - for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - - -/* - * s e t u p A u x i l i a r y W o r k i n g S e t - */ -returnValue QProblem::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, - const Constraints* const auxiliaryConstraints, - BooleanType setupAfresh - ) -{ - int i; - int nV = getNV( ); - int nC = getNC( ); - - /* consistency checks */ - if ( auxiliaryBounds != 0 ) - { - for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) - return THROWERROR( RET_UNKNOWN_BUG ); - } - else - { - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - if ( auxiliaryConstraints != 0 ) - { - for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) - return THROWERROR( RET_UNKNOWN_BUG ); - } - else - { - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - - /* I) SETUP CHOLESKY FLAG: - * Cholesky decomposition shall only be updated if working set - * shall be updated (i.e. NOT setup afresh!) */ - BooleanType updateCholesky; - if ( setupAfresh == BT_TRUE ) - updateCholesky = BT_FALSE; - else - updateCholesky = BT_TRUE; - - - /* II) REMOVE FORMERLY ACTIVE (CONSTRAINTS') BOUNDS (IF NECESSARY): */ - if ( setupAfresh == BT_FALSE ) - { - /* 1) Remove all active constraints that shall be inactive AND - * all active constraints that are active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_LOWER ) ) - if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - - if ( ( constraints.getStatus( i ) == ST_UPPER ) && ( auxiliaryConstraints->getStatus( i ) != ST_UPPER ) ) - if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - - /* 2) Remove all active bounds that shall be inactive AND - * all active bounds that are active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_LOWER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - - if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - - - /* III) ADD NEWLY ACTIVE (CONSTRAINTS') BOUNDS: */ - /* 1) Add all inactive bounds that shall be active AND - * all formerly active bounds that have been active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_INACTIVE ) ) - { - /* Add bound only if it is linearly independent from the current working set. */ - if ( addBound_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) - { - if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - } - - /* 2) Add all inactive constraints that shall be active AND - * all formerly active constraints that have been active at the wrong bound. */ - for( i=0; igetStatus( i ) == ST_LOWER ) || ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) ) - { - /* formerly inactive */ - if ( constraints.getStatus( i ) == ST_INACTIVE ) - { - /* Add constraint only if it is linearly independent from the current working set. */ - if ( addConstraint_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) - { - if ( addConstraint( i,auxiliaryConstraints->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A u x i l i a r y Q P s o l u t i o n - */ -returnValue QProblem::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt - ) -{ - int i, j; - int nV = getNV( ); - int nC = getNC( ); - - - /* Setup primal/dual solution vector for auxiliary initial QP: - * if a null pointer is passed, a zero vector is assigned; - * old solution vector is kept if pointer to internal solution vevtor is passed. */ - if ( xOpt != 0 ) - { - if ( xOpt != x ) - for( i=0; igetStatus( i ) == ST_LOWER ) - lb[i] = x[i]; - else - lb[i] = x[i] - BOUNDRELAXATION; - - if ( auxiliaryBounds->getStatus( i ) == ST_UPPER ) - ub[i] = x[i]; - else - ub[i] = x[i] + BOUNDRELAXATION; - } - } - break; - - case ST_LOWER: - lb[i] = x[i]; - if ( bounds.getType( i ) == ST_EQUALITY ) - { - ub[i] = x[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - ub[i] = x[i] + BOUNDRELAXATION; - } - break; - - case ST_UPPER: - ub[i] = x[i]; - if ( bounds.getType( i ) == ST_EQUALITY ) - { - lb[i] = x[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - lb[i] = x[i] - BOUNDRELAXATION; - } - break; - - default: - return THROWERROR( RET_UNKNOWN_BUG ); - } - } - - /* 2) Setup constraints vectors. */ - for ( i=0; igetStatus( i ) == ST_LOWER ) - lbA[i] = Ax[i]; - else - lbA[i] = Ax[i] - BOUNDRELAXATION; - - if ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) - ubA[i] = Ax[i]; - else - ubA[i] = Ax[i] + BOUNDRELAXATION; - } - } - break; - - case ST_LOWER: - lbA[i] = Ax[i]; - if ( constraints.getType( i ) == ST_EQUALITY ) - { - ubA[i] = Ax[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - ubA[i] = Ax[i] + BOUNDRELAXATION; - } - break; - - case ST_UPPER: - ubA[i] = Ax[i]; - if ( constraints.getType( i ) == ST_EQUALITY ) - { - lbA[i] = Ax[i]; - } - else - { - if ( useRelaxation == BT_TRUE ) - lbA[i] = Ax[i] - BOUNDRELAXATION; - } - break; - - default: - return THROWERROR( RET_UNKNOWN_BUG ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * a d d C o n s t r a i n t - */ -returnValue QProblem::addConstraint( int number, SubjectToStatus C_status, - BooleanType updateCholesky - ) -{ - int i, j, ii; - - /* consistency checks */ - if ( constraints.getStatus( number ) != ST_INACTIVE ) - return THROWERROR( RET_CONSTRAINT_ALREADY_ACTIVE ); - - if ( ( constraints.getNC( ) - getNAC( ) ) == constraints.getNUC( ) ) - return THROWERROR( RET_ALL_CONSTRAINTS_ACTIVE ); - - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - - /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, - * i.e. remove a constraint or bound if linear dependence occurs. */ - /* check for LI only if Cholesky decomposition shall be updated! */ - if ( updateCholesky == BT_TRUE ) - { - returnValue ensureLIreturnvalue = addConstraint_ensureLI( number,C_status ); - - switch ( ensureLIreturnvalue ) - { - case SUCCESSFUL_RETURN: - break; - - case RET_LI_RESOLVED: - break; - - case RET_ENSURELI_FAILED_NOINDEX: - return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); - - case RET_ENSURELI_FAILED_CYCLING: - return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); - - default: - return THROWERROR( RET_ENSURELI_FAILED ); - } - } - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADDCONSTRAINT_FAILED ); - - real_t aFR[NVMAX]; - real_t wZ[NVMAX]; - for( i=0; i 0 ) - { - for( j=0; j 0 ) - { - /* II) RESTORE TRIANGULAR FORM OF T: */ - /* Use column-wise Givens rotations to restore reverse triangular form - * of T, simultanenous change of Q (i.e. Z) and R. */ - for( j=0; jgetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - /* Check if constraint is linearly independent from the - the active ones (<=> is element of null space of Afr). */ - real_t sum; - - for( i=0; i 10.0*EPS ) - return RET_LINEARLY_INDEPENDENT; - } - - return RET_LINEARLY_DEPENDENT; -} - - -/* - * a d d C o n s t r a i n t _ e n s u r e L I - */ -returnValue QProblem::addConstraint_ensureLI( int number, SubjectToStatus C_status ) -{ - int i, j, ii, jj; - int nV = getNV( ); - int nFR = getNFR( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - - /* I) Check if new constraint is linearly independent from the active ones. */ - returnValue returnvalueCheckLI = addConstraint_checkLI( number ); - - if ( returnvalueCheckLI == RET_INDEXLIST_CORRUPTED ) - return THROWERROR( RET_ENSURELI_FAILED ); - - if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) - return SUCCESSFUL_RETURN; - - - /* II) NEW CONSTRAINT IS LINEARLY DEPENDENT: */ - /* 1) Determine coefficients of linear combination, - * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: - * An Algorithm for the Solution of the Parametric Quadratic Programming - * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - int FX_idx[NVMAX]; - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - real_t xiC[NCMAX_ALLOC]; - real_t xiC_TMP[NCMAX_ALLOC]; - real_t xiB[NVMAX]; - - /* 2) Calculate xiC */ - if ( nAC > 0 ) - { - if ( C_status == ST_LOWER ) - { - for( i=0; igetNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - if ( C_status == ST_LOWER ) - { - for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - else - { - if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - } - - /* 2) Bounds. */ - for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - else - { - if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - } - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ - if ( y_min_number >= 0 ) - { - /* 1) Check for cycling due to infeasibility. */ - if ( ( cyclingManager.getCyclingStatus( number,BT_FALSE ) == CYC_PREV_REMOVED ) && - ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) - { - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); - } - else - { - /* set cycling data */ - cyclingManager.clearCyclingData( ); - cyclingManager.setCyclingStatus( number,BT_FALSE, CYC_PREV_ADDED ); - cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); - } - - /* 2) Update Lagrange multiplier... */ - for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[y_min_number] = 0.0; - } - else - { - #ifdef PC_DEBUG - sprintf( messageString,"constraint no. %d.",y_min_number ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[nV+y_min_number] = 0.0; - } - } - else - { - /* no constraint/bound can be removed => QP is infeasible! */ - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); - } - - return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); -} - - - -/* - * a d d B o u n d - */ -returnValue QProblem::addBound( int number, SubjectToStatus B_status, - BooleanType updateCholesky - ) -{ - int i, j, ii; - - /* consistency checks */ - if ( bounds.getStatus( number ) != ST_INACTIVE ) - return THROWERROR( RET_BOUND_ALREADY_ACTIVE ); - - if ( getNFR( ) == bounds.getNUV( ) ) - return THROWERROR( RET_ALL_BOUNDS_ACTIVE ); - - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - - /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, - * i.e. remove a constraint or bound if linear dependence occurs. */ - /* check for LI only if Cholesky decomposition shall be updated! */ - if ( updateCholesky == BT_TRUE ) - { - returnValue ensureLIreturnvalue = addBound_ensureLI( number,B_status ); - - switch ( ensureLIreturnvalue ) - { - case SUCCESSFUL_RETURN: - break; - - case RET_LI_RESOLVED: - break; - - case RET_ENSURELI_FAILED_NOINDEX: - return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); - - case RET_ENSURELI_FAILED_CYCLING: - return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); - - default: - return THROWERROR( RET_ENSURELI_FAILED ); - } - } - - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - - - /* I) SWAP INDEXLIST OF FREE VARIABLES: - * move the variable to be fixed to the end of the list of free variables. */ - int lastfreenumber = bounds.getFree( )->getLastNumber( ); - if ( lastfreenumber != number ) - if ( bounds.swapFree( number,lastfreenumber ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_ADDBOUND_FAILED ); - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADDBOUND_FAILED ); - - real_t w[NVMAX]; - - - /* II) ADD NEW ACTIVE BOUND TO TOP OF MATRIX T: */ - /* 1) add row [wZ wY] = [Z Y](number) at the top of T: assign w */ - for( i=0; i 0 ) /* ( nAC == 0 ) <=> ( nZ == nFR ) <=> Y and T are empty => nothing to do */ - { - /* store new column a in a temporary vector instead of shifting T one column to the left */ - real_t tmp[NCMAX_ALLOC]; - for( i=0; i is linearly independent from the - the active ones (<=> is element of null space of Afr). */ - for( i=0; i EPS ) - return RET_LINEARLY_INDEPENDENT; - } - - return RET_LINEARLY_DEPENDENT; -} - - -/* - * a d d B o u n d _ e n s u r e L I - */ -returnValue QProblem::addBound_ensureLI( int number, SubjectToStatus B_status ) -{ - int i, j, ii, jj; - int nV = getNV( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - - /* I) Check if new constraint is linearly independent from the active ones. */ - returnValue returnvalueCheckLI = addBound_checkLI( number ); - - if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) - return SUCCESSFUL_RETURN; - - - /* II) NEW BOUND IS LINEARLY DEPENDENT: */ - /* 1) Determine coefficients of linear combination, - * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: - * An Algorithm for the Solution of the Parametric Quadratic Programming - * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - int FX_idx[NVMAX]; - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - int AC_idx[NCMAX_ALLOC]; - if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ENSURELI_FAILED ); - - real_t xiC[NCMAX_ALLOC]; - real_t xiC_TMP[NCMAX_ALLOC]; - real_t xiB[NVMAX]; - - /* 2) Calculate xiC. */ - if ( nAC > 0 ) - { - if ( B_status == ST_LOWER ) - { - for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - else - { - if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) - { - if ( y[nV+ii]/xiC[i] < y_min ) - { - y_min = y[nV+ii]/xiC[i]; - y_min_number = ii; - } - } - } - } - - /* 2) Bounds. */ - for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - else - { - if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) - { - if ( y[ii]/xiB[i] < y_min ) - { - y_min = y[ii]/xiB[i]; - y_min_number = ii; - y_min_isBound = BT_TRUE; - } - } - } - } - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ - if ( y_min_number >= 0 ) - { - /* 1) Check for cycling due to infeasibility. */ - if ( ( cyclingManager.getCyclingStatus( number,BT_TRUE ) == CYC_PREV_REMOVED ) && - ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) - { - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); - } - else - { - /* set cycling data */ - cyclingManager.clearCyclingData( ); - cyclingManager.setCyclingStatus( number,BT_TRUE, CYC_PREV_ADDED ); - cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); - } - - - /* 2) Update Lagrange multiplier... */ - for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[y_min_number] = 0.0; - } - else - { - #ifdef PC_DEBUG - sprintf( messageString,"constraint no. %d.",y_min_number ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[nV+y_min_number] = 0.0; - } - } - else - { - /* no constraint/bound can be removed => QP is infeasible! */ - infeasible = BT_TRUE; - - return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); - } - - return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); -} - - - -/* - * r e m o v e C o n s t r a i n t - */ -returnValue QProblem::removeConstraint( int number, - BooleanType updateCholesky - ) -{ - int i, j, ii, jj; - - /* consistency check */ - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - int number_idx = constraints.getActive( )->getIndex( number ); - - - /* consistency checks */ - if ( constraints.getStatus( number ) == ST_INACTIVE ) - return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); - - if ( ( number_idx < 0 ) || ( number_idx >= nAC ) ) - return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); - - - /* I) REMOVE th ROW FROM T, - * i.e. shift rows number+1 through nAC upwards (instead of the actual - * constraint number its corresponding index within matrix A is used). */ - if ( number_idx < nAC-1 ) - { - for( i=(number_idx+1); i=0; --j ) - { - computeGivens( T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j], T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j],c,s ); - - for( i=(nAC-j-1); i<(nAC-1); ++i ) - applyGivens( c,s,T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j], T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j] ); - - for( i=0; i 0 ) - { - real_t ZHz[NVMAX]; - for ( i=0; i 0.0 ) - R[nZ*NVMAX + nZ] = sqrt( rho2 ); - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - } - - /* IV) UPDATE INDICES */ - if ( constraints.moveActiveToInactive( number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); - - - return SUCCESSFUL_RETURN; -} - - -/* - * r e m o v e B o u n d - */ -returnValue QProblem::removeBound( int number, - BooleanType updateCholesky - ) -{ - int i, j, ii, jj; - - /* consistency checks */ - if ( bounds.getStatus( number ) == ST_INACTIVE ) - return THROWERROR( RET_BOUND_NOT_ACTIVE ); - - if ( ( getStatus( ) == QPS_NOTINITIALISED ) || - ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - return THROWERROR( RET_UNKNOWN_BUG ); - } - - /* some definitions */ - int nFR = getNFR( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - int tcol = sizeT - nAC; - - - /* I) UPDATE INDICES */ - if ( bounds.moveFixedToFree( number ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - /* I) APPEND th UNITY VECOTR TO Q. */ - int nnFRp1 = FR_idx[nFR]; - for( i=0; i 0 ) - { - /* store new column a in a temporary vector instead of shifting T one column to the left and appending a */ - int AC_idx[NCMAX_ALLOC]; - if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - real_t tmp[NCMAX_ALLOC]; - for( i=0; i=0; --j ) - { - computeGivens( tmp[nAC-1-j],T[(nAC-1-j)*NVMAX + tcol+j],T[(nAC-1-j)*NVMAX + tcol+j],tmp[nAC-1-j],c,s ); - - for( i=(nAC-j); i 0 ) - { - real_t Hz[NVMAX]; - for( i=0; i 0 ) - { - real_t r[NVMAX]; - real_t rhs[NVMAX]; - for( i=0; i 0.0 ) - R[nZ*NVMAX + nZ] = sqrt( rho2 ); - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) - */ -returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, - real_t* const a - ) -{ - /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ - return backsolveR( b,transposed,BT_FALSE,a ); -} - - -/* - * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) - */ -returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, - BooleanType removingBound, - real_t* const a - ) -{ - int i, j; - int nR = getNZ( ); - - real_t sum; - - /* if backsolve is called while removing a bound, reduce nZ by one. */ - if ( removingBound == BT_TRUE ) - --nR; - - /* nothing to do */ - if ( nR <= 0 ) - return SUCCESSFUL_RETURN; - - - /* Solve Ra = b, where R might be transposed. */ - if ( transposed == BT_FALSE ) - { - /* solve Ra = b */ - for( i=(nR-1); i>=0; --i ) - { - sum = b[i]; - for( j=(i+1); j ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - else - { - /* solve R^T*a = b */ - for( i=0; i ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - - return SUCCESSFUL_RETURN; -} - - - -/* - * b a c k s o l v e T - */ -returnValue QProblem::backsolveT( const real_t* const b, BooleanType transposed, real_t* const a ) -{ - int i, j; - int nT = getNAC( ); - int tcol = sizeT - nT; - - real_t sum; - - /* nothing to do */ - if ( nT <= 0 ) - return SUCCESSFUL_RETURN; - - - /* Solve Ta = b, where T might be transposed. */ - if ( transposed == BT_FALSE ) - { - /* solve Ta = b */ - for( i=0; i ZERO ) - a[nT-1-i] = sum / T[i*NVMAX + sizeT-1-i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - else - { - /* solve T^T*a = b */ - for( i=0; i ZERO ) - a[nT-1-i] = sum / T[(nT-1-i)*NVMAX + tcol+i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ d e t e r m i n e D a t a S h i f t - */ -returnValue QProblem::hotstart_determineDataShift( const int* const FX_idx, const int* const AC_idx, - const real_t* const g_new, const real_t* const lbA_new, const real_t* const ubA_new, - const real_t* const lb_new, const real_t* const ub_new, - real_t* const delta_g, real_t* const delta_lbA, real_t* const delta_ubA, - real_t* const delta_lb, real_t* const delta_ub, - BooleanType& Delta_bC_isZero, BooleanType& Delta_bB_isZero - ) -{ - int i, ii; - int nC = getNC( ); - int nAC = getNAC( ); - - - /* I) DETERMINE DATA SHIFT FOR BOUNDS */ - QProblemB::hotstart_determineDataShift( FX_idx,g_new,lb_new,ub_new, delta_g,delta_lb,delta_ub, Delta_bB_isZero ); - - - /* II) DETERMINE DATA SHIFT FOR CONSTRAINTS */ - /* 1) Calculate shift directions. */ - for( i=0; i EPS ) || ( getAbs( delta_ubA[ii] ) > EPS ) ) - { - Delta_bC_isZero = BT_FALSE; - break; - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ d e t e r m i n e S t e p D i r e c t i o n - */ -returnValue QProblem::hotstart_determineStepDirection( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, - const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, - const real_t* const delta_lb, const real_t* const delta_ub, - BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero, - real_t* const delta_xFX, real_t* const delta_xFR, - real_t* const delta_yAC, real_t* const delta_yFX - ) -{ - int i, j, ii, jj; - int nFR = getNFR( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nZ = getNZ( ); - - /* initialise auxiliary vectors */ - real_t HMX_delta_xFX[NVMAX]; - real_t YFR_delta_xFRy[NVMAX]; - real_t ZFR_delta_xFRz[NVMAX]; - real_t HFR_YFR_delta_xFRy[NVMAX]; - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - /* 1) Determine delta_xFRy. */ - if ( nAC > 0 ) - { - if ( ( Delta_bC_isZero == BT_TRUE ) && ( Delta_bB_isZero == BT_TRUE ) ) - { - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - if ( ( Delta_bC_isZero == BT_FALSE ) || ( Delta_bB_isZero == BT_FALSE ) ) - { - for( i=0; i 0 ) - { - /* auxiliary variable */ - real_t delta_xFRz_TMP[NVMAX]; - real_t delta_xFRz_RHS[NVMAX]; - - - if ( ( nAC > 0 ) && ( nFX > 0 ) && ( Delta_bB_isZero == BT_FALSE ) ) - { - for( j=0; j 0 ) /* => Delta_bB_isZero == BT_TRUE, as BT_FALSE would imply nFX>0 */ - { - for( j=0; j 0 ) /* => ( nFR = nZ + nAC > 0 ) */ - { - /* auxiliary variables */ - real_t delta_yAC_TMP[NCMAX_ALLOC]; - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - if ( Delta_bB_isZero == BT_FALSE ) - { - for( i=0; i 0 ) - { - for( i=0; i 0.0 ) - maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); - else - maxStepLength[nV+ii] = 0.0; - } - } - else - { - /* active upper constraints' bounds */ - if ( delta_yAC[i] > ZERO ) - { - if ( y[nV+ii] < 0.0 ) - maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); - else - maxStepLength[nV+ii] = 0.0; - } - } - } - } - - /* 2) Ensure that active dual bounds remain valid - * (ignoring implicitly fixed variables). */ - for( i=0; i 0.0 ) - maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); - else - maxStepLength[ii] = 0.0; - } - } - else - { - /* active upper bounds */ - if ( delta_yFX[i] > ZERO ) - { - if ( y[ii] < 0.0 ) - maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); - else - maxStepLength[ii] = 0.0; - } - } - } - } - - - /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH */ - /* 1) Ensure that inactive constraints' bounds remain valid - * (ignoring unbounded constraints). */ - real_t delta_x[NVMAX]; - for( j=0; j delta_Ax[ii] ) - { - if ( Ax[ii] > lbA[ii] ) - maxStepLength[nV+ii] = ( Ax[ii] - lbA[ii] ) / ( delta_lbA[ii] - delta_Ax[ii] ); - else - maxStepLength[nV+ii] = 0.0; - } - } - - /* inactive upper constraints' bounds */ - if ( constraints.isNoUpper( ) == BT_FALSE ) - { - if ( delta_ubA[ii] < delta_Ax[ii] ) - { - if ( Ax[ii] < ubA[ii] ) - maxStepLength[nV+nC+nV+ii] = ( Ax[ii] - ubA[ii] ) / ( delta_ubA[ii] - delta_Ax[ii] ); - else - maxStepLength[nV+nC+nV+ii] = 0.0; - } - } - } - } - - - /* 2) Ensure that inactive bounds remain valid - * (ignoring unbounded variables). */ - /* inactive lower bounds */ - if ( bounds.isNoLower( ) == BT_FALSE ) - { - for( i=0; i delta_xFR[i] ) - { - if ( x[ii] > lb[ii] ) - maxStepLength[ii] = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); - else - maxStepLength[ii] = 0.0; - } - } - } - - /* inactive upper bounds */ - if ( bounds.isNoUpper( ) == BT_FALSE ) - { - for( i=0; i EPS ) - cyclingManager.clearCyclingData( ); - - - /* V) SET MAXIMUM HOMOTOPY STEPLENGTH */ - tau = tau_new; - - #ifdef PC_DEBUG - if ( printlevel == PL_HIGH ) - { - - char messageString[80]; - - if ( BC_status == ST_UNDEFINED ) - sprintf( messageString,"Stepsize is %.6e!",tau ); - else - sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_isBound = %d, BC_status = %d)",tau,BC_idx,BC_isBound,BC_status ); - - getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - #endif - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ p e r f o r m S t e p - */ -returnValue QProblem::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, const int* const IAC_idx, - const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, - const real_t* const delta_lb, const real_t* const delta_ub, - const real_t* const delta_xFX, const real_t* const delta_xFR, - const real_t* const delta_yAC, const real_t* const delta_yFX, - const real_t* const delta_Ax, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound - ) -{ - int i, j, ii; - int nV = getNV( ); - int nC = getNC( ); - int nFR = getNFR( ); - int nFX = getNFX( ); - int nAC = getNAC( ); - int nIAC = getNIAC( ); - - - /* I) CHECK (CONSTRAINTS') BOUNDS' CONSISTENCY */ - if ( areBoundsConsistent( delta_lb,delta_ub,delta_lbA,delta_ubA ) == BT_FALSE ) - { - infeasible = BT_TRUE; - tau = 0.0; - - return THROWERROR( RET_QP_INFEASIBLE ); - } - - - /* II) GO TO ACTIVE SET CHANGE */ - if ( tau > ZERO ) - { - /* 1) Perform step in primal und dual space... */ - for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* III) UPDATE ACTIVE SET */ - switch ( BC_status ) - { - /* Optimal solution found as no working set change detected. */ - case ST_UNDEFINED: - return RET_OPTIMAL_SOLUTION_FOUND; - - - /* Remove one variable from active set. */ - case ST_INACTIVE: - if ( BC_isBound == BT_TRUE ) - { - #ifdef PC_DEBUG - sprintf( messageString,"bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[BC_idx] = 0.0; - } - else - { - #ifdef PC_DEBUG - sprintf( messageString,"constraint no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeConstraint( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[nV+BC_idx] = 0.0; - } - break; - - - /* Add one variable to active set. */ - default: - if ( BC_isBound == BT_TRUE ) - { - #ifdef PC_DEBUG - if ( BC_status == ST_LOWER ) - sprintf( messageString,"lower bound no. %d.", BC_idx ); - else - sprintf( messageString,"upper bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); - } - else - { - #ifdef PC_DEBUG - if ( BC_status == ST_LOWER ) - sprintf( messageString,"lower constraint's bound no. %d.", BC_idx ); - else - sprintf( messageString,"upper constraint's bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( addConstraint( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); - } - break; - } - - return SUCCESSFUL_RETURN; -} - - -/* - * a r e B o u n d s C o n s i s t e n t - */ -BooleanType QProblem::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub, - const real_t* const delta_lbA, const real_t* const delta_ubA - ) const -{ - int i; - - /* 1) Check bounds' consistency. */ - if ( QProblemB::areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) - return BT_FALSE; - - /* 2) Check constraints' consistency, i.e. - * check if delta_lb[i] is greater than delta_ub[i] - * for a component i whose bounds are already (numerically) equal. */ - for( i=0; i ubA[i] - BOUNDTOL ) && ( delta_lbA[i] > delta_ubA[i] + EPS ) ) - return BT_FALSE; - - return BT_TRUE; -} - - -/* - * s e t u p Q P d a t a - */ -returnValue QProblem::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, const real_t* const _A, - const real_t* const _lb, const real_t* const _ub, - const real_t* const _lbA, const real_t* const _ubA - ) -{ - int i, j; - int nV = getNV( ); - int nC = getNC( ); - - - /* 1) Load Hessian matrix as well as lower and upper bounds vectors. */ - if (QProblemB::setupQPdata(_H, _R, _g, _lb, _ub) != SUCCESSFUL_RETURN) - return THROWERROR( RET_INVALID_ARGUMENTS ); - - /* 2) Load constraint matrix. */ - if ( ( nC > 0 ) && ( _A == 0 ) ) - return THROWERROR( RET_INVALID_ARGUMENTS ); - - if ( nC > 0 ) - { - for( i=0; igetNumberArray( AC_idx ); - - /* 1) check for Hx + g - [yFX yAC]*[Id A]' = 0. */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = getAbs( tmp ); - } - - /* 2) Check for [lb lbA] <= [Id A]*x <= [ub ubA]. */ - /* lbA <= Ax <= ubA */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = lbA[i] - Ax[i]; - - if ( Ax[i] - ubA[i] > maxKKTviolation ) - maxKKTviolation = Ax[i] - ubA[i]; - } - - /* lb <= x <= ub */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = lb[i] - x[i]; - - if ( x[i] - ub[i] > maxKKTviolation ) - maxKKTviolation = x[i] - ub[i]; - } - - /* 3) Check for correct sign of y and for complementary slackness. */ - /* bounds */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = -y[i]; - if ( getAbs( x[i] - lb[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( x[i] - lb[i] ); - break; - - case ST_UPPER: - if ( y[i] > maxKKTviolation ) - maxKKTviolation = y[i]; - if ( getAbs( ub[i] - x[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ub[i] - x[i] ); - break; - - default: /* inactive */ - if ( getAbs( y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( y[i] ); - break; - } - } - - /* constraints */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = -y[nV+i]; - if ( getAbs( Ax[i] - lbA[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( Ax[i] - lbA[i] ); - break; - - case ST_UPPER: - if ( y[nV+i] > maxKKTviolation ) - maxKKTviolation = y[nV+i]; - if ( getAbs( ubA[i] - Ax[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ubA[i] - Ax[i] ); - break; - - default: /* inactive */ - if ( getAbs( y[nV+i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( y[nV+i] ); - break; - } - } - - if ( maxKKTviolation > CRITICALACCURACY ) - return RET_NO_SOLUTION; - - if ( maxKKTviolation > DESIREDACCURACY ) - return RET_INACCURATE_SOLUTION; - - #endif /* __PERFORM_KKT_TEST__ */ - - return SUCCESSFUL_RETURN; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/QProblem.ipp b/phonelibs/qpoases/SRC/QProblem.ipp deleted file mode 100644 index e98ada633..000000000 --- a/phonelibs/qpoases/SRC/QProblem.ipp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblem.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the QProblem class which - * is able to use the newly developed online active set strategy for - * parametric quadratic programming. - */ - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t A - */ -inline returnValue QProblem::getA( real_t* const _A ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - for ( int i=0; i= 0 ) && ( number < getNC( ) ) ) - { - value = lbA[number]; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * g e t U B A - */ -inline returnValue QProblem::getUBA( real_t* const _ubA ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - value = ubA[number]; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * g e t C o n s t r a i n t s - */ -inline returnValue QProblem::getConstraints( Constraints* const _constraints ) const -{ - *_constraints = constraints; - - return SUCCESSFUL_RETURN; -} - - - -/* - * g e t N C - */ -inline int QProblem::getNC( ) const -{ - return constraints.getNC( ); -} - - -/* - * g e t N E C - */ -inline int QProblem::getNEC( ) const -{ - return constraints.getNEC( ); -} - - -/* - * g e t N A C - */ -inline int QProblem::getNAC( ) -{ - return constraints.getNAC( ); -} - - -/* - * g e t N I A C - */ -inline int QProblem::getNIAC( ) -{ - return constraints.getNIAC( ); -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - - -/* - * s e t A - */ -inline returnValue QProblem::setA( const real_t* const A_new ) -{ - int i, j; - int nV = getNV( ); - int nC = getNC( ); - - /* Set constraint matrix AND update member AX. */ - for( j=0; j= 0 ) && ( number < getNC( ) ) ) - { - Ax[number] = 0.0; - - for( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - lbA[number] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * s e t U B A - */ -inline returnValue QProblem::setUBA( const real_t* const ubA_new ) -{ - int i; - int nC = getNC(); - - for( i=0; i= 0 ) && ( number < getNC( ) ) ) - { - ubA[number] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/QProblemB.cpp b/phonelibs/qpoases/SRC/QProblemB.cpp deleted file mode 100644 index 47ac3536f..000000000 --- a/phonelibs/qpoases/SRC/QProblemB.cpp +++ /dev/null @@ -1,2151 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblemB.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the QProblemB class which is able to use the newly - * developed online active set strategy for parametric quadratic programming. - */ - - -#include - -#include - -void printmatrix(char *name, double *A, int m, int n) { - int i, j; - - printf("%s = [...\n", name); - for (i = 0; i < m; i++) { - for (j = 0; j < n; j++) - printf(" % 9.4f", A[i*n+j]); - printf(",\n"); - } - printf("];\n"); -} - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * Q P r o b l e m B - */ -QProblemB::QProblemB( ) -{ - /* reset global message handler */ - getGlobalMessageHandler( )->reset( ); - - hasHessian = BT_FALSE; - - bounds.init( 0 ); - - hasCholesky = BT_FALSE; - - tau = 0.0; - - hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ - infeasible = BT_FALSE; - unbounded = BT_FALSE; - - status = QPS_NOTINITIALISED; - - #ifdef PC_DEBUG - printlevel = PL_MEDIUM; - setPrintLevel( PL_MEDIUM ); - #else - printlevel = QPOASES_PRINTLEVEL; - #endif - - count = 0; -} - - -/* - * Q P r o b l e m B - */ -QProblemB::QProblemB( int _nV ) -{ - /* consistency check */ - if ( _nV <= 0 ) - { - _nV = 1; - THROWERROR( RET_INVALID_ARGUMENTS ); - } - - hasHessian = BT_FALSE; - - /* reset global message handler */ - getGlobalMessageHandler( )->reset( ); - - bounds.init( _nV ); - - hasCholesky = BT_FALSE; - - tau = 0.0; - - hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ - infeasible = BT_FALSE; - unbounded = BT_FALSE; - - status = QPS_NOTINITIALISED; - - #ifdef PC_DEBUG - printlevel = PL_MEDIUM; - setPrintLevel( PL_MEDIUM ); - #else - printlevel = QPOASES_PRINTLEVEL; - #endif - - count = 0; -} - - -/* - * Q P r o b l e m B - */ -QProblemB::QProblemB( const QProblemB& rhs ) -{ - int i, j; - - int _nV = rhs.bounds.getNV( ); - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; - - hasHessian = rhs.hasHessian; - - for( i=0; i<_nV; ++i ) - g[i] = rhs.g[i]; - - for( i=0; i<_nV; ++i ) - lb[i] = rhs.lb[i]; - - for( i=0; i<_nV; ++i ) - ub[i] = rhs.ub[i]; - - - bounds = rhs.bounds; - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; - hasCholesky = rhs.hasCholesky; - - for( i=0; i<_nV; ++i ) - x[i] = rhs.x[i]; - - for( i=0; i<_nV; ++i ) - y[i] = rhs.y[i]; - - tau = rhs.tau; - - hessianType = rhs.hessianType; - infeasible = rhs.infeasible; - unbounded = rhs.unbounded; - - status = rhs.status; - - printlevel = rhs.printlevel; - - count = rhs.count; -} - - -/* - * ~ Q P r o b l e m B - */ -QProblemB::~QProblemB( ) -{ -} - - -/* - * o p e r a t o r = - */ -QProblemB& QProblemB::operator=( const QProblemB& rhs ) -{ - int i, j; - - if ( this != &rhs ) - { - int _nV = rhs.bounds.getNV( ); - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; - - hasHessian = rhs.hasHessian; - - for( i=0; i<_nV; ++i ) - g[i] = rhs.g[i]; - - for( i=0; i<_nV; ++i ) - lb[i] = rhs.lb[i]; - - for( i=0; i<_nV; ++i ) - ub[i] = rhs.ub[i]; - - bounds = rhs.bounds; - - for( i=0; i<_nV; ++i ) - for( j=0; j<_nV; ++j ) - R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; - hasCholesky = rhs.hasCholesky; - - - for( i=0; i<_nV; ++i ) - x[i] = rhs.x[i]; - - for( i=0; i<_nV; ++i ) - y[i] = rhs.y[i]; - - tau = rhs.tau; - - hessianType = rhs.hessianType; - infeasible = rhs.infeasible; - unbounded = rhs.unbounded; - - status = rhs.status; - - printlevel = rhs.printlevel; - setPrintLevel( rhs.printlevel ); - - count = rhs.count; - } - - return *this; -} - - -/* - * r e s e t - */ -returnValue QProblemB::reset( ) -{ - int i, j; - int nV = getNV( ); - - /** 0) Reset has Hessian flag. */ - hasHessian = BT_FALSE; - - /* 1) Reset bounds. */ - bounds.init( nV ); - - /* 2) Reset Cholesky decomposition. */ - for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* 1) Setup index arrays. */ - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_HOTSTART_FAILED ); - - /* 2) Initialize shift direction of the gradient and the bounds. */ - returnvalue = hotstart_determineDataShift( FX_idx, - g_new,lb_new,ub_new, - delta_g,delta_lb,delta_ub, - Delta_bB_isZero - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 3) Determination of step direction of X and Y. */ - returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx, - delta_g,delta_lb,delta_ub, - Delta_bB_isZero, - delta_xFX,delta_xFR,delta_yFX - ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); - return returnvalue; - } - - - /* 4) Determination of step length TAU. */ - returnvalue = hotstart_determineStepLength( FR_idx,FX_idx, - delta_lb,delta_ub, - delta_xFR,delta_yFX, - BC_idx,BC_status ); - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); - return returnvalue; - } - - /* 5) Realization of the homotopy step. */ - returnvalue = hotstart_performStep( FR_idx,FX_idx, - delta_g,delta_lb,delta_ub, - delta_xFX,delta_xFR,delta_yFX, - BC_idx,BC_status - ); - - - if ( returnvalue != SUCCESSFUL_RETURN ) - { - nWSR = l; - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - /* optimal solution found? */ - if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) - { - status = QPS_SOLVED; - - if ( printlevel == PL_HIGH ) - THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - - /* check KKT optimality conditions */ - return checkKKTconditions( ); - } - else - { - /* checks for infeasibility... */ - if ( infeasible == BT_TRUE ) - { - status = QPS_HOMOTOPYQPSOLVED; - return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); - } - - /* ...unboundedness... */ - if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ - return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); - - /* ... and throw unspecific error otherwise */ - THROWERROR( RET_HOMOTOPY_STEP_FAILED ); - return returnvalue; - } - } - - /* 6) Output information of successful QP iteration. */ - status = QPS_HOMOTOPYQPSOLVED; - - #ifdef PC_DEBUG - if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) - THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ - #endif - } - - - /* stop runtime measurement */ - if ( cputime != 0 ) - *cputime = getCPUtime( ) - starttime; - - - /* if programm gets to here, output information that QP could not be solved - * within the given maximum numbers of working set changes */ - if ( printlevel == PL_HIGH ) - { - #ifdef PC_DEBUG - sprintf( messageString,"(nWSR = %d)",nWSR ); - return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - /* Finally check KKT optimality conditions. */ - returnValue returnvalueKKTcheck = checkKKTconditions( ); - - if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) - return returnvalueKKTcheck; - else - return RET_MAX_NWSR_REACHED; -} - - -/* - * g e t N Z - */ -int QProblemB::getNZ( ) -{ - /* if no constraints are present: nZ=nFR */ - return bounds.getFree( )->getLength( ); -} - - -/* - * g e t O b j V a l - */ -real_t QProblemB::getObjVal( ) const -{ - real_t objVal; - - /* calculated optimal objective function value - * only if current QP has been solved */ - if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || - ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || - ( getStatus( ) == QPS_SOLVED ) ) - { - objVal = getObjVal( x ); - } - else - { - objVal = INFTY; - } - - return objVal; -} - - -/* - * g e t O b j V a l - */ -real_t QProblemB::getObjVal( const real_t* const _x ) const -{ - int i, j; - int nV = getNV( ); - - real_t obj_tmp = 0.0; - - for( i=0; i= PL_MEDIUM ) && ( printlevel != _printlevel ) ) - THROWINFO( RET_PRINTLEVEL_CHANGED ); - #endif - - printlevel = _printlevel; - - /* update message handler preferences */ - switch ( printlevel ) - { - case PL_NONE: - getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_HIDDEN ); - getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); - getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); - break; - - case PL_LOW: - getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); - getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); - getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); - break; - - default: /* PL_MEDIUM, PL_HIGH */ - getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); - getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_VISIBLE ); - getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_VISIBLE ); - break; - } - - return SUCCESSFUL_RETURN; -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - -/* - * c h e c k F o r I d e n t i t y H e s s i a n - */ -returnValue QProblemB::checkForIdentityHessian( ) -{ - int i, j; - int nV = getNV( ); - - /* nothing to do as status flag remains unaltered - * if Hessian differs from identity matrix */ - if ( hessianType == HST_IDENTITY ) - return SUCCESSFUL_RETURN; - - /* 1) If Hessian differs from identity matrix, - * return without changing the internal HessianType. */ - for ( i=0; i EPS ) - return SUCCESSFUL_RETURN; - - for ( i=0; i EPS ) || ( getAbs( H[j*NVMAX + i] ) > EPS ) ) - return SUCCESSFUL_RETURN; - } - - /* 2) If this point is reached, Hessian equals the idetity matrix. */ - hessianType = HST_IDENTITY; - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p S u b j e c t T o T y p e - */ -returnValue QProblemB::setupSubjectToType( ) -{ - int i; - int nV = getNV( ); - - - /* 1) Check if lower bounds are present. */ - bounds.setNoLower( BT_TRUE ); - for( i=0; i -INFTY ) - { - bounds.setNoLower( BT_FALSE ); - break; - } - - /* 2) Check if upper bounds are present. */ - bounds.setNoUpper( BT_TRUE ); - for( i=0; i INFTY - BOUNDTOL ) ) - { - bounds.setType( i,ST_UNBOUNDED ); - ++nUV; - } - else - { - if ( lb[i] > ub[i] - BOUNDTOL ) - { - bounds.setType( i,ST_EQUALITY ); - ++nFV; - } - else - { - bounds.setType( i,ST_BOUNDED ); - } - } - - /* 4) Set dimensions of bounds structure. */ - bounds.setNFV( nFV ); - bounds.setNUV( nUV ); - bounds.setNBV( nV - nFV - nUV ); - - return SUCCESSFUL_RETURN; -} - - -/* - * c h o l e s k y D e c o m p o s i t i o n - */ -returnValue QProblemB::setupCholeskyDecomposition( ) -{ - int i, j, k, ii, jj; - int nV = getNV( ); - int nFR = getNFR( ); - - /* If Hessian flag is false, it means that H & R already contain Cholesky - * factorization -- provided from outside. */ - if (hasHessian == BT_FALSE) - return SUCCESSFUL_RETURN; - - /* 1) Initialises R with all zeros. */ - for( i=0; i 0 ) - { - int FR_idx[NVMAX]; - if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INDEXLIST_CORRUPTED ); - - /* R'*R = H */ - real_t sum; - real_t inv; - - for( i=0; i=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; - - if ( sum > 0.0 ) - { - R[i*NVMAX + i] = sqrt( sum ); - inv = 1.0 / R[i*NVMAX + i]; - } - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - /* j > i */ - for( j=(i+1); j=0; --k ) - sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; - - R[i*NVMAX + j] = sum * inv; - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s o l v e I n i t i a l Q P - */ -returnValue QProblemB::solveInitialQP( const real_t* const xOpt, const real_t* const yOpt, - const Bounds* const guessedBounds, - int& nWSR, real_t* const cputime - ) -{ - int i, nFR; - int nV = getNV( ); - - - /* start runtime measurement */ - real_t starttime = 0.0; - if ( cputime != 0 ) - starttime = getCPUtime( ); - - - status = QPS_NOTINITIALISED; - - /* I) ANALYSE QP DATA: */ - /* 1) Check if Hessian happens to be the identity matrix. */ - if ( checkForIdentityHessian( ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 2) Setup type of bounds (i.e. unbounded, implicitly fixed etc.). */ - if ( setupSubjectToType( ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - status = QPS_PREPARINGAUXILIARYQP; - - - /* II) SETUP AUXILIARY QP WITH GIVEN OPTIMAL SOLUTION: */ - /* 1) Setup bounds data structure. */ - if ( bounds.setupAllFree( ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 2) Setup optimal primal/dual solution for auxiliary QP. */ - if ( setupAuxiliaryQPsolution( xOpt,yOpt ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 3) Obtain linear independent working set for auxiliary QP. */ - - static Bounds auxiliaryBounds; - - auxiliaryBounds.init( nV ); - - if ( obtainAuxiliaryWorkingSet( xOpt,yOpt,guessedBounds, &auxiliaryBounds ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - /* 4) Setup working set of auxiliary QP and setup cholesky decomposition. */ - if ( setupAuxiliaryWorkingSet( &auxiliaryBounds,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_INIT_FAILED ); - - nFR = getNFR(); - /* At the moment we can only provide a Cholesky of the Hessian if - * the solver is cold-started. */ - if (hasCholesky == BT_FALSE || nFR != nV) - if (setupCholeskyDecomposition() != SUCCESSFUL_RETURN) - return THROWERROR( RET_INIT_FAILED_CHOLESKY ); - - /* 5) Store original QP formulation... */ - real_t g_original[NVMAX]; - real_t lb_original[NVMAX]; - real_t ub_original[NVMAX]; - - for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,guessedBounds->getStatus( i ) ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - else /* No initial working set specified. */ - { - if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) - { - /* Obtain initial working set by "clipping". */ - for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( xOpt[i] >= ub[i] - BOUNDTOL ) - { - if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all implictly fixed variables if specified. */ - if ( bounds.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) - { - /* Obtain initial working set in accordance to sign of dual solution vector. */ - for( i=0; i ZERO ) - { - if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - if ( yOpt[i] < -ZERO ) - { - if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - continue; - } - - /* Moreover, add all implictly fixed variables if specified. */ - if ( bounds.getType( i ) == ST_EQUALITY ) - { - if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - - /* If xOpt and yOpt are null pointer and no initial working is specified, - * start with empty working set (or implicitly fixed bounds only) - * for auxiliary QP. */ - if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) - { - for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - else - { - if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); - } - } - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A u x i l i a r y W o r k i n g S e t - */ -returnValue QProblemB::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, - BooleanType setupAfresh - ) -{ - int i; - int nV = getNV( ); - - /* consistency checks */ - if ( auxiliaryBounds != 0 ) - { - for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) - return THROWERROR( RET_UNKNOWN_BUG ); - } - else - { - return THROWERROR( RET_INVALID_ARGUMENTS ); - } - - - /* I) SETUP CHOLESKY FLAG: - * Cholesky decomposition shall only be updated if working set - * shall be updated (i.e. NOT setup afresh!) */ - BooleanType updateCholesky; - if ( setupAfresh == BT_TRUE ) - updateCholesky = BT_FALSE; - else - updateCholesky = BT_TRUE; - - - /* II) REMOVE FORMERLY ACTIVE BOUNDS (IF NECESSARY): */ - if ( setupAfresh == BT_FALSE ) - { - /* Remove all active bounds that shall be inactive AND - * all active bounds that are active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_LOWER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - - if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) - if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - - - /* III) ADD NEWLY ACTIVE BOUNDS: */ - /* Add all inactive bounds that shall be active AND - * all formerly active bounds that have been active at the wrong bound. */ - for( i=0; igetStatus( i ) != ST_INACTIVE ) ) - { - if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * s e t u p A u x i l i a r y Q P s o l u t i o n - */ -returnValue QProblemB::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt - ) -{ - int i; - int nV = getNV( ); - - - /* Setup primal/dual solution vectors for auxiliary initial QP: - * if a null pointer is passed, a zero vector is assigned; - * old solution vector is kept if pointer to internal solution vector is passed. */ - if ( xOpt != 0 ) - { - if ( xOpt != x ) - for( i=0; igetIndex( number ); - - real_t c, s; - - /* 2) Use row-wise Givens rotations to restore upper triangular form of R. */ - for( i=number_idx+1; ith column and ... */ - for( i=0; igetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVEBOUND_FAILED ); - - /* 1) Calculate new column of cholesky decomposition. */ - real_t rhs[NVMAX]; - real_t r[NVMAX]; - real_t r0 = H[number*NVMAX + number]; - - for( i=0; i 0.0 ) - R[nFR*NVMAX + nFR] = sqrt( r0 ); - else - { - hessianType = HST_SEMIDEF; - return THROWERROR( RET_HESSIAN_NOT_SPD ); - } - - - return SUCCESSFUL_RETURN; -} - - -/* - * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) - */ -returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, - real_t* const a - ) -{ - /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ - return backsolveR( b,transposed,BT_FALSE,a ); -} - - -/* - * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) - */ -returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, - BooleanType removingBound, - real_t* const a - ) -{ - int i, j; - int nR = getNZ( ); - - real_t sum; - - /* if backsolve is called while removing a bound, reduce nZ by one. */ - if ( removingBound == BT_TRUE ) - --nR; - - /* nothing to do */ - if ( nR <= 0 ) - return SUCCESSFUL_RETURN; - - - /* Solve Ra = b, where R might be transposed. */ - if ( transposed == BT_FALSE ) - { - /* solve Ra = b */ - for( i=(nR-1); i>=0; --i ) - { - sum = b[i]; - for( j=(i+1); j ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - else - { - /* solve R^T*a = b */ - for( i=0; i ZERO ) - a[i] = sum / R[i*NVMAX + i]; - else - return THROWERROR( RET_DIV_BY_ZERO ); - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ d e t e r m i n e D a t a S h i f t - */ -returnValue QProblemB::hotstart_determineDataShift( const int* const FX_idx, - const real_t* const g_new, const real_t* const lb_new, const real_t* const ub_new, - real_t* const delta_g, real_t* const delta_lb, real_t* const delta_ub, - BooleanType& Delta_bB_isZero - ) -{ - int i, ii; - int nV = getNV( ); - int nFX = getNFX( ); - - - /* 1) Calculate shift directions. */ - for( i=0; i EPS ) || ( getAbs( delta_ub[ii] ) > EPS ) ) - { - Delta_bB_isZero = BT_FALSE; - break; - } - } - - return SUCCESSFUL_RETURN; -} - - -/* - * a r e B o u n d s C o n s i s t e n t - */ -BooleanType QProblemB::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub - ) const -{ - int i; - - /* Check if delta_lb[i] is greater than delta_ub[i] - * for a component i whose bounds are already (numerically) equal. */ - for( i=0; i ub[i] - BOUNDTOL ) && ( delta_lb[i] > delta_ub[i] + EPS ) ) - return BT_FALSE; - - return BT_TRUE; -} - - -/* - * s e t u p Q P d a t a - */ -returnValue QProblemB::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, - const real_t* const _lb, const real_t* const _ub - ) -{ - int i, j; - int nV = getNV( ); - - /* 1) Setup Hessian matrix and it's Cholesky factorization. */ - if (_H != 0) - { - for( i=0; i 0 ) - { - for( i=0; i 0 ) - { - /* auxiliary variables */ - real_t delta_xFRz_TMP[NVMAX]; - real_t delta_xFRz_RHS[NVMAX]; - - /* Determine delta_xFRz. */ - if ( Delta_bB_isZero == BT_FALSE ) - { - for( i=0; i 0 ) - { - for( i=0; i= 0.0 ) ) - { - tau_tmp = y[ii] / ( -delta_yFX[i] ); - if ( tau_tmp < tau_new ) - { - if ( tau_tmp >= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_INACTIVE; - } - } - } - } - else - { - /* 2) Active upper bounds. */ - if ( ( delta_yFX[i] > ZERO ) && ( y[ii] <= 0.0 ) ) - { - tau_tmp = y[ii] / ( -delta_yFX[i] ); - if ( tau_tmp < tau_new ) - { - if ( tau_tmp >= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_INACTIVE; - } - } - } - } - } - } - - - /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH, i.e. ensure that - * inactive bounds remain valid (ignoring unbounded variables). */ - /* 1) Inactive lower bounds. */ - if ( bounds.isNoLower( ) == BT_FALSE ) - { - for( i=0; i delta_xFR[i] ) - { - if ( x[ii] > lb[ii] ) - tau_tmp = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); - else - tau_tmp = 0.0; - - if ( tau_tmp < tau_new ) - { - if ( tau_tmp >= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_LOWER; - } - } - } - } - } - } - - /* 2) Inactive upper bounds. */ - if ( bounds.isNoUpper( ) == BT_FALSE ) - { - for( i=0; i= 0.0 ) - { - tau_new = tau_tmp; - BC_idx = ii; - BC_status = ST_UPPER; - } - } - } - } - } - } - - - /* III) SET MAXIMUM HOMOTOPY STEPLENGTH */ - tau = tau_new; - - if ( printlevel == PL_HIGH ) - { - #ifdef PC_DEBUG - char messageString[80]; - - if ( BC_status == ST_UNDEFINED ) - sprintf( messageString,"Stepsize is %.6e!",tau ); - else - sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_status = %d)",tau,BC_idx,BC_status ); - - getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - return SUCCESSFUL_RETURN; -} - - -/* - * h o t s t a r t _ p e r f o r m S t e p - */ -returnValue QProblemB::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, - const real_t* const delta_g, const real_t* const delta_lb, const real_t* const delta_ub, - const real_t* const delta_xFX, const real_t* const delta_xFR, - const real_t* const delta_yFX, - int BC_idx, SubjectToStatus BC_status - ) -{ - int i, ii; - int nV = getNV( ); - int nFR = getNFR( ); - int nFX = getNFX( ); - - - /* I) CHECK BOUNDS' CONSISTENCY */ - if ( areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) - { - infeasible = BT_TRUE; - tau = 0.0; - - return THROWERROR( RET_QP_INFEASIBLE ); - } - - - /* II) GO TO ACTIVE SET CHANGE */ - if ( tau > ZERO ) - { - /* 1) Perform step in primal und dual space. */ - for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - #endif - } - - - /* setup output preferences */ - #ifdef PC_DEBUG - char messageString[80]; - VisibilityStatus visibilityStatus; - - if ( printlevel == PL_HIGH ) - visibilityStatus = VS_VISIBLE; - else - visibilityStatus = VS_HIDDEN; - #endif - - - /* III) UPDATE ACTIVE SET */ - switch ( BC_status ) - { - /* Optimal solution found as no working set change detected. */ - case ST_UNDEFINED: - return RET_OPTIMAL_SOLUTION_FOUND; - - - /* Remove one variable from active set. */ - case ST_INACTIVE: - #ifdef PC_DEBUG - sprintf( messageString,"bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); - - y[BC_idx] = 0.0; - break; - - - /* Add one variable to active set. */ - default: - #ifdef PC_DEBUG - if ( BC_status == ST_LOWER ) - sprintf( messageString,"lower bound no. %d.", BC_idx ); - else - sprintf( messageString,"upper bound no. %d.", BC_idx ); - getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); - #endif - - if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); - break; - } - - return SUCCESSFUL_RETURN; -} - - -#ifdef PC_DEBUG /* Define print functions only for debugging! */ - -/* - * p r i n t I t e r a t i o n - */ -returnValue QProblemB::printIteration( int iteration, - int BC_idx, SubjectToStatus BC_status - ) -{ - char myPrintfString[160]; - - /* consistency check */ - if ( iteration < 0 ) - return THROWERROR( RET_INVALID_ARGUMENTS ); - - /* nothing to do */ - if ( printlevel != PL_MEDIUM ) - return SUCCESSFUL_RETURN; - - - /* 1) Print header at first iteration. */ - if ( iteration == 0 ) - { - sprintf( myPrintfString,"\n############## qpOASES -- QP NO.%4.1d ###############\n", count ); - myPrintf( myPrintfString ); - - sprintf( myPrintfString," Iter | StepLength | Info | nFX \n" ); - myPrintf( myPrintfString ); - } - - /* 2) Print iteration line. */ - if ( BC_status == ST_UNDEFINED ) - { - sprintf( myPrintfString," %4.1d | %1.5e | QP SOLVED | %4.1d \n", iteration,tau,getNFX( ) ); - myPrintf( myPrintfString ); - } - else - { - char info[8]; - - if ( BC_status == ST_INACTIVE ) - sprintf( info,"REM BND" ); - else - sprintf( info,"ADD BND" ); - - sprintf( myPrintfString," %4.1d | %1.5e | %s%4.1d | %4.1d \n", iteration,tau,info,BC_idx,getNFX( ) ); - myPrintf( myPrintfString ); - } - - return SUCCESSFUL_RETURN; -} - -#endif /* PC_DEBUG */ - - - -/* - * c h e c k K K T c o n d i t i o n s - */ -returnValue QProblemB::checkKKTconditions( ) -{ - #ifdef __PERFORM_KKT_TEST__ - - int i, j; - int nV = getNV( ); - - real_t tmp; - real_t maxKKTviolation = 0.0; - - - /* 1) Check for Hx + g - y*A' = 0 (here: A = Id). */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = getAbs( tmp ); - } - - /* 2) Check for lb <= x <= ub. */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = lb[i] - x[i]; - - if ( x[i] - ub[i] > maxKKTviolation ) - maxKKTviolation = x[i] - ub[i]; - } - - /* 3) Check for correct sign of y and for complementary slackness. */ - for( i=0; i maxKKTviolation ) - maxKKTviolation = -y[i]; - if ( getAbs( ( x[i] - lb[i] ) * y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ( x[i] - lb[i] ) * y[i] ); - break; - - case ST_UPPER: - if ( y[i] > maxKKTviolation ) - maxKKTviolation = y[i]; - if ( getAbs( ( ub[i] - x[i] ) * y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( ( ub[i] - x[i] ) * y[i] ); - break; - - default: /* inactive */ - if ( getAbs( y[i] ) > maxKKTviolation ) - maxKKTviolation = getAbs( y[i] ); - break; - } - } - - if ( maxKKTviolation > CRITICALACCURACY ) - return RET_NO_SOLUTION; - - if ( maxKKTviolation > DESIREDACCURACY ) - return RET_INACCURATE_SOLUTION; - - #endif /* __PERFORM_KKT_TEST__ */ - - return SUCCESSFUL_RETURN; -} - - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/QProblemB.ipp b/phonelibs/qpoases/SRC/QProblemB.ipp deleted file mode 100644 index 0b031301e..000000000 --- a/phonelibs/qpoases/SRC/QProblemB.ipp +++ /dev/null @@ -1,425 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/QProblemB.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of inlined member functions of the QProblemB class which - * is able to use the newly developed online active set strategy for - * parametric quadratic programming. - */ - - - -#include - - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - -/* - * g e t H - */ -inline returnValue QProblemB::getH( real_t* const _H ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - value = lb[number]; - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * g e t U B - */ -inline returnValue QProblemB::getUB( real_t* const _ub ) const -{ - int i; - - for ( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - value = ub[number]; - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * g e t B o u n d s - */ -inline returnValue QProblemB::getBounds( Bounds* const _bounds ) const -{ - *_bounds = bounds; - - return SUCCESSFUL_RETURN; -} - - -/* - * g e t N V - */ -inline int QProblemB::getNV( ) const -{ - return bounds.getNV( ); -} - - -/* - * g e t N F R - */ -inline int QProblemB::getNFR( ) -{ - return bounds.getNFR( ); -} - - -/* - * g e t N F X - */ -inline int QProblemB::getNFX( ) -{ - return bounds.getNFX( ); -} - - -/* - * g e t N F V - */ -inline int QProblemB::getNFV( ) const -{ - return bounds.getNFV( ); -} - - -/* - * g e t S t a t u s - */ -inline QProblemStatus QProblemB::getStatus( ) const -{ - return status; -} - - -/* - * i s I n i t i a l i s e d - */ -inline BooleanType QProblemB::isInitialised( ) const -{ - if ( status == QPS_NOTINITIALISED ) - return BT_FALSE; - else - return BT_TRUE; -} - - -/* - * i s S o l v e d - */ -inline BooleanType QProblemB::isSolved( ) const -{ - if ( status == QPS_SOLVED ) - return BT_TRUE; - else - return BT_FALSE; -} - - -/* - * i s I n f e a s i b l e - */ -inline BooleanType QProblemB::isInfeasible( ) const -{ - return infeasible; -} - - -/* - * i s U n b o u n d e d - */ -inline BooleanType QProblemB::isUnbounded( ) const -{ - return unbounded; -} - - -/* - * g e t P r i n t L e v e l - */ -inline PrintLevel QProblemB::getPrintLevel( ) const -{ - return printlevel; -} - - -/* - * g e t H e s s i a n T y p e - */ -inline HessianType QProblemB::getHessianType( ) const -{ - return hessianType; -} - - -/* - * s e t H e s s i a n T y p e - */ -inline returnValue QProblemB::setHessianType( HessianType _hessianType ) -{ - hessianType = _hessianType; - return SUCCESSFUL_RETURN; -} - - - -/***************************************************************************** - * P R O T E C T E D * - *****************************************************************************/ - -/* - * s e t H - */ -inline returnValue QProblemB::setH( const real_t* const H_new ) -{ - int i, j; - - int nV = getNV(); - - for( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - lb[number] = value; - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * s e t U B - */ -inline returnValue QProblemB::setUB( const real_t* const ub_new ) -{ - int i; - - int nV = getNV(); - - for( i=0; i= 0 ) && ( number < getNV( ) ) ) - { - ub[number] = value; - - return SUCCESSFUL_RETURN; - } - else - { - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); - } -} - - -/* - * c o m p u t e G i v e n s - */ -inline void QProblemB::computeGivens( real_t xold, real_t yold, real_t& xnew, real_t& ynew, - real_t& c, real_t& s - ) const -{ - if ( getAbs( yold ) <= ZERO ) - { - c = 1.0; - s = 0.0; - - xnew = xold; - ynew = yold; - } - else - { - real_t t, mu; - - mu = getAbs( xold ); - if ( getAbs( yold ) > mu ) - mu = getAbs( yold ); - - t = mu * sqrt( (xold/mu)*(xold/mu) + (yold/mu)*(yold/mu) ); - - if ( xold < 0.0 ) - t = -t; - - c = xold/t; - s = yold/t; - xnew = t; - ynew = 0.0; - } - - return; -} - - -/* - * a p p l y G i v e n s - */ -inline void QProblemB::applyGivens( real_t c, real_t s, real_t xold, real_t yold, - real_t& xnew, real_t& ynew - ) const -{ - /* Usual Givens plane rotation requiring four multiplications. */ - xnew = c*xold + s*yold; - ynew = -s*xold + c*yold; -// double nu = s/(1.0+c); -// -// xnew = xold*c + yold*s; -// ynew = (xnew+xold)*nu - yold; - - return; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/SubjectTo.cpp b/phonelibs/qpoases/SRC/SubjectTo.cpp deleted file mode 100644 index 371f0d76d..000000000 --- a/phonelibs/qpoases/SRC/SubjectTo.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/SubjectTo.cpp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the SubjectTo class designed to manage working sets of - * constraints and bounds within a QProblem. - */ - - -#include - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * S u b j e c t T o - */ -SubjectTo::SubjectTo( ) : noLower( BT_TRUE ), - noUpper( BT_TRUE ), - size( 0 ) -{ - int i; - - for( i=0; iaddNumber( newnumber ) == RET_INDEXLIST_EXCEEDS_MAX_LENGTH ) - return THROWERROR( RET_ADDINDEX_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * r e m o v e I n d e x - */ -returnValue SubjectTo::removeIndex( Indexlist* const indexlist, - int removenumber - ) -{ - status[removenumber] = ST_UNDEFINED; - - if ( indexlist->removeNumber( removenumber ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_UNKNOWN_BUG ); - - return SUCCESSFUL_RETURN; -} - - -/* - * s w a p I n d e x - */ -returnValue SubjectTo::swapIndex( Indexlist* const indexlist, - int number1, int number2 - ) -{ - /* consistency checks */ - if ( status[number1] != status[number2] ) - return THROWERROR( RET_SWAPINDEX_FAILED ); - - if ( number1 == number2 ) - { - THROWWARNING( RET_NOTHING_TO_DO ); - return SUCCESSFUL_RETURN; - } - - if ( indexlist->swapNumbers( number1,number2 ) != SUCCESSFUL_RETURN ) - return THROWERROR( RET_SWAPINDEX_FAILED ); - - return SUCCESSFUL_RETURN; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/SubjectTo.ipp b/phonelibs/qpoases/SRC/SubjectTo.ipp deleted file mode 100644 index 32215ba7e..000000000 --- a/phonelibs/qpoases/SRC/SubjectTo.ipp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/SubjectTo.ipp - * \author Hans Joachim Ferreau - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of the inlined member functions of the SubjectTo class - * designed to manage working sets of constraints and bounds within a QProblem. - */ - - -/***************************************************************************** - * P U B L I C * - *****************************************************************************/ - - -/* - * g e t T y p e - */ -inline SubjectToType SubjectTo::getType( int i ) const -{ - if ( ( i >= 0 ) && ( i < size ) ) - return type[i]; - else - return ST_UNKNOWN; -} - - -/* - * g e t S t a t u s - */ -inline SubjectToStatus SubjectTo::getStatus( int i ) const -{ - if ( ( i >= 0 ) && ( i < size ) ) - return status[i]; - else - return ST_UNDEFINED; -} - - -/* - * s e t T y p e - */ -inline returnValue SubjectTo::setType( int i, SubjectToType value ) -{ - if ( ( i >= 0 ) && ( i < size ) ) - { - type[i] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * s e t S t a t u s - */ -inline returnValue SubjectTo::setStatus( int i, SubjectToStatus value ) -{ - if ( ( i >= 0 ) && ( i < size ) ) - { - status[i] = value; - return SUCCESSFUL_RETURN; - } - else - return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); -} - - -/* - * s e t N o L o w e r - */ -inline void SubjectTo::setNoLower( BooleanType _status ) -{ - noLower = _status; -} - - -/* - * s e t N o U p p e r - */ -inline void SubjectTo::setNoUpper( BooleanType _status ) -{ - noUpper = _status; -} - - -/* - * i s N o L o w e r - */ -inline BooleanType SubjectTo::isNoLower( ) const -{ - return noLower; -} - - -/* - * i s N o L o w e r - */ -inline BooleanType SubjectTo::isNoUpper( ) const -{ - return noUpper; -} - - -/* - * end of file - */ diff --git a/phonelibs/qpoases/SRC/Utils.cpp b/phonelibs/qpoases/SRC/Utils.cpp deleted file mode 100644 index c11722c47..000000000 --- a/phonelibs/qpoases/SRC/Utils.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* - * This file is part of qpOASES. - * - * qpOASES -- An Implementation of the Online Active Set Strategy. - * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. - * - * qpOASES is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * qpOASES is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with qpOASES; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -/** - * \file SRC/Utils.cpp - * \author Hans Joachim Ferreau, Eckhard Arnold - * \version 1.3embedded - * \date 2007-2008 - * - * Implementation of some inlined utilities for working with the different QProblem - * classes. - */ - - -#include - -#if defined(__WIN32__) || defined(WIN32) - #include -#elif defined(LINUX) - #include - #include -#endif - -#ifdef __MATLAB__ - #include -#endif - - -#include - - - -#ifdef PC_DEBUG /* Define print functions only for debugging! */ -/* - * p r i n t - */ -returnValue print( const real_t* const v, int n ) -{ - int i; - char myPrintfString[160]; - - /* Print a vector. */ - myPrintf( "[\t" ); - for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - - /* 2) Read data from file. */ - for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - data[i*ncol + j] = ( (real_t) float_data ); - } - } - - /* 3) Close file. */ - fclose( datafile ); - - return SUCCESSFUL_RETURN; -} - - -/* - * r e a d F r o m F i l e - */ -returnValue readFromFile( real_t* data, int n, - const char* datafilename - ) -{ - return readFromFile( data, n, 1, datafilename ); -} - - - -/* - * r e a d F r o m F i l e - */ -returnValue readFromFile( int* data, int n, - const char* datafilename - ) -{ - int i; - myFILE* datafile; - - /* 1) Open file. */ - if ( ( datafile = fopen( datafilename, "r" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - - /* 2) Read data from file. */ - for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - - /* 3) Close file. */ - fclose( datafile ); - - return SUCCESSFUL_RETURN; -} - - -/* - * w r i t e I n t o F i l e - */ -returnValue writeIntoFile( const real_t* const data, int nrow, int ncol, - const char* datafilename, BooleanType append - ) -{ - int i, j; - myFILE* datafile; - - /* 1) Open file. */ - if ( append == BT_TRUE ) - { - /* append data */ - if ( ( datafile = fopen( datafilename, "a" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - else - { - /* do not append data */ - if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - - /* 2) Write data into file. */ - for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - else - { - /* do not append data */ - if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) - { - char errstr[80]; - sprintf( errstr,"(%s)",datafilename ); - return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); - } - } - - /* 2) Write data into file. */ - for( i=0; i