Go to the documentation of this file.
46 #ifndef O2SCL_OOL_CONSTR_MMIN_H
47 #define O2SCL_OOL_CONSTR_MMIN_H
53 #include <o2scl/multi_funct.h>
54 #include <o2scl/mmin.h>
55 #include <o2scl/vector.h>
57 #ifndef DOXYGEN_NO_O2NS
63 typedef std::function<int
76 template<
class func_t,
class dfunc_t=func_t,
82 #ifndef DOXYGEN_INTERNAL
125 void shrink(
const size_t nind, gsl_vector_uint *Ind,
129 for( ii = 0; ii < nind; ii++ ) {
130 indii = gsl_vector_uint_get(Ind,ii);
139 void expand(
const size_t nind, gsl_vector_uint *Ind,
142 size_t jj, ii, indii;
145 for( jj = 0; jj < nind; jj++ ) {
147 indii = gsl_vector_uint_get( Ind, ii );
156 double calc_f(
const size_t nind, gsl_vector_uint *Ind,
157 vec_t &X, vec_t &Xc) {
159 const size_t missing=this->dim-nind;
165 for(
size_t i=nind;i<nind+missing;i++) {
185 int calc_g(
const size_t nind, gsl_vector_uint *Ind, vec_t &X,
186 vec_t &Xc, vec_t &G) {
188 const size_t missing=this->dim-nind;
193 for(
size_t i=nind;i<nind+missing;i++) {
214 int calc_Hv(
const size_t nind, gsl_vector_uint *Ind,
215 vec_t &X, vec_t &Xc, vec_t &V, vec_t &Hv) {
217 const size_t missing=this->ndim-nind;
221 for(
size_t i=nind;i<nind+missing;i++) {
231 hfunc(this->dim,X,V,Hv);
253 virtual ~mmin_constr() {
265 for(
size_t i=0;i<n;i++) {
278 for(
size_t i=0;i<
dim;i++)
dx[i]=0.0;
289 virtual int set(func_t &fn, dfunc_t &dfn, vec_t &init) {
292 for(
size_t i=0;i<
dim;i++)
dx[i]=0.0;
308 virtual int set_hess(func_t &fn, dfunc_t &dfn, hfunc_t &hfn,
312 for(
size_t i=0;i<
dim;i++)
dx[i]=0.0;
347 virtual int mmin(
size_t nvar, vec_t &xx,
double &fmin,
350 O2SCL_ERR(
"Not yet implemented mmin_constr::mmin().",
359 virtual int mmin_hess(
size_t nvar, vec_t &xx,
double &fmin,
360 func_t &ff, dfunc_t &df, hfunc_t &hf)
374 for(
size_t i=0;i<nvar;i++) xx[i]=this->x[i];
385 virtual int mmin_de(
size_t nvar, vec_t &xx,
double &fmin,
386 func_t &ff, dfunc_t &df) {
398 for(
size_t i=0;i<nvar;i++) xx[i]=this->x[i];
406 const char *
type() {
return "mmin_constr"; }
408 #ifndef DOXYGEN_INTERNAL
421 #ifndef DOXYGEN_NO_O2NS
Constrained multidimensional minimization (OOL) [abstract base].
int calc_Hv(const size_t nind, gsl_vector_uint *Ind, vec_t &X, vec_t &Xc, vec_t &V, vec_t &Hv)
Evaluate a hessian times a vector from the reduced space.
Class for automatically computing gradients [abstract base].
void shrink(const size_t nind, gsl_vector_uint *Ind, const vec_t &V)
Shrink vector V from the full to the reduced space.
size_t hcount
Number of Hessian evaluations.
virtual int is_optimal()=0
See if we're finished.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
virtual int mmin_de(size_t nvar, vec_t &xx, double &fmin, func_t &ff, dfunc_t &df)
Calculate the minimum min of func w.r.t. the array x of size nvar with gradient dfunc.
virtual int restart()
Restart the minimizer.
int ntrial
Maximum number of iterations.
int last_ntrial
The number of iterations for in the most recent minimization.
void vector_copy(const vec_t &src, vec2_t &dest)
Simple vector copy.
size_t dim
Number of parameters.
@ exc_eunimpl
requested feature not (yet) implemented
size_t nconstr
Number of constraints.
virtual int set(func_t &fn, dfunc_t &dfn, vec_t &init)
Set the function, the gradient, and the initial guess.
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.
vec_t x
The current minimum vector.
virtual int iterate()=0
Perform an iteration.
virtual int set_constraints(size_t nc, vec_t &lower, vec_t &upper)
Set the constraints.
virtual int allocate(const size_t n)
Allocate memory.
@ gsl_continue
iteration has not converged
void expand(const size_t nind, gsl_vector_uint *Ind, const vec_t &V)
Expand vector V from the reduced to the full space.
func_t * func
User-supplied function.
size_t gcount
Number of gradient evaluations.
hfunc_t * hfunc
Hessian function.
double calc_f(const size_t nind, gsl_vector_uint *Ind, vec_t &X, vec_t &Xc)
Evaluate the objective function from the reduced space.
int calc_g(const size_t nind, gsl_vector_uint *Ind, vec_t &X, vec_t &Xc, vec_t &G)
Compute gradient in the reduced space.
virtual int mmin(size_t nvar, vec_t &xx, double &fmin, func_t &ff)
Calculate the minimum min of func w.r.t. the array x of size nvar.
vec_t L
Lower bound constraints.
virtual int mmin_hess(size_t nvar, vec_t &xx, double &fmin, func_t &ff, dfunc_t &df, hfunc_t &hf)
Calculate the minimum min of ff w.r.t. the array x of size nvar with gradient df and hessian vector p...
virtual int set_hess(func_t &fn, dfunc_t &dfn, hfunc_t &hfn, vec_t &init)
Set the function, the gradient, the Hessian product, and the initial guess.
Multidimensional minimization [abstract base].
vec_t U
Upper bound constraints.
vec_t gradient
The current gradient vector.
dfunc_t * dfunc
Gradient function.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
double f
The current function value.
size_t fcount
Number of function evaluations.
bool requires_hess
If true, the algorithm requires the hessian vector product.
const char * type()
Return string denoting type ("mmin_constr")
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).