test_sebastien1.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
36 #include <qpOASES.hpp>
37 #include <qpOASES/UnitTesting.hpp>
38 
39 
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};
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 
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.
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 }
#define PL_NONE
Provides a generic way to set and pass user-specified options.
Definition: options.hpp:65
int main()
#define TEST_PASSED
Definition: UnitTesting.hpp:45
#define BT_TRUE
Definition: acado_types.hpp:47
#define QPOASES_TEST_FOR_NEAR(x, y)
Definition: UnitTesting.hpp:58
double real_t
Definition: AD_test.c:10
Implements the online active set strategy for QPs with general constraints.
#define QPOASES_TEST_FOR_TRUE(x)
Definition: UnitTesting.hpp:64


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