├── .coin-or └── projDesc.xml ├── .gitattributes ├── .gitignore ├── .gitmodules ├── AUTHORS ├── AUTHORS.txt ├── CMakeLists.txt ├── INSTALL ├── INSTALL.txt ├── LICENSE ├── LICENSE.txt ├── Makefile ├── README ├── README.txt ├── VERSIONS ├── VERSIONS.txt ├── doc ├── DoxygenLayout.xml ├── Makefile ├── doxygen.config ├── mainpage.dox └── manual.pdf ├── examples ├── Makefile ├── example1.cpp ├── example1a.cpp ├── example1b.cpp ├── example2.cpp ├── example3.cpp ├── example3b.cpp ├── example4.cpp ├── example4CP.cpp ├── example5.cpp ├── exampleLP.cpp ├── generate_sparse_qp │ ├── main.py │ ├── qp_data.in.hpp │ ├── simple_qp_data.hpp │ └── trivial_qp_data.hpp ├── qrecipe.cpp ├── qrecipeSchur.cpp └── qrecipe_data.hpp ├── include ├── qpOASES.hpp └── qpOASES │ ├── Bounds.hpp │ ├── Bounds.ipp │ ├── Constants.hpp │ ├── ConstraintProduct.hpp │ ├── Constraints.hpp │ ├── Constraints.ipp │ ├── Flipper.hpp │ ├── Indexlist.hpp │ ├── Indexlist.ipp │ ├── LapackBlasReplacement.hpp │ ├── Matrices.hpp │ ├── MessageHandling.hpp │ ├── MessageHandling.ipp │ ├── Options.hpp │ ├── QProblem.hpp │ ├── QProblem.ipp │ ├── QProblemB.hpp │ ├── QProblemB.ipp │ ├── SQProblem.hpp │ ├── SQProblem.ipp │ ├── SQProblemSchur.hpp │ ├── SQProblemSchur.ipp │ ├── SparseSolver.hpp │ ├── SubjectTo.hpp │ ├── SubjectTo.ipp │ ├── Types.hpp │ ├── UnitTesting.hpp │ ├── Utils.hpp │ ├── Utils.ipp │ └── extras │ ├── OQPinterface.hpp │ ├── SolutionAnalysis.hpp │ └── SolutionAnalysis.ipp ├── interfaces ├── CUTEst │ ├── Makefile │ ├── makeprob │ ├── qpoasesCutest.cpp │ └── readme.txt ├── c │ ├── Makefile │ ├── c_example1.c │ ├── c_example1a.c │ ├── c_example1b.c │ ├── qpOASES_wrapper.cpp │ └── qpOASES_wrapper.h ├── matlab │ ├── Makefile │ ├── example1.mat │ ├── example1a.mat │ ├── example1b.mat │ ├── make.m │ ├── qpOASES.cpp │ ├── qpOASES.m │ ├── qpOASES_auxInput.m │ ├── qpOASES_matlab_utils.cpp │ ├── qpOASES_matlab_utils.hpp │ ├── qpOASES_options.m │ ├── qpOASES_sequence.cpp │ ├── qpOASES_sequence.m │ ├── testQPset.m │ └── testSchur.m ├── octave │ ├── clean │ ├── clean.sh │ ├── example1.mat │ ├── example1a.mat │ ├── example1b.mat │ ├── make.m │ ├── qpOASES.cpp │ ├── qpOASES.m │ ├── qpOASES_auxInput.m │ ├── qpOASES_octave_utils.cpp │ ├── qpOASES_octave_utils.hpp │ ├── qpOASES_options.m │ ├── qpOASES_sequence.cpp │ └── qpOASES_sequence.m ├── python │ ├── README.rst │ ├── examples │ │ ├── cython │ │ │ ├── example1.pyx │ │ │ └── setup.py │ │ ├── example1.py │ │ ├── example1b.py │ │ └── example2.py │ ├── qpoases.pxd │ ├── qpoases.pyx │ ├── setup.py │ └── tests │ │ ├── __init__.py │ │ └── test_examples.py ├── scilab │ ├── Makefile │ ├── example1.dat │ ├── example1a.dat │ ├── example1b.dat │ ├── qpOASESinterface.c │ ├── qpOASESinterface.sce │ └── qpOASESroutines.cpp └── simulink │ ├── example_QProblem.mdl │ ├── example_QProblemB.mdl │ ├── example_SQProblem.mdl │ ├── load_example_QProblem.m │ ├── load_example_QProblemB.m │ ├── load_example_SQProblem.m │ ├── make.m │ ├── qpOASES_QProblem.cpp │ ├── qpOASES_QProblemB.cpp │ ├── qpOASES_SQProblem.cpp │ └── qpOASES_simulink_utils.cpp ├── make.mk ├── make_cygwin.mk ├── make_linux.mk ├── make_osx.mk ├── make_windows.mk ├── qpOASESConfig.cmake.in ├── src ├── BLASReplacement.cpp ├── Bounds.cpp ├── Constraints.cpp ├── Flipper.cpp ├── Indexlist.cpp ├── LAPACKReplacement.cpp ├── Makefile ├── Matrices.cpp ├── MessageHandling.cpp ├── OQPinterface.cpp ├── Options.cpp ├── QProblem.cpp ├── QProblemB.cpp ├── SQProblem.cpp ├── SQProblemSchur.cpp ├── SolutionAnalysis.cpp ├── SparseSolver.cpp ├── SubjectTo.cpp └── Utils.cpp └── testing ├── c ├── Makefile ├── test_c_example1.c ├── test_c_example1a.c └── test_c_example1b.c ├── checkForMemoryLeaks ├── cpp ├── Makefile ├── data │ └── fetch_cpp_data ├── test_bench.cpp ├── test_constraintProduct1.cpp ├── test_constraintProduct2.cpp ├── test_example1.cpp ├── test_example1a.cpp ├── test_example1b.cpp ├── test_example2.cpp ├── test_example4.cpp ├── test_example5.cpp ├── test_example6.cpp ├── test_example7.cpp ├── test_exampleLP.cpp ├── test_externalChol1.cpp ├── test_gradientShift.cpp ├── test_guessedWS1.cpp ├── test_hs268.cpp ├── test_identitySqproblem.cpp ├── test_indexlist.cpp ├── test_infeasible1.cpp ├── test_janick1.cpp ├── test_janick2.cpp ├── test_matrices.cpp ├── test_matrices2.cpp ├── test_matrices3.cpp ├── test_qrecipe.cpp ├── test_qrecipeSchur.cpp ├── test_qrecipe_data.hpp ├── test_runAllOqpExamples.cpp ├── test_sebastien1.cpp ├── test_smallSchur.cpp └── test_vanBarelsUnboundedQP.cpp ├── matlab ├── auxFiles │ ├── generateExample.m │ ├── generateRandomQp.m │ ├── getKktResidual.m │ ├── isoctave.m │ ├── setupQpDataStruct.m │ └── setupQpFeaturesStruct.m ├── data │ └── fetch_matlab_data ├── runAllTests.m ├── setupTestingPaths.m └── tests │ ├── runAlexInfeas1.m │ ├── runAlexInfeas2.m │ ├── runAlternativeX0Test.m │ ├── runBenchmarkCHAIN1.m │ ├── runBenchmarkCHAIN1A.m │ ├── runBenchmarkCRANE1.m │ ├── runBenchmarkCRANE2.m │ ├── runBenchmarkCRANE3.m │ ├── runBenchmarkDIESEL.m │ ├── runBenchmarkEQUALITY1.m │ ├── runBenchmarkEQUALITY2.m │ ├── runBenchmarkEXAMPLE1.m │ ├── runBenchmarkEXAMPLE1A.m │ ├── runBenchmarkEXAMPLE1B.m │ ├── runBenchmarkIDHESSIAN1.m │ ├── runEmptyHessianTests.m │ ├── runExternalCholeskyTests.m │ ├── runInterfaceSeqTest.m │ ├── runInterfaceTest.m │ ├── runQAP8.m │ ├── runQSHARE1B.m │ ├── runRandomIdHessian.m │ ├── runRandomZeroHessian.m │ ├── runSimpleSpringExample.m │ ├── runTestAPrioriKnownSeq1.m │ ├── runTestSeq.m │ ├── runTestSparse.m │ ├── runTestSparse2.m │ ├── runTestSparse3.m │ ├── runTestSparse4.m │ ├── runTestWorkingSetLI.m │ └── runVanBarelsUnboundedQP.m └── runUnitTests /.coin-or/projDesc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | qpOASES 6 | 7 | qpOASES is an open-source C++ implementation of the recently 8 | proposed online active set strategy for solving quadratic 9 | programming (QP) problems. It has several theoretical features 10 | that make it particularly suited for model predictive control 11 | (MPC) applications. Further numerical modifications have made 12 | qpOASES a reliable QP solver, even when tackling semi-definite, 13 | ill-posed or degenerated QP problems. Moreover, several 14 | interfaces to third-party software make qpOASES easy-to-use 15 | even for users without knowledge of C/C++. 16 | 17 | An open-source C++ implementation of the recently proposed online active set strategy. 18 | Joachim Ferreau 19 | https://github.com/coin-or/qpOASES 20 | ​GNU Lesser General Public License (LGPL), v2.1 21 | http://www.gnu.org/licenses/lgpl-2.1.html 22 | 23 | 24 | 25 | BLAS 26 | http://www.netlib.org/blas 27 | Optional 28 | 29 | 30 | LAPACK 31 | http://www.netlib.org/lapack 32 | Optional 33 | 34 | 35 | C++ 36 | 37 | Active 38 | 3 39 | 40 | 41 | 42 | Linux 43 | g++ 44 | 45 | 46 | Microsoft Windows 47 | CYGWIN/g++ 48 | 49 | 50 | 51 | Optimization deterministic nonlinear 52 | 53 | 54 | 55 | http://www.qpOASES.org/go/manual 56 | https://github.com/coin-or/qpOASES 57 | 58 | http://list.coin-or.org/mailman/listinfo/qpOASES 59 | 60 | 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*.mex 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/ThirdParty-Mumps"] 2 | path = external/ThirdParty-Mumps 3 | url = https://github.com/coin-or-tools/ThirdParty-Mumps.git 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | MAIN AUTHORS 26 | ============ 27 | 28 | qpOASES's core functionality and software design have been developed by the 29 | following main developers (in alphabetical order): 30 | 31 | Hans Joachim Ferreau 32 | Christian Kirches 33 | Andreas Potschka 34 | 35 | 36 | 37 | FURTHER AUTHORS 38 | =============== 39 | 40 | Moreover, the following developers have contributed code to qpOASES's 41 | third-party interfaces or provided additional functionality 42 | (in alphabetical order): 43 | 44 | Alexander Buchner 45 | Holger Diedam 46 | Dennis Janka 47 | Manuel Kudruss 48 | Andreas Waechter 49 | Sebastian F. Walter 50 | 51 | 52 | 53 | CONTRIBUTORS 54 | ============ 55 | 56 | Finally, the following people have not contributed to the source code, 57 | but have helped making qpOASES even more useful by testing, reporting 58 | bugs or proposing algorithmic improvements (in alphabetical order): 59 | 60 | Eckhard Arnold 61 | Joris Gillis 62 | Boris Houska 63 | D. Kwame Minde Kufoalor 64 | Aude Perrin 65 | Silvio Traversaro 66 | Milan Vukov 67 | Thomas Wiese 68 | Leonard Wirsching 69 | 70 | 71 | 72 | SCIENTIFIC MENTORS 73 | ================== 74 | 75 | We also would like to thank two persons who had a major share in making 76 | qpOASES a success. Not by writing even a single line of code, but by 77 | establishing the idea of using a homotopy-based approach for high-speed 78 | QP solutions and by excellent scientific guidance during the development 79 | process: 80 | 81 | Hans Georg Bock 82 | Moritz Diehl 83 | 84 | 85 | 86 | All users are invited to further improve qpOASES by providing comments, 87 | code enhancements, bug reports, additional documentation or whatever you 88 | feel is missing. 89 | 90 | 91 | 92 | ## 93 | ## end of file 94 | ## 95 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | MAIN AUTHORS 26 | ============ 27 | 28 | qpOASES's core functionality and software design have been developed by the 29 | following main developers (in alphabetical order): 30 | 31 | Hans Joachim Ferreau 32 | Christian Kirches 33 | Andreas Potschka 34 | 35 | 36 | 37 | FURTHER AUTHORS 38 | =============== 39 | 40 | Moreover, the following developers have contributed code to qpOASES's 41 | third-party interfaces or provided additional functionality 42 | (in alphabetical order): 43 | 44 | Alexander Buchner 45 | Holger Diedam 46 | Dennis Janka 47 | Manuel Kudruss 48 | Andreas Waechter 49 | Sebastian F. Walter 50 | 51 | 52 | 53 | CONTRIBUTORS 54 | ============ 55 | 56 | Finally, the following people have not contributed to the source code, 57 | but have helped making qpOASES even more useful by testing, reporting 58 | bugs or proposing algorithmic improvements (in alphabetical order): 59 | 60 | Eckhard Arnold 61 | Joris Gillis 62 | Boris Houska 63 | D. Kwame Minde Kufoalor 64 | Aude Perrin 65 | Silvio Traversaro 66 | Milan Vukov 67 | Thomas Wiese 68 | Leonard Wirsching 69 | 70 | 71 | 72 | SCIENTIFIC MENTORS 73 | ================== 74 | 75 | We also would like to thank two persons who had a major share in making 76 | qpOASES a success. Not by writing even a single line of code, but by 77 | establishing the idea of using a homotopy-based approach for high-speed 78 | QP solutions and by excellent scientific guidance during the development 79 | process: 80 | 81 | Hans Georg Bock 82 | Moritz Diehl 83 | 84 | 85 | 86 | All users are invited to further improve qpOASES by providing comments, 87 | code enhancements, bug reports, additional documentation or whatever you 88 | feel is missing. 89 | 90 | 91 | 92 | ## 93 | ## end of file 94 | ## 95 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | INSTALLATION UNDER LINUX 26 | ======================== 27 | 28 | 0. Obtain qpOASES from COIN-OR: 29 | 30 | Download a zipped archive containg the latest stable release and unpack it 31 | into . Alternatively, you check out the latest stable branch, 32 | e.g. by running 33 | 34 | svn co https://projects.coin-or.org/svn/qpOASES/stable/3.2 35 | 36 | from your shell. 37 | 38 | 39 | 1. Compilation of the qpOASES library libqpOASES.a (or .so) and test examples: 40 | 41 | cd 42 | make 43 | 44 | The library libqpOASES.a (or .so) provides the complete functionality of the 45 | qpOASES software package. It can be used by, e.g., linking it against a main 46 | function from the examples folder. The make also compiles a couple of test 47 | examples; executables are stored within the directory /bin. 48 | 49 | 50 | 2. Running a simple test example: 51 | 52 | Among others, an executable called example1 should have been created; run 53 | it in order to test your installation: 54 | 55 | cd /bin 56 | ./example1 57 | 58 | If it terminates after successfully solving two QP problems, qpOASES has been 59 | successfully installed! 60 | 61 | 62 | 3. Optional, create source code documentation (using doxygen): 63 | 64 | cd /doc 65 | doxygen doxygen.config 66 | 67 | Afterwards, you can open the file /doc/html/index.html with 68 | your favorite browser in order to view qpOASES's source code documentation. 69 | 70 | 71 | NOTE: More detailed installation instructions, including information on how 72 | to run unit tests can be found in the qpOASES User's Manual located 73 | at /doc/manual.pdf! 74 | 75 | 76 | 77 | ## 78 | ## end of file 79 | ## 80 | -------------------------------------------------------------------------------- /INSTALL.txt: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | INSTALLATION UNDER LINUX 26 | ======================== 27 | 28 | 0. Obtain qpOASES from COIN-OR: 29 | 30 | Download a zipped archive containg the latest stable release and unpack it 31 | into . Alternatively, you check out the latest stable branch, 32 | e.g. by running 33 | 34 | svn co https://projects.coin-or.org/svn/qpOASES/stable/3.2 35 | 36 | from your shell. 37 | 38 | 39 | 1. Compilation of the qpOASES library libqpOASES.a (or .so) and test examples: 40 | 41 | cd 42 | make 43 | 44 | The library libqpOASES.a (or .so) provides the complete functionality of the 45 | qpOASES software package. It can be used by, e.g., linking it against a main 46 | function from the examples folder. The make also compiles a couple of test 47 | examples; executables are stored within the directory /bin. 48 | 49 | 50 | 2. Running a simple test example: 51 | 52 | Among others, an executable called example1 should have been created; run 53 | it in order to test your installation: 54 | 55 | cd /bin 56 | ./example1 57 | 58 | If it terminates after successfully solving two QP problems, qpOASES has been 59 | successfully installed! 60 | 61 | 62 | 3. Optional, create source code documentation (using doxygen): 63 | 64 | cd /doc 65 | doxygen doxygen.config 66 | 67 | Afterwards, you can open the file /doc/html/index.html with 68 | your favorite browser in order to view qpOASES's source code documentation. 69 | 70 | 71 | NOTE: More detailed installation instructions, including information on how 72 | to run unit tests can be found in the qpOASES User's Manual located 73 | at /doc/manual.pdf! 74 | 75 | 76 | 77 | ## 78 | ## end of file 79 | ## 80 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: Makefile 27 | ## Author: Hans Joachim Ferreau 28 | ## Version: 3.2 29 | ## Date: 2007-2017 30 | ## 31 | 32 | include make.mk 33 | 34 | ## 35 | ## targets 36 | ## 37 | 38 | 39 | ifeq ($(DEF_SOLVER), SOLVER_MUMPS) 40 | EXTERNAL = mumps 41 | else 42 | EXTERNAL = 43 | endif 44 | 45 | all: $(EXTERNAL) bin src examples 46 | #src_aw testing 47 | 48 | ifeq ($(DEF_SOLVER), SOLVER_MUMPS) 49 | mumps: 50 | @echo $(QPOASESROOT) 51 | @cd external/ThirdParty-Mumps; \ 52 | if [ -d "MUMPS" ]; then \ 53 | echo "Found MUMPS source code."; \ 54 | else get.Mumps; ./configure --prefix=$(PWD)/external/mumps_installation; fi; \ 55 | make && make install 56 | endif 57 | 58 | src: $(EXTERNAL) 59 | @cd $@; ${MAKE} -s 60 | 61 | bin: 62 | mkdir bin 63 | 64 | #src_aw: 65 | # @cd $@; ${MAKE} -s 66 | 67 | examples: src 68 | @cd $@; ${MAKE} -s 69 | 70 | doc: 71 | @cd $@; ${MAKE} -s 72 | 73 | testing: src 74 | @cd testing/cpp; ${MAKE} -s 75 | 76 | test: testing 77 | @cd testing/cpp; ${MAKE} -s runTests 78 | 79 | debugging: 80 | @cd $@; ${MAKE} -s 81 | 82 | clean: 83 | ifeq ($(DEF_SOLVER), SOLVER_MUMPS) 84 | @echo Cleaning up \(mumps\) 85 | @cd external/ThirdParty-Mumps && ${MAKE} -s clean 86 | @cd external && ${RM} -rf mumps_installation 87 | endif 88 | @cd src && ${MAKE} -s clean 89 | @cd examples && ${MAKE} -s clean 90 | @cd bin && ${RM} -f *.* *{EXE} 91 | @cd testing/cpp && ${MAKE} -s clean 92 | 93 | # && cd src_aw && ${MAKE} -s clean && cd .. \ 94 | # && cd debugging && ${MAKE} -s clean && cd .. \ 95 | 96 | 97 | clobber: clean 98 | 99 | scilab: 100 | @echo Compiling Scilab interface... 101 | @cd ./interfaces/scilab/; ${MAKE} -s 102 | 103 | python: all 104 | cd ./interfaces/python/ && python setup.py build_ext --inplace 105 | 106 | pythoninstall: all 107 | cd ./interfaces/python/ && python setup.py install 108 | 109 | c_wrapper: 110 | @echo Compiling C interface... 111 | @cd ./interfaces/c/; ${MAKE} -s 112 | 113 | .PHONY : all src examples doc testing debugging clean clobber scilab python phythoninstall c_wrapper 114 | 115 | 116 | ## 117 | ## end of file 118 | ## 119 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | INTRODUCTION 26 | ============ 27 | 28 | qpOASES is an open-source C++ implementation of the recently proposed 29 | online active set strategy, which was inspired by important observations 30 | from the field of parametric quadratic programming (QP). It has several 31 | theoretical features that make it particularly suited for model predictive 32 | control (MPC) applications. Further numerical modifications have made 33 | qpOASES a reliable QP solver, even when tackling semi-definite, ill-posed or 34 | degenerated QP problems. Moreover, several interfaces to third-party software 35 | like ​Matlab or ​Simulink are provided that make qpOASES easy-to-use even for 36 | users without knowledge of C/C++. 37 | 38 | 39 | 40 | GETTING STARTED 41 | =============== 42 | 43 | 1. For installation, usage and additional information on this software package 44 | see the qpOASES User's Manual located at doc/manual.pdf or check its 45 | source code documentation! 46 | 47 | 48 | 2. The file LICENSE.txt contains a copy of the GNU Lesser General Public 49 | License (v2.1). Please read it carefully before using qpOASES! 50 | 51 | 52 | 3. The whole software package can be obtained from 53 | 54 | http://www.qpOASES.org/ or 55 | https://github.com/coin-or/qpOASES/ 56 | 57 | On this webpage you will also find further support such as a list of 58 | questions posed by other users. 59 | 60 | 61 | 62 | CONTACT THE AUTHORS 63 | =================== 64 | 65 | If you have got questions, remarks or comments on qpOASES, it is strongly 66 | encouraged to report them by creating a new ticket at the qpOASES webpage. 67 | In case you do not want to disclose your feedback to the public, you may 68 | send an e-mail to 69 | 70 | support@qpOASES.org 71 | 72 | Finally, you may contact one of the main authors directly: 73 | 74 | Hans Joachim Ferreau, joachim.ferreau@ch.abb.com 75 | Andreas Potschka, potschka@iwr.uni-heidelberg.de 76 | Christian Kirches, christian.kirches@iwr.uni-heidelberg.de 77 | 78 | Also bug reports, source code enhancements or success stories are most welcome! 79 | 80 | 81 | 82 | ## 83 | ## end of file 84 | ## 85 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | INTRODUCTION 26 | ============ 27 | 28 | qpOASES is an open-source C++ implementation of the recently proposed 29 | online active set strategy, which was inspired by important observations 30 | from the field of parametric quadratic programming (QP). It has several 31 | theoretical features that make it particularly suited for model predictive 32 | control (MPC) applications. Further numerical modifications have made 33 | qpOASES a reliable QP solver, even when tackling semi-definite, ill-posed or 34 | degenerated QP problems. Moreover, several interfaces to third-party software 35 | like ​Matlab or ​Simulink are provided that make qpOASES easy-to-use even for 36 | users without knowledge of C/C++. 37 | 38 | 39 | 40 | GETTING STARTED 41 | =============== 42 | 43 | 1. For installation, usage and additional information on this software package 44 | see the qpOASES User's Manual located at doc/manual.pdf or check its 45 | source code documentation! 46 | 47 | 48 | 2. The file LICENSE.txt contains a copy of the GNU Lesser General Public 49 | License (v2.1). Please read it carefully before using qpOASES! 50 | 51 | 52 | 3. The whole software package can be obtained from 53 | 54 | http://www.qpOASES.org/ or 55 | https://projects.coin-or.org/qpOASES/ 56 | 57 | On this webpage you will also find further support such as a list of 58 | questions posed by other users. 59 | 60 | 61 | 62 | CONTACT THE AUTHORS 63 | =================== 64 | 65 | If you have got questions, remarks or comments on qpOASES, it is strongly 66 | encouraged to report them by creating a new ticket at the qpOASES webpage. 67 | In case you do not want to disclose your feedback to the public, you may 68 | send an e-mail to 69 | 70 | support@qpOASES.org 71 | 72 | Finally, you may contact one of the main authors directly: 73 | 74 | Hans Joachim Ferreau, joachim.ferreau@ch.abb.com 75 | Andreas Potschka, potschka@iwr.uni-heidelberg.de 76 | Christian Kirches, christian.kirches@iwr.uni-heidelberg.de 77 | 78 | Also bug reports, source code enhancements or success stories are most welcome! 79 | 80 | 81 | 82 | ## 83 | ## end of file 84 | ## 85 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: Makefile 27 | ## Author: Hans Joachim Ferreau 28 | ## Version: 3.2 29 | ## Date: 2007-2017 30 | ## 31 | 32 | 33 | 34 | ## 35 | ## settings 36 | ## 37 | 38 | MAKEPDF = pdflatex 39 | LATEX = latex 40 | 41 | 42 | ## 43 | ## targets 44 | ## 45 | 46 | all: doc 47 | 48 | 49 | .PHONY: doc 50 | doc: 51 | @ echo "Creating doxygen documentation " 52 | @ doxygen doxygen.config 53 | 54 | 55 | .PHONY: clean 56 | clean: 57 | @ ${RM} -rf ./html 58 | 59 | 60 | .PHONY: clobber 61 | clobber: clean 62 | 63 | 64 | ## 65 | ## end of file 66 | ## 67 | -------------------------------------------------------------------------------- /doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/doc/manual.pdf -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: examples/Makefile 27 | ## Author: Hans Joachim Ferreau 28 | ## Version: 3.2 29 | ## Date: 2007-2017 30 | ## 31 | 32 | include ../make.mk 33 | 34 | ## 35 | ## flags 36 | ## 37 | 38 | IFLAGS = -I. \ 39 | -I${IDIR} 40 | 41 | QPOASES_EXES = \ 42 | ${BINDIR}/example1${EXE} \ 43 | ${BINDIR}/example1a${EXE} \ 44 | ${BINDIR}/example1b${EXE} \ 45 | ${BINDIR}/example2${EXE} \ 46 | ${BINDIR}/example3${EXE} \ 47 | ${BINDIR}/example3b${EXE} \ 48 | ${BINDIR}/example4${EXE} \ 49 | ${BINDIR}/example5${EXE} \ 50 | ${BINDIR}/exampleLP${EXE} \ 51 | ${BINDIR}/qrecipe${EXE} \ 52 | ${BINDIR}/qrecipeSchur${EXE} 53 | 54 | 55 | ## 56 | ## targets 57 | ## 58 | 59 | all: ${QPOASES_EXES} 60 | 61 | ${BINDIR}/%${EXE}: %.${OBJEXT} ${LINK_DEPENDS} 62 | @${ECHO} "Creating" $@ 63 | @${CPP} ${DEF_TARGET} ${CPPFLAGS} $< ${QPOASES_LINK} ${LINK_LIBRARIES} 64 | 65 | ${BINDIR}/example4${EXE}: example4.${OBJEXT} example4CP.cpp ${LINK_DEPENDS} 66 | @${ECHO} "Creating" $@ 67 | @${CPP} ${DEF_TARGET} ${CPPFLAGS} $< ${QPOASES_LINK} ${LINK_LIBRARIES} 68 | 69 | ${BINDIR}/qrecipe${EXE}: qrecipe.${OBJEXT} qrecipe_data.hpp ${LINK_DEPENDS} 70 | @${ECHO} "Creating" $@ 71 | @${CPP} ${DEF_TARGET} ${CPPFLAGS} $< ${QPOASES_LINK} ${LINK_LIBRARIES} 72 | 73 | ${BINDIR}/qrecipeSchur${EXE}: qrecipeSchur.${OBJEXT} qrecipe_data.hpp ${LINK_DEPENDS} 74 | @${ECHO} "Creating" $@ 75 | @${CPP} ${DEF_TARGET} ${CPPFLAGS} $< ${QPOASES_LINK} ${LINK_LIBRARIES} 76 | 77 | 78 | clean: 79 | @${ECHO} "Cleaning up (examples)" 80 | @${RM} -f *.${OBJEXT} ${QPOASES_EXES} 81 | 82 | clobber: clean 83 | 84 | 85 | ${LINK_DEPENDS}: 86 | @cd ..; ${MAKE} -s src 87 | 88 | example4.${OBJEXT}: example4.cpp example4CP.cpp 89 | @${ECHO} "Creating" $@ 90 | @${CPP} ${DEF_TARGET} -c ${IFLAGS} ${CPPFLAGS} $< 91 | 92 | qrecipe.${OBJEXT}: qrecipe.cpp qrecipe_data.hpp 93 | @${ECHO} "Creating" $@ 94 | @${CPP} ${DEF_TARGET} ${IFLAGS} ${CPPFLAGS} -c $< 95 | 96 | qrecipeSchur.${OBJEXT}: qrecipeSchur.cpp qrecipe_data.hpp 97 | @${ECHO} "Creating" $@ 98 | @${CPP} ${DEF_TARGET} ${IFLAGS} ${CPPFLAGS} -c $< 99 | 100 | %.${OBJEXT}: %.cpp 101 | @${ECHO} "Creating" $@ 102 | @${CPP} ${DEF_TARGET} -c ${IFLAGS} ${CPPFLAGS} $< 103 | 104 | 105 | ## 106 | ## end of file 107 | ## 108 | -------------------------------------------------------------------------------- /examples/example1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/example1.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Very simple example for testing qpOASES using the QProblem class. 32 | */ 33 | 34 | 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | USING_NAMESPACE_QPOASES 43 | 44 | /* Setup data of first QP. */ 45 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 46 | real_t A[1*2] = { 1.0, 1.0 }; 47 | real_t g[2] = { 1.5, 1.0 }; 48 | real_t lb[2] = { 0.5, -2.0 }; 49 | real_t ub[2] = { 5.0, 2.0 }; 50 | real_t lbA[1] = { -1.0 }; 51 | real_t ubA[1] = { 2.0 }; 52 | 53 | /* Setup data of second QP. */ 54 | real_t g_new[2] = { 1.0, 1.5 }; 55 | real_t lb_new[2] = { 0.0, -1.0 }; 56 | real_t ub_new[2] = { 5.0, -0.5 }; 57 | real_t lbA_new[1] = { -2.0 }; 58 | real_t ubA_new[1] = { 1.0 }; 59 | 60 | 61 | /* Setting up QProblem object. */ 62 | QProblem example( 2,1 ); 63 | 64 | Options options; 65 | example.setOptions( options ); 66 | 67 | /* Solve first QP. */ 68 | int_t nWSR = 10; 69 | example.init( H,g,A,lb,ub,lbA,ubA, nWSR ); 70 | 71 | /* Get and print solution of first QP. */ 72 | real_t xOpt[2]; 73 | real_t yOpt[2+1]; 74 | example.getPrimalSolution( xOpt ); 75 | example.getDualSolution( yOpt ); 76 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 77 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() ); 78 | 79 | /* Solve second QP. */ 80 | nWSR = 10; 81 | example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR ); 82 | 83 | /* Get and print solution of second QP. */ 84 | example.getPrimalSolution( xOpt ); 85 | example.getDualSolution( yOpt ); 86 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 87 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() ); 88 | 89 | example.printOptions(); 90 | /*example.printProperties();*/ 91 | 92 | /*getGlobalMessageHandler()->listAllMessages();*/ 93 | 94 | return 0; 95 | } 96 | 97 | 98 | /* 99 | * end of file 100 | */ 101 | -------------------------------------------------------------------------------- /examples/example1a.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/example1a.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Very simple example for testing qpOASES using the SQProblem class. 32 | */ 33 | 34 | 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the SQProblem class. */ 40 | int main( ) 41 | { 42 | USING_NAMESPACE_QPOASES 43 | 44 | /* Setup data of first QP. */ 45 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 46 | real_t A[1*2] = { 1.0, 1.0 }; 47 | real_t g[2] = { 1.5, 1.0 }; 48 | real_t lb[2] = { 0.5, -2.0 }; 49 | real_t ub[2] = { 5.0, 2.0 }; 50 | real_t lbA[1] = { -1.0 }; 51 | real_t ubA[1] = { 2.0 }; 52 | 53 | /* Setup data of second QP. */ 54 | real_t H_new[2*2] = { 1.0, 0.5, 0.5, 0.5 }; 55 | real_t A_new[1*2] = { 1.0, 5.0 }; 56 | real_t g_new[2] = { 1.0, 1.5 }; 57 | real_t lb_new[2] = { 0.0, -1.0 }; 58 | real_t ub_new[2] = { 5.0, -0.5 }; 59 | real_t lbA_new[1] = { -2.0 }; 60 | real_t ubA_new[1] = { 1.0 }; 61 | 62 | 63 | /* Setting up SQProblem object. */ 64 | SQProblem example( 2,1 ); 65 | 66 | /* Solve first QP. */ 67 | int_t nWSR = 10; 68 | example.init( H,g,A,lb,ub,lbA,ubA, nWSR,0 ); 69 | 70 | /* Solve second QP. */ 71 | nWSR = 10; 72 | example.hotstart( H_new,g_new,A_new,lb_new,ub_new,lbA_new,ubA_new, nWSR,0 ); 73 | 74 | /* Get and print solution of second QP. */ 75 | real_t xOpt[2]; 76 | example.getPrimalSolution( xOpt ); 77 | printf( "\nxOpt = [ %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],example.getObjVal() ); 78 | 79 | return 0; 80 | } 81 | 82 | 83 | /* 84 | * end of file 85 | */ 86 | -------------------------------------------------------------------------------- /examples/example1b.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/example1b.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Very simple example for testing qpOASES using the QProblemB class. 32 | */ 33 | 34 | 35 | #include 36 | 37 | 38 | /** Example for qpOASES main function using the QProblemB class. */ 39 | int main( ) 40 | { 41 | USING_NAMESPACE_QPOASES 42 | 43 | /* Setup data of first QP. */ 44 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 45 | real_t g[2] = { 1.5, 1.0 }; 46 | real_t lb[2] = { 0.5, -2.0 }; 47 | real_t ub[2] = { 5.0, 2.0 }; 48 | 49 | /* Setup data of second QP. */ 50 | real_t g_new[2] = { 1.0, 1.5 }; 51 | real_t lb_new[2] = { 0.0, -1.0 }; 52 | real_t ub_new[2] = { 5.0, -0.5 }; 53 | 54 | 55 | /* Setting up QProblemB object. */ 56 | QProblemB example( 2 ); 57 | 58 | Options options; 59 | //options.enableFlippingBounds = BT_FALSE; 60 | options.initialStatusBounds = ST_INACTIVE; 61 | options.numRefinementSteps = 1; 62 | options.enableCholeskyRefactorisation = 1; 63 | example.setOptions( options ); 64 | 65 | 66 | /* Solve first QP. */ 67 | int_t nWSR = 10; 68 | example.init( H,g,lb,ub, nWSR,0 ); 69 | 70 | /* Get and print solution of first QP. */ 71 | real_t xOpt[2]; 72 | example.getPrimalSolution( xOpt ); 73 | printf( "\nxOpt = [ %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],example.getObjVal() ); 74 | 75 | /* Solve second QP. */ 76 | nWSR = 10; 77 | example.hotstart( g_new,lb_new,ub_new, nWSR,0 ); 78 | // printf( "\nnWSR = %d\n\n", nWSR ); 79 | 80 | /* Get and print solution of second QP. */ 81 | example.getPrimalSolution( xOpt ); 82 | printf( "\nxOpt = [ %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],example.getObjVal() ); 83 | 84 | return 0; 85 | } 86 | 87 | 88 | /* 89 | * end of file 90 | */ 91 | -------------------------------------------------------------------------------- /examples/example3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/example3.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2008-2017 30 | * 31 | * Example demonstrating usage of qpOASES for solving a QP sequence of the 32 | * Online QP Benchmark Collection. In order to run it, you have to download 33 | * "Example 02" from from http://www.qpOASES.org/onlineQP/ and store it into 34 | * the directory bin/chain80w/. 35 | */ 36 | 37 | 38 | 39 | #include 40 | 41 | 42 | /** Example for qpOASES main function using the OQP interface. */ 43 | int main( ) 44 | { 45 | USING_NAMESPACE_QPOASES 46 | 47 | /* 1) Define benchmark arguments. */ 48 | BooleanType isSparse = BT_FALSE; 49 | Options options; 50 | options.setToMPC(); 51 | options.printLevel = PL_NONE; 52 | 53 | int_t nWSR = 600; 54 | real_t maxCPUtime = 10.0; /* seconds */ 55 | real_t maxStationarity, maxFeasibility, maxComplementarity; 56 | 57 | /* 2) Run benchmark. */ 58 | if ( runOqpBenchmark( "./chain80w/", 59 | isSparse, 60 | options, 61 | nWSR, 62 | maxCPUtime, 63 | maxStationarity, 64 | maxFeasibility, 65 | maxComplementarity 66 | ) != SUCCESSFUL_RETURN ) 67 | { 68 | myPrintf( "In order to run this example, you need to download example no. 02\nfrom the Online QP Benchmark Collection website first!\n" ); 69 | return -1; 70 | } 71 | 72 | /* 3) Print results. */ 73 | printf( "\n\n" ); 74 | printf( "OQP Benchmark Results:\n" ); 75 | printf( "======================\n\n" ); 76 | printf( "maximum violation stationarity: %.3e\n",maxStationarity ); 77 | printf( "maximum violation feasibility: %.3e\n",maxFeasibility ); 78 | printf( "maximum violation complementarity: %.3e\n",maxComplementarity ); 79 | printf( "\n" ); 80 | printf( "maximum CPU time: %.3f milliseconds\n\n",1000.0*maxCPUtime ); 81 | 82 | return 0; 83 | } 84 | 85 | 86 | /* 87 | * end of file 88 | */ 89 | -------------------------------------------------------------------------------- /examples/example3b.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/example3b.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2008-2017 30 | * 31 | * Example demonstrating usage of qpOASES for solving a QP sequence of the 32 | * Online QP Benchmark Collection. In order to run it, you have to download 33 | * "Example 02" from http://www.qpOASES.org/onlineQP/ and store it into 34 | * the directory bin/chain80/. 35 | */ 36 | 37 | 38 | 39 | #include 40 | 41 | 42 | /** Example for qpOASES main function using the OQP interface. */ 43 | int main( ) 44 | { 45 | USING_NAMESPACE_QPOASES 46 | 47 | /* 1) Define benchmark arguments. */ 48 | BooleanType isSparse = BT_FALSE; 49 | Options options; 50 | options.setToMPC(); 51 | options.printLevel = PL_NONE; 52 | 53 | int_t nWSR = 300; 54 | real_t maxCPUtime = 10.0; /* seconds */ 55 | real_t maxStationarity, maxFeasibility, maxComplementarity; 56 | 57 | /* 2) Run benchmark. */ 58 | if ( runOqpBenchmark( "./chain80/", 59 | isSparse, 60 | options, 61 | nWSR, 62 | maxCPUtime, 63 | maxStationarity, 64 | maxFeasibility, 65 | maxComplementarity 66 | ) != SUCCESSFUL_RETURN ) 67 | { 68 | myPrintf( "In order to run this example, you need to download example no. 02\nfrom the Online QP Benchmark Collection website first!\n" ); 69 | return -1; 70 | } 71 | 72 | /* 3) Print results. */ 73 | printf( "\n\n" ); 74 | printf( "OQP Benchmark Results:\n" ); 75 | printf( "======================\n\n" ); 76 | printf( "maximum violation stationarity: %.3e\n",maxStationarity ); 77 | printf( "maximum violation feasibility: %.3e\n",maxFeasibility ); 78 | printf( "maximum violation complementarity: %.3e\n",maxComplementarity ); 79 | printf( "\n" ); 80 | printf( "maximum CPU time: %.3f milliseconds\n\n",1000.0*maxCPUtime ); 81 | 82 | return 0; 83 | } 84 | 85 | 86 | /* 87 | * end of file 88 | */ 89 | -------------------------------------------------------------------------------- /examples/example4CP.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/example4CP.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2009-2017 30 | * 31 | * Sample implementation of the ConstraintProduct class tailored for Example4. 32 | */ 33 | 34 | 35 | BEGIN_NAMESPACE_QPOASES 36 | 37 | 38 | /** 39 | * \brief Example illustrating the use of the \a ConstraintProduct class. 40 | * 41 | * Example illustrating the use of the \a ConstraintProduct class. 42 | * 43 | * \author Hans Joachim Ferreau 44 | * \version 3.2 45 | * \date 2007-2017 46 | */ 47 | class MyConstraintProduct : public ConstraintProduct 48 | { 49 | public: 50 | /** Default constructor. */ 51 | MyConstraintProduct( ) {}; 52 | 53 | /** Constructor. */ 54 | MyConstraintProduct( int_t _nV, 55 | int_t _nC, 56 | real_t* _A 57 | ) 58 | { 59 | nV = _nV; 60 | nC = _nC; 61 | A = _A; 62 | }; 63 | 64 | /** Copy constructor (flat copy). */ 65 | MyConstraintProduct( const MyConstraintProduct& rhs 66 | ) 67 | { 68 | nV = rhs.nV; 69 | nC = rhs.nC; 70 | A = rhs.A; 71 | }; 72 | 73 | /** Destructor. */ 74 | virtual ~MyConstraintProduct( ) {}; 75 | 76 | /** Assignment operator (flat copy). */ 77 | MyConstraintProduct& operator=( const MyConstraintProduct& rhs 78 | ) 79 | { 80 | if ( this != &rhs ) 81 | { 82 | nV = rhs.nV; 83 | nC = rhs.nC; 84 | A = rhs.A; 85 | } 86 | return *this; 87 | }; 88 | 89 | virtual int_t operator() ( int_t constrIndex, 90 | const real_t* const x, 91 | real_t* const constrValue 92 | ) const 93 | { 94 | int_t i; 95 | 96 | constrValue[0] = 1.0 * x[(constrIndex/10)+2]; 97 | 98 | for( i=0; i<2; ++i ) 99 | constrValue[0] += A[constrIndex*nV + i] * x[i]; 100 | 101 | return 0; 102 | }; 103 | 104 | protected: 105 | int_t nV; /**< Number of variables. */ 106 | int_t nC; /**< Number of constraints. */ 107 | real_t* A; /**< Pointer to full constraint matrix (typically not needed!). */ 108 | }; 109 | 110 | 111 | END_NAMESPACE_QPOASES 112 | 113 | -------------------------------------------------------------------------------- /examples/exampleLP.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file examples/exampleLP.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2008-2017 30 | * 31 | * Very simple example for solving a LP sequence using qpOASES. 32 | */ 33 | 34 | 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function solving LPs. */ 40 | int main( ) 41 | { 42 | USING_NAMESPACE_QPOASES 43 | 44 | /* Setup data of first LP. */ 45 | real_t A[1*2] = { 1.0, 1.0 }; 46 | real_t g[2] = { 1.5, 1.0 }; 47 | real_t lb[2] = { 0.5, -2.0 }; 48 | real_t ub[2] = { 5.0, 2.0 }; 49 | real_t lbA[1] = { -1.0 }; 50 | real_t ubA[1] = { 2.0 }; 51 | 52 | /* Setup data of second LP. */ 53 | real_t g_new[2] = { 1.0, 1.5 }; 54 | real_t lb_new[2] = { 0.0, -1.0 }; 55 | real_t ub_new[2] = { 5.0, -0.5 }; 56 | real_t lbA_new[1] = { -2.0 }; 57 | real_t ubA_new[1] = { 1.0 }; 58 | 59 | 60 | /* Setting up QProblem object with zero Hessian matrix. */ 61 | QProblem example( 2,1,HST_ZERO ); 62 | 63 | Options options; 64 | //options.setToMPC(); 65 | example.setOptions( options ); 66 | 67 | /* Solve first LP. */ 68 | int_t nWSR = 10; 69 | example.init( 0,g,A,lb,ub,lbA,ubA, nWSR,0 ); 70 | 71 | /* Solve second LP. */ 72 | nWSR = 10; 73 | example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR,0 ); 74 | 75 | 76 | /* Get and print solution of second LP. */ 77 | real_t xOpt[2]; 78 | example.getPrimalSolution( xOpt ); 79 | printf( "\nxOpt = [ %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],example.getObjVal() ); 80 | 81 | return 0; 82 | } 83 | 84 | 85 | /* 86 | * end of file 87 | */ 88 | -------------------------------------------------------------------------------- /examples/generate_sparse_qp/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import scipy as sp 3 | from scipy.sparse import csc_matrix, coo_matrix, csr_matrix, lil_matrix, random 4 | from jinja2 import Environment 5 | from jinja2.loaders import FileSystemLoader 6 | import os 7 | 8 | seed = 42 9 | density = 0.1 10 | gamma = 0.01 11 | 12 | out_file_name = 'qp_data.hpp' 13 | in_file_name = 'qp_data.in.hpp' 14 | 15 | NV = 100 16 | NC = 10 17 | 18 | H = csc_matrix((NV, NV)) 19 | A = csc_matrix((NV, NV)) 20 | 21 | myinf = 1e10 22 | 23 | for i in range(NV): 24 | H[i,i] = 1.0 25 | 26 | # H = H + gamma*random(NV, NV, density=density, format='csc', random_state=seed) 27 | # H = H.T*H 28 | 29 | for i in range(NC): 30 | A[i,i] = 1.0 31 | 32 | H_ri = H.indices 33 | H_cp = H.indptr 34 | H_val = H.data 35 | H_nnz = H.nnz 36 | 37 | A_ri = A.indices 38 | A_cp = A.indptr 39 | A_val = A.data 40 | A_nnz = A.nnz 41 | 42 | g = np.ones((NV,1)) 43 | 44 | lb = -myinf*np.ones((NV, 1)) 45 | ub = myinf*np.ones((NV, 1)) 46 | 47 | lbA = -np.ones((NC, 1)) 48 | ubA = np.ones((NC, 1)) 49 | 50 | print('rendering templated C++ code...') 51 | env = Environment(loader=FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))) 52 | tmpl = env.get_template(in_file_name) 53 | 54 | code = tmpl.render(NV = NV, NC = NC, H_cp = H_cp, H_ri = H_ri, H_val = H_val, H_nnz = H_nnz, \ 55 | A_cp = A_cp, A_ri = A_ri, A_val = A_val, A_nnz = A_nnz, g = g, lb = lb, ub = ub, lbA = lbA, ubA = ubA) 56 | 57 | with open(out_file_name, "w+") as f: 58 | f.write(code.replace('inf', 'Inf')) 59 | -------------------------------------------------------------------------------- /examples/generate_sparse_qp/qp_data.in.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \author Andrea Zanelli 27 | * \version 3.2 28 | * \date 2022 29 | * 30 | * QP data generated by a Python script for testing purposes. 31 | */ 32 | 33 | 34 | USING_NAMESPACE_QPOASES 35 | 36 | #define NV {{NV}} 37 | #define NC {{NC}} 38 | 39 | const real_t Inf = INFTY; 40 | 41 | sparse_int_t H_ri[] = { 42 | {% for d in H_ri %} 43 | {{ d }}, 44 | {%- endfor %} 45 | }; 46 | 47 | sparse_int_t H_cp[] = { 48 | {% for d in H_cp %} 49 | {{ d }}, 50 | {%- endfor %} 51 | }; 52 | 53 | real_t H_val[] = { 54 | {% for d in H_val %} 55 | {{ d }}, 56 | {%- endfor %} 57 | }; 58 | 59 | sparse_int_t A_ri[] = { 60 | {% for d in A_ri %} 61 | {{ d }}, 62 | {%- endfor %} 63 | }; 64 | 65 | sparse_int_t A_cp[] = { 66 | {% for d in A_cp %} 67 | {{ d }}, 68 | {%- endfor %} 69 | }; 70 | 71 | real_t A_val[] = { 72 | {% for d in A_val %} 73 | {{ d }}, 74 | {%- endfor %} 75 | }; 76 | 77 | real_t g[] = { 78 | {% for d in g %} 79 | {{ d[0] }}, 80 | {%- endfor %} 81 | }; 82 | 83 | real_t lb[] = { 84 | {% for d in lb %} 85 | {{ d[0] }}, 86 | {%- endfor %} 87 | }; 88 | 89 | real_t ub[] = { 90 | {% for d in ub %} 91 | {{ d[0] }}, 92 | {%- endfor %} 93 | }; 94 | 95 | real_t lbA[] = { 96 | {% for d in lbA %} 97 | {{ d[0] }}, 98 | {%- endfor %} 99 | }; 100 | 101 | real_t ubA[] = { 102 | {% for d in ubA %} 103 | {{ d[0] }}, 104 | {%- endfor %} 105 | }; 106 | 107 | long H_nnz = {{ H_nnz }}; 108 | long A_nnz = {{ A_nnz }}; 109 | -------------------------------------------------------------------------------- /include/qpOASES.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES.hpp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2007-2017 30 | */ 31 | 32 | 33 | #if defined(__SINGLE_OBJECT__) || defined(__C_WRAPPER__) 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #if !defined(__MATLAB__) || defined(WIN32) 43 | #include 44 | #include 45 | #endif 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | 54 | #if defined(SOLVER_MA27) || defined(SOLVER_MA57) 55 | #include 56 | #include 57 | #endif 58 | 59 | #if !defined(__C_WRAPPER__) && !defined(__MATLAB__) 60 | #include 61 | #include 62 | #endif 63 | 64 | #else /* default compilation mode */ 65 | 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /include/qpOASES/Bounds.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/Bounds.ipp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Implementation of inlined member functions of the Bounds class designed 32 | * to manage working sets of bounds within a QProblem. 33 | */ 34 | 35 | 36 | BEGIN_NAMESPACE_QPOASES 37 | 38 | 39 | /***************************************************************************** 40 | * P U B L I C * 41 | *****************************************************************************/ 42 | 43 | /* 44 | * g e t N V 45 | */ 46 | inline int_t Bounds::getNV( ) const 47 | { 48 | return n; 49 | } 50 | 51 | 52 | /* 53 | * g e t N F V 54 | */ 55 | inline int_t Bounds::getNFV( ) const 56 | { 57 | return getNumberOfType( ST_EQUALITY ); 58 | } 59 | 60 | 61 | /* 62 | * g e t N B V 63 | */ 64 | inline int_t Bounds::getNBV( ) const 65 | { 66 | return getNumberOfType( ST_BOUNDED ); 67 | } 68 | 69 | 70 | /* 71 | * g e t N U V 72 | */ 73 | inline int_t Bounds::getNUV( ) const 74 | { 75 | return getNumberOfType( ST_UNBOUNDED ); 76 | } 77 | 78 | 79 | /* 80 | * g e t N F R 81 | */ 82 | inline int_t Bounds::getNFR( ) const 83 | { 84 | return freee.getLength( ); 85 | } 86 | 87 | 88 | /* 89 | * g e t N F X 90 | */ 91 | inline int_t Bounds::getNFX( ) const 92 | { 93 | return fixed.getLength( ); 94 | } 95 | 96 | 97 | /* 98 | * g e t F r e e 99 | */ 100 | inline Indexlist* Bounds::getFree( ) 101 | { 102 | return &freee; 103 | } 104 | 105 | 106 | /* 107 | * g e t F i x e d 108 | */ 109 | inline Indexlist* Bounds::getFixed( ) 110 | { 111 | return &fixed; 112 | } 113 | 114 | 115 | END_NAMESPACE_QPOASES 116 | 117 | 118 | /* 119 | * end of file 120 | */ 121 | -------------------------------------------------------------------------------- /include/qpOASES/Constants.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/Constants.hpp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Definition of all global constants. 32 | */ 33 | 34 | 35 | #ifndef QPOASES_CONSTANTS_HPP 36 | #define QPOASES_CONSTANTS_HPP 37 | 38 | 39 | #include 40 | 41 | 42 | BEGIN_NAMESPACE_QPOASES 43 | 44 | 45 | /** Numerical value of machine precision (min eps, s.t. 1+eps > 1). 46 | * Note: this value has to be positive! */ 47 | #ifdef __USE_SINGLE_PRECISION__ 48 | const real_t EPS = 1.193e-07f; 49 | #else 50 | const real_t EPS = 2.221e-16; 51 | #endif /* __USE_SINGLE_PRECISION__ */ 52 | 53 | 54 | /** Numerical value of zero (for situations in which it would be 55 | * unreasonable to compare with 0.0). 56 | * Note: this value has to be positive! */ 57 | const real_t ZERO = 1.0e-25; 58 | 59 | /** Numerical value of infinity (e.g. for non-existing bounds). 60 | Note: this value has to be positive! */ 61 | const real_t INFTY = 1.0e20; 62 | 63 | 64 | /** Maximum number of characters within a string. 65 | * Note: this value should be at least 41! */ 66 | const uint_t MAX_STRING_LENGTH = 160; 67 | 68 | 69 | END_NAMESPACE_QPOASES 70 | 71 | 72 | #endif /* QPOASES_CONSTANTS_HPP */ 73 | 74 | 75 | /* 76 | * end of file 77 | */ 78 | -------------------------------------------------------------------------------- /include/qpOASES/ConstraintProduct.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/ConstraintProduct.hpp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2009-2017 30 | * 31 | * Declaration of the ConstraintProduct class which allows to specify a 32 | * user-defined function for evaluating the constraint product at the 33 | * current iterate to speed-up QP solution in case of a specially structured 34 | * constraint matrix. 35 | */ 36 | 37 | 38 | 39 | #ifndef QPOASES_CONSTRAINT_PRODUCT_HPP 40 | #define QPOASES_CONSTRAINT_PRODUCT_HPP 41 | 42 | 43 | BEGIN_NAMESPACE_QPOASES 44 | 45 | 46 | /** 47 | * \brief Interface for specifying user-defined evaluations of constraint products. 48 | * 49 | * A class which allows to specify a user-defined function for evaluating the 50 | * constraint product at the current iterate to speed-up QP solution in case 51 | * of a specially structured constraint matrix. 52 | * 53 | * \author Hans Joachim Ferreau 54 | * \version 3.2 55 | * \date 2009-2017 56 | */ 57 | class ConstraintProduct 58 | { 59 | public: 60 | /** Default constructor. */ 61 | ConstraintProduct( ) {}; 62 | 63 | /** Copy constructor. */ 64 | ConstraintProduct( const ConstraintProduct &toCopy /**< Rhs object. */ 65 | ) {}; 66 | 67 | /** Destructor. */ 68 | virtual ~ConstraintProduct( ) {}; 69 | 70 | /** Assignment operator. */ 71 | ConstraintProduct &operator=( const ConstraintProduct &toCopy /**< Rhs object. */ 72 | ) 73 | { 74 | return *this; 75 | } 76 | 77 | /** Evaluates the product of a given constraint with the current iterate. 78 | * This function needs to be implemented in a derived class for the 79 | * user-defined constraint product function. 80 | * \return 0: successful \n 81 | otherwise: not successful */ 82 | virtual int_t operator() ( int_t constrIndex, /**< Number of constraint to be evaluated. */ 83 | const real_t* const x, /**< Array containing current primal iterate. */ 84 | real_t* const constrValue /**< Output: Scalar value of the evaluated constraint. */ 85 | ) const = 0; 86 | }; 87 | 88 | END_NAMESPACE_QPOASES 89 | 90 | 91 | #endif /* QPOASES_CONSTRAINT_PRODUCT_HPP */ 92 | -------------------------------------------------------------------------------- /include/qpOASES/Constraints.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/Constraints.ipp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Declaration of inlined member functions of the Constraints class designed 32 | * to manage working sets of constraints within a QProblem. 33 | */ 34 | 35 | 36 | BEGIN_NAMESPACE_QPOASES 37 | 38 | 39 | /***************************************************************************** 40 | * P U B L I C * 41 | *****************************************************************************/ 42 | 43 | 44 | /* 45 | * g e t N C 46 | */ 47 | inline int_t Constraints::getNC( ) const 48 | { 49 | return n; 50 | } 51 | 52 | 53 | /* 54 | * g e t N E C 55 | */ 56 | inline int_t Constraints::getNEC( ) const 57 | { 58 | return getNumberOfType( ST_EQUALITY ); 59 | } 60 | 61 | 62 | /* 63 | * g e t N I C 64 | */ 65 | inline int_t Constraints::getNIC( ) const 66 | { 67 | return getNumberOfType( ST_BOUNDED ); 68 | } 69 | 70 | 71 | /* 72 | * g e t N U C 73 | */ 74 | inline int_t Constraints::getNUC( ) const 75 | { 76 | return getNumberOfType( ST_UNBOUNDED ); 77 | } 78 | 79 | 80 | /* 81 | * g e t N A C 82 | */ 83 | inline int_t Constraints::getNAC( ) const 84 | { 85 | return active.getLength( ); 86 | } 87 | 88 | 89 | /* 90 | * g e t N I A C 91 | */ 92 | inline int_t Constraints::getNIAC( ) const 93 | { 94 | return inactive.getLength( ); 95 | } 96 | 97 | 98 | 99 | /* 100 | * g e t A c t i v e 101 | */ 102 | inline Indexlist* Constraints::getActive( ) 103 | { 104 | return &active; 105 | } 106 | 107 | 108 | /* 109 | * g e t I n a c t i v e 110 | */ 111 | inline Indexlist* Constraints::getInactive( ) 112 | { 113 | return &inactive; 114 | } 115 | 116 | 117 | END_NAMESPACE_QPOASES 118 | 119 | 120 | /* 121 | * end of file 122 | */ 123 | -------------------------------------------------------------------------------- /include/qpOASES/Indexlist.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/Indexlist.ipp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Implementation of inlined member functions of the Indexlist class designed 32 | * to manage index lists of constraints and bounds within a QProblem_SubjectTo. 33 | */ 34 | 35 | 36 | BEGIN_NAMESPACE_QPOASES 37 | 38 | 39 | /***************************************************************************** 40 | * P U B L I C * 41 | *****************************************************************************/ 42 | 43 | 44 | /* 45 | * g e t N u m b e r 46 | */ 47 | inline int_t Indexlist::getNumber( int_t physicalindex ) const 48 | { 49 | /* consistency check */ 50 | if ( ( physicalindex < 0 ) || ( physicalindex > length ) ) 51 | return -RET_INDEXLIST_OUTOFBOUNDS; 52 | 53 | return number[physicalindex]; 54 | } 55 | 56 | 57 | /* 58 | * g e t L e n g t h 59 | */ 60 | inline int_t Indexlist::getLength( ) const 61 | { 62 | return length; 63 | } 64 | 65 | 66 | /* 67 | * g e t L a s t N u m b e r 68 | */ 69 | inline int_t Indexlist::getLastNumber( ) const 70 | { 71 | return number[length-1]; 72 | } 73 | 74 | 75 | /* 76 | * g e t L a s t N u m b e r 77 | */ 78 | inline BooleanType Indexlist::isMember( int_t _number ) const 79 | { 80 | if ( getIndex( _number ) >= 0 ) 81 | return BT_TRUE; 82 | else 83 | return BT_FALSE; 84 | } 85 | 86 | 87 | END_NAMESPACE_QPOASES 88 | 89 | 90 | /* 91 | * end of file 92 | */ 93 | -------------------------------------------------------------------------------- /include/qpOASES/SQProblem.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/SQProblem.ipp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Implementation of inlined member functions of the SQProblem class which 32 | * is able to use the newly developed online active set strategy for 33 | * parametric quadratic programming with varying matrices. 34 | */ 35 | 36 | 37 | 38 | /***************************************************************************** 39 | * P U B L I C * 40 | *****************************************************************************/ 41 | 42 | 43 | BEGIN_NAMESPACE_QPOASES 44 | 45 | 46 | END_NAMESPACE_QPOASES 47 | 48 | 49 | /* 50 | * end of file 51 | */ 52 | -------------------------------------------------------------------------------- /include/qpOASES/SQProblemSchur.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2013 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/SQProblemSchur.ipp 27 | * \author Andreas Waechter, Dennis Janka 28 | * \version 3.2 29 | * \date 2012-2017 30 | * 31 | * Implementation of inlined member functions of the SQProblemSchur class which 32 | * is able to use the newly developed online active set strategy for 33 | * parametric quadratic programming. 34 | */ 35 | 36 | 37 | BEGIN_NAMESPACE_QPOASES 38 | 39 | 40 | /***************************************************************************** 41 | * P U B L I C * 42 | *****************************************************************************/ 43 | 44 | /* 45 | * g e t N u m F a c t o r i z a t i o n s 46 | */ 47 | inline int_t SQProblemSchur::getNumFactorizations( ) const 48 | { 49 | return numFactorizations; 50 | } 51 | 52 | END_NAMESPACE_QPOASES 53 | 54 | 55 | /* 56 | * end of file 57 | */ 58 | -------------------------------------------------------------------------------- /include/qpOASES/UnitTesting.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/UnitTesting.hpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Definition of auxiliary functions/macros for unit testing. 32 | */ 33 | 34 | 35 | #ifndef QPOASES_UNIT_TESTING_HPP 36 | #define QPOASES_UNIT_TESTING_HPP 37 | 38 | 39 | #ifndef TEST_TOL_FACTOR 40 | #define TEST_TOL_FACTOR 1 41 | #endif 42 | 43 | 44 | /** Return value for tests that passed. */ 45 | #define TEST_PASSED 0 46 | 47 | /** Return value for tests that failed. */ 48 | #define TEST_FAILED 1 49 | 50 | /** Return value for tests that could not run due to missing external data. */ 51 | #define TEST_DATA_NOT_FOUND 99 52 | 53 | 54 | /** Macro verifying that two numerical values are equal in order to pass unit test. */ 55 | #define QPOASES_TEST_FOR_EQUAL( x,y ) if ( REFER_NAMESPACE_QPOASES isEqual( (x),(y) ) == BT_FALSE ) { return TEST_FAILED; } 56 | 57 | /** Macro verifying that two numerical values are close to each other in order to pass unit test. */ 58 | #define QPOASES_TEST_FOR_NEAR( x,y ) if ( REFER_NAMESPACE_QPOASES getAbs((x)-(y)) / REFER_NAMESPACE_QPOASES getMax( 1.0,REFER_NAMESPACE_QPOASES getAbs(x) ) >= 1e-10 ) { return TEST_FAILED; } 59 | 60 | /** Macro verifying that first quantity is lower or equal than second one in order to pass unit test. */ 61 | #define QPOASES_TEST_FOR_TOL( x,tol ) if ( (x) > (tol)*(TEST_TOL_FACTOR) ) { return TEST_FAILED; } 62 | 63 | /** Macro verifying that a logical expression holds in order to pass unit test. */ 64 | #define QPOASES_TEST_FOR_TRUE( x ) if ( (x) == false ) { return TEST_FAILED; } 65 | 66 | 67 | 68 | BEGIN_NAMESPACE_QPOASES 69 | 70 | 71 | END_NAMESPACE_QPOASES 72 | 73 | 74 | #endif /* QPOASES_UNIT_TESTING_HPP */ 75 | 76 | 77 | /* 78 | * end of file 79 | */ 80 | -------------------------------------------------------------------------------- /include/qpOASES/extras/SolutionAnalysis.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file include/qpOASES/extras/SolutionAnalysis.ipp 27 | * \author Hans Joachim Ferreau (thanks to Boris Houska) 28 | * \version 3.2 29 | * \date 2008-2017 30 | * 31 | * Implementation of inlined member functions of the SolutionAnalysis class 32 | * designed to perform additional analysis after solving a QP with qpOASES. 33 | * 34 | */ 35 | 36 | 37 | 38 | /***************************************************************************** 39 | * P U B L I C * 40 | *****************************************************************************/ 41 | 42 | 43 | BEGIN_NAMESPACE_QPOASES 44 | 45 | 46 | END_NAMESPACE_QPOASES 47 | 48 | 49 | /* 50 | * end of file 51 | */ 52 | -------------------------------------------------------------------------------- /interfaces/CUTEst/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: cutestDriver/Makefile 27 | ## Author: Dennis Janka 28 | ## Version: 3.2 29 | ## Date: 2015-2017 30 | ## 31 | 32 | # include directories, relative 33 | IDIR = ../../include 34 | SRCDIR = ../../src 35 | BINDIR = ../../bin 36 | CUTESTLIBPATH = ${CUTEST}/objects/${MYARCH}/double 37 | 38 | # don't change that (for now) ... 39 | PROBLEMPATH = ./prob 40 | 41 | # file extensions 42 | CPP = g++ 43 | CPPFLAGS = -Wall -pedantic -Wshadow -O0 -finline-functions -fPIC -DLINUX -g 44 | FF = gfortran 45 | FFLAGS = 46 | 47 | #link against CUTEst library, qpOASES library and compiled test problem 48 | LINKOPTS = -L${CUTESTLIBPATH} -L${PROBLEMPATH} -Wl,-rpath=${PROBLEMPATH} \ 49 | -L${BINDIR} -Wl,-rpath=${BINDIR} -lqpOASES \ 50 | -lcutest -llapack -lm -lgfortran -lprob 51 | 52 | IFLAGS = -I${IDIR} \ 53 | -I${CUTEST}/include 54 | 55 | QPOASES_EXES = \ 56 | qpoasesCutest 57 | 58 | ## 59 | ## targets 60 | ## 61 | 62 | all: ${QPOASES_EXES} 63 | 64 | qpoasesCutest: qpoasesCutest.o 65 | @echo "Creating" $@ 66 | ${CPP} -o $@ ${CPPFLAGS} $< ${LINKOPTS} 67 | 68 | clean: 69 | rm -f *.o ${QPOASES_EXES} 70 | 71 | clobber: clean 72 | 73 | %.o: %.cpp 74 | @echo "Creating" $@ 75 | @${CPP} -c ${IFLAGS} ${CPPFLAGS} $< -o $@ 76 | 77 | ## 78 | ## end of file 79 | ## 80 | -------------------------------------------------------------------------------- /interfaces/CUTEst/makeprob: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ]; then 4 | echo Usage: $0 problemname 5 | exit 6 | fi 7 | 8 | PROBLEMPATH="./prob" 9 | mkdir -p $PROBLEMPATH 10 | cd $PROBLEMPATH 11 | 12 | # Call sifdecoder (additional parameter for problem size can be passed) 13 | if [ -z "$2" ]; then 14 | sifdecoder $MASTSIF/$1 15 | else 16 | sifdecoder -param N=$2 $MASTSIF/$1 17 | fi 18 | 19 | # Compile objects 20 | gfortran -c RANGE.f -fPIC -o RANGE.o 21 | gfortran -c ELFUN.f -fPIC -o ELFUN.o 22 | gfortran -c GROUP.f -fPIC -o GROUP.o 23 | 24 | # Build shared library 25 | gfortran -shared -o libprob.so RANGE.o ELFUN.o GROUP.o 26 | 27 | cd ../ 28 | 29 | -------------------------------------------------------------------------------- /interfaces/CUTEst/readme.txt: -------------------------------------------------------------------------------- 1 | CUTEst interface for qpOASES 2 | by Dennis Janka 3 | 4 | ==================================================== 5 | 6 | 0.) Files included: 7 | 8 | - qpoasesCutest.cpp 9 | - Makefile 10 | - makeprob 11 | - readme.txt 12 | 13 | 1.) Download and install CUTEst from 14 | 15 | http://ccpforge.cse.rl.ac.uk/gf/project/cutest/wiki/ 16 | 17 | Make sure all environment variables are set as instructed. 18 | (in particular $CUTEST, $MYARCH and $MASTSIF) 19 | 20 | 2.) To decode and compile a problem, type: 21 | 22 | ./makeprob 23 | 24 | For problems that come in different sizes (e.g. NCVXQP[1-9]) the size 25 | parameter ( N= ) may be passed as a second argument: 26 | 27 | ./makeprob 28 | 29 | This calls "sifdecoder" to decode the .sif file and creates a shared 30 | library libprob.so in prob/ that will be linked against the 31 | qpOASES CUTEst interface. 32 | 33 | 3.) Finally, call "make" to compile and link qpoasesCutest. 34 | You may have to set the correct paths for the qpOASES library and 35 | header files in the makefile. 36 | 37 | 4.) The command ./qpoasesCutest runs qpOASES with the latest compiled 38 | .sif problem. For solving further problems, only the appropriate 39 | "./makeprob" call is required. 40 | -------------------------------------------------------------------------------- /interfaces/c/c_example1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file interfaces/c/c_example1.c 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Very simple example for testing qpOASES (using QProblem class through C interface). 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | /* Setup data of first QP. */ 43 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 44 | real_t A[1*2] = { 1.0, 1.0 }; 45 | real_t g[2] = { 1.5, 1.0 }; 46 | real_t lb[2] = { 0.5, -2.0 }; 47 | real_t ub[2] = { 5.0, 2.0 }; 48 | real_t lbA[1] = { -1.0 }; 49 | real_t ubA[1] = { 2.0 }; 50 | 51 | /* Setup data of second QP. */ 52 | real_t g_new[2] = { 1.0, 1.5 }; 53 | real_t lb_new[2] = { 0.0, -1.0 }; 54 | real_t ub_new[2] = { 5.0, -0.5 }; 55 | real_t lbA_new[1] = { -2.0 }; 56 | real_t ubA_new[1] = { 1.0 }; 57 | 58 | int nWSR; 59 | qpOASES_Options options; 60 | 61 | real_t xOpt[2]; 62 | real_t yOpt[2+1]; 63 | real_t obj; 64 | int status; 65 | 66 | qpOASES_Options_init( &options,0 ); 67 | options.printLevel = PL_MEDIUM; 68 | 69 | 70 | QProblem_setup( 2,1,HST_UNKNOWN ); 71 | 72 | /* Solve first QP. */ 73 | nWSR = 10; 74 | QProblem_init( H,g,A,lb,ub,lbA,ubA, 75 | (int_t* const)&nWSR,0,&options, 76 | xOpt,yOpt,&obj,(int_t* const)&status 77 | ); 78 | 79 | /* Print solution of first QP. */ 80 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 81 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 82 | 83 | 84 | /* Solve second QP. */ 85 | nWSR = 10; 86 | QProblem_hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, 87 | (int_t* const)&nWSR,0, 88 | xOpt,yOpt,&obj,(int_t* const)&status 89 | ); 90 | 91 | /* Print solution of first QP. */ 92 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 93 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 94 | 95 | 96 | QProblem_cleanup(); 97 | 98 | return 0; 99 | } 100 | 101 | 102 | /* 103 | * end of file 104 | */ 105 | -------------------------------------------------------------------------------- /interfaces/c/c_example1a.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file interfaces/c/c_example1a.c 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Very simple example for testing qpOASES (using SQProblem class through C interface). 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | /* Setup data of first QP. */ 43 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 44 | real_t A[1*2] = { 1.0, 1.0 }; 45 | real_t g[2] = { 1.5, 1.0 }; 46 | real_t lb[2] = { 0.5, -2.0 }; 47 | real_t ub[2] = { 5.0, 2.0 }; 48 | real_t lbA[1] = { -1.0 }; 49 | real_t ubA[1] = { 2.0 }; 50 | 51 | /* Setup data of second QP. */ 52 | real_t H_new[2*2] = { 1.0, 0.5, 0.5, 0.5 }; 53 | real_t A_new[1*2] = { 1.0, 5.0 }; 54 | real_t g_new[2] = { 1.0, 1.5 }; 55 | real_t lb_new[2] = { 0.0, -1.0 }; 56 | real_t ub_new[2] = { 5.0, -0.5 }; 57 | real_t lbA_new[1] = { -2.0 }; 58 | real_t ubA_new[1] = { 1.0 }; 59 | 60 | int nWSR; 61 | 62 | real_t xOpt[2]; 63 | real_t yOpt[2+1]; 64 | real_t obj; 65 | int status; 66 | 67 | qpOASES_Options options; 68 | qpOASES_Options_init( &options,0 ); 69 | 70 | 71 | SQProblem_setup( 2,1,HST_UNKNOWN ); 72 | 73 | /* Solve first QP. */ 74 | nWSR = 10; 75 | SQProblem_init( H,g,A,lb,ub,lbA,ubA, 76 | (int_t* const)&nWSR,0,&options, 77 | xOpt,yOpt,&obj,(int_t* const)&status 78 | ); 79 | 80 | /* Print solution of first QP. */ 81 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 82 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 83 | 84 | 85 | /* Solve second QP. */ 86 | nWSR = 10; 87 | SQProblem_hotstart( H_new,g_new,A_new,lb_new,ub_new,lbA_new,ubA_new, 88 | (int_t* const)&nWSR,0, 89 | xOpt,yOpt,&obj,(int_t* const)&status 90 | ); 91 | 92 | /* Print solution of first QP. */ 93 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 94 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 95 | 96 | 97 | SQProblem_cleanup(); 98 | 99 | return 0; 100 | } 101 | 102 | 103 | /* 104 | * end of file 105 | */ 106 | -------------------------------------------------------------------------------- /interfaces/c/c_example1b.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file interfaces/c/example1b.c 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Very simple example for testing qpOASES (using QProblemB class through C interface). 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | /* Setup data of first QP. */ 43 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 44 | real_t g[2] = { 1.5, 1.0 }; 45 | real_t lb[2] = { 0.5, -2.0 }; 46 | real_t ub[2] = { 5.0, 2.0 }; 47 | 48 | /* Setup data of second QP. */ 49 | real_t g_new[2] = { 1.0, 1.5 }; 50 | real_t lb_new[2] = { 0.0, -1.0 }; 51 | real_t ub_new[2] = { 5.0, -0.5 }; 52 | 53 | int nWSR; 54 | qpOASES_Options options; 55 | 56 | real_t xOpt[2]; 57 | real_t yOpt[2]; 58 | real_t obj; 59 | int status; 60 | 61 | qpOASES_Options_init( &options,0 ); 62 | /*options.enableFlippingBounds = 0; */ 63 | options.initialStatusBounds = ST_INACTIVE; 64 | options.numRefinementSteps = 1; 65 | options.enableCholeskyRefactorisation = 1; 66 | 67 | 68 | QProblemB_setup( 2,HST_UNKNOWN ); 69 | 70 | /* Solve first QP. */ 71 | nWSR = 10; 72 | QProblemB_init( H,g,lb,ub, 73 | (int_t* const)&nWSR,0,&options, 74 | xOpt,yOpt,&obj,(int_t* const)&status 75 | ); 76 | 77 | /* Print solution of first QP. */ 78 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e ]; objVal = %e\n\n", 79 | xOpt[0],xOpt[1],yOpt[0],yOpt[1], obj ); 80 | 81 | 82 | /* Solve second QP. */ 83 | nWSR = 10; 84 | QProblemB_hotstart( g_new,lb_new,ub_new, 85 | (int_t* const)&nWSR,0, 86 | xOpt,yOpt,&obj,(int_t* const)&status 87 | ); 88 | 89 | /* Print solution of first QP. */ 90 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e ]; objVal = %e\n\n", 91 | xOpt[0],xOpt[1],yOpt[0],yOpt[1], obj ); 92 | 93 | 94 | QProblemB_cleanup(); 95 | 96 | return 0; 97 | } 98 | 99 | 100 | /* 101 | * end of file 102 | */ 103 | -------------------------------------------------------------------------------- /interfaces/matlab/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: src/interfaces/matlab/Makefile 27 | ## Author: Christian Kirches, Hans Joachim Ferreau, Andreas Potschka 28 | ## Version: 3.2 29 | ## Date: 2007-2017 30 | ## 31 | 32 | include ../../make.mk 33 | 34 | ## 35 | ## flags 36 | ## 37 | 38 | IDIR = ../../include 39 | 40 | IFLAGS = -I. \ 41 | -I${IDIR} \ 42 | -I${MATLAB_IDIR} 43 | 44 | LINK_MATLAB_LIBS = -L${MATLAB_LIBDIR} -lmex -lmat -lmx 45 | 46 | EXTRAFLAGS = -largeArrayDims -O -D__cpluplus -D__MATLAB__ -fexceptions 47 | 48 | QPOASES_OBJECT = qpOASES.${OBJEXT} 49 | QPOASES_SEQUENCE_OBJECT = qpOASES_sequence.${OBJEXT} 50 | 51 | ## 52 | ## targets 53 | ## 54 | 55 | all: ${BINDIR}/qpOASES.${MEXEXT} ${BINDIR}/qpOASES_sequence.${MEXEXT} copyMs 56 | 57 | ${BINDIR}/qpOASES.${MEXEXT}: ${QPOASES_OBJECT} 58 | @${ECHO} "Creating" $@ 59 | @${CPP} -shared -o $@ $? ${QPOASES_LINK} ${LINK_LIBRARIES} ${LINK_MATLAB_LIBS} 60 | 61 | ${BINDIR}/qpOASES_sequence.${MEXEXT}: ${QPOASES_SEQUENCE_OBJECT} 62 | @${ECHO} "Creating" $@ 63 | @${CPP} -shared -o $@ $? ${QPOASES_LINK} ${LINK_LIBRARIES} ${LINK_MATLAB_LIBS} 64 | 65 | copyMs: 66 | @${ECHO} "Copying M files ..." 67 | @${CP} qpOASES.m ${BINDIR} 68 | @${CP} qpOASES_options.m ${BINDIR} 69 | @${CP} qpOASES_sequence.m ${BINDIR} 70 | 71 | #@${CP} qpOASES_sequenceVM.m ${BINDIR} 72 | 73 | clean: 74 | @${RM} -f *.${OBJEXT} *.mex* 75 | 76 | clobber: clean 77 | 78 | %.${OBJEXT}: %.cpp 79 | @${ECHO} "Creating" $@ 80 | @${CPP} ${DEF_TARGET} -c ${IFLAGS} ${EXTRAFLAGS} ${CPPFLAGS} $< 81 | 82 | 83 | ## 84 | ## end of file 85 | ## 86 | -------------------------------------------------------------------------------- /interfaces/matlab/example1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/matlab/example1.mat -------------------------------------------------------------------------------- /interfaces/matlab/example1a.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/matlab/example1a.mat -------------------------------------------------------------------------------- /interfaces/matlab/example1b.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/matlab/example1b.mat -------------------------------------------------------------------------------- /interfaces/matlab/qpOASES_matlab_utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file interfaces/matlab/qpOASES_matlab_utils.hpp 27 | * \author Hans Joachim Ferreau, Alexander Buchner 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Collects utility functions for Interface to Matlab(R) that 32 | * enables to call qpOASES as a MEX function. 33 | * 34 | */ 35 | 36 | 37 | 38 | /* Work-around for settings where mexErrMsgTxt causes unexpected behaviour. */ 39 | #ifdef __AVOID_MEXERRMSGTXT__ 40 | #define myMexErrMsgTxt( TEXT ) mexPrintf( "%s\n\n",(TEXT) ); 41 | #else 42 | #define myMexErrMsgTxt mexErrMsgTxt 43 | #endif 44 | 45 | 46 | /* Workaround for problem on Matlab 2012b 47 | * see https://github.com/robotology/codyco-superbuild/issues/84 48 | * see http://stackoverflow.com/questions/22440523/mex-files-using-xcode-5-1-under-os-x-10-9-with-matlab-2012a/22705789#22705789 */ 49 | #ifdef __APPLE__ 50 | #include 51 | #endif 52 | 53 | #include "mex.h" 54 | #include "matrix.h" 55 | #include "string.h" 56 | #include 57 | 58 | 59 | /* 60 | * QProblem instance class 61 | */ 62 | class QPInstance 63 | { 64 | private: 65 | static int_t s_nexthandle; 66 | 67 | public: 68 | QPInstance( uint_t _nV = 0, 69 | uint_t _nC = 0, 70 | HessianType _hessianType = HST_UNKNOWN, 71 | BooleanType _isSimplyBounded = BT_FALSE, 72 | BooleanType _sparseLA = BT_FALSE 73 | ); 74 | 75 | ~QPInstance( ); 76 | 77 | returnValue deleteQPMatrices(); 78 | 79 | int_t getNV() const; 80 | int_t getNC() const; 81 | 82 | int_t handle; 83 | 84 | SQProblem* sqp; 85 | QProblemB* qpb; 86 | BooleanType isSimplyBounded; 87 | BooleanType sparseLA; 88 | 89 | SymmetricMatrix* H; 90 | Matrix* A; 91 | sparse_int_t* Hir; 92 | sparse_int_t* Hjc; 93 | sparse_int_t* Air; 94 | sparse_int_t* Ajc; 95 | real_t* Hv; 96 | real_t* Av; 97 | }; 98 | 99 | 100 | /* 101 | * end of file 102 | */ 103 | -------------------------------------------------------------------------------- /interfaces/matlab/testQPset.m: -------------------------------------------------------------------------------- 1 | % Requires Lukas Schork's Matlab repository of the Maros Meszaros test set 2 | QPsetDIR = '~/git/QPset/maros'; 3 | 4 | files = dir(QPsetDIR); 5 | 6 | options = qpOASES_options('default', ... 7 | 'printLevel', 0, 'maxIter', 1e8, 'maxCpuTime', 60, ... 8 | 'initialStatusBounds', 0); 9 | nQP = 0; 10 | for i = 1:length(files) 11 | clear mex 12 | try 13 | load([QPsetDIR, '/', files(i).name]); 14 | H = sparse(H); 15 | A = sparse(A); 16 | catch 17 | continue 18 | end 19 | 20 | startTime = tic; 21 | try 22 | [x,fval,exitflag,iter,lambda] = qpOASES(H,g,A,xl,xu,al,au,options); 23 | catch 24 | exitflag = 666; 25 | iter = 666; 26 | fval = 666; 27 | end 28 | elapsedTime = toc(startTime); 29 | 30 | if mod(nQP, 20) == 0 31 | fprintf('\n%-10s %6s %6s %5s %7s %15s %9s\n', ... 32 | 'name', 'nvar', 'ncon', 'eflag', 'iter', 'fval', 'time [s]'); 33 | end 34 | fprintf('%-10s %6d %6d %5d %7d %15g %9g\n', ... 35 | files(i).name(1:findstr(files(i).name, '.')-1), ... 36 | size(A,2), size(A,1), exitflag, iter, fval, elapsedTime); 37 | 38 | nQP = nQP + 1; 39 | end 40 | 41 | -------------------------------------------------------------------------------- /interfaces/matlab/testSchur.m: -------------------------------------------------------------------------------- 1 | m = 2000; 2 | n = 2*m+1; 3 | H = 2*speye(n); 4 | A = 0.5*H(1:m,:); 5 | g = zeros(n,1); 6 | lb = -ones(n,1); 7 | ub = -lb; 8 | lbA = 0.5*ones(m,1); 9 | ubA = 0.5*ones(m,1); 10 | 11 | options = qpOASES_options('default', 'printLevel', -1, 'maxIter', n+m+1, ... 12 | 'enableEqualities', 0, 'initialStatusBounds', 1); 13 | 14 | %[x,fval,exitflag,iter,lambda] = qpOASES(full(H),g,full(A),lb,ub,lbA,ubA,options); 15 | [x,fval,exitflag,iter,lambda] = qpOASES(H,g,A,lb,ub,lbA,ubA,options); 16 | 17 | -------------------------------------------------------------------------------- /interfaces/octave/clean: -------------------------------------------------------------------------------- 1 | rm *.*~ 2 | rm *.o 3 | rm qpOASES qpOASES_sequence 4 | -------------------------------------------------------------------------------- /interfaces/octave/clean.sh: -------------------------------------------------------------------------------- 1 | rm *.*~ 2 | rm *.o 3 | rm qpOASES qpOASES_sequence 4 | -------------------------------------------------------------------------------- /interfaces/octave/example1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/octave/example1.mat -------------------------------------------------------------------------------- /interfaces/octave/example1a.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/octave/example1a.mat -------------------------------------------------------------------------------- /interfaces/octave/example1b.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/octave/example1b.mat -------------------------------------------------------------------------------- /interfaces/octave/qpOASES_octave_utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file interfaces/octave/qpOASES_octave_utils.hpp 27 | * \author Hans Joachim Ferreau, Andreas Potschka, Alexander Buchner 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Collects utility functions for Interface to octave that 32 | * enables to call qpOASES as a MEX function. 33 | * 34 | */ 35 | 36 | 37 | 38 | /* Work-around for settings where mexErrMsgTxt causes unexpected behaviour. */ 39 | #ifdef __AVOID_MEXERRMSGTXT__ 40 | #define myMexErrMsgTxt( TEXT ) mexPrintf( "%s\n\n",(TEXT) ); 41 | #else 42 | #define myMexErrMsgTxt mexErrMsgTxt 43 | #endif 44 | 45 | 46 | #include "mex.h" 47 | /* #include "matrix.h" */ 48 | #include "string.h" 49 | #include 50 | 51 | 52 | /* 53 | * QProblem instance class 54 | */ 55 | class QPInstance 56 | { 57 | private: 58 | static int_t s_nexthandle; 59 | 60 | public: 61 | QPInstance( uint_t _nV = 0, 62 | uint_t _nC = 0, 63 | HessianType _hessianType = HST_UNKNOWN, 64 | BooleanType _isSimplyBounded = BT_FALSE 65 | ); 66 | 67 | ~QPInstance( ); 68 | 69 | returnValue deleteQPMatrices(); 70 | 71 | int_t getNV() const; 72 | int_t getNC() const; 73 | 74 | int_t handle; 75 | 76 | SQProblem* sqp; 77 | QProblemB* qpb; 78 | BooleanType isSimplyBounded; 79 | 80 | SymmetricMatrix* H; 81 | Matrix* A; 82 | sparse_int_t* Hir; 83 | sparse_int_t* Hjc; 84 | sparse_int_t* Air; 85 | sparse_int_t* Ajc; 86 | real_t* Hv; 87 | real_t* Av; 88 | }; 89 | 90 | 91 | /* 92 | * end of file 93 | */ 94 | -------------------------------------------------------------------------------- /interfaces/python/README.rst: -------------------------------------------------------------------------------- 1 | pyqpOASES: a Python interface to qpOASES 2 | 3 | :Author: Sebastian F. Walter, Manuel Kudruss 4 | 5 | Known to work with 6 | ------------------ 7 | 8 | * python2.7 9 | * qpOASES 3.2 (rev 259) 10 | 11 | 12 | Installation 13 | ------------ 14 | 15 | Requirements: 16 | 17 | You'll need numpy and cython. Install for instance with:: 18 | 19 | sudo pip install cython 20 | sudo pip install numpy 21 | 22 | Method 1: 23 | 24 | This is a local installation and creates `./interfaces/python/qpoases.so`:: 25 | 26 | make python 27 | 28 | Then, you'll have to update your PYTHONPATH, e.g., on LINUX you have to add:: 29 | 30 | export PYTHONPATH=$PYTHONPATH:/home/swalter/projects/qpOASES/interfaces/python 31 | 32 | to your ``~/.bashrc``. 33 | 34 | Method 2: 35 | 36 | global installation:: 37 | 38 | sudo make pythoninstall 39 | 40 | Method 3:: 41 | 42 | cd ./interfaces/python/ 43 | python setup.py build_ext --inplace 44 | # or python setup.py install 45 | 46 | 47 | Testing your installation 48 | ------------------------- 49 | 50 | For a quick test run:: 51 | 52 | cd ./interfaces/python 53 | python example1.py 54 | 55 | 56 | To run a complete unit test you need ``nose``. Install for instance with:: 57 | 58 | sudo pip install nose 59 | 60 | Then:: 61 | 62 | cd ./interfaces/python/ 63 | nosestests ./tests 64 | 65 | The results of the tests can be found in `./interfaces/python/tests/results`. 66 | 67 | Tested setups 68 | ------------- 69 | 70 | The Python interface is known to work on 71 | 72 | * Windows, Python 3 73 | * Linux (Ubuntu 12.04) using Python 2.7.3, Python 3.2.3. NumPy 1.8, Cython 0.19 74 | * MacOS Mojave (10.14.3) using Python 3.7 (anaconda suite) 75 | 76 | -------------------------------------------------------------------------------- /interfaces/python/examples/cython/example1.pyx: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | ## Example adapted from examples/example1.cpp. 24 | ## author of this file: Sebastian F. Walter 25 | 26 | import numpy as np 27 | from qpoases import PyQProblem as QProblem 28 | from qpoases import PyPrintLevel as PrintLevel 29 | from qpoases import PyOptions as Options 30 | cimport numpy as np 31 | 32 | def run(): 33 | 34 | #Setup data of QP. 35 | 36 | cdef np.ndarray[np.double_t, ndim=2] H 37 | cdef np.ndarray[np.double_t, ndim=2] A 38 | cdef np.ndarray[np.double_t, ndim=1] g 39 | cdef np.ndarray[np.double_t, ndim=1] lb 40 | cdef np.ndarray[np.double_t, ndim=1] ub 41 | cdef np.ndarray[np.double_t, ndim=1] lbA 42 | cdef np.ndarray[np.double_t, ndim=1] ubA 43 | 44 | H = np.array([1.0, 0.0, 0.0, 0.5 ]).reshape((2,2)) 45 | A = np.array([1.0, 1.0 ]).reshape((2,1)) 46 | g = np.array([1.5, 1.0 ]) 47 | lb = np.array([0.5, -2.0]) 48 | ub = np.array([5.0, 2.0 ]) 49 | lbA = np.array([-1.0 ]) 50 | ubA = np.array([2.0]) 51 | 52 | # Setting up QProblem object. 53 | 54 | cdef example = QProblem(2, 1) 55 | cdef options = Options() 56 | options.printLevel = PrintLevel.NONE 57 | example.setOptions(options) 58 | 59 | # Solve first QP. 60 | 61 | cdef int nWSR = 10 62 | example.init(H, g, A, lb, ub, lbA, ubA, nWSR) 63 | 64 | # Solve subsequent QPs 65 | 66 | cdef int i,j 67 | for i in range(100000): 68 | for j in range(1, 100): 69 | g[0] = i%j 70 | example.hotstart(g, lb, ub, lbA, ubA, nWSR) 71 | 72 | run() 73 | 74 | -------------------------------------------------------------------------------- /interfaces/python/examples/cython/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Distutils import build_ext 4 | 5 | ext_module = Extension( 6 | "example1", 7 | ["example1.pyx"], 8 | extra_compile_args=['-fopenmp'], 9 | extra_link_args=['-fopenmp'], 10 | ) 11 | 12 | setup( 13 | name = 'Hello world app', 14 | cmdclass = {'build_ext': build_ext}, 15 | ext_modules = [ext_module], 16 | ) 17 | -------------------------------------------------------------------------------- /interfaces/python/examples/example1.py: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | ## Example adapted from examples/example1.cpp. 24 | ## author of this file: Sebastian F. Walter 25 | 26 | import numpy as np 27 | from qpoases import PyQProblem as QProblem 28 | from qpoases import PyOptions as Options 29 | from qpoases import PyPrintLevel as PrintLevel 30 | 31 | #Setup data of first QP. 32 | 33 | H = np.array([1.0, 0.0, 0.0, 0.5 ]).reshape((2,2)) 34 | A = np.array([1.0, 1.0 ]).reshape((2,1)) 35 | g = np.array([1.5, 1.0 ]) 36 | lb = np.array([0.5, -2.0]) 37 | ub = np.array([5.0, 2.0 ]) 38 | lbA = np.array([-1.0 ]) 39 | ubA = np.array([2.0]) 40 | 41 | 42 | # Setup data of second QP. 43 | 44 | g_new = np.array([1.0, 1.5]) 45 | lb_new = np.array([0.0, -1.0]) 46 | ub_new = np.array([5.0, -0.5]) 47 | lbA_new = np.array([-2.0]) 48 | ubA_new = np.array([1.0]) 49 | 50 | 51 | # Setting up QProblem object. 52 | 53 | example = QProblem(2, 1) 54 | options = Options() 55 | #options.printLevel = PrintLevel.NONE 56 | example.setOptions(options) 57 | 58 | # Solve first QP. 59 | nWSR = np.array([10]) 60 | example.init(H, g, A, lb, ub, lbA, ubA, nWSR) 61 | 62 | xOpt = np.zeros(2) 63 | example.getPrimalSolution(xOpt) 64 | print("\nxOpt = [ %e, %e ]; objVal = %e\n\n"%(xOpt[0],xOpt[1],example.getObjVal())) 65 | 66 | # Solve second QP. 67 | nWSR = np.array([10]) 68 | example.hotstart( g_new, lb_new, ub_new, lbA_new, ubA_new, nWSR) 69 | 70 | # Get and print solution of second QP. 71 | 72 | example.getPrimalSolution(xOpt) 73 | print("\nxOpt = [ %e, %e ]; objVal = %e\n\n"%(xOpt[0],xOpt[1],example.getObjVal())) 74 | example.printOptions() 75 | -------------------------------------------------------------------------------- /interfaces/python/examples/example1b.py: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | ## Example adapted from examples/example1b.cpp. 24 | ## author of this file: Sebastian F. Walter 25 | 26 | import numpy as np 27 | from qpoases import PyQProblemB as QProblemB 28 | from qpoases import PyBooleanType as BooleanType 29 | from qpoases import PySubjectToStatus as SubjectToStatus 30 | from qpoases import PyOptions as Options 31 | 32 | # Example for qpOASES main function using the QProblemB class. 33 | 34 | #Setup data of first QP. 35 | 36 | H = np.array([1.0, 0.0, 0.0, 0.5 ]).reshape((2,2)) 37 | g = np.array([1.5, 1.0 ]) 38 | lb = np.array([0.5, -2.0]) 39 | ub = np.array([5.0, 2.0 ]) 40 | 41 | # Setup data of second QP. 42 | 43 | g_new = np.array([1.0, 1.5]) 44 | lb_new = np.array([0.0, -1.0]) 45 | ub_new = np.array([5.0, -0.5]) 46 | 47 | 48 | # Setting up QProblemB object. 49 | example = QProblemB(2) 50 | 51 | options = Options() 52 | options.enableFlippingBounds = BooleanType.FALSE 53 | options.initialStatusBounds = SubjectToStatus.INACTIVE 54 | options.numRefinementSteps = 1 55 | 56 | example.setOptions(options) 57 | 58 | # Solve first QP. 59 | nWSR = np.array([10]) 60 | example.init(H, g, lb, ub, nWSR) 61 | print("\nnWSR = %d\n\n"%nWSR) 62 | 63 | # Solve second QP. 64 | nWSR = np.array([10]) 65 | example.hotstart(g_new, lb_new, ub_new, nWSR) 66 | print("\nnWSR = %d\n\n"% nWSR) 67 | 68 | # Get and print solution of second QP. 69 | xOpt = np.zeros(2) 70 | example.getPrimalSolution(xOpt) 71 | print("\nxOpt = [ %e, %e ]; objVal = %e\n\n" %(xOpt[0], xOpt[1], 72 | example.getObjVal())) 73 | -------------------------------------------------------------------------------- /interfaces/python/examples/example2.py: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | ## Example adapted from examples/example2.cpp. 24 | ## author of this file: Sebastian F. Walter 25 | 26 | import os 27 | import sys 28 | import numpy as np 29 | from qpoases import PySQProblem as SQProblem 30 | from qpoases import PySolutionAnalysis as SolutionAnalysis 31 | 32 | 33 | # Setup data of first QP. 34 | H = np.array([ 1.0, 0.0, 0.0, 0.5 ]).reshape((2,2)) 35 | A = np.array([ 1.0, 1.0 ]).reshape((2,1)) 36 | g = np.array([ 1.5, 1.0 ]) 37 | lb = np.array([ 0.5, -2.0 ]) 38 | ub = np.array([ 5.0, 2.0 ]) 39 | lbA = np.array([ -1.0 ]) 40 | ubA = np.array([ 2.0 ]) 41 | 42 | # Setup data of second QP. 43 | H_new = np.array([ 1.0, 0.5, 0.5, 0.5 ]).reshape((2,2)) 44 | A_new = np.array([ 1.0, 5.0 ]).reshape((2,1)) 45 | g_new = np.array([ 1.0, 1.5 ]) 46 | lb_new = np.array([ 0.0, -1.0 ]) 47 | ub_new = np.array([ 5.0, -0.5 ]) 48 | lbA_new = np.array([ -2.0 ]) 49 | ubA_new = np.array([ 1.0 ]) 50 | 51 | # Setting up SQProblem object and solution analyser. 52 | example = SQProblem(2, 1) 53 | analyser = SolutionAnalysis() 54 | 55 | # Solve first QP ... 56 | nWSR = np.array([10]) 57 | example.init(H, g, A, lb, ub, lbA, ubA, nWSR) 58 | 59 | # ... and analyse it. 60 | maxStat = np.zeros(1) 61 | maxFeas = np.zeros(1) 62 | maxCmpl = np.zeros(1) 63 | 64 | analyser.getKktViolation(example, maxStat, maxFeas, maxCmpl) 65 | print("maxStat: %e, maxFeas:%e, maxCmpl: %e\n"%(maxStat, maxFeas, maxCmpl)) 66 | 67 | # Solve second QP ... 68 | nWSR = np.array([10]) 69 | example.hotstart(H_new, g_new, A_new, lb_new, ub_new, 70 | lbA_new, ubA_new, nWSR) 71 | 72 | # ... and analyse it. 73 | analyser.getKktViolation(example, maxStat, maxFeas, maxCmpl) 74 | print("maxStat: %e, maxFeas:%e, maxCmpl: %e\n"%(maxStat, maxFeas, maxCmpl)) 75 | 76 | 77 | # ------------ VARIANCE-COVARIANCE EVALUATION -------------------- 78 | 79 | Var = np.zeros(5*5) 80 | Primal_Dual_Var = np.zeros(5*5) 81 | 82 | Var.reshape((5,5))[0,0] = 1. 83 | Var.reshape((5,5))[1,1] = 1. 84 | 85 | # ( 1 0 0 0 0 ) 86 | # ( 0 1 0 0 0 ) 87 | # Var = ( 0 0 0 0 0 ) 88 | # ( 0 0 0 0 0 ) 89 | # ( 0 0 0 0 0 ) 90 | 91 | 92 | analyser.getVarianceCovariance(example, Var, Primal_Dual_Var) 93 | print('Primal_Dual_Var=\n', Primal_Dual_Var.reshape((5,5))) 94 | print("maxStat: %e, maxFeas:%e, maxCmpl: %e\n"%(maxStat, maxFeas, maxCmpl)) 95 | -------------------------------------------------------------------------------- /interfaces/python/tests/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /interfaces/scilab/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: interfaces/scilab/Makefile 27 | ## Author: Holger Diedam, Hans Joachim Ferreau 28 | ## Version: 3.2 29 | ## Date: 2007-2017 30 | ## 31 | 32 | 33 | 34 | PATH_LIB = . 35 | PATH_SRC = . 36 | PATH_OBJ = . 37 | PATH_QPOASES_INC = ../../include 38 | PATH_QPOASES_SRC = ../../src 39 | PATH_QPOASES_OBJ = ../../src 40 | 41 | 42 | ## 43 | ## bins 44 | ## 45 | 46 | CC = gcc 47 | CPP = g++ 48 | LD = g++ 49 | CP = cp 50 | 51 | 52 | 53 | ## 54 | ## flags 55 | ## 56 | 57 | CFLAGS = -I$(PATH_QPOASES_INC) -I$(PATH_QPOASES_SRC) -Wall -pedantic -Wshadow -O3 -fPIC 58 | CPPFLAGS = -I$(PATH_QPOASES_INC) -I$(PATH_QPOASES_SRC) -Wall -pedantic -Wshadow -O3 -fPIC -DLINUX -D__SCILAB__ -D__SINGLE_OBJECT__ 59 | LDFLAGS = -shared 60 | LIBEXT = .so 61 | 62 | 63 | LIB = libqpOASESinterface$(LIBEXT) 64 | 65 | OBJ = \ 66 | qpOASESroutines.o \ 67 | qpOASESinterface.o 68 | 69 | 70 | 71 | ## 72 | ## targets 73 | ## 74 | 75 | all: $(PATH_LIB)/$(LIB) 76 | 77 | $(PATH_OBJ)/%.o: $(PATH_SRC)/%.c 78 | $(CC) -c -o $(@) $(CFLAGS) $< 79 | 80 | $(PATH_OBJ)/%.o: $(PATH_SRC)/%.cpp 81 | $(CPP) -c -o $(@) $(CPPFLAGS) $< 82 | 83 | $(PATH_LIB)/$(LIB) : $(addprefix $(PATH_OBJ)/, $(OBJ)) 84 | $(LD) $(LDFLAGS) $^ -o $@ 85 | 86 | clean: 87 | $(RM) $(PATH_OBJ)/*.o $(PATH_LIB)/$(LIB) 88 | 89 | 90 | 91 | ## 92 | ## end of file 93 | ## 94 | -------------------------------------------------------------------------------- /interfaces/scilab/example1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/scilab/example1.dat -------------------------------------------------------------------------------- /interfaces/scilab/example1a.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/scilab/example1a.dat -------------------------------------------------------------------------------- /interfaces/scilab/example1b.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coin-or/qpOASES/680f18c8ef0018a120e1604b769f056e8368df97/interfaces/scilab/example1b.dat -------------------------------------------------------------------------------- /interfaces/scilab/qpOASESinterface.sce: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of qpOASES. 3 | // 4 | // qpOASES -- An Implementation of the Online Active Set Strategy. 5 | // Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | // Christian Kirches et al. All rights reserved. 7 | // 8 | // qpOASES is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Lesser General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2.1 of the License, or (at your option) any later version. 12 | // 13 | // qpOASES is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with qpOASES; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | // 22 | 23 | 24 | 25 | // 26 | // Filename: interfaces/scilab/qpOASESinterface.sci 27 | // Author: Holger Diedam, Hans Joachim Ferreau 28 | // Version: 3.2 29 | // Date: 2007-2017 30 | // 31 | 32 | 33 | 34 | sharedlib = link( './libqpOASESinterface.so' ); 35 | addinter( './libqpOASESinterface.so', 'qpOASESgateway', ["qpOASES", "qpOASES_init","qpOASES_initSB","qpOASES_initVM", "qpOASES_hotstart","qpOASES_hotstartSB","qpOASES_hotstartVM", "qpOASES_cleanup","qpOASES_cleanupSB","qpOASES_cleanupVM"] ); 36 | 37 | 38 | 39 | // 40 | // end of file 41 | // 42 | -------------------------------------------------------------------------------- /interfaces/simulink/load_example_QProblem.m: -------------------------------------------------------------------------------- 1 | %% 2 | %% This file is part of qpOASES. 3 | %% 4 | %% qpOASES -- An Implementation of the Online Active Set Strategy. 5 | %% Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | %% Christian Kirches et al. All rights reserved. 7 | %% 8 | %% qpOASES is free software; you can redistribute it and/or 9 | %% modify it under the terms of the GNU Lesser General Public 10 | %% License as published by the Free Software Foundation; either 11 | %% version 2.1 of the License, or (at your option) any later version. 12 | %% 13 | %% qpOASES is distributed in the hope that it will be useful, 14 | %% but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | %% See the GNU Lesser General Public License for more details. 17 | %% 18 | %% You should have received a copy of the GNU Lesser General Public 19 | %% License along with qpOASES; if not, write to the Free Software 20 | %% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | %% 22 | 23 | 24 | 25 | %% 26 | %% Filename: interfaces/simulink/load_example_QProblem.m 27 | %% Author: Hans Joachim Ferreau (thanks to Aude Perrin) 28 | %% Version: 3.2 29 | %% Date: 2007-2017 30 | %% 31 | 32 | 33 | 34 | clear all; 35 | 36 | 37 | %% setup QP data 38 | simulationTime = [0;0.1]; 39 | 40 | H = [ 1.0,0.0; ... 41 | 0.0,0.5 ]; 42 | 43 | A = [ 1.0,1.0 ]; 44 | 45 | g.time = simulationTime; 46 | data1 = [ 1.5,1.0 ]; 47 | data2 = [ 1.0,1.5 ]; 48 | g.signals.values = [data1; data2]; 49 | g.signals.dimensions = numel(data1); 50 | 51 | lb.time = simulationTime; 52 | data1 = [ 0.5,-2.0 ]; 53 | data2 = [ 0.0,-1.0 ]; 54 | lb.signals.values = [data1; data2]; 55 | lb.signals.dimensions = numel(data1); 56 | 57 | ub.time = simulationTime; 58 | data1 = [ 5.0,2.0 ]; 59 | data2 = [ 5.0,-0.5 ]; 60 | ub.signals.values = [data1; data2]; 61 | ub.signals.dimensions = numel(data1); 62 | 63 | lbA.time = simulationTime; 64 | data1 = [ -1.0 ]; 65 | data2 = [ -2.0 ]; 66 | lbA.signals.values = [data1; data2]; 67 | lbA.signals.dimensions = numel(data1); 68 | 69 | ubA.time = simulationTime; 70 | data1 = [ 2.0 ]; 71 | data2 = [ 1.0 ]; 72 | ubA.signals.values = [data1; data2]; 73 | ubA.signals.dimensions = numel(data1); 74 | 75 | 76 | clear simulationTime data1 data2 77 | 78 | 79 | %% open corresponding simulink example 80 | open( 'example_QProblem.mdl' ); 81 | 82 | 83 | 84 | %% 85 | %% end of file 86 | %% 87 | -------------------------------------------------------------------------------- /interfaces/simulink/load_example_QProblemB.m: -------------------------------------------------------------------------------- 1 | %% 2 | %% This file is part of qpOASES. 3 | %% 4 | %% qpOASES -- An Implementation of the Online Active Set Strategy. 5 | %% Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | %% Christian Kirches et al. All rights reserved. 7 | %% 8 | %% qpOASES is free software; you can redistribute it and/or 9 | %% modify it under the terms of the GNU Lesser General Public 10 | %% License as published by the Free Software Foundation; either 11 | %% version 2.1 of the License, or (at your option) any later version. 12 | %% 13 | %% qpOASES is distributed in the hope that it will be useful, 14 | %% but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | %% See the GNU Lesser General Public License for more details. 17 | %% 18 | %% You should have received a copy of the GNU Lesser General Public 19 | %% License along with qpOASES; if not, write to the Free Software 20 | %% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | %% 22 | 23 | 24 | 25 | %% 26 | %% Filename: interfaces/simulink/load_example_QProblemB.m 27 | %% Author: Hans Joachim Ferreau (thanks to Aude Perrin) 28 | %% Version: 3.2 29 | %% Date: 2007-2017 30 | %% 31 | 32 | 33 | 34 | clear all; 35 | 36 | 37 | %% setup QP data 38 | simulationTime = [0;0.1]; 39 | 40 | H = [ 1.0,0.0; ... 41 | 0.0,0.5 ]; 42 | 43 | g.time = simulationTime; 44 | data1 = [ 1.5,1.0 ]; 45 | data2 = [ 1.0,1.5 ]; 46 | g.signals.values = [data1; data2]; 47 | g.signals.dimensions = numel(data1); 48 | 49 | lb.time = simulationTime; 50 | data1 = [ 0.5,-2.0 ]; 51 | data2 = [ 0.0,-1.0 ]; 52 | lb.signals.values = [data1; data2]; 53 | lb.signals.dimensions = numel(data1); 54 | 55 | ub.time = simulationTime; 56 | data1 = [ 5.0,2.0 ]; 57 | data2 = [ 5.0,-0.5 ]; 58 | ub.signals.values = [data1; data2]; 59 | ub.signals.dimensions = numel(data1); 60 | 61 | 62 | clear simulationTime data1 data2 63 | 64 | 65 | %% open corresponding simulink example 66 | open( 'example_QProblemB.mdl' ); 67 | 68 | 69 | 70 | %% 71 | %% end of file 72 | %% 73 | -------------------------------------------------------------------------------- /interfaces/simulink/load_example_SQProblem.m: -------------------------------------------------------------------------------- 1 | %% 2 | %% This file is part of qpOASES. 3 | %% 4 | %% qpOASES -- An Implementation of the Online Active Set Strategy. 5 | %% Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | %% Christian Kirches et al. All rights reserved. 7 | %% 8 | %% qpOASES is free software; you can redistribute it and/or 9 | %% modify it under the terms of the GNU Lesser General Public 10 | %% License as published by the Free Software Foundation; either 11 | %% version 2.1 of the License, or (at your option) any later version. 12 | %% 13 | %% qpOASES is distributed in the hope that it will be useful, 14 | %% but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | %% See the GNU Lesser General Public License for more details. 17 | %% 18 | %% You should have received a copy of the GNU Lesser General Public 19 | %% License along with qpOASES; if not, write to the Free Software 20 | %% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | %% 22 | 23 | 24 | 25 | %% 26 | %% Filename: interfaces/simulink/load_example_SQProblem.m 27 | %% Author: Hans Joachim Ferreau (thanks to Aude Perrin) 28 | %% Version: 3.2 29 | %% Date: 2007-2017 30 | %% 31 | 32 | 33 | 34 | clear all; 35 | 36 | 37 | %% setup QP data 38 | simulationTime = [0;0.1]; 39 | 40 | H.time = simulationTime; 41 | data1 = [ 1.0,0.0; ... 42 | 0.0,0.5 ]; 43 | data2 = [ 1.0,0.5; ... 44 | 0.5,0.5 ]; 45 | H.signals.values = [ data1(:)'; data2(:)' ]; 46 | H.signals.dimensions = numel(data1); 47 | 48 | g.time = simulationTime; 49 | data1 = [ 1.5,1.0 ]; 50 | data2 = [ 1.0,1.5 ]; 51 | g.signals.values = [data1; data2]; 52 | g.signals.dimensions = numel(data1); 53 | 54 | A.time = simulationTime; 55 | data1 = [ 1.0,1.0 ]; 56 | data2 = [ 1.0,5.0 ]; 57 | A.signals.values = [ data1(:)'; data2(:)' ]; 58 | A.signals.dimensions = numel(data1); 59 | 60 | lb.time = simulationTime; 61 | data1 = [ 0.5,-2.0 ]; 62 | data2 = [ 0.0,-1.0 ]; 63 | lb.signals.values = [data1; data2]; 64 | lb.signals.dimensions = numel(data1); 65 | 66 | ub.time = simulationTime; 67 | data1 = [ 5.0,2.0 ]; 68 | data2 = [ 5.0,-0.5 ]; 69 | ub.signals.values = [data1; data2]; 70 | ub.signals.dimensions = numel(data1); 71 | 72 | lbA.time = simulationTime; 73 | data1 = [ -1.0 ]; 74 | data2 = [ -2.0 ]; 75 | lbA.signals.values = [data1; data2]; 76 | lbA.signals.dimensions = numel(data1); 77 | 78 | ubA.time = simulationTime; 79 | data1 = [ 2.0 ]; 80 | data2 = [ 1.0 ]; 81 | ubA.signals.values = [data1; data2]; 82 | ubA.signals.dimensions = numel(data1); 83 | 84 | 85 | clear simulationTime data1 data2 86 | 87 | 88 | %% open corresponding simulink example 89 | open( 'example_SQProblem.mdl' ); 90 | 91 | 92 | 93 | %% 94 | %% end of file 95 | %% 96 | -------------------------------------------------------------------------------- /interfaces/simulink/qpOASES_simulink_utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file interfaces/simulink/qpOASES_simulink_utils.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Collects utility functions for Interface to Simulink(R) that 32 | * enables to call qpOASES as a C S function. 33 | * 34 | */ 35 | 36 | #ifndef __SINGLE_OBJECT__ 37 | #include 38 | #endif 39 | 40 | 41 | USING_NAMESPACE_QPOASES 42 | 43 | 44 | /* 45 | * i s N a N 46 | */ 47 | BooleanType isNaN( real_t val ) 48 | { 49 | if ( (( val <= 0.0 ) || ( val >= 0.0 )) == 0 ) 50 | return BT_TRUE; 51 | else 52 | return BT_FALSE; 53 | } 54 | 55 | 56 | /* 57 | * r e m o v e N a N s 58 | */ 59 | returnValue removeNaNs( real_t* const data, unsigned int dim ) 60 | { 61 | unsigned int i; 62 | 63 | if ( data == 0 ) 64 | return RET_INVALID_ARGUMENTS; 65 | 66 | for ( i=0; i INFTY ) 90 | data[i] = INFTY; 91 | } 92 | 93 | return SUCCESSFUL_RETURN; 94 | } 95 | 96 | 97 | 98 | /* 99 | * c o n v e r t F o r t r a n T o C 100 | */ 101 | returnValue convertFortranToC( const real_t* const M_for, int nV, int nC, real_t* const M ) 102 | { 103 | int i,j; 104 | 105 | if ( ( M_for == 0 ) || ( M == 0 ) ) 106 | return RET_INVALID_ARGUMENTS; 107 | 108 | if ( ( nV < 0 ) || ( nC < 0 ) ) 109 | return RET_INVALID_ARGUMENTS; 110 | 111 | for ( i=0; i. 9 | 10 | 11 | 12 | @PACKAGE_INIT@ 13 | 14 | set(qpOASES_VERSION @PACKAGE_VERSION@) 15 | 16 | 17 | set_and_check(qpOASES_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") 18 | 19 | 20 | set(qpOASES_INCLUDE_DIR "${qpOASES_INCLUDE_DIR}" CACHE STRING "Include path for qpOASES and its dependencies") 21 | set_and_check(qpOASES_LIBRARY_DIR @PACKAGE_LIB_INSTALL_DIR@) 22 | set(qpOASES_LIBRARY_DIR "${qpOASES_LIBRARY_DIR}" CACHE STRING "Library path for qpOASES and its dependencies") 23 | 24 | find_library(qpOASES_LIBRARY NAMES qpOASES 25 | PATHS ${qpOASES_LIBRARY_DIR} NO_DEFAULT_PATH) 26 | 27 | 28 | include(FindPackageHandleStandardArgs) 29 | find_package_handle_standard_args(qpOASES DEFAULT_MSG qpOASES_INCLUDE_DIR qpOASES_LIBRARY_DIR qpOASES_LIBRARY qpOASES_VERSION) -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: src/Makefile 27 | ## Author: Hans Joachim Ferreau, Andreas Potschka, Christian Kirches 28 | ## Version: 3.2 29 | ## Date: 2007-2017 30 | ## 31 | 32 | include ../make.mk 33 | 34 | ## 35 | ## flags 36 | ## 37 | 38 | IFLAGS = -I. \ 39 | -I${IDIR} 40 | 41 | QPOASES_OBJECTS = \ 42 | SQProblem.${OBJEXT} \ 43 | QProblem.${OBJEXT} \ 44 | QProblemB.${OBJEXT} \ 45 | SQProblemSchur.${OBJEXT} \ 46 | Bounds.${OBJEXT} \ 47 | Constraints.${OBJEXT} \ 48 | SubjectTo.${OBJEXT} \ 49 | Indexlist.${OBJEXT} \ 50 | Flipper.${OBJEXT} \ 51 | Utils.${OBJEXT} \ 52 | Options.${OBJEXT} \ 53 | Matrices.${OBJEXT} \ 54 | MessageHandling.${OBJEXT} \ 55 | SparseSolver.${OBJEXT} 56 | 57 | 58 | QPOASES_EXTRAS_OBJECTS = \ 59 | SolutionAnalysis.${OBJEXT} \ 60 | OQPinterface.${OBJEXT} 61 | 62 | QPOASES_DEPENDS = \ 63 | ${IDIR}/qpOASES.hpp \ 64 | ${IDIR}/qpOASES/LapackBlasReplacement.hpp \ 65 | ${IDIR}/qpOASES/SQProblem.hpp \ 66 | ${IDIR}/qpOASES/QProblem.hpp \ 67 | ${IDIR}/qpOASES/Flipper.hpp \ 68 | ${IDIR}/qpOASES/QProblemB.hpp \ 69 | ${IDIR}/qpOASES/Bounds.hpp \ 70 | ${IDIR}/qpOASES/Constraints.hpp \ 71 | ${IDIR}/qpOASES/SubjectTo.hpp \ 72 | ${IDIR}/qpOASES/Indexlist.hpp \ 73 | ${IDIR}/qpOASES/Utils.hpp \ 74 | ${IDIR}/qpOASES/Constants.hpp \ 75 | ${IDIR}/qpOASES/Types.hpp \ 76 | ${IDIR}/qpOASES/Options.hpp \ 77 | ${IDIR}/qpOASES/Matrices.hpp \ 78 | ${IDIR}/qpOASES/MessageHandling.hpp \ 79 | ${IDIR}/qpOASES/UnitTesting.hpp 80 | 81 | 82 | ## 83 | ## targets 84 | ## 85 | 86 | all: ${LINK_DEPENDS} 87 | 88 | 89 | ${BINDIR}/libqpOASES.${LIBEXT}: ${QPOASES_OBJECTS} ${QPOASES_EXTRAS_OBJECTS} 90 | @${ECHO} "Creating static lib" $@ 91 | @${AR} r $@ $^ 92 | 93 | ${BINDIR}/libqpOASES.${DLLEXT}: ${QPOASES_OBJECTS} ${QPOASES_EXTRAS_OBJECTS} 94 | @${ECHO} "Creating shared lib" $@ 95 | @${CPP} ${DEF_TARGET} ${SHARED} $^ ${LINK_LIBRARIES} 96 | 97 | clean: 98 | @${ECHO} "Cleaning up (src)" 99 | @${RM} -f *.${OBJEXT} *.${LIBEXT} *.${DLLEXT} 100 | 101 | clobber: clean 102 | 103 | 104 | %.${OBJEXT}: %.cpp ${QPOASES_DEPENDS} 105 | @${ECHO} "Creating" $@ 106 | @${CPP} ${DEF_TARGET} -c ${IFLAGS} ${CPPFLAGS} $< 107 | 108 | 109 | ## 110 | ## end of file 111 | ## 112 | -------------------------------------------------------------------------------- /testing/c/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of qpOASES. 3 | ## 4 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 5 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | ## Christian Kirches et al. All rights reserved. 7 | ## 8 | ## qpOASES is free software; you can redistribute it and/or 9 | ## modify it under the terms of the GNU Lesser General Public 10 | ## License as published by the Free Software Foundation; either 11 | ## version 2.1 of the License, or (at your option) any later version. 12 | ## 13 | ## qpOASES is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | ## See the GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public 19 | ## License along with qpOASES; if not, write to the Free Software 20 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | ## 22 | 23 | 24 | 25 | ## 26 | ## Filename: testing/c/Makefile 27 | ## Author: Hans Joachim Ferreau 28 | ## Version: 3.2 29 | ## Date: 2014-2017 30 | ## 31 | 32 | 33 | 34 | include ../../make.mk 35 | 36 | ## 37 | ## flags 38 | ## 39 | 40 | IFLAGS = -I. \ 41 | -I${IDIR} \ 42 | -I${TOP}/interfaces/c 43 | 44 | QPOASES_TEST_EXES = \ 45 | ${BINDIR}/test_c_example1${EXE} \ 46 | ${BINDIR}/test_c_example1a${EXE} \ 47 | ${BINDIR}/test_c_example1b${EXE} 48 | 49 | 50 | ## 51 | ## targets 52 | ## 53 | 54 | all: ${QPOASES_TEST_EXES} 55 | 56 | ${BINDIR}/%${EXE}: %.${OBJEXT} ${LINK_DEPENDS_WRAPPER} 57 | @${ECHO} "Creating" $@ 58 | @${CPP} ${DEF_TARGET} ${CPPFLAGS} $< ${QPOASES_LINK_WRAPPER} ${LINK_LIBRARIES_WRAPPER} 59 | 60 | 61 | clean: 62 | @${ECHO} "Cleaning up (testing/cpp)" 63 | @${RM} -f *.${OBJEXT} ${QPOASES_TEST_EXES} 64 | 65 | clobber: clean 66 | 67 | 68 | ${LINK_DEPENDS_WRAPPER}: 69 | @cd ../..; ${MAKE} -s c_wrapper 70 | 71 | %.${OBJEXT}: %.c 72 | @${ECHO} "Creating" $@ 73 | @${CC} ${DEF_TARGET} -c ${IFLAGS} ${CPPFLAGS} $< 74 | 75 | 76 | ## 77 | ## end of file 78 | ## 79 | -------------------------------------------------------------------------------- /testing/c/test_c_example1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/c/test_c_example1.c 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Very simple example for testing qpOASES (using QProblem class through C interface). 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | /* Setup data of first QP. */ 43 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 44 | real_t A[1*2] = { 1.0, 1.0 }; 45 | real_t g[2] = { 1.5, 1.0 }; 46 | real_t lb[2] = { 0.5, -2.0 }; 47 | real_t ub[2] = { 5.0, 2.0 }; 48 | real_t lbA[1] = { -1.0 }; 49 | real_t ubA[1] = { 2.0 }; 50 | 51 | /* Setup data of second QP. */ 52 | real_t g_new[2] = { 1.0, 1.5 }; 53 | real_t lb_new[2] = { 0.0, -1.0 }; 54 | real_t ub_new[2] = { 5.0, -0.5 }; 55 | real_t lbA_new[1] = { -2.0 }; 56 | real_t ubA_new[1] = { 1.0 }; 57 | 58 | int_t nWSR; 59 | qpOASES_Options options; 60 | 61 | real_t xOpt[2]; 62 | real_t yOpt[2+1]; 63 | real_t obj; 64 | int_t status; 65 | 66 | qpOASES_Options_init( &options,0 ); 67 | options.printLevel = PL_MEDIUM; 68 | 69 | 70 | QProblem_setup( 2,1,HST_UNKNOWN ); 71 | 72 | /* Solve first QP. */ 73 | nWSR = 10; 74 | QProblem_init( H,g,A,lb,ub,lbA,ubA, 75 | &nWSR,0,&options, 76 | xOpt,yOpt,&obj,&status 77 | ); 78 | 79 | /* Print solution of first QP. */ 80 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 81 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 82 | 83 | 84 | /* Solve second QP. */ 85 | nWSR = 10; 86 | QProblem_hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, 87 | &nWSR,0, 88 | xOpt,yOpt,&obj,&status 89 | ); 90 | 91 | /* Print solution of first QP. */ 92 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 93 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 94 | 95 | 96 | QProblem_cleanup(); 97 | 98 | return 0; 99 | } 100 | 101 | 102 | /* 103 | * end of file 104 | */ 105 | -------------------------------------------------------------------------------- /testing/c/test_c_example1a.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/c/test_c_example1a.c 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Very simple example for testing qpOASES (using SQProblem class through C interface). 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | /* Setup data of first QP. */ 43 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 44 | real_t A[1*2] = { 1.0, 1.0 }; 45 | real_t g[2] = { 1.5, 1.0 }; 46 | real_t lb[2] = { 0.5, -2.0 }; 47 | real_t ub[2] = { 5.0, 2.0 }; 48 | real_t lbA[1] = { -1.0 }; 49 | real_t ubA[1] = { 2.0 }; 50 | 51 | /* Setup data of second QP. */ 52 | real_t H_new[2*2] = { 1.0, 0.5, 0.5, 0.5 }; 53 | real_t A_new[1*2] = { 1.0, 5.0 }; 54 | real_t g_new[2] = { 1.0, 1.5 }; 55 | real_t lb_new[2] = { 0.0, -1.0 }; 56 | real_t ub_new[2] = { 5.0, -0.5 }; 57 | real_t lbA_new[1] = { -2.0 }; 58 | real_t ubA_new[1] = { 1.0 }; 59 | 60 | int_t nWSR; 61 | 62 | real_t xOpt[2]; 63 | real_t yOpt[2+1]; 64 | real_t obj; 65 | int_t status; 66 | 67 | qpOASES_Options options; 68 | qpOASES_Options_init( &options,0 ); 69 | 70 | 71 | SQProblem_setup( 2,1,HST_UNKNOWN ); 72 | 73 | /* Solve first QP. */ 74 | nWSR = 10; 75 | SQProblem_init( H,g,A,lb,ub,lbA,ubA, 76 | &nWSR,0,&options, 77 | xOpt,yOpt,&obj,&status 78 | ); 79 | 80 | /* Print solution of first QP. */ 81 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 82 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 83 | 84 | 85 | /* Solve second QP. */ 86 | nWSR = 10; 87 | SQProblem_hotstart( H_new,g_new,A_new,lb_new,ub_new,lbA_new,ubA_new, 88 | &nWSR,0, 89 | xOpt,yOpt,&obj,&status 90 | ); 91 | 92 | /* Print solution of first QP. */ 93 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 94 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2], obj ); 95 | 96 | 97 | SQProblem_cleanup(); 98 | 99 | return 0; 100 | } 101 | 102 | 103 | /* 104 | * end of file 105 | */ 106 | -------------------------------------------------------------------------------- /testing/c/test_c_example1b.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/c/test_example1b.c 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Very simple example for testing qpOASES (using QProblemB class through C interface). 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | /** Example for qpOASES main function using the QProblem class. */ 40 | int main( ) 41 | { 42 | /* Setup data of first QP. */ 43 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 44 | real_t g[2] = { 1.5, 1.0 }; 45 | real_t lb[2] = { 0.5, -2.0 }; 46 | real_t ub[2] = { 5.0, 2.0 }; 47 | 48 | /* Setup data of second QP. */ 49 | real_t g_new[2] = { 1.0, 1.5 }; 50 | real_t lb_new[2] = { 0.0, -1.0 }; 51 | real_t ub_new[2] = { 5.0, -0.5 }; 52 | 53 | int_t nWSR; 54 | qpOASES_Options options; 55 | 56 | real_t xOpt[2]; 57 | real_t yOpt[2]; 58 | real_t obj; 59 | int_t status; 60 | 61 | qpOASES_Options_init( &options,0 ); 62 | /*options.enableFlippingBounds = 0; */ 63 | options.initialStatusBounds = ST_INACTIVE; 64 | options.numRefinementSteps = 1; 65 | options.enableCholeskyRefactorisation = 1; 66 | 67 | 68 | QProblemB_setup( 2,HST_UNKNOWN ); 69 | 70 | /* Solve first QP. */ 71 | nWSR = 10; 72 | QProblemB_init( H,g,lb,ub, 73 | &nWSR,0,&options, 74 | xOpt,yOpt,&obj,&status 75 | ); 76 | 77 | /* Print solution of first QP. */ 78 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e ]; objVal = %e\n\n", 79 | xOpt[0],xOpt[1],yOpt[0],yOpt[1], obj ); 80 | 81 | 82 | /* Solve second QP. */ 83 | nWSR = 10; 84 | QProblemB_hotstart( g_new,lb_new,ub_new, 85 | &nWSR,0, 86 | xOpt,yOpt,&obj,&status 87 | ); 88 | 89 | /* Print solution of first QP. */ 90 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e ]; objVal = %e\n\n", 91 | xOpt[0],xOpt[1],yOpt[0],yOpt[1], obj ); 92 | 93 | 94 | QProblemB_cleanup(); 95 | 96 | return 0; 97 | } 98 | 99 | 100 | /* 101 | * end of file 102 | */ 103 | -------------------------------------------------------------------------------- /testing/cpp/data/fetch_cpp_data: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## 4 | ## This file is part of qpOASES. 5 | ## 6 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 7 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 8 | ## Christian Kirches et al. All rights reserved. 9 | ## 10 | ## qpOASES is free software; you can redistribute it and/or 11 | ## modify it under the terms of the GNU Lesser General Public 12 | ## License as published by the Free Software Foundation; either 13 | ## version 2.1 of the License, or (at your option) any later version. 14 | ## 15 | ## qpOASES is distributed in the hope that it will be useful, 16 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | ## See the GNU Lesser General Public License for more details. 19 | ## 20 | ## You should have received a copy of the GNU Lesser General Public 21 | ## License along with qpOASES; if not, write to the Free Software 22 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ## 24 | 25 | 26 | 27 | ## 28 | ## Filename: testing/cpp/data/fetch_cpp_data 29 | ## Author: Hans Joachim Ferreau 30 | ## Version: 3.2 31 | ## Date: 2014 32 | 33 | 34 | svn export https://projects.coin-or.org/svn/qpOASES/misc/testingdata/cpp . --force 35 | -------------------------------------------------------------------------------- /testing/cpp/test_externalChol1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_externalChol1.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2015-2017 30 | * 31 | * Very simple example for testing qpOASES using the QProblem class 32 | * and providing a pre-computed Cholesky factor of the Hessian matrix. 33 | */ 34 | 35 | 36 | 37 | #include 38 | 39 | 40 | /** Example for qpOASES main function using the QProblem class. */ 41 | int main( ) 42 | { 43 | USING_NAMESPACE_QPOASES 44 | 45 | /* Setup data of first QP. */ 46 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; 47 | real_t A[1*2] = { 1.0, 1.0 }; 48 | real_t g[2] = { 1.5, 1.0 }; 49 | real_t lb[2] = { 0.5, -2.0 }; 50 | real_t ub[2] = { 5.0, 2.0 }; 51 | real_t lbA[1] = { -1.0 }; 52 | real_t ubA[1] = { 2.0 }; 53 | 54 | /* Setup data of second QP. */ 55 | real_t g_new[2] = { 1.0, 1.5 }; 56 | real_t lb_new[2] = { 0.0, -1.0 }; 57 | real_t ub_new[2] = { 5.0, -0.5 }; 58 | real_t lbA_new[1] = { -2.0 }; 59 | real_t ubA_new[1] = { 1.0 }; 60 | 61 | real_t R[2*2] = { sqrt(1.0), 0.0, 0.0, sqrt(0.5) }; 62 | 63 | 64 | /* Setting up QProblem object. */ 65 | QProblem example( 2,1 ); 66 | 67 | Options options; 68 | example.setOptions( options ); 69 | 70 | /* Solve first QP. */ 71 | int_t nWSR = 10; 72 | example.init( H,g,A,lb,ub,lbA,ubA, nWSR,0, 0,0,0,0, R ); 73 | 74 | /* Get and print solution of first QP. */ 75 | real_t xOpt[2]; 76 | real_t yOpt[2+1]; 77 | example.getPrimalSolution( xOpt ); 78 | example.getDualSolution( yOpt ); 79 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 80 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() ); 81 | 82 | /* Solve second QP. */ 83 | nWSR = 10; 84 | example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR ); 85 | 86 | /* Get and print solution of second QP. */ 87 | example.getPrimalSolution( xOpt ); 88 | example.getDualSolution( yOpt ); 89 | printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", 90 | xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() ); 91 | 92 | example.printOptions(); 93 | /*example.printProperties();*/ 94 | 95 | return 0; 96 | } 97 | 98 | 99 | /* 100 | * end of file 101 | */ 102 | -------------------------------------------------------------------------------- /testing/cpp/test_hs268.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_hs268.cpp 27 | * \author Andreas Potschka, Christian Kirches, Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2010-2017 30 | * 31 | * Unit test running all benchmark examples stored in problems directory. 32 | */ 33 | 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | 43 | /** Run benchmark examples. */ 44 | int main( int argc, char *argv[] ) 45 | { 46 | USING_NAMESPACE_QPOASES 47 | 48 | /* 1) Define benchmark arguments. */ 49 | BooleanType isSparse = BT_FALSE; 50 | //BooleanType isSparse = BT_TRUE; 51 | Options options; 52 | options.setToDefault(); 53 | //options.setToMPC(); 54 | //options.setToReliable(); 55 | //options.printLevel = PL_LOW; 56 | //options.printLevel = PL_MEDIUM; 57 | options.printLevel = PL_TABULAR; 58 | 59 | 60 | int_t nWSR; 61 | int_t npass = 0; 62 | real_t maxCPUtime; /* seconds */ 63 | real_t maxStationarity = 0.0, maxFeasibility = 0.0, maxComplementarity = 0.0; 64 | 65 | char oqpProblem[MAX_STRING_LENGTH]; 66 | char problem[] = "HS268"; 67 | returnValue returnvalue; 68 | 69 | 70 | /* 3) Run benchmark. */ 71 | fprintf(stdFile, "%-10s ", problem); 72 | fflush(stdFile); 73 | 74 | snprintf(oqpProblem, MAX_STRING_LENGTH, "../testing/cpp/data/problems/%s/", problem); 75 | maxCPUtime = 100.0; 76 | nWSR = 100; 77 | 78 | returnvalue = runOqpBenchmark( oqpProblem, isSparse, options, 79 | nWSR, maxCPUtime, maxStationarity, maxFeasibility, maxComplementarity 80 | ); 81 | 82 | if(returnvalue == RET_UNABLE_TO_READ_BENCHMARK) 83 | return TEST_DATA_NOT_FOUND; 84 | 85 | if(returnvalue == SUCCESSFUL_RETURN) 86 | npass += 1; 87 | 88 | QPOASES_TEST_FOR_TRUE( npass >= 1 ); 89 | 90 | printf( "\n" ); 91 | printf( "stat: %e\n", maxStationarity ); 92 | printf( "feas: %e\n", maxFeasibility ); 93 | printf( "cmpl: %e\n", maxComplementarity ); 94 | 95 | QPOASES_TEST_FOR_TOL( maxStationarity, 1e-11 ); 96 | QPOASES_TEST_FOR_TOL( maxFeasibility, 1e-14 ); 97 | QPOASES_TEST_FOR_TOL( maxComplementarity, 1e-14 ); 98 | 99 | 100 | return TEST_PASSED; 101 | } 102 | 103 | 104 | /* 105 | * end of file 106 | */ 107 | -------------------------------------------------------------------------------- /testing/cpp/test_indexlist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_indexlist.cpp 27 | * \author Andreas Potschka, Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2010-2017 30 | * 31 | * Unit test for Indexlist class. 32 | */ 33 | 34 | 35 | 36 | #include 37 | #include 38 | 39 | 40 | /** Test Indexlist sorting */ 41 | int main() 42 | { 43 | USING_NAMESPACE_QPOASES 44 | 45 | Indexlist il(10); 46 | int_t i, *numbers; 47 | 48 | il.addNumber(1); 49 | il.addNumber(3); 50 | il.addNumber(5); 51 | il.addNumber(2); 52 | il.addNumber(4); 53 | il.addNumber(0); 54 | il.addNumber(7); 55 | il.addNumber(6); 56 | il.addNumber(8); 57 | il.addNumber(9); 58 | 59 | il.getNumberArray(&numbers); 60 | fprintf(stdFile, "Unsorted numbers: "); 61 | for (i = 0; i < 10; i++) 62 | fprintf(stdFile, " %2d", (int)(numbers[i]) ); 63 | fprintf(stdFile, "\n"); 64 | 65 | fprintf(stdFile, "Unsorted index of number 0: %3d\n", (int)(il.getIndex(0)) ); 66 | 67 | QPOASES_TEST_FOR_TRUE( il.getIndex(0) == 5 ) 68 | 69 | il.removeNumber(5); 70 | fprintf(stdFile, "Unsorted index of (removed) number 5: %3d\n", (int)(il.getIndex(5)) ); 71 | 72 | QPOASES_TEST_FOR_TRUE( il.getIndex(5) == -1 ) 73 | 74 | il.getNumberArray(&numbers); 75 | fprintf(stdFile, "Unsorted numbers: "); 76 | for (i = 0; i < 9; i++) 77 | fprintf(stdFile, " %2d", (int)(numbers[i]) ); 78 | fprintf(stdFile, "\n"); 79 | 80 | il.swapNumbers(2, 7); 81 | 82 | il.getNumberArray(&numbers); 83 | fprintf(stdFile, "Unsorted numbers: "); 84 | for (i = 0; i < 9; i++) 85 | fprintf(stdFile, " %2d", (int)(numbers[i]) ); 86 | fprintf(stdFile, "\n"); 87 | 88 | QPOASES_TEST_FOR_TRUE( numbers[2] == 7 ) 89 | 90 | return TEST_PASSED; 91 | } 92 | 93 | 94 | /* 95 | * end of file 96 | */ 97 | -------------------------------------------------------------------------------- /testing/cpp/test_matrices2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_matrices2.cpp 27 | * \author Hans Joachim Ferreau,Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Unit test for Matrix classes. 32 | */ 33 | 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | 41 | #include "test_qrecipe_data.hpp" 42 | 43 | 44 | /** Compare deviations when performing matrix operations. */ 45 | int main( ) 46 | { 47 | USING_NAMESPACE_QPOASES 48 | 49 | int_t i; 50 | 51 | real_t errH=0.0, errA=0.0; 52 | real_t v[180]; 53 | real_t resHs[180]; 54 | real_t resHd[180]; 55 | real_t resAs[91]; 56 | real_t resAd[91]; 57 | 58 | /* create sparse matrices */ 59 | SymSparseMat *H = new SymSparseMat(180, 180, H_ir, H_jc, H_val); 60 | SparseMatrix *A = new SparseMatrix(91, 180, A_ir, A_jc, A_val); 61 | 62 | H->createDiagInfo(); 63 | 64 | real_t* H_full = H->full(); 65 | real_t* A_full = A->full(); 66 | 67 | //print( A_full,91,180 ); 68 | 69 | 70 | SymDenseMat *Hd = new SymDenseMat(180,180,180,H_full); 71 | DenseMatrix *Ad = new DenseMatrix(91,180,180,A_full); 72 | 73 | for( i=0; i<180; ++i ) 74 | v[i] = 2.0 * ((real_t)rand()) / ((real_t)RAND_MAX) - 1.0; 75 | 76 | H ->times(1, 1.0, v, 180, 0.0, resHs, 180); 77 | Hd->times(1, 1.0, v, 180, 0.0, resHd, 180); 78 | 79 | A ->times(1, 1.0, v, 180, 0.0, resAs, 91); 80 | Ad->times(1, 1.0, v, 180, 0.0, resAd, 91); 81 | 82 | 83 | for ( i=0; i<180; ++i ) 84 | if ( getAbs(resHs[i] - resHd[i]) > errH) 85 | errH = getAbs(resHs[i] - resHd[i]); 86 | 87 | fprintf(stdFile, "maximum difference in H*v: %9.2e\n", errH); 88 | 89 | 90 | for ( i=0; i<91; ++i ) 91 | if ( getAbs(resAs[i] - resAd[i]) > errA) 92 | errA = getAbs(resAs[i] - resAd[i]); 93 | 94 | fprintf(stdFile, "maximum difference in A*v: %9.2e\n", errA); 95 | 96 | delete H; 97 | delete A; 98 | delete[] H_full; 99 | delete[] A_full; 100 | delete Hd; 101 | delete Ad; 102 | 103 | 104 | QPOASES_TEST_FOR_TOL( errH,1e-13 ) 105 | QPOASES_TEST_FOR_TOL( errA,1e-13 ) 106 | 107 | return TEST_PASSED; 108 | } 109 | 110 | 111 | /* 112 | * end of file 113 | */ 114 | -------------------------------------------------------------------------------- /testing/cpp/test_matrices3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_matrices3.cpp 27 | * \author Hans Joachim Ferreau,Andreas Potschka, Christian Kirches 28 | * \version 3.2 29 | * \date 2014-2017 30 | * 31 | * Unit test for Matrix classes. 32 | */ 33 | 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | 41 | #include "test_qrecipe_data.hpp" 42 | 43 | 44 | /** Compare deviations when performing matrix operations. */ 45 | int main( ) 46 | { 47 | USING_NAMESPACE_QPOASES 48 | 49 | int_t i; 50 | 51 | real_t errH=0.0; 52 | real_t v[180]; 53 | real_t resHn[180]; 54 | real_t resHt[180]; 55 | 56 | /* create sparse matrices */ 57 | SymSparseMat *H = new SymSparseMat(180, 180, H_ir, H_jc, H_val); 58 | 59 | H->createDiagInfo(); 60 | 61 | real_t* H_full = H->full(); 62 | 63 | SymDenseMat *Hd = new SymDenseMat(180,180,180,H_full); 64 | 65 | for( i=0; i<180; ++i ) 66 | v[i] = 2.0 * ((real_t)rand()) / ((real_t)RAND_MAX) - 1.0; 67 | 68 | Hd->times( 1, 1.0, v, 180, 0.0, resHn, 180); 69 | Hd->transTimes(1, 1.0, v, 180, 0.0, resHt, 180); 70 | 71 | for ( i=0; i<180; ++i ) 72 | if ( getAbs(resHn[i] - resHt[i]) > errH) 73 | errH = getAbs(resHn[i] - resHt[i]); 74 | 75 | fprintf(stdFile, "maximum difference in H*v vs. H'*v: %9.2e\n", errH); 76 | 77 | delete H; 78 | delete[] H_full; 79 | delete Hd; 80 | 81 | 82 | QPOASES_TEST_FOR_TOL( errH,1e-15 ) 83 | 84 | return TEST_PASSED; 85 | } 86 | 87 | 88 | /* 89 | * end of file 90 | */ 91 | -------------------------------------------------------------------------------- /testing/cpp/test_sebastien1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_sebastien1.cpp 27 | * \author Sebastien B. 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Example that caused troubles in an earlier release. 32 | */ 33 | 34 | 35 | 36 | #include 37 | #include 38 | 39 | 40 | /** qpOASES main function defining a unit test. */ 41 | int main( ) 42 | { 43 | REFER_NAMESPACE_QPOASES real_t solution[2] = {0.0f, 0.0f}; 44 | REFER_NAMESPACE_QPOASES real_t expectedFirst[2] = {0.5f, -1.5f}; 45 | 46 | REFER_NAMESPACE_QPOASES real_t H[2*2] = {1.0f, 0.0f, 0.0f, 0.5f}; 47 | REFER_NAMESPACE_QPOASES real_t g[2] = {1.5f, 1.0f}; 48 | 49 | REFER_NAMESPACE_QPOASES real_t A[1*2] = {1.0f, 1.0f}; 50 | REFER_NAMESPACE_QPOASES real_t lbA[1] = {-1.0f}; 51 | REFER_NAMESPACE_QPOASES real_t ubA[1] = {2.0f}; 52 | 53 | REFER_NAMESPACE_QPOASES real_t lb[2] = {0.5f, -2.0f}; 54 | REFER_NAMESPACE_QPOASES real_t ub[2] = {5.0f, 2.0f}; 55 | 56 | REFER_NAMESPACE_QPOASES QProblem example(2, 1); 57 | REFER_NAMESPACE_QPOASES Options options = example.getOptions(); 58 | //options.enableFarBounds = REFER_NAMESPACE_QPOASES BT_FALSE; 59 | example.setOptions(options); 60 | example.setPrintLevel(REFER_NAMESPACE_QPOASES PL_NONE); 61 | 62 | // Solve first QP. 63 | REFER_NAMESPACE_QPOASES int_t nWSR = 10; 64 | QPOASES_TEST_FOR_TRUE( example.init(H, g, A, lb, ub, lbA, ubA, nWSR, NULL) == REFER_NAMESPACE_QPOASES SUCCESSFUL_RETURN ); 65 | QPOASES_TEST_FOR_TRUE( example.isSolved() == REFER_NAMESPACE_QPOASES BT_TRUE ); 66 | example.getPrimalSolution(solution); 67 | 68 | printf( "\nxOpt = [ %e, %e ];\n\n", solution[0],solution[1] ); 69 | 70 | for( REFER_NAMESPACE_QPOASES uint_t i=0; i<2; i++ ) 71 | QPOASES_TEST_FOR_NEAR( solution[i],expectedFirst[i] ); 72 | 73 | return TEST_PASSED; 74 | } 75 | -------------------------------------------------------------------------------- /testing/cpp/test_vanBarelsUnboundedQP.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of qpOASES. 3 | * 4 | * qpOASES -- An Implementation of the Online Active Set Strategy. 5 | * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 6 | * Christian Kirches et al. All rights reserved. 7 | * 8 | * qpOASES is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * qpOASES is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * See the GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with qpOASES; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | 25 | /** 26 | * \file testing/cpp/test_vanBarelsUnboundedQP.cpp 27 | * \author Hans Joachim Ferreau 28 | * \version 3.2 29 | * \date 2007-2017 30 | * 31 | * Example that causes troubles when hotstarting. 32 | */ 33 | 34 | 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | 42 | 43 | int main( ) 44 | { 45 | USING_NAMESPACE_QPOASES 46 | 47 | real_t H[2*2] = { 1.0, 0.0, 0.0, 0.0 }; 48 | real_t g[2] = { 1.5, 1.0 }; 49 | 50 | Options options; 51 | //options.enableFarBounds = BT_FALSE; 52 | 53 | QProblemB qp(2); 54 | qp.setOptions( options ); 55 | 56 | int_t iter = 10; 57 | qp.init( H,g,0,0,iter ); 58 | 59 | real_t xOpt[2]; 60 | qp.getPrimalSolution( xOpt ); 61 | print( xOpt,2 ); 62 | 63 | return TEST_PASSED; 64 | } 65 | 66 | 67 | /* 68 | * end of file 69 | */ 70 | -------------------------------------------------------------------------------- /testing/matlab/auxFiles/generateExample.m: -------------------------------------------------------------------------------- 1 | function [ qpData ] = generateExample( nV,nC, isSparseH,isSparseA, hasLowerB,hasUpperB,hasLowerC,hasUpperC, seed, givenH,givenA ) 2 | 3 | if ( nargin < 11 ) 4 | givenA = []; 5 | if ( nargin < 10 ) 6 | givenH = []; 7 | end 8 | end 9 | 10 | qpFeatures = setupQpFeaturesStruct( ); 11 | 12 | qpFeatures.nV = nV; 13 | qpFeatures.nC = nC; 14 | 15 | qpFeatures.isSparseH = isSparseH; 16 | qpFeatures.isSparseA = isSparseA; 17 | 18 | qpFeatures.hasLowerB = hasLowerB; 19 | qpFeatures.hasUpperB = hasUpperB; 20 | qpFeatures.hasLowerC = hasLowerC; 21 | qpFeatures.hasUpperC = hasUpperC; 22 | 23 | qpData = generateRandomQp( qpFeatures,seed, givenH,givenA ); 24 | 25 | end 26 | -------------------------------------------------------------------------------- /testing/matlab/auxFiles/generateRandomQp.m: -------------------------------------------------------------------------------- 1 | function [ qpData ] = generateRandomQp( qpFeatures,randSeed, givenH,givenA ) 2 | 3 | if ( nargin < 4 ) 4 | givenA = []; 5 | if ( nargin < 3 ) 6 | givenH = []; 7 | end 8 | end 9 | 10 | if ( isoctave == 0 ) 11 | if ( nargin < 2 ) 12 | s = RandStream( 'mt19937ar', 'Seed','shuffle' ); 13 | RandStream.setGlobalStream(s); 14 | else 15 | s = RandStream( 'mt19937ar', 'Seed',randSeed ); 16 | RandStream.setGlobalStream(s); 17 | end 18 | end 19 | 20 | 21 | qpData = setupQpDataStruct( ); 22 | qpData.nV = qpFeatures.nV; 23 | qpData.nC = qpFeatures.nC; 24 | 25 | 26 | % generate random optimal primal solution 27 | xFeas = rand( qpFeatures.nV,1 ); 28 | 29 | % generate random optimal dual solution 30 | %yOpt = zeros( qpFeatures.nV+qpFeatures.nC,1 ); 31 | 32 | if ( isempty(givenH) > 0 ) 33 | 34 | switch ( qpFeatures.hessianType ) 35 | 36 | case 0 37 | qpData.H = 100 * rand( qpData.nV,qpData.nV ) - 50; 38 | qpData.H = qpData.H' * qpData.H / 2; 39 | 40 | case 1 41 | qpData.H = 100 * rand( qpData.nV,round(qpData.nV/2) ) - 50; 42 | qpData.H = qpData.H' * qpData.H / 2; 43 | 44 | case 2 45 | qpData.H = eye( qpData.nV ); 46 | 47 | case 3 48 | qpData.H = zeros( qpData.nV,qpData.nV ); 49 | 50 | end 51 | 52 | else 53 | qpData.H = givenH; 54 | end 55 | 56 | qpData.g = 1000 * rand( qpFeatures.nV,1 ) - 500; 57 | 58 | if ( isempty(givenA) > 0 ) 59 | 60 | if ( qpFeatures.nC > 0 ) 61 | qpData.Ain = 100 * rand( qpData.nC,qpData.nV ) - 50; 62 | else 63 | qpData.Ain = []; 64 | end 65 | 66 | else 67 | qpData.Ain = givenA; 68 | end 69 | 70 | if ( qpFeatures.makeInfeas > 0 ) 71 | alpha = -0.1; 72 | beta = -0.001; 73 | else 74 | alpha = 1; 75 | beta = 1; 76 | end 77 | 78 | if ( qpFeatures.hasLowerB > 0 ) 79 | qpData.lb = xFeas - 3*rand( qpData.nV,1 ); 80 | else 81 | qpData.lb = []; 82 | end 83 | 84 | if ( qpFeatures.hasUpperB > 0 ) 85 | qpData.ub = xFeas + alpha*3*rand( qpData.nV,1 ); 86 | else 87 | qpData.ub = []; 88 | end 89 | 90 | if ( ( qpFeatures.hasLowerC > 0 ) && ( qpData.nC > 0 ) ) 91 | qpData.lbA = qpData.Ain*xFeas - 100*rand( qpData.nC,1 ); 92 | else 93 | qpData.lbA = []; 94 | end 95 | 96 | if ( ( qpFeatures.hasUpperC > 0 ) && ( qpData.nC > 0 ) ) 97 | qpData.ubA = qpData.Ain*xFeas + beta*100*rand( qpData.nC,1 ); 98 | else 99 | qpData.ubA = []; 100 | end 101 | 102 | if ( qpFeatures.isSparseH > 0 ) 103 | qpData.H = sparse( qpData.H ); 104 | end 105 | 106 | if ( qpFeatures.isSparseA > 0 ) 107 | qpData.Ain = sparse( qpData.Ain ); 108 | end 109 | 110 | end 111 | -------------------------------------------------------------------------------- /testing/matlab/auxFiles/isoctave.m: -------------------------------------------------------------------------------- 1 | 2 | % ISOCTAVE True if the operating environment is octave. 3 | % Usage: t=isoctave(); 4 | % 5 | % Returns 1 if the operating environment is octave, otherwise 6 | % 0 (Matlab) 7 | % 8 | % --------------------------------------------------------------- 9 | function t=isoctave() 10 | %ISOCTAVE True if the operating environment is octave. 11 | % Usage: t=isoctave(); 12 | % 13 | % Returns 1 if the operating environment is octave, otherwise 14 | % 0 (Matlab) 15 | 16 | if exist('OCTAVE_VERSION') 17 | % Only Octave has this variable. 18 | t=1; 19 | else 20 | t=0; 21 | end; 22 | -------------------------------------------------------------------------------- /testing/matlab/auxFiles/setupQpDataStruct.m: -------------------------------------------------------------------------------- 1 | function [ qpData ] = setupQpDataStruct( ) 2 | 3 | qpData = struct( 'H', [], ... % Hessian matrix 4 | 'g', [], ... % gradient vector 5 | 'Aeq', [], ... % equality constraints matrix 6 | 'beq', [], ... % equality constraints vector 7 | 'lb', [], ... % lower bound vector 8 | 'ub', [], ... % upper bound vector 9 | 'Ain', [], ... % inequality constraints matrix 10 | 'lbA', [], ... % lower constraints vector 11 | 'ubA', [], ... % upper constraints vector 12 | 'x0', [], ... % primal initial guess 13 | 'options', [], ... % QP solver options 14 | 'nV', 0, ... % number of QP variables 15 | 'nC', 0 ... % number of constraints 16 | ); 17 | 18 | end 19 | -------------------------------------------------------------------------------- /testing/matlab/auxFiles/setupQpFeaturesStruct.m: -------------------------------------------------------------------------------- 1 | function [ qpFeatures ] = setupQpFeaturesStruct( ) 2 | 3 | qpFeatures = struct( 'nV', 0, ... 4 | 'nIB', 0, ... 5 | 'nEB', 0, ... 6 | 'nC', 0, ... 7 | 'nIC', 0, ... 8 | 'nEC', 0, ... 9 | 'nActB', 0, ... 10 | 'nActC', 0, ... 11 | 'hasLowerB', 0, ... 12 | 'hasUpperB', 0, ... 13 | 'hasLowerC', 0, ... 14 | 'hasUpperC', 0, ... 15 | 'isSparseH', 0, ... 16 | 'isSparseA', 0, ... 17 | 'makeInfeas', 0, ... 18 | 'hessianType', 0 ... % 0 = pos def; 1 = pos sem def; 2 = id; 3 = zero 19 | ); 20 | 21 | end 22 | -------------------------------------------------------------------------------- /testing/matlab/data/fetch_matlab_data: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## 4 | ## This file is part of qpOASES. 5 | ## 6 | ## qpOASES -- An Implementation of the Online Active Set Strategy. 7 | ## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, 8 | ## Christian Kirches et al. All rights reserved. 9 | ## 10 | ## qpOASES is free software; you can redistribute it and/or 11 | ## modify it under the terms of the GNU Lesser General Public 12 | ## License as published by the Free Software Foundation; either 13 | ## version 2.1 of the License, or (at your option) any later version. 14 | ## 15 | ## qpOASES is distributed in the hope that it will be useful, 16 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | ## See the GNU Lesser General Public License for more details. 19 | ## 20 | ## You should have received a copy of the GNU Lesser General Public 21 | ## License along with qpOASES; if not, write to the Free Software 22 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ## 24 | 25 | 26 | 27 | ## 28 | ## Filename: testing/matlab/data/fetch_matlab_data 29 | ## Author: Hans Joachim Ferreau 30 | ## Version: 3.2 31 | ## Date: 2014-2017 32 | 33 | 34 | svn export https://projects.coin-or.org/svn/qpOASES/misc/testingdata/matlab . --force 35 | -------------------------------------------------------------------------------- /testing/matlab/setupTestingPaths.m: -------------------------------------------------------------------------------- 1 | function [] = setupTestingPaths( ) 2 | 3 | addpath(genpath(pwd)); 4 | addpath(genpath([pwd 'auxFiles'])); 5 | addpath(genpath([pwd 'data'])); 6 | addpath(genpath([pwd 'tests'])); 7 | 8 | if isoctave 9 | addpath('../../interfaces/octave/'); 10 | else 11 | addpath('../../interfaces/matlab/'); 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /testing/matlab/tests/runAlexInfeas1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runAlexInfeas1( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | try 10 | data = load( 'alexInfeas1.mat' ); 11 | catch 12 | successFlag = -1; 13 | return; 14 | end 15 | 16 | options1 = qpOASES_options( 'default', 'printLevel',-2*doPrint ); 17 | 18 | [x1,dummy,exitflag1] = qpOASES( data.H,data.g,data.A, ... 19 | data.lb,data.ub,data.lbA,data.ubA, options1 ); %#ok<*NASGU> 20 | 21 | % should return "QP infeasible" 22 | if ( exitflag1 == -2 ) 23 | successFlag = 1; 24 | else 25 | if ( doPrint > 0 ) 26 | disp( [data.lbA data.A*x1 data.ubA] ); 27 | end 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /testing/matlab/tests/runAlexInfeas2.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runAlexInfeas2( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | try 10 | data = load( 'alexInfeas2.mat' ); 11 | catch 12 | successFlag = -1; 13 | return; 14 | end 15 | 16 | options1 = qpOASES_options( 'default', 'printLevel',-2*doPrint,... 17 | 'maxIter',7000, 'enableFlippingBounds',0,... 18 | 'terminationTolerance',1e7*eps); 19 | 20 | options2 = qpOASES_options( 'MPC', 'printLevel',-2*doPrint,... 21 | 'maxIter',3000, 'terminationTolerance',1e8*eps ); 22 | 23 | [x1,dummy,exitflag1] = qpOASES( data.H,data.g,data.A, ... 24 | data.lb,data.ub,data.lbA,data.ubA, options1 ); %#ok<*NASGU> 25 | 26 | % should return "QP infeasible" 27 | if ( exitflag1 == -2 ) 28 | successFlag = 1; 29 | else 30 | if ( doPrint > 0 ) 31 | %disp( [data.lbA data.A*x1 data.ubA] ); 32 | end 33 | end 34 | 35 | end 36 | -------------------------------------------------------------------------------- /testing/matlab/tests/runAlternativeX0Test.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runAlternativeX0Test( nV,nC, doPrint,seed ) 2 | 3 | if ( nargin < 4 ) 4 | seed = 4242; 5 | if ( nargin < 3 ) 6 | doPrint = 0; 7 | if ( nargin < 2 ) 8 | nC = 300; 9 | if ( nargin < 1 ) 10 | nV = 50; 11 | end 12 | end 13 | end 14 | end 15 | 16 | successFlag = 1; 17 | TOL = eps; 18 | 19 | qpData = generateExample( nV,nC, 0,0, 0,1,1,1, seed ); 20 | 21 | H = qpData.H; 22 | g = qpData.g; 23 | A = [qpData.Aeq;qpData.Ain]; 24 | lb = qpData.lb; 25 | ub = qpData.ub; 26 | lbA = [qpData.beq;qpData.lbA]; 27 | ubA = [qpData.beq;qpData.ubA]; 28 | 29 | x0 = nV*rand( nV,1 ); 30 | 31 | options = qpOASES_options( 'default', 'printLevel',2*doPrint ); 32 | auxInput = qpOASES_auxInput( 'x0',x0 ); 33 | 34 | [ x1,f1,e1,i1,l1 ] = qpOASES( H,g,A,lb,ub,lbA,ubA,[],x0 ); 35 | [ x2,f2,e2,i2,l2 ] = qpOASES( H,g,A,lb,ub,lbA,ubA,[],auxInput ); 36 | [ x3,f3,e3,i3,l3 ] = qpOASES( H,g,A,lb,ub,lbA,ubA,options,x0 ); 37 | [ x4,f4,e4,i4,l4 ] = qpOASES( H,g,A,lb,ub,lbA,ubA,options,auxInput ); 38 | 39 | if ( ( norm(x1-x2) > TOL ) || ... 40 | ( norm(x1-x3) > TOL ) || ... 41 | ( norm(x1-x4) > TOL ) ) 42 | if ( doPrint > 0 ) 43 | disp('diff in x') 44 | end 45 | successFlag = 0; 46 | end 47 | 48 | if ( ( norm(f1-f2) > TOL ) || ... 49 | ( norm(f1-f3) > TOL ) || ... 50 | ( norm(f1-f4) > TOL ) ) 51 | if ( doPrint > 0 ) 52 | disp('diff in fval') 53 | end 54 | successFlag = 0; 55 | end 56 | 57 | if ( ( norm(e1-e2) > TOL ) || ... 58 | ( norm(e1-e3) > TOL ) || ... 59 | ( norm(e1-e4) > TOL ) ) 60 | if ( doPrint > 0 ) 61 | disp('diff in exitflag') 62 | end 63 | successFlag = 0; 64 | end 65 | 66 | if ( ( norm(i1-i2) > TOL ) || ... 67 | ( norm(i1-i3) > TOL ) || ... 68 | ( norm(i1-i4) > TOL ) ) 69 | if ( doPrint > 0 ) 70 | disp('diff in iter') 71 | end 72 | successFlag = 0; 73 | end 74 | 75 | if ( ( norm(l1-l2) > TOL ) || ... 76 | ( norm(l1-l3) > TOL ) || ... 77 | ( norm(l1-l4) > TOL ) ) 78 | if ( doPrint > 0 ) 79 | disp('diff in lambda') 80 | end 81 | successFlag = 0; 82 | end 83 | 84 | end 85 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkCHAIN1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkCHAIN1( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkCHAIN1.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | iter = zeros(1,nP); 30 | 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | %options = qpOASES_options( 'maxIter',nWSR ); 33 | 34 | for i=1:nP 35 | %disp(i); 36 | 37 | if ( i == 1 ) 38 | [QP,x,obj,status,nWSRout,lambda,ws] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 39 | %disp(ws') 40 | else 41 | [x,obj,status,nWSRout,lambda,ws] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 42 | %disp(ws') 43 | end 44 | 45 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 46 | maxViolation = max( [maxViolation,maxViolationTMP] ); 47 | 48 | xOpt(:,i) = x; 49 | yOpt(:,i) = lambda; 50 | objOpt(:,i) = obj; 51 | iter(:,i) = nWSRout; 52 | end 53 | 54 | qpOASES_sequence( 'c',QP ); 55 | 56 | if ( ( maxViolation < 9e-13 ) && ( status == 0 ) ) 57 | successFlag = 1; 58 | end 59 | 60 | end 61 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkCHAIN1A.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkCHAIN1A( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkCHAIN1A.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 31 | %options = qpOASES_options( 'reliable', 'maxIter',500,'printLevel',1 ); 32 | % ,'enableRamping',0,'enableFlippingBounds',0,'enableFullLITests',0,'enableDriftCorrection',0 33 | 34 | 35 | for jj=1:1 36 | 37 | for i=1:nP 38 | %disp(i); 39 | if ( i == 1 ) 40 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),lb(:,i),ub(:,i),options ); 41 | else 42 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),options ); 43 | end 44 | 45 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),[],lb(:,i),ub(:,i),[],[], x,lambda ); 46 | maxViolation = max( [maxViolation,maxViolationTMP] ); 47 | 48 | xOpt(:,i) = x; 49 | yOpt(:,i) = lambda; 50 | objOpt(:,i) = obj; 51 | end 52 | 53 | qpOASES_sequence( 'c',QP ); 54 | 55 | end 56 | 57 | if ( ( maxViolation < 1e-14 ) && ( status == 0 ) ) 58 | successFlag = 1; 59 | end 60 | 61 | end 62 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkCRANE1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkCRANE1( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkCRANE1.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 31 | 32 | for i=1:nP 33 | %disp(i); 34 | 35 | if ( i == 1 ) 36 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 37 | else 38 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 39 | end 40 | 41 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 42 | maxViolation = max( [maxViolation,maxViolationTMP] ); 43 | 44 | xOpt(:,i) = x; 45 | yOpt(:,i) = lambda; 46 | objOpt(:,i) = obj; 47 | end 48 | 49 | qpOASES_sequence( 'c',QP ); 50 | 51 | if ( ( maxViolation < 3e-9 ) && ( status == 0 ) ) 52 | successFlag = 1; 53 | end 54 | 55 | end 56 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkCRANE2.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkCRANE2( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkCRANE2.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | %options = qpOASES_options( 'maxIter',nWSR ); 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | 33 | for i=1:nP 34 | %disp(i); 35 | 36 | if ( i == 1 ) 37 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 38 | else 39 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'm',QP,H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 40 | end 41 | 42 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 43 | maxViolation = max( [maxViolation,maxViolationTMP] ); 44 | 45 | xOpt(:,i) = x; 46 | yOpt(:,i) = lambda; 47 | objOpt(:,i) = obj; 48 | end 49 | 50 | qpOASES_sequence( 'c',QP ); 51 | 52 | if ( ( maxViolation < 1e-11 ) && ( status == 0 ) ) 53 | successFlag = 1; 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkCRANE3.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkCRANE3( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | try 12 | load 'benchmarkCRANE3.mat'; 13 | catch 14 | successFlag = -1; 15 | return; 16 | end 17 | 18 | if ( exist( 'A','var' ) ) 19 | [nC,nV] = size(A); 20 | else 21 | nC = 0; 22 | end 23 | [nV,nP] = size(g); 24 | 25 | xOpt = zeros(nV,nP); 26 | yOpt = zeros(nV+nC,nP); 27 | objOpt = zeros(1,nP); 28 | 29 | %options = qpOASES_options( 'maxIter',nWSR ); 30 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 31 | 32 | for i=1:nP 33 | %disp(i); 34 | 35 | if ( i == 1 ) 36 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 37 | else 38 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 39 | end 40 | 41 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 42 | maxViolation = max( [maxViolation,maxViolationTMP] ); 43 | 44 | xOpt(:,i) = x; 45 | yOpt(:,i) = lambda; 46 | objOpt(:,i) = obj; 47 | end 48 | 49 | qpOASES_sequence( 'c',QP ); 50 | 51 | if ( ( maxViolation < 5e-11 ) && ( status == 0 ) ) 52 | successFlag = 1; 53 | end 54 | 55 | end 56 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkDIESEL.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkDIESEL( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | try 12 | load 'benchmarkDIESEL.mat'; 13 | catch 14 | successFlag = -1; 15 | return; 16 | end 17 | 18 | if ( exist( 'A','var' ) ) 19 | [nC,nV] = size(A); 20 | else 21 | nC = 0; 22 | nEC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | iter = zeros(1,nP); 30 | 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | %options = qpOASES_options( 'maxIter',nWSR ); 33 | %options = qpOASES_options( 'maxIter',nWSR, 'initialStatusBounds',0 ); 34 | 35 | for i=1:nP 36 | %disp(i); 37 | 38 | if ( i == 1 ) 39 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 40 | else 41 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 42 | end 43 | 44 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 45 | maxViolation = max( [maxViolation,maxViolationTMP] ); 46 | 47 | xOpt(:,i) = x; 48 | yOpt(:,i) = lambda; 49 | objOpt(:,i) = obj; 50 | iter(:,i) = nWSRout; 51 | end 52 | 53 | qpOASES_sequence( 'c',QP ); 54 | 55 | if ( ( maxViolation < 6e-13 ) && ( status == 0 ) ) 56 | successFlag = 1; 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkEQUALITY1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkEQUALITY1( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkEQUALITY1.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | %options = qpOASES_options( 'maxIter',nWSR ); 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | 33 | for i=1:nP 34 | %disp(i); 35 | 36 | if ( i == 1 ) 37 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 38 | else 39 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 40 | end 41 | 42 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 43 | maxViolation = max( [maxViolation,maxViolationTMP] ); 44 | 45 | xOpt(:,i) = x; 46 | yOpt(:,i) = lambda; 47 | objOpt(:,i) = obj; 48 | end 49 | 50 | qpOASES_sequence( 'c',QP ); 51 | 52 | if ( ( maxViolation < 4e-15 ) && ( status == 0 ) ) 53 | successFlag = 1; 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkEQUALITY2.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkEQUALITY2( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkEQUALITY2.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | %H = H; 31 | %lbA(65:320) = lbA(65:320) - 0.000000000; 32 | %ubA(65:320) = ubA(65:320) + 0.000000000; 33 | 34 | options = qpOASES_options( 'maxIter',nWSR, 'enableEqualities',1, 'printLevel',2*doPrint ); 35 | %options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',-2 ); 36 | 37 | for i=1:nP 38 | %disp(i); 39 | 40 | if ( i == 1 ) 41 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 42 | else 43 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 44 | end 45 | 46 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 47 | maxViolation = max( [maxViolation,maxViolationTMP] ); 48 | 49 | xOpt(:,i) = x; 50 | yOpt(:,i) = lambda; 51 | objOpt(:,i) = obj; 52 | end 53 | 54 | qpOASES_sequence( 'c',QP ); 55 | 56 | if ( ( maxViolation < 3e-7 ) && ( status == 0 ) ) 57 | successFlag = 1; 58 | end 59 | 60 | end 61 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkEXAMPLE1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkEXAMPLE1( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkEXAMPLE1.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | %options = qpOASES_options( 'maxIter',nWSR ); 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | 33 | for i=1:nP 34 | %disp(i); 35 | 36 | if ( i == 1 ) 37 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 38 | else 39 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 40 | end 41 | 42 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 43 | maxViolation = max( [maxViolation,maxViolationTMP] ); 44 | 45 | xOpt(:,i) = x; 46 | yOpt(:,i) = lambda; 47 | objOpt(:,i) = obj; 48 | end 49 | 50 | qpOASES_sequence( 'c',QP ); 51 | 52 | if ( ( maxViolation < 1e-12 ) && ( status == 0 ) ) 53 | successFlag = 1; 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkEXAMPLE1A.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkEXAMPLE1A( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkEXAMPLE1A.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | %options = qpOASES_options( 'maxIter',nWSR ); 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | 33 | for i=1:2 34 | %disp(i); 35 | 36 | if ( i == 1 ) 37 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H(:,:,i),g(:,i),A(:,:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 38 | else 39 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'm',QP,H(:,:,i),g(:,i),A(:,:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 40 | end 41 | 42 | [ maxViolationTMP ] = getKktResidual( H(:,:,i),g(:,i),A(:,:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 43 | maxViolation = max( [maxViolation,maxViolationTMP] ); 44 | 45 | xOpt(:,i) = x; 46 | yOpt(:,i) = lambda; 47 | objOpt(:,i) = obj; 48 | end 49 | 50 | qpOASES_sequence( 'c',QP ); 51 | 52 | if ( ( maxViolation < 3e-13 ) && ( status == 0 ) ) 53 | successFlag = 1; 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkEXAMPLE1B.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkEXAMPLE1B( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkEXAMPLE1B.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | %options = qpOASES_options( 'maxIter',nWSR ); 31 | options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2*doPrint ); 32 | 33 | for i=1:nP 34 | %disp(i); 35 | 36 | if ( i == 1 ) 37 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),lb(:,i),ub(:,i),options ); 38 | else 39 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),options ); 40 | end 41 | 42 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),[],lb(:,i),ub(:,i),[],[], x,lambda ); 43 | maxViolation = max( [maxViolation,maxViolationTMP] ); 44 | 45 | xOpt(:,i) = x; 46 | yOpt(:,i) = lambda; 47 | objOpt(:,i) = obj; 48 | end 49 | 50 | qpOASES_sequence( 'c',QP ); 51 | 52 | if ( ( maxViolation < 3e-12 ) && ( status == 0 ) ) 53 | successFlag = 1; 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /testing/matlab/tests/runBenchmarkIDHESSIAN1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runBenchmarkIDHESSIAN1( nWSR,doPrint ) 2 | 3 | if ( nargin < 2 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | maxViolation = 0; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkIDHESSIAN1.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | if ( exist( 'A','var' ) ) 20 | [nC,nV] = size(A); 21 | else 22 | nC = 0; 23 | end 24 | [nV,nP] = size(g); 25 | 26 | xOpt = zeros(nV,nP); 27 | yOpt = zeros(nV+nC,nP); 28 | objOpt = zeros(1,nP); 29 | 30 | options = qpOASES_options( 'maxIter',nWSR, 'printLevel',-2*doPrint ); 31 | %options = qpOASES_options( 'fast','maxIter',nWSR, 'printLevel',2 ); 32 | 33 | 34 | for i=1:nP 35 | %disp(i); 36 | 37 | if ( i == 1 ) 38 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i)-1e-11,ubA(:,i)+1e-11,options ); 39 | %disp(status); 40 | else 41 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i)-1e-11,ubA(:,i)+1e-11,options ); 42 | %disp(status); 43 | end 44 | 45 | [ maxViolationTMP ] = getKktResidual( H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i), x,lambda ); 46 | maxViolation = max( [maxViolation,maxViolationTMP] ); 47 | 48 | xOpt(:,i) = x; 49 | yOpt(:,i) = lambda; 50 | objOpt(:,i) = obj; 51 | end 52 | 53 | qpOASES_sequence( 'c',QP ); 54 | 55 | if ( ( maxViolation < 8e-6 ) && ( status == 0 ) ) 56 | successFlag = 1; 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /testing/matlab/tests/runQAP8.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runQAP8( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | try 10 | load 'QAP8.mat'; 11 | catch 12 | successFlag = -1; 13 | return; 14 | end 15 | 16 | options = qpOASES_options('default', 'maxIter',30000, 'printLevel',-2*doPrint ); 17 | tic 18 | [x, fval, status, nWSRout, y] = qpOASES(sparse(QP.H), QP.f, ... 19 | sparse(QP.C), QP.lb, QP.ub, QP.cl, QP.cu, options); 20 | t = toc; 21 | 22 | if ( doPrint > 0 ) 23 | disp( ['solution time: ',num2str(t),' seconds'] ); 24 | end 25 | 26 | if ( ( status == 0 ) && ( nWSRout < 23200 ) ) 27 | successFlag = 1; 28 | end 29 | 30 | % check error and print 31 | if doPrint 32 | [stat, feas, cmpl] = qpresidual(S.B, S.b1, S.C, S.cl1, S.cu1, x, -y); 33 | fprintf( '%d iters in %.3fs to tolerance %.2e\n', nWSRout, t, max([stat,feas,cmpl]) ); 34 | fprintf( 'Status: %d\n', status ); 35 | end 36 | 37 | end 38 | -------------------------------------------------------------------------------- /testing/matlab/tests/runQSHARE1B.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runQSHARE1B( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | try 10 | load 'QSHARE1B.mat'; 11 | catch 12 | successFlag = -1; 13 | return; 14 | end 15 | 16 | options = qpOASES_options('default', 'maxIter',600, 'maxCpuTime',2.0, 'printLevel',-2*doPrint ); 17 | auxInput = qpOASES_auxInput( 'hessianType',[] ); 18 | tic 19 | [xD,fvalD,exitflagD,iterD,lambdaD] = qpOASES( H,g,A,lb,ub,lbA,ubA,options,auxInput ); 20 | tD = toc; 21 | kktD = getKktResidual( H,g,A,lb,ub,lbA,ubA, xD,lambdaD ); 22 | 23 | if ( doPrint > 0 ) 24 | disp( ['dense kkt tol: ',num2str(kktD, '%.3e')] ); 25 | disp( ['dense solution time: ',num2str(tD),' seconds'] ); 26 | disp( ['dense #iterations: ',num2str(iterD),] ); 27 | end 28 | 29 | tic 30 | [xS,fvalS,exitflagS,iterS,lambdaS] = qpOASES( sparse(H),g,sparse(A),lb,ub,lbA,ubA,options ); 31 | tS = toc; 32 | kktS = getKktResidual( H,g,A,lb,ub,lbA,ubA, xS,lambdaS ); 33 | 34 | if ( doPrint > 0 ) 35 | disp( ['sparse kkt tol: ',num2str(kktS, '%.3e')] ); 36 | disp( ['sparse solution time: ',num2str(tS),' seconds'] ); 37 | disp( ['sparse #iterations: ',num2str(iterS),] ); 38 | end 39 | 40 | if ( ( exitflagD == 0 ) && ( kktD < 1e-6 ) && ( exitflagS == 0 ) && ( kktS < 1e-6 ) ) 41 | successFlag = 1; 42 | end 43 | 44 | end 45 | -------------------------------------------------------------------------------- /testing/matlab/tests/runSimpleSpringExample.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runSimpleSpringExample( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | % parameter 10 | k1 = 100; 11 | k2 = 100; 12 | 13 | m = 1; 14 | g = 9.81; 15 | 16 | % QP data 17 | H = [ k1,0; 0,k2 ]; 18 | g = [ m*g; 0 ]; 19 | 20 | lb = [ 0; 0 ]; 21 | ub = [ 1; 1 ]; 22 | 23 | A = [ 1,1 ]; 24 | lbA = 1; 25 | ubA = 1; 26 | 27 | options = qpOASES_options( 'default', 'printLevel',2*doPrint ); 28 | [x,fval,exitflag,iter] = qpOASES( H,g,A,lb,ub,lbA,ubA,options ); 29 | 30 | if ( ( exitflag == 0 ) && ( iter < 5 ) ) 31 | successFlag = 1; 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestAPrioriKnownSeq1.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestAPrioriKnownSeq1( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 1; 8 | TOL = eps; 9 | 10 | clear H g A lb ub lbA ubA; 11 | 12 | try 13 | load 'benchmarkCRANE1.mat'; 14 | catch 15 | successFlag = -1; 16 | return; 17 | end 18 | 19 | [nC,nV] = size(A); 20 | [nV,nP] = size(g); 21 | 22 | xOptSeq = zeros(nV,nP); 23 | objOptSeq = zeros(1,nP); 24 | statusSeq = zeros(1,nP); 25 | iterSeq = zeros(1,nP); 26 | yOptSeq = zeros(nV+nC,nP); 27 | 28 | options = qpOASES_options( 'fast','maxIter',100, 'printLevel',2*doPrint ); 29 | 30 | for i=1:nP 31 | %disp(i); 32 | 33 | if ( i == 1 ) 34 | [QP,x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'i',H,g(:,i),A,lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 35 | else 36 | [x,obj,status,nWSRout,lambda] = qpOASES_sequence( 'h',QP,g(:,i),lb(:,i),ub(:,i),lbA(:,i),ubA(:,i),options ); 37 | end 38 | 39 | xOptSeq(:,i) = x; 40 | objOptSeq(:,i) = obj; 41 | statusSeq(:,i) = status; 42 | iterSeq(:,i) = nWSRout; 43 | yOptSeq(:,i) = lambda; 44 | 45 | end 46 | 47 | qpOASES_sequence( 'c',QP ); 48 | 49 | 50 | [xOptAPKSeq,objOptAPKSeq,statusAPKSeq,iterAPKSeq,yOptAPKSeq] = qpOASES( H,g,A,lb,ub,lbA,ubA,options ); 51 | 52 | if ( norm( xOptSeq-xOptAPKSeq ) > TOL ) 53 | successFlag = 0; 54 | if ( doPrint > 0 ) 55 | disp( 'xOpt error' ) 56 | end 57 | end 58 | 59 | if ( norm( objOptSeq-objOptAPKSeq ) > TOL ) 60 | successFlag = 0; 61 | if ( doPrint > 0 ) 62 | disp( 'objOpt error' ) 63 | end 64 | end 65 | 66 | if ( sum( statusSeq~=statusAPKSeq ) > 0 ) 67 | successFlag = 0; 68 | if ( doPrint > 0 ) 69 | disp( 'status error' ) 70 | end 71 | end 72 | 73 | if ( sum( iterSeq~=iterAPKSeq ) > 0 ) 74 | successFlag = 0; 75 | if ( doPrint > 0 ) 76 | disp( 'iter error' ) 77 | end 78 | end 79 | 80 | if ( norm( yOptSeq-yOptAPKSeq ) > TOL ) 81 | successFlag = 0; 82 | if ( doPrint > 0 ) 83 | disp( 'yOpt error' ) 84 | end 85 | end 86 | 87 | end 88 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestSeq.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestSeq( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 1; 8 | 9 | 10 | % test case constants 11 | m = 50; 12 | n = 100; 13 | nMajSeq = 8; 14 | nMinSeq = 4; 15 | nSeq = nMajSeq * nMinSeq; 16 | p = 2; % interpolation monomial power 17 | fldim = 5; % feedback law dimension 18 | 19 | % generate start and end problem 20 | Ls = sprand(n, n, 0.03); 21 | Hs = Ls' * Ls + 1e-8 * eye(n); 22 | As = sprand(m, n, 0.05); 23 | 24 | % negative (!) definite Hessian 25 | Le = sprand(n, n, 0.03); 26 | He = -Le' * Le; 27 | Ae = sprand(m, n, 0.05); 28 | 29 | lbAs = -rand(m,1); 30 | ubAs = rand(m,1); 31 | ubs = ones(n,1); 32 | lbs = -ones(n,1); 33 | gs = 10*rand(n,1); 34 | 35 | lbAe = -rand(m,1); 36 | ubAe = rand(m,1); 37 | ube = ones(n,1); 38 | lbe = -ones(n,1); 39 | ge = 10*rand(n,1); 40 | 41 | % monomial interpolation 42 | tmaj = 1 - (1:1/(1-nMajSeq):0).^p; 43 | for i = 1:nMajSeq 44 | tau = tmaj(i); 45 | H{i} = (1-tau) * Hs + tau * He; 46 | A{i} = (1-tau) * As + tau * Ae; 47 | end 48 | t = 1 - (1:1/(1-nSeq):0).^p; 49 | for i = 1:nSeq 50 | tau = t(i); 51 | lbA{i} = (1-tau) * lbAs + tau * lbAe; 52 | ubA{i} = (1-tau) * ubAs + tau * ubAe; 53 | lb{i} = (1-tau) * lbs + tau * lbe; 54 | ub{i} = (1-tau) * ubs + tau * ube; 55 | g{i} = (1-tau) * gs + tau * ge; 56 | end 57 | 58 | x = zeros(n,1); 59 | 60 | if ~exist('cumIters', 'var') 61 | cumIters = zeros(nSeq, 1); 62 | end 63 | 64 | % solve sequence of QPs 65 | if ( doPrint > 0 ) 66 | fprintf('%3s %5s\n', 'seq', 'iters') 67 | end 68 | 69 | for i = 1:nSeq 70 | if i == 1 71 | [QP, x, fval, exitflag, iter, lambda] = qpOASES_sequence('i', ... 72 | H{i}, g{i}, A{i}, lb{i}, ub{i}, lbA{i}, ubA{i}, x); 73 | else 74 | if mod(i-1, nMinSeq) == 0 75 | j = (i-1) / nMinSeq + 1; 76 | [x, fval, exitflag, iter, lambda] = qpOASES_sequence('m', QP, ... 77 | H{j}, g{i}, A{j}, lb{i}, ub{i}, lbA{i}, ubA{i}); 78 | else 79 | [x, fval, exitflag, iter, lambda] = qpOASES_sequence('h', QP, ... 80 | g{i}, lb{i}, ub{i}, lbA{i}, ubA{i}); 81 | end 82 | end 83 | 84 | if ( doPrint > 0 ) 85 | fprintf('%3d %5d\n', i, iter) 86 | end 87 | 88 | cumIters(i) = cumIters(i) + iter; 89 | 90 | if ( exitflag ~= 0 ) 91 | successFlag = 0; 92 | end 93 | end 94 | 95 | % solve EQP 96 | V0 = zeros(n, fldim); 97 | Lambda = eye(m, fldim); 98 | [X, Y] = qpOASES_sequence('e', QP, V0, V0, V0, Lambda, Lambda); 99 | FL = X(1:fldim,:); 100 | 101 | % clear 102 | qpOASES_sequence('c', QP) 103 | 104 | end 105 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestSparse.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestSparse( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | 10 | m = 50; 11 | n = 100; 12 | 13 | L = sprand(n, n, 0.03); 14 | H = L' * L; 15 | A = sprand(m, n, 0.05); 16 | 17 | lbA = -rand(m,1); 18 | ubA = rand(m,1); 19 | ub = ones(n,1); 20 | lb = -ones(n,1); 21 | g = 10*rand(n,1); 22 | 23 | options = qpOASES_options( 'default', 'printLevel',2*doPrint ); 24 | 25 | [x1,dummy1,exitflag1,iter1] = qpOASES(full(H), g, full(A), lb, ub, lbA, ubA, options); 26 | [x2,dummy1,exitflag2,iter2] = qpOASES(H, g, A, lb, ub, lbA, ubA, options); 27 | 28 | if ( ( exitflag1 == 0 ) && ( exitflag2 == 0 ) && ( iter1 == iter2 ) ... 29 | && ( norm(x1-x2) < 1e-10 ) ) 30 | successFlag = 1; 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestSparse2.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestSparse2( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | 10 | m = 50; 11 | n = 100; 12 | 13 | L = sprand(n, n, 0.03); 14 | H = L' * L; 15 | A = sprand(m, n, 0.05); 16 | 17 | lbA = -rand(m,1); 18 | ubA = rand(m,1); 19 | ub = ones(n,1); 20 | lb = -ones(n,1); 21 | g = 10*rand(n,1); 22 | 23 | options = qpOASES_options( 'default', 'printLevel',2*doPrint ); 24 | 25 | [QP,dummy1,dummy2,exitflag1] = qpOASES_sequence( 'i', H, g, A, lb, ub, lbA, ubA, options ); 26 | [dummy1,dummy2,exitflag2] = qpOASES_sequence( 'h',QP, g*2, lb, ub, lbA, ubA ); 27 | qpOASES_sequence( 'c',QP ); 28 | 29 | if ( ( exitflag1 == 0 ) && ( exitflag2 == 0 ) ) 30 | successFlag = 1; 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestSparse3.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestSparse3( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | 10 | m = 50; 11 | n = 100; 12 | 13 | L = sprand(n, n, 0.03); 14 | H = L' * L; 15 | A = sprand(m, n, 0.05); 16 | 17 | lbA = -rand(m,1); 18 | ubA = rand(m,1); 19 | ub = ones(n,1); 20 | lb = -ones(n,1); 21 | g = 10*rand(n,1); 22 | 23 | options = qpOASES_options( 'default', 'printLevel',2*doPrint ); 24 | 25 | 26 | [QP,dummy1,dummy2,exitflag1] = qpOASES_sequence( 'i', H, g, A, lb, ub, lbA, ubA, options ); 27 | 28 | L = sprand(n, n, 0.03); 29 | H = L' * L; 30 | A = sprand(m, n, 0.05); 31 | 32 | [dummy1,dummy2,exitflag2] = qpOASES_sequence( 'm',QP, H, g*2, A, lb, ub, lbA, ubA ); 33 | qpOASES_sequence( 'c',QP ); 34 | 35 | if ( ( exitflag1 == 0 ) && ( exitflag2 == 0 ) ) 36 | successFlag = 1; 37 | end 38 | 39 | end 40 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestSparse4.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestSparse4( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | 10 | n = 100; 11 | 12 | L = sprand(n, n, 0.03); 13 | H = L' * L; 14 | 15 | ub = ones(n,1); 16 | lb = -ones(n,1); 17 | g = 10*rand(n,1); 18 | 19 | options = qpOASES_options( 'default', 'printLevel',2*doPrint ); 20 | 21 | [QP,dummy1,dummy2,exitflag1] = qpOASES_sequence( 'i', H, g, lb, ub, options ); 22 | [dummy1,dummy2,exitflag2] = qpOASES_sequence( 'h',QP, g*2, lb, ub ); 23 | qpOASES_sequence( 'c',QP ); 24 | 25 | if ( ( exitflag1 == 0 ) && ( exitflag2 == 0 ) ) 26 | successFlag = 1; 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /testing/matlab/tests/runTestWorkingSetLI.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runTestWorkingSetLI( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 1; 8 | 9 | qpFeatures = setupQpFeaturesStruct( ); 10 | 11 | qpFeatures.nV = 20; 12 | qpFeatures.nC = 100; 13 | 14 | qpFeatures.isSparseH = 0; 15 | qpFeatures.isSparseA = 0; 16 | 17 | qpFeatures.hasLowerB = 1; 18 | qpFeatures.hasUpperB = 1; 19 | qpFeatures.hasLowerC = 1; 20 | qpFeatures.hasUpperC = 1; 21 | 22 | qpFeatures.makeInfeas = 1; 23 | 24 | options = qpOASES_options( 'default', 'printLevel',2*doPrint, 'initialStatusBounds',0 ); 25 | 26 | exitflag = 0; 27 | counter = 0; 28 | 29 | while ( ( exitflag ~= -42 ) && ( counter < 100 ) ) 30 | 31 | counter = counter+1; 32 | 33 | qpData = generateRandomQp( qpFeatures ); 34 | B = [ eye( qpFeatures.nV ); qpData.Ain ]; 35 | 36 | [x,dummy1,exitflag,dummy2,dummy3,auxOutput] = qpOASES( qpData.H,qpData.g,qpData.Ain, ... 37 | qpData.lb,qpData.ub,qpData.lbA,qpData.ubA, options ); %#ok<*NASGU> 38 | 39 | WS = [auxOutput.workingSetB; auxOutput.workingSetC]; 40 | nAct = sum( WS~=0 ); 41 | Bact = B( WS~=0,: ); 42 | 43 | if ( nAct ~= rank(Bact) ) 44 | successFlag = 0; 45 | return; 46 | end 47 | 48 | end 49 | 50 | end 51 | -------------------------------------------------------------------------------- /testing/matlab/tests/runVanBarelsUnboundedQP.m: -------------------------------------------------------------------------------- 1 | function [ successFlag ] = runVanBarelsUnboundedQP( doPrint ) 2 | 3 | if ( nargin < 1 ) 4 | doPrint = 0; 5 | end 6 | 7 | successFlag = 0; 8 | 9 | try 10 | data = load( 'vanBarelsUnboundedQP.mat' ); 11 | catch 12 | successFlag = -1; 13 | return; 14 | end 15 | 16 | options1 = qpOASES_options( 'default', 'printLevel',-1*doPrint ); 17 | 18 | [dummy1,dummy2,exitflag1,iter1] = qpOASES( data.H,data.g,data.lb,data.ub,options1 ); %#ok<*NASGU> 19 | 20 | % should return "QP unbounded" 21 | if ( exitflag1 == -3 ) 22 | successFlag = 1; 23 | end 24 | 25 | end 26 | --------------------------------------------------------------------------------