example1b.cpp
Go to the documentation of this file.
00001 /*
00002  *      This file is part of qpOASES.
00003  *
00004  *      qpOASES -- An Implementation of the Online Active Set Strategy.
00005  *      Copyright (C) 2007-2011 by Hans Joachim Ferreau, Andreas Potschka,
00006  *      Christian Kirches et al. All rights reserved.
00007  *
00008  *      qpOASES is free software; you can redistribute it and/or
00009  *      modify it under the terms of the GNU Lesser General Public
00010  *      License as published by the Free Software Foundation; either
00011  *      version 2.1 of the License, or (at your option) any later version.
00012  *
00013  *      qpOASES is distributed in the hope that it will be useful,
00014  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  *      See the GNU Lesser General Public License for more details.
00017  *
00018  *      You should have received a copy of the GNU Lesser General Public
00019  *      License along with qpOASES; if not, write to the Free Software
00020  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  */
00023 
00024 
00035 #include <qpOASES.hpp>
00036 
00037 
00039 int main( )
00040 {
00041         USING_NAMESPACE_QPOASES
00042 
00043         /* Setup data of first QP. */
00044         real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 };
00045         real_t g[2] = { 1.5, 1.0 };
00046         real_t lb[2] = { 0.5, -2.0 };
00047         real_t ub[2] = { 5.0, 2.0 };
00048 
00049         /* Setup data of second QP. */
00050         real_t g_new[2] = { 1.0, 1.5 };
00051         real_t lb_new[2] = { 0.0, -1.0 };
00052         real_t ub_new[2] = { 5.0, -0.5 };
00053 
00054 
00055         /* Setting up QProblemB object. */
00056         QProblemB example( 2 );
00057 
00058         Options options;
00059         options.enableFlippingBounds = BT_FALSE;
00060         options.initialStatusBounds = ST_INACTIVE;
00061         options.numRefinementSteps = 1;
00062         example.setOptions( options );
00063 
00064         /* Solve first QP. */
00065         int nWSR = 10;
00066         example.init( H,g,lb,ub, nWSR,0 );
00067 //      printf( "\nnWSR = %d\n\n", nWSR );
00068         
00069         /* Solve second QP. */
00070         nWSR = 10;
00071         example.hotstart( g_new,lb_new,ub_new, nWSR,0 );
00072 //      printf( "\nnWSR = %d\n\n", nWSR );
00073 
00074         /* Get and print solution of second QP. */
00075         real_t xOpt[2];
00076         example.getPrimalSolution( xOpt );
00077         printf( "\nxOpt = [ %e, %e ];  objVal = %e\n\n", xOpt[0],xOpt[1],example.getObjVal() );
00078 
00079         return 0;
00080 }
00081 
00082 
00083 /*
00084  *      end of file
00085  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:09