function.h
//
// function.h
//
// Copyright (C) 1996 Limit Point Systems, Inc.
//
// Author: Curtis Janssen <cljanss@limitpt.com>
// Maintainer: LPS
//
// This file is part of the SC Toolkit.
//
// The SC Toolkit is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// The SC Toolkit is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//
// The U.S. Government is granted a limited license as per AL 91-7.
//
#ifdef __GNUC__
#pragma interface
#endif
#ifndef _math_optimize_function_h
#define _math_optimize_function_h
#include <math.h>
#include <float.h>
#include <util/state/state.h>
#include <math/optimize/transform.h>
#include <math/scmat/matrix.h>
#include <math/scmat/result.h>
namespace sc {
class Function: virtual public SavableState, public Compute {
protected:
Ref<SCMatrixKit> matrixkit_;
RefSCVector x_;
RefSCDimension dim_;
AccResultdouble value_;
AccResultRefSCVector gradient_;
AccResultRefSymmSCMatrix hessian_;
virtual void set_value(double);
virtual void set_gradient(RefSCVector&);
virtual void set_hessian(RefSymmSCMatrix&);
virtual void set_matrixkit(const Ref<SCMatrixKit>&);
virtual void set_dimension(const RefSCDimension&);
virtual void set_actual_value_accuracy(double);
virtual void set_actual_gradient_accuracy(double);
virtual void set_actual_hessian_accuracy(double);
RefSCVector& get_x_reference() { obsolete(); return x_; }
void do_change_coordinates(const Ref<NonlinearTransform>&);
public:
Function();
Function(StateIn&);
Function(const Function&);
Function(const Ref<KeyVal>&, double funcacc = DBL_EPSILON,
double gradacc = DBL_EPSILON, double hessacc = DBL_EPSILON);
virtual ~Function();
Function & operator=(const Function&);
Ref<SCMatrixKit> matrixkit() const;
RefSCDimension dimension() const;
virtual void save_data_state(StateOut&);
virtual double value();
int value_needed() const;
int do_value(int);
AccResultdouble& value_result() { return value_; }
virtual void set_desired_value_accuracy(double);
virtual double actual_value_accuracy() const;
virtual double desired_value_accuracy() const;
virtual RefSCVector gradient();
int gradient_needed() const;
int do_gradient(int);
virtual void set_desired_gradient_accuracy(double);
virtual double actual_gradient_accuracy() const;
virtual double desired_gradient_accuracy() const;
AccResultRefSCVector& gradient_result() { return gradient_; }
virtual RefSymmSCMatrix hessian();
int hessian_needed() const;
int do_hessian(int);
virtual void set_desired_hessian_accuracy(double);
virtual double actual_hessian_accuracy() const;
virtual double desired_hessian_accuracy() const;
AccResultRefSymmSCMatrix& hessian_result() { return hessian_; }
// hessian by gradients at finite displacements
// virtual RefSCMatrix fd1_hessian();
virtual void guess_hessian(RefSymmSCMatrix&);
virtual RefSymmSCMatrix inverse_hessian(RefSymmSCMatrix&);
virtual int value_implemented() const;
virtual int gradient_implemented() const;
virtual int hessian_implemented() const;
virtual void set_x(const RefSCVector&);
RefSCVector get_x() const { return x_.copy(); }
const RefSCVector& get_x_no_copy() const { return x_; }
virtual Ref<NonlinearTransform> change_coordinates();
virtual void print(std::ostream& = ExEnv::out0()) const;
};
}
#endif
// Local Variables:
// mode: c++
// c-file-style: "CLJ"
// End: