examples/ocp/getting_started.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
27 
35 #include <acado_gnuplot.hpp>
36 
37 
38 int main( ){
39 
41 
42 
43  // INTRODUCE THE VARIABLES:
44  // -------------------------
45 
47  Control u;
48  Disturbance w;
49  Parameter p,q;
51 
52  const double t_start = 0.0;
53  const double t_end = 1.0;
54 
55 
56  // DEFINE A DIFFERENTIAL EQUATION:
57  // -------------------------------
58 
59  f << -dot(x) -x*x + p + u*u + w;
60 
61 
62  // DEFINE AN OPTIMAL CONTROL PROBLEM:
63  // ----------------------------------
64  OCP ocp( t_start, t_end, 20 );
65 
66  ocp.minimizeMayerTerm( x + p*p + q*q );
67  ocp.subjectTo( f );
68  ocp.subjectTo( AT_START, x == 1.0 );
69  ocp.subjectTo( 0.1 <= u <= 2.0 );
70  ocp.subjectTo( -0.1 <= w <= 2.1 );
71 
72 
73  // DEFINE AN OPTIMIZATION ALGORITHM AND SOLVE THE OCP:
74  // ---------------------------------------------------
75  OptimizationAlgorithm algorithm(ocp);
76 
77 // algorithm.set( HESSIAN_APPROXIMATION, EXACT_HESSIAN );
78  algorithm.solve();
79 
80 
81  return 0;
82 }
83 
84 
85 
User-interface to formulate and solve optimal control problems and static NLPs.
#define USING_NAMESPACE_ACADO
returnValue subjectTo(const DifferentialEquation &differentialEquation_)
Definition: ocp.cpp:153
returnValue minimizeMayerTerm(const Expression &arg)
Definition: ocp.cpp:238
Data class for defining optimal control problems.
Definition: ocp.hpp:89
Expression dot(const Expression &arg)
const double t_end
const double t_start
virtual returnValue solve()
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.


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