Go to the documentation of this file.
47 #ifndef O2SCL_OOL_MMIN_PGRAD_H
48 #define O2SCL_OOL_MMIN_PGRAD_H
54 #include <gsl/gsl_math.h>
56 #include <o2scl/multi_funct.h>
57 #include <o2scl/mmin_constr.h>
59 #ifndef DOXYGEN_NO_O2NS
87 public mmin_constr<func_t,dfunc_t,ool_hfunct,vec_t> {
89 #ifndef DOXYGEN_INTERNAL
101 size_t ii, n=this->
dim;
103 for(ii=0;ii<n;ii++) {
105 if (xt[ii]<this->
U[ii]) dtmp=xt[ii];
106 else dtmp=this->
U[ii];
107 if (this->
L[ii]>dtmp) xt[ii]=this->
L[ii];
117 double t, tnew, fx, fxx, dif2, gtd;
131 fxx=(*this->
func)(this->dim,
xx);
134 for(
size_t i=0;i<this->
dim;i++) this->
dx[i]-=this->
x[i];
137 for(
size_t i=0;i<this->
dim;i++) dif2+=this->
dx[i]*this->
dx[i];
140 for(
size_t i=0;i<this->
dim;i++) {
144 tnew = - t * t * gtd / (2*(fxx - this->
f - gtd));
150 if (arg1>arg2) tnew=arg1;
154 }
while(fxx > fx - (
alpha/t) * dif2 );
212 virtual int set(func_t &fn, dfunc_t &dfn, vec_t &init) {
220 this->
f=(*this->
func)(this->
dim,this->
x);
232 this->
f=(*this->
func)(this->
dim,this->
x);
246 for(
size_t i=0;i<this->
dim;i++) {
250 for(
size_t i=0;i<this->
dim;i++)
xx[i]-=this->
x[i];
252 double maxval=fabs(
xx[0]);
253 for(
size_t i=1;i<this->
dim;i++) {
254 if (fabs(
xx[i])>maxval) {
258 this->
size=fabs(maxval);
265 if (this->
size>tol && this->
f>fmin) {
272 const char *
type() {
return "mmin_constr_pgrad"; }
274 #ifndef DOXYGEN_INTERNAL
287 #ifndef DOXYGEN_NO_O2NS
const char * type()
Return string denoting type ("mmin_constr_pgrad")
ool_hfunct hfunc_t
A convenient typedef for the unused Hessian product type.
Constrained multidimensional minimization (OOL) [abstract base].
Class for automatically computing gradients [abstract base].
virtual int allocate(const size_t n)
Allocate memory.
boost::numeric::ublas::vector< double > dx
Desc.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
double tol
Tolerance on infinite norm.
int ntrial
Maximum number of iterations.
void vector_copy(const vec_t &src, vec2_t &dest)
Simple vector copy.
size_t dim
Number of parameters.
vec_t xx
Temporary vector.
double alpha
Constant for the sufficient decrease condition (default )
virtual int set(func_t &fn, dfunc_t &dfn, vec_t &init)
Set the function, the gradient, and the initial guess.
double sigma1
Lower bound to the step length reduction.
std::function< int(size_t, const boost::numeric::ublas::vector< double > &, const boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &)> ool_hfunct
Hessian product function for o2scl::mmin_constr.
std::function< double(size_t, const boost::numeric::ublas::vector< double > &)> multi_funct
Multi-dimensional function typedef in src/base/multi_funct.h.
virtual int restart()
Restart the minimizer.
boost::numeric::ublas::vector< double > x
The current minimum vector.
virtual int allocate(const size_t n)
Allocate memory.
int proj(vec_t &xt)
Project into feasible region.
@ gsl_continue
iteration has not converged
multi_funct * func
User-supplied function.
double sigma2
Upper bound to the step length reduction.
std::function< int(size_t, boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &)> grad_funct
Array of multi-dimensional functions typedef in src/min/mmin.h.
double fmin
Minimum function value (default )
boost::numeric::ublas::vector< double > L
Lower bound constraints.
boost::numeric::ublas::vector< double > U
Upper bound constraints.
grad_funct * dfunc
Gradient function.
Constrained minimization by the projected gradient method (OOL)
virtual int free()
Free previously allocated memory.
virtual int iterate()
Perform an iteration.
double f
The current function value.
virtual int set(func_t &fn, dfunc_t &dfn, vec_t &init)
Set the function, the initial guess, and the parameters.
int line_search()
Line search.
virtual int is_optimal()
See if we're finished.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).