example1b.c
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 
35 #include <qpOASES_e.h>
36 
37 
39 int main( )
40 {
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  static QProblemB example;
57  static Options options;
58 
59  int nWSR = 10;
60  real_t xOpt[2];
61 
62  QProblemBCON( &example,2,HST_UNKNOWN );
63  Options_setToDefault( &options );
64  /* options.enableFlippingBounds = BT_FALSE; */
66  options.numRefinementSteps = 1;
67  /* options.enableCholeskyRefactorisation = 1; */
68  QProblemB_setOptions( &example,options );
69 
70 
71  /* Solve first QP. */
72  nWSR = 10;
73  QProblemB_init( &example,H,g,lb,ub, &nWSR,0 );
74 
75  /* Get and print solution of second QP. */
76  QProblemB_getPrimalSolution( &example,xOpt );
77  printf( "\nxOpt = [ %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],QProblemB_getObjVal(&example) );
78 
79  /* Solve second QP. */
80  nWSR = 10;
81  QProblemB_hotstart( &example,g_new,lb_new,ub_new, &nWSR,0 );
82 
83  /* Get and print solution of second QP. */
84  QProblemB_getPrimalSolution( &example,xOpt );
85  printf( "\nxOpt = [ %e, %e ]; objVal = %e\n\n", xOpt[0],xOpt[1],QProblemB_getObjVal(&example) );
86 
87  return 0;
88 }
89 
90 
91 /*
92  * end of file
93  */
void QProblemBCON(QProblemB *_THIS, int _nV, HessianType _hessianType)
Definition: QProblemB.c:45
Implements the online active set strategy for box-constrained QPs.
real_t QProblemB_getObjVal(QProblemB *_THIS)
Definition: QProblemB.c:807
#define ST_INACTIVE
int main()
Definition: example1b.c:39
int_t QProblemB_hotstart(const real_t *const g, const real_t *const lb, const real_t *const ub, int_t *const nWSR, real_t *const cputime, real_t *const x, real_t *const y, real_t *const obj, int_t *const status)
Provides a generic way to set and pass user-specified options.
Definition: options.hpp:65
static returnValue QProblemB_setOptions(QProblemB *_THIS, Options _options)
Definition: QProblemB.h:1299
returnValue QProblemB_getPrimalSolution(QProblemB *_THIS, real_t *const xOpt)
Definition: QProblemB.c:880
returnValue Options_setToDefault(Options *_THIS)
Definition: Options.c:112
int_t QProblemB_init(const real_t *const H, const real_t *const g, const real_t *const lb, const real_t *const ub, int_t *const nWSR, real_t *const cputime, const qpOASES_Options *const options, real_t *const x, real_t *const y, real_t *const obj, int_t *const status)
#define HST_UNKNOWN
double real_t
Definition: AD_test.c:10


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