Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

function.h

00001 //
00002 // function.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031 
00032 #ifndef _math_optimize_function_h
00033 #define _math_optimize_function_h
00034 
00035 #include <math.h>
00036 #include <float.h>
00037 
00038 #include <util/state/state.h>
00039 #include <math/optimize/transform.h>
00040 #include <math/scmat/matrix.h>
00041 #include <math/scmat/result.h>
00042 
00043 namespace sc {
00044 
00048 class Function: virtual public SavableState, public Compute {
00049   protected:
00050     Ref<SCMatrixKit> matrixkit_;          
00051 
00052     RefSCVector x_;                     
00053     RefSCDimension dim_;                
00054     AccResultdouble value_;             
00055     AccResultRefSCVector gradient_;     
00056     AccResultRefSymmSCMatrix hessian_;  
00057 
00062     virtual void set_value(double);
00063     virtual void set_gradient(RefSCVector&);
00064     virtual void set_hessian(RefSymmSCMatrix&);
00066 
00069     virtual void set_matrixkit(const Ref<SCMatrixKit>&);
00070     virtual void set_dimension(const RefSCDimension&);
00071 
00076     virtual void set_actual_value_accuracy(double);
00077     virtual void set_actual_gradient_accuracy(double);
00078     virtual void set_actual_hessian_accuracy(double);
00080 
00082     RefSCVector& get_x_reference() { obsolete(); return x_; }
00083 
00086     void do_change_coordinates(const Ref<NonlinearTransform>&);
00087   public:
00088     Function();
00089     Function(StateIn&);
00090     Function(const Function&);
00091 
00108     Function(const Ref<KeyVal>&, double funcacc = DBL_EPSILON,
00109              double gradacc = DBL_EPSILON, double hessacc = DBL_EPSILON);
00110     virtual ~Function();
00111 
00112     Function & operator=(const Function&);
00113 
00116     Ref<SCMatrixKit> matrixkit() const;
00118     RefSCDimension dimension() const;
00119 
00120     virtual void save_data_state(StateOut&);
00121 
00123     virtual double value();
00125     int value_needed() const;
00129     int do_value(int);
00130     AccResultdouble& value_result() { return value_; }
00131 
00133     virtual void set_desired_value_accuracy(double);
00135     virtual double actual_value_accuracy() const;
00137     virtual double desired_value_accuracy() const;
00138 
00143     virtual RefSCVector gradient();
00144     int gradient_needed() const;
00145     int do_gradient(int);
00146     virtual void set_desired_gradient_accuracy(double);
00147     virtual double actual_gradient_accuracy() const;
00148     virtual double desired_gradient_accuracy() const;
00149     AccResultRefSCVector& gradient_result() { return gradient_; }
00151 
00156     virtual RefSymmSCMatrix hessian();
00157     int hessian_needed() const;
00158     int do_hessian(int);
00159     virtual void set_desired_hessian_accuracy(double);
00160     virtual double actual_hessian_accuracy() const;
00161     virtual double desired_hessian_accuracy() const;
00162     AccResultRefSymmSCMatrix& hessian_result() { return hessian_; }
00164 
00165     // hessian by gradients at finite displacements
00166     // virtual RefSCMatrix fd1_hessian();
00167 
00169     virtual void guess_hessian(RefSymmSCMatrix&);
00170     virtual RefSymmSCMatrix inverse_hessian(RefSymmSCMatrix&);
00171 
00174     virtual int value_implemented() const;
00175     virtual int gradient_implemented() const;
00176     virtual int hessian_implemented() const;
00177 
00179     virtual void set_x(const RefSCVector&);
00180     RefSCVector get_x() const { return x_.copy(); }
00181     const RefSCVector& get_x_no_copy() const { return x_; }
00182 
00189     virtual Ref<NonlinearTransform> change_coordinates();
00190 
00192     virtual void print(std::ostream& = ExEnv::out0()) const;
00193 };
00194 
00195 }
00196 
00197 #endif
00198 
00199 // Local Variables:
00200 // mode: c++
00201 // c-file-style: "CLJ"
00202 // End:

Generated at Fri Jan 10 08:14:08 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.