Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
Function.hpp
Go to the documentation of this file.
1 /*
2  * $Id: Function.hpp 196 2014-10-26 19:00:57Z jdl3 $
3  * Copyright (C) 2011, 2012, 2013, 2014 John D Lamb
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or (at
8  * your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef IPO_FUNCTION_HPP
21 #define IPO_FUNCTION_HPP
22 
23 #include"../ipo/detail/GSL.hpp"
25 
26 namespace ipo_function {
38  class Function : public virtual detail::FunctionBase {
39  public:
45  Function( size_t const size = 0 );
52  virtual double operator()( gsl::vector const& vector ) = 0;
59  virtual gsl::vector gradient( gsl::vector const& vector );
66  virtual gsl::matrix hessian( gsl::vector const& vector );
76  virtual std::tuple<gsl::vector,gsl::matrix> derivatives( gsl::vector const& vector );
77  protected:
82  double h = std::sqrt( std::numeric_limits<double>::epsilon() );
87  double h2 = std::sqrt( h );
88  };
89 
90 }
91 
92 #endif
virtual std::tuple< gsl::vector, gsl::matrix > derivatives(gsl::vector const &vector)
Compute or estimate derivative values.
Definition: Function.cc:109
double h
Value used for default gradient estimates.
Definition: Function.hpp:82
virtual double operator()(gsl::vector const &vector)=0
Compute a function value.
virtual gsl::vector gradient(gsl::vector const &vector)
Compute or estimate a gradient value.
Definition: Function.cc:31
double h2
Value used for default Hessian estimates.
Definition: Function.hpp:87
Namespace for functions that can be used by ipo::Objective and ipo::Constraint.
This class computes a function at a vector.
Definition: Function.hpp:38
Base class for Function and DerivativesEstimates.
Function(size_t const size=0)
Constructor.
Definition: Function.cc:28
size_t const size
Size of vector arguments to supply to subclass functions.
virtual gsl::matrix hessian(gsl::vector const &vector)
Compute or estimate a Hessian value.
Definition: Function.cc:54