getting_started.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00027 
00034 #include <acado_integrators.hpp>
00035 
00036 using namespace std;
00037 
00038 USING_NAMESPACE_ACADO
00039 
00040 /* >>> start tutorial code >>> */
00041 int main( )
00042 {
00043         // Setup an equidistant VariablesGrid with 5 grid points
00044         // and vectors of dimension 2 at each grid point and assign values
00045         double tStart =  0.0;
00046         double tEnd   =  2.0;
00047 
00048         VariablesGrid equidistantGrid(2, tStart, tEnd, 5);
00049 
00050         equidistantGrid.setZero();
00051 
00052         DVector v(2);
00053         v(0) = 1.0;
00054         v(1) = 2.0;
00055         equidistantGrid.setVector(1, v);
00056         equidistantGrid.setVector(2, v);
00057 
00058         v.setAll(5.0);
00059         equidistantGrid.setVector(3, v);
00060         equidistantGrid.setVector(4, v);
00061 
00062         cout << "The grid consists of the following grid points:\n"
00063                  << equidistantGrid
00064                  << "Its number of grid points is:  " <<  equidistantGrid.getNumPoints() << endl
00065                  << "Each vector has dimension:     " <<  equidistantGrid.getNumValues() << endl;
00066 
00067         // Construct another VariablesGrid from file
00068         VariablesGrid gridFromFile;
00069         gridFromFile.read( "./data.txt" );
00070 
00071         cout << "\nThe second grid consists of the following grid points:\n"
00072                  << gridFromFile;
00073 
00074         // Append (in time) grid points of second VariablesGrid to first one
00075         equidistantGrid.appendTimes(gridFromFile);
00076 
00077         cout << "\nNow, the grid consists of the following grid points:\n"
00078                  << equidistantGrid
00079                  << "Its number of grid points is:  " << equidistantGrid.getNumPoints() << endl
00080                  << "Each vector has dimension:     " << equidistantGrid.getNumValues() << endl;
00081 
00082         // Setup a third grid with identical grid points as modified first one,
00083         // and comprising Vectors of dimension 1...
00084         VariablesGrid thirdGrid(1, equidistantGrid);
00085 
00086         // ... and initialise these vectors
00087         for (unsigned int i = 0; i < thirdGrid.getNumPoints(); ++i)
00088                 thirdGrid(i, 0) = (double) i;
00089 
00090         cout << "\nThe third grid consists of the following grid points:\n" << thirdGrid;
00091 
00092         // Append values of all grid points of third VariablesGrid to ones of first VariablesGrid
00093         equidistantGrid.appendValues(thirdGrid);
00094 
00095         cout << "\nNow, the grid consists of the following grid points:\n";
00096         equidistantGrid.print();
00097         cout << "Its number of grid points is:  " << equidistantGrid.getNumPoints() << endl;
00098         cout << "Each vector has dimension:     " << equidistantGrid.getNumValues() << endl;
00099 
00100         return 0;
00101 }
00102 /* <<< end tutorial code <<< */
00103 
00104 


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