33 #ifndef __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__LINE_SEARCH__
34 #define __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__LINE_SEARCH__
45 #include "lib_disc/operator/non_linear_operator/newton_solver/nestedNewtonRFSwitch.h"
47 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
69 template <
typename TVector>
108 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
114 template <
typename TVector>
126 #
if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
136 #
if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
146 #
if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
155 std::stringstream ss;
202 number norm, norm_old = defect;
203 bool converged =
false;
204 std::vector<number> vRho;
212 <<
" + Iter lambda Defect Rate \n");
218 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
223 bool acceptedNewtonUpdate = m_newtonUpdater->updateSolution(u, 1.0, u, (-1)*lambda,
p);
226 if( ! acceptedNewtonUpdate )
229 UG_LOG(
"Update in Line Search did not work.\n");
230 norm = std::numeric_limits<number>::max();
263 vRho.push_back(norm/norm_old);
268 << k <<
": " << std::setw(11)
269 << std::resetiosflags( ::std::ios::scientific )<<
271 << std::scientific << norm <<
" " << vRho.back() <<
"\n");
274 if(vRho.back() <= 1 -
m_alpha * std::fabs(lambda))
294 number rho_min = vRho.front();
295 for(
size_t i = 1; i < vRho.size(); ++i)
297 if(rho_min > vRho[i])
316 best+1 <<
", Rate = "<< vRho[best] <<
".\n");
318 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
325 UG_LOG(
"Update in Line Search kmax did not work.\n");
327 norm = std::numeric_limits<number>::max();
358 UG_LOG(
"ERROR in 'StandardLineSearch::search':"
359 " maximum defect-limit is reached.\n");
367 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
370 m_newtonUpdater->resetSolution(u,
s);
387 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
388 if( ! m_newtonUpdater->tellAndFixUpdateEvents(u) )
390 UG_LOG(
"unable to fix local Newton updates" << std::endl );
399 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
403 m_newtonUpdater = nU;
440 #if ENABLE_NESTED_NEWTON_RESOLFUNC_UPDATE
Definition: smart_pointer.h:108
Definition: line_search.h:71
virtual std::string config_string() const =0
returns information about configuration parameters
virtual void set_offset(std::string offset)=0
set string to be printed before each output of line search
virtual ~ILineSearch()
virtual destructor
Definition: line_search.h:106
TVector vector_type
Definition: line_search.h:73
virtual bool search(SmartPtr< IOperator< vector_type > > spOp, vector_type &u, vector_type &p, vector_type &d, number defect)=0
describes a mapping X->Y
Definition: operator.h:86
Definition: newtonUpdaterGeneric.h:25
standard implementation of the line search based on the "sufficient descent"
Definition: line_search.h:116
void set_reduce_factor(number factor)
sets factor by which line search factor is multiplied in each step
Definition: line_search.h:169
std::string m_offset
number of spaces inserted before output
Definition: line_search.h:438
number m_lambdaStart
initial step length scaling
Definition: line_search.h:417
int m_maxSteps
maximum number of steps to be performed
Definition: line_search.h:414
void set_check_all(bool bCheckAll)
sets iff all the max_steps line search steps must be tested even if the sufficient descent is achieve...
Definition: line_search.h:178
void set_suff_descent_factor(number factor)
sets the factor controlling the sufficient descent
Definition: line_search.h:172
vector_type s
solution in line direction
Definition: line_search.h:410
number m_alpha
sufficient descent factor
Definition: line_search.h:423
virtual std::string config_string() const
returns information about configuration parameters
Definition: line_search.h:153
TVector vector_type
Definition: line_search.h:119
number m_maxDefect
maximum allowed defect
Definition: line_search.h:426
void set_maximum_defect(number maxDef)
sets maximum allowed norm of the defect (an exception is thrown if this value if exceeded)
Definition: line_search.h:181
virtual void set_offset(std::string offset)
set string to be printed before each output of line search
Definition: line_search.h:187
void set_maximum_steps(int steps)
sets maximum number of line search steps
Definition: line_search.h:163
void set_verbose(bool level)
sets if info should be printed
Definition: line_search.h:184
void set_lambda_start(number start)
sets start factor
Definition: line_search.h:166
StandardLineSearch(int maxSteps, number lambdaStart, number lambdaReduce, bool bAcceptBest)
constructor
Definition: line_search.h:133
StandardLineSearch()
default constructor (setting default values)
Definition: line_search.h:123
void set_accept_best(bool bAcceptBest)
sets iff after max_steps the best try is used
Definition: line_search.h:175
bool m_bAcceptBest
accept best
Definition: line_search.h:432
virtual bool search(SmartPtr< IOperator< vector_type > > spOp, vector_type &u, vector_type &p, vector_type &d, number defect)
Definition: line_search.h:190
bool m_bCheckAll
check all
Definition: line_search.h:435
bool m_verbose
verbosity level
Definition: line_search.h:429
StandardLineSearch(int maxSteps, number lambdaStart, number lambdaReduce, bool bAcceptBest, bool bCheckAll)
constructor
Definition: line_search.h:143
number m_lambdaReduce
reduction factor for the step length
Definition: line_search.h:420
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
if(!(yy_init))
Definition: lexer.cpp:997
#define PROFILE_BEGIN_GROUP(name, groups)
Definition: profiler.h:255
function ProblemDisc new(problemDesc, dom)