optimization_algorithm.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 
35 
36 
38 
39 
40 
41 //
42 // PUBLIC MEMBER FUNCTIONS:
43 //
44 
45 
47 {
48  setupOptions( );
49  setupLogging( );
50 
52 }
53 
54 
56 {
57  setupOptions( );
58  setupLogging( );
59 }
60 
61 
64 {
65 }
66 
67 
69 {
70 }
71 
72 
73 
75 {
76  if( this != &arg )
77  {
80  }
81 
82  return *this;
83 }
84 
85 
87 {
88  if ( ( getStatus( ) == BS_READY ) && ( haveOptionsChanged( ) == BT_FALSE ) )
89  return SUCCESSFUL_RETURN;
90 
91  returnValue returnvalue = OptimizationAlgorithmBase::init( this );
92 
95 
96  return returnvalue;
97 }
98 
99 
101 
102  returnValue returnvalue = SUCCESSFUL_RETURN;
103 
104  if ( ( getStatus( ) != BS_READY ) || ( haveOptionsChanged( ) == BT_TRUE ) )
105  returnvalue = init( );
106 
107  if( returnvalue != SUCCESSFUL_RETURN ) return returnvalue;
108 
109  returnvalue = nlpSolver->solve( );
110 
111  if( returnvalue != SUCCESSFUL_RETURN &&
112  returnvalue != CONVERGENCE_ACHIEVED )
113  {
114  if ( returnvalue == RET_MAX_NUMBER_OF_STEPS_EXCEEDED)
115  {
116  int PrintLevel;
117  get( PRINTLEVEL, PrintLevel );
118  if (PrintLevel != NONE)
119  {
121  }
122  }
123  else
124  {
126  }
127  }
128  return SUCCESSFUL_RETURN;
129 }
130 
131 
132 
133 
134 //
135 // PROTECTED MEMBER FUNCTIONS:
136 //
137 
139 {
140  // add NLP solver options
165 
166  // add integration options
171 
172  // add integrator options
186 
187  return SUCCESSFUL_RETURN;
188 }
189 
190 
192 {
193 // LogRecord tmp( LOG_AT_EACH_ITERATION,stdout,PS_DEFAULT,BT_FALSE );
194 //
195 // tmp.addItem( LOG_NUM_NLP_ITERATIONS );
196 //
197 // addLogRecord( tmp );
198 
199  return SUCCESSFUL_RETURN;
200 }
201 
202 
204 {
205  if( nlpSolver != 0 )
206  delete nlpSolver;
207 
208  nlpSolver = new SCPmethod( this, F,G,H, isLinearQuadratic( F,G,H ) );
209 
210  return SUCCESSFUL_RETURN;
211 }
212 
213 
215 {
216  ACADO_TRY( nlpSolver->init( _userInit.x, _userInit.xa, _userInit.p, _userInit.u, _userInit.w ) );
217  return SUCCESSFUL_RETURN;
218 }
219 
220 
222  )
223 {
224  return SUCCESSFUL_RETURN;
225 }
226 
227 
228 
229 
231 
232 
233 // end of file.
BooleanType haveOptionsChanged() const
Definition: options.cpp:251
const int defaultDiscretizationType
const int defaultPrintlevel
virtual returnValue initializeNlpSolver(const OCPiterate &_userInit)
Data class for storing generic optimization variables.
Definition: ocp_iterate.hpp:57
OptimizationAlgorithmBase & operator=(const OptimizationAlgorithmBase &arg)
const int defaultFeasibilityCheck
const double defaultKKTtoleranceSafeguard
UserInteraction & operator=(const UserInteraction &rhs)
VariablesGrid * x
const double defaultRelaxationParameter
const double defaultMaxStepsize
VariablesGrid * u
returnValue setStatus(BlockStatus _status)
User-interface to formulate and solve optimal control problems and static NLPs.
const int defaultObjectiveSensitivity
const int defaultFreezeIntegrator
Stores and evaluates the constraints of optimal control problems.
Definition: constraint.hpp:60
virtual returnValue initializeObjective(Objective *F)
Allows to pass back messages to the calling function.
virtual returnValue solve(const DVector &x0_=emptyConstVector, const DVector &p_=emptyConstVector)
Definition: nlp_solver.cpp:82
const double defaultStepsizeTuning
virtual returnValue init()
const double defaultMinStepsize
const int defaultMaxNumSteps
const int defaultDynamicSensitivity
virtual returnValue init(VariablesGrid *xd, VariablesGrid *xa, VariablesGrid *p, VariablesGrid *u, VariablesGrid *w)=0
const double defaultMinLinesearchParameter
#define CLOSE_NAMESPACE_ACADO
const int defaultHotstartQP
Base class for user-interfaces to formulate and solve optimal control problems and static NLPs...
Base class for discretizing a DifferentialEquation for use in optimal control algorithms.
const double defaultIntegratorTolerance
VariablesGrid * xa
const int defaultIntegratorPrintlevel
#define ACADO_TRY(X)
BlockStatus getStatus() const
const int defaultTerminateAtConvergence
const int defaultHessianApproximation
BooleanType isLinearQuadratic(Objective *F, DynamicDiscretization *G, Constraint *H) const
const double defaultHessianProjectionFactor
const double defaultCorrectorTolerance
virtual returnValue setupOptions()
const double defaultInfeasibleQPrelaxation
const double defaultLinesearchTolerance
Encapsulates all user interaction for setting options, logging data and plotting results.
Data class for defining optimal control problems.
Definition: ocp.hpp:89
Implements different sequential convex programming methods for solving NLPs.
Definition: scp_method.hpp:67
PrintLevel
returnValue declareOptionsUnchanged()
Definition: options.cpp:276
const double defaultInitialStepsize
const int defaultprintSCPmethodProfile
const int defaultprintIntegratorProfile
const int defaultDynamicHessianApproximation
const double defaultLevenbergMarguardt
VariablesGrid * p
#define BT_TRUE
Definition: acado_types.hpp:47
const int defaultGlobalizationStrategy
const int defaultAlgebraicRelaxation
virtual returnValue allocateNlpSolver(Objective *F, DynamicDiscretization *G, Constraint *H)
const int defaultConstraintSensitivity
VariablesGrid * w
#define BEGIN_NAMESPACE_ACADO
const int defaultSparseQPsolution
#define BT_FALSE
Definition: acado_types.hpp:49
const int defaultPlotResoltion
const int defaultLinearAlgebraSolver
const int defaultIntegratorType
const double defaultKKTtolerance
returnValue init(UserInteraction *_userIteraction)
returnValue addOption(OptionsName name, int value)
Definition: options.cpp:301
OptimizationAlgorithm & operator=(const OptimizationAlgorithm &arg)
const int defaultPrintCopyright
virtual returnValue setupLogging()
const int defaultUseRealtimeIterations
BEGIN_NAMESPACE_ACADO const int defaultMaxNumIterations
virtual returnValue solve()
const double defaultAbsoluteTolerance
const int defaultInfeasibleQPhandling
Stores and evaluates the objective function of optimal control problems.
Definition: objective.hpp:123
const int defaultMaxNumQPiterations
#define ACADOERROR(retval)


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