test_infeasible1.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 {
44 
45  /* Setup data of first QP. */
46  real_t H[5*5] = { 1.224642131370767e+01, 2.908638763113702e+00, 0.0, 0.0, 0.0,
47  2.908638763113702e+00, 2.497106275003180e+00, 0.0, 0.0, 0.0,
48  0.0, 0.0, 1.0, 0.0, 0.0,
49  0.0, 0.0, 0.0, 5.158460640334052e-02, 4.723556059962540e-02,
50  0.0, 0.0, 0.0, 4.723556059962540e-02, 4.325317843302175e-02 };
51  real_t A[2*5] = { -1.404358970692652e+00, -2.556613491156063e+00, 3.202524559238066e+00, -1.0, 0.0,
52  6.587910295430314e-01, -5.349454475937998e-01, 4.391976356955536e-01, 0.0, -1.0 };
53  real_t g[5] = { 2.474135331302147e+01,
54  5.857286430296258e+00,
55  2.359382646348721e-01,
56  1.721047069188781e-01,
57  1.575947337774199e-01 };
58  real_t lb[5] = { 5.0, 5.0, 8.0, 9.0, 5.0 };
59  real_t ub[5] = { 10.0, 10.0, 10.0, 10.0, 10.0 };
60  real_t lbA[2] = { 1.643135416077167e+00, 1.056813028189597e+00 };
61  real_t ubA[2] = { 1.643135416077167e+00, 1.056813028189597e+00 };
62 
63  /* Setting up QProblem object. */
64  QProblem example( 5,2 );
65 
67  //options.enableFlippingBounds = BT_FALSE;
68  //options.enableEqualities = BT_TRUE;
69  //options.initialStatusBounds = ST_INACTIVE;
70  example.setOptions( options );
71  example.setPrintLevel( PL_NONE );
72 
73  /* Solve first QP. */
74  returnValue retVal;
75  int_t simpleStatus = -1;
76 
77  int_t nWSR = 10;
78  retVal = example.init( H,g,A,lb,ub,lbA,ubA, nWSR,0 );
79  simpleStatus = getSimpleStatus( retVal,BT_TRUE );
80 
81 
82  /* Get and print solution of second QP. */
83  real_t xOpt[5];
84  real_t yOpt[5+2];
85 
86  printf( "getPrimalSolution = %d\n", example.getPrimalSolution( xOpt ) );
87  printf( "getDualSolution = %d\n", example.getDualSolution( yOpt ) );
88  printf( "\nxOpt = [ %e, %e, %e, %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],xOpt[2],xOpt[3],xOpt[4],example.getObjVal() );
89 
90  /* Compute KKT tolerances */
91  real_t stat, feas, cmpl;
92 
93  getKktViolation( 5,2, H,g,A,lb,ub,lbA,ubA, xOpt,yOpt, stat,feas,cmpl );
94  printf( "stat = %e\nfeas = %e\ncmpl = %e\n", stat,feas,cmpl );
95 
96  QPOASES_TEST_FOR_TRUE( simpleStatus == -2 );
97 
98  return TEST_PASSED;
99 }
100 
101 
102 /*
103  * end of file
104  */
returnValue init(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
returnValue getKktViolation(int_t nV, int_t nC, const real_t *const H, const real_t *const g, const real_t *const A, const real_t *const lb, const real_t *const ub, const real_t *const lbA, const real_t *const ubA, const real_t *const x, const real_t *const y, real_t &stat, real_t &feas, real_t &cmpl, const real_t *const workingSetB=0, const real_t *const workingSetC=0, BooleanType hasIdentityHessian=BT_FALSE)
Allows to pass back messages to the calling function.
#define PL_NONE
returnValue setOptions(const Options &_options)
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
double real_t
Definition: AD_test.c:10
int_t getSimpleStatus(returnValue returnvalue, BooleanType doPrintStatus=BT_FALSE)
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