dae_optimization_tutorial2.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 
36 #include <acado_gnuplot.hpp>
37 
38 
39 int main( ){
40 
42 
43  DifferentialState x; // definition of a differential state
44  AlgebraicState z; // definition of an algebraic state
45  Control u; // definition of a control
46  Parameter p; // definition of a parameter
47  DifferentialEquation f; // a differential equation
48 
49 
50  f << dot(x) == -0.5*x-z+u*u; // an example for a differential-
51  f << 0 == z+exp(z)+x-1.0+u; // algebraic equation.
52 
53  OCP ocp( 0.0, 4.0 ); // define an OCP with t_0 = 0.0 and T = 4.0
54  ocp.minimizeMayerTerm( x*x + p*p ); // a Mayer term to be minimized
55 
56  ocp.subjectTo( f ); // OCP should regard the DAE
57  ocp.subjectTo( AT_START, x == 1.0 ); // an initial value constraint
58  ocp.subjectTo( AT_END , x + p == 1.0 ); // an end (or terminal) constraint
59 
60  ocp.subjectTo( -1.0 <= x*u <= 1.0 ); // a path constraint
61 
62  OptimizationAlgorithm algorithm(ocp); // define an algorithm
63  algorithm.set( KKT_TOLERANCE, 1e-5 ); // define a termination criterion
64  algorithm.solve(); // to solve the OCP.
65 
66  return 0;
67 }
68 
69 
70 
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
returnValue set(OptionsName name, int value)
Definition: options.cpp:126
Data class for defining optimal control problems.
Definition: ocp.hpp:89
Expression dot(const Expression &arg)
IntermediateState exp(const Expression &arg)
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:32