OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
LineSearch.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 Ferdinando Ametrano
5 Copyright (C) 2001, 2002, 2003 Nicolas Di Césaré
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file linesearch.hpp
22 \brief Line search abstract class
23*/
24
25#ifndef quantlib_optimization_line_search_h_
26#define quantlib_optimization_line_search_h_
27
30
31using namespace OpenMD;
32namespace QuantLib {
33
34 class Problem;
35 class Constraint;
36 class EndCriteria;
37
38 //! Base class for line search
39 class LineSearch {
40 public:
41 //! Default constructor
42 explicit LineSearch(RealType = 0.0) : qt_(0.0), qpt_(0.0), succeed_(true) {}
43 //! Destructor
44 virtual ~LineSearch() {}
45
46 //! return last x value
47 const DynamicVector<RealType>& lastX() { return xtd_; }
48 //! return last objective function value
49 RealType lastFunctionValue() { return qt_; }
50 //! return last gradient
51 const DynamicVector<RealType>& lastGradient() { return gradient_; }
52 //! return square norm of last gradient
53 RealType lastGradientNorm2() { return qpt_; }
54
55 bool succeed() { return succeed_; }
56
57 //! Perform line search
58 virtual RealType operator()(
59 Problem& P, // Optimization problem
60 EndCriteria::Type& ecType, const EndCriteria&,
61 const RealType t_ini) = 0; // initial value of line-search step
62 RealType update(DynamicVector<RealType>& params,
63 const DynamicVector<RealType>& direction, RealType beta,
64 const Constraint& constraint);
65
66 //! current value of the search direction
71
72 protected:
73 //! current values of the search direction
75 //! new x and its gradient
77 //! objective function value and gradient norm corresponding to xtd_
78 RealType qt_, qpt_;
79 //! flag to know if linesearch succeed
81 };
82} // namespace QuantLib
83
84#endif
Optimization criteria class.
Dynamically-sized vector class.
Base constraint class.
Criteria to end optimization process:
Base class for line search.
DynamicVector< RealType > xtd_
new x and its gradient
LineSearch(RealType=0.0)
Default constructor.
RealType lastFunctionValue()
return last objective function value
virtual RealType operator()(Problem &P, EndCriteria::Type &ecType, const EndCriteria &, const RealType t_ini)=0
Perform line search.
const DynamicVector< RealType > & searchDirection() const
current value of the search direction
DynamicVector< RealType > searchDirection_
current values of the search direction
RealType lastGradientNorm2()
return square norm of last gradient
virtual ~LineSearch()
Destructor.
const DynamicVector< RealType > & lastGradient()
return last gradient
const DynamicVector< RealType > & lastX()
return last x value
RealType qt_
objective function value and gradient norm corresponding to xtd_
bool succeed_
flag to know if linesearch succeed
Constrained optimization problem.
Definition Problem.hpp:37
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.