IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
core/ConjugateGradients.h
Go to the documentation of this file.
1
/**
2
* \file IMP/core/ConjugateGradients.h
3
* \brief Simple conjugate gradients optimizer.
4
*
5
* Copyright 2007-2013 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPCORE_CONJUGATE_GRADIENTS_H
10
#define IMPCORE_CONJUGATE_GRADIENTS_H
11
12
#include <IMP/core/core_config.h>
13
14
#include <
IMP/Optimizer.h
>
15
#include <
IMP/optimizer_macros.h
>
16
17
IMPCORE_BEGIN_NAMESPACE
18
19
//! Simple conjugate gradients optimizer.
20
/** Algorithm is as per Shanno and Phua, ACM Transactions On Mathematical
21
Software 6 (December 1980), 618-622
22
23
Conjugate gradients optimization is sensitive to the scales of the
24
derivatives of the various attributes being optimized. By default,
25
the scales are estimated from the range of values found for the attribute
26
upon initialization. These estimates can be viewed either by calling
27
Model::get_range(my_float_key) or by turning on TERSE logging and looking
28
at logged messages. If this estimate does not accurately reflect the
29
scale, then you can use Model::set_range to set a more accurate range
30
for the parameters.
31
*/
32
class
IMPCOREEXPORT
ConjugateGradients
:
public
Optimizer
33
{
34
public
:
35
ConjugateGradients
(
Model
*m=
nullptr
);
36
37
//! Set the threshold for the minimum gradient
38
void
set_gradient_threshold
(
Float
t){ threshold_=t;}
39
40
#ifndef IMP_DOXYGEN
41
void
set_threshold(
Float
t) {set_gradient_threshold(t);}
42
#endif
43
44
45
//! Limit how far anything can change each time step
46
void
set_max_change
(
Float
t) { max_change_ = t; }
47
48
IMP_OPTIMIZER
(
ConjugateGradients
);
49
private
:
50
51
typedef
double
NT;
52
53
// Handle optimization failing badly
54
void
failure();
55
56
NT get_score(
base::Vector<FloatIndex>
float_indices,
57
base::Vector<NT>
&x,
base::Vector<NT>
&dscore);
58
bool
line_search(
base::Vector<NT>
&x,
base::Vector<NT>
&dx,
59
NT &alpha,
const
base::Vector<FloatIndex>
&float_indices,
60
int
&ifun, NT &f, NT &dg, NT &dg1,
61
int
max_steps,
const
base::Vector<NT>
&search,
62
const
base::Vector<NT>
&estimate);
63
Float
threshold_;
64
Float
max_change_;
65
};
66
67
IMPCORE_END_NAMESPACE
68
69
#endif
/* IMPCORE_CONJUGATE_GRADIENTS_H */