NPL
Neurological Programs and Libraries
gradient.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2014 Micah C Chambers (micahc.vt@gmail.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * @file gradient.h Definition for the GradientOpt class which implements
17  * a gradient descent energy minimization (optimization) algorithm.
18  *
19  *****************************************************************************/
20 
21 #ifndef GRADIENT_H
22 #define GRADIENT_H
23 
24 #include <iostream>
25 #include <cmath>
26 #include <Eigen/Dense>
27 
28 #include "opt.h"
29 
30 namespace npl {
31 
36 class GradientOpt : virtual public Optimizer
37 {
38 public:
43  double opt_maxstep;
44 
50 
55  double opt_rdec_scale;
56 
57 
72  GradientOpt(size_t dim, const ValFunc& valfunc,
73  const GradFunc& gradfunc,
74  const ValGradFunc& valgradfunc,
75  const CallBackFunc& callback = noopCallback);
76 
88  GradientOpt(size_t dim, const ValFunc& valfunc,
89  const GradFunc& gradfunc,
90  const CallBackFunc& callback = noopCallback);
91 public:
93 };
94 
97 }
98 
99 #endif // GRADIENT_H
Definition: accessors.h:29
function< int(const VectorXd &x, double &v, VectorXd &g)> ValGradFunc
Value and Gradient Computation Function.
Definition: opt.h:41
int noopCallback(const VectorXd &x, double value, const VectorXd &grad, size_t iter)
Callback that does nothing.
Definition: opt.h:132
double opt_init_scale
Initial scale to use during optimization, actual scale may differ due to other options.
Definition: gradient.h:49
function< int(const VectorXd &x, VectorXd &g)> GradFunc
Gradient Only Computation Function.
Definition: opt.h:46
GradientOpt(size_t dim, const ValFunc &valfunc, const GradFunc &gradfunc, const ValGradFunc &valgradfunc, const CallBackFunc &callback=noopCallback)
Constructor for optimizer function.
function< int(const VectorXd &x, double &v)> ValFunc
Value Only Computation Function.
Definition: opt.h:51
StopReason optimize()
Perform optimization.
StopReason
Definition: opt.h:141
double opt_rdec_scale
Multiply scale by this value after each iteration ( 0 < v < 1 ). Values <= 0 will be considered unuse...
Definition: gradient.h:55
double opt_maxstep
Maximum step size, step will be rescaled to this length if it exceeds it after other scaling is compl...
Definition: gradient.h:43
function< int(const VectorXd &x, double v, const VectorXd &g, size_t iter)> CallBackFunc
Callback function.
Definition: opt.h:56