OpenMD
3.2
Molecular Dynamics in the Open
Toggle main menu visibility
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
28
#include "
math/DynamicVector.hpp
"
29
#include "
optimization/EndCriteria.hpp
"
30
31
using namespace
OpenMD
;
32
namespace
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
67
const
DynamicVector<RealType>
&
searchDirection
()
const
{
68
return
searchDirection_
;
69
}
70
DynamicVector<RealType>
&
searchDirection
() {
return
searchDirection_
; }
71
72
protected
:
73
//! current values of the search direction
74
DynamicVector<RealType>
searchDirection_
;
75
//! new x and its gradient
76
DynamicVector<RealType>
xtd_
, gradient_;
77
//! objective function value and gradient norm corresponding to xtd_
78
RealType
qt_
, qpt_;
79
//! flag to know if linesearch succeed
80
bool
succeed_
;
81
};
82
}
// namespace QuantLib
83
84
#endif
DynamicVector.hpp
EndCriteria.hpp
Optimization criteria class.
OpenMD::DynamicVector
Dynamically-sized vector class.
Definition
DynamicVector.hpp:74
QuantLib::Constraint
Base constraint class.
Definition
Constraint.hpp:35
QuantLib::EndCriteria
Criteria to end optimization process:
Definition
EndCriteria.hpp:42
QuantLib::LineSearch::xtd_
DynamicVector< RealType > xtd_
new x and its gradient
Definition
LineSearch.hpp:76
QuantLib::LineSearch::LineSearch
LineSearch(RealType=0.0)
Default constructor.
Definition
LineSearch.hpp:42
QuantLib::LineSearch::lastFunctionValue
RealType lastFunctionValue()
return last objective function value
Definition
LineSearch.hpp:49
QuantLib::LineSearch::operator()
virtual RealType operator()(Problem &P, EndCriteria::Type &ecType, const EndCriteria &, const RealType t_ini)=0
Perform line search.
QuantLib::LineSearch::searchDirection
const DynamicVector< RealType > & searchDirection() const
current value of the search direction
Definition
LineSearch.hpp:67
QuantLib::LineSearch::searchDirection_
DynamicVector< RealType > searchDirection_
current values of the search direction
Definition
LineSearch.hpp:74
QuantLib::LineSearch::lastGradientNorm2
RealType lastGradientNorm2()
return square norm of last gradient
Definition
LineSearch.hpp:53
QuantLib::LineSearch::~LineSearch
virtual ~LineSearch()
Destructor.
Definition
LineSearch.hpp:44
QuantLib::LineSearch::lastGradient
const DynamicVector< RealType > & lastGradient()
return last gradient
Definition
LineSearch.hpp:51
QuantLib::LineSearch::lastX
const DynamicVector< RealType > & lastX()
return last x value
Definition
LineSearch.hpp:47
QuantLib::LineSearch::qt_
RealType qt_
objective function value and gradient norm corresponding to xtd_
Definition
LineSearch.hpp:78
QuantLib::LineSearch::succeed_
bool succeed_
flag to know if linesearch succeed
Definition
LineSearch.hpp:80
QuantLib::Problem
Constrained optimization problem.
Definition
Problem.hpp:37
OpenMD
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Definition
ActionCorrFunc.cpp:63
optimization
LineSearch.hpp
Generated on
for OpenMD by
1.17.0