The abstract base class for a function. More...
#include <func.h>
Public Types | |
enum | CurvatureType { CONVEX = 1, CONCAVE = 2, LINEAR = CONVEX | CONCAVE, UNKNOWN = 4, INDEFINITE = 12 } |
Gets the convex shift parameter. More... | |
Public Member Functions | |
Func (int n=0, Pointer< ostream > out_func_p_=out_out_p, Pointer< ostream > out_func_log_p_=out_log_p) | |
(Standard-)Constructor for optional dimension. | |
virtual | ~Func () |
Virtual Destructor. | |
int | dim () const |
Gives the dimension. | |
virtual bool | sparsity_available () const |
To check, whether the sparsity information is set. | |
virtual const SparsityInfo & | get_sparsity () const |
Gives the sparsity information with read-permissions. | |
virtual bool | compute_sparsity_pattern (const vector< dvector > &sample_set) |
virtual double | eval (const UserVector< double > &x) const =0 |
Computes the value of this function for a UserVector<double>. | |
virtual void | grad (UserVector< double > &g, const UserVector< double > &x) const =0 |
Computes the (sub)gradient for a UserVector<double>. | |
virtual dvector | grad (const dvector &x) const |
Computes the (sub)gradient for a UserVector<double>. | |
virtual void | HessMult (UserVector< double > &y, const UserVector< double > &x, const UserVector< double > &z) const =0 |
Evaluates the product of the Hessian and a UserVector<double>. | |
virtual dvector | HessMult (const dvector &x, const dvector &z) const |
Evaluates the product of the Hessian and a dvector. | |
virtual int | valgrad (double &val, UserVector< double > &g, const UserVector< double > &x) const |
Computes the (sub)gradient and the value of this function for a UserVector<double>. | |
virtual void | add_grad (UserVector< double > &g, const UserVector< double > &x) const |
Add's the (sub)gradient of this function to a UserVector<double>. | |
virtual void | add_valgrad (double &val, UserVector< double > &g, const UserVector< double > &x) const |
Add's the (sub)gradient and the value of this function to a UserVector<double> and a double. | |
virtual double | min_eig_hess (const UserVector< double > &x, Param *param=NULL) const |
Gives the minimum eigenvector of the Hessian in point x. | |
virtual void | set_curvature (CurvatureType ct)=0 |
virtual CurvatureType | get_curvature () const =0 |
virtual void | print (ostream &out) const |
Print's out the dimension. | |
Static Public Member Functions | |
static CurvatureType | add_curvatures (double a1, CurvatureType ct1, double a2, CurvatureType ct2) |
static CurvatureType | mult_curvature (double a, CurvatureType ct) |
Public Attributes | |
Pointer< ostream > | out_func_p |
A Pointer to an output-stream for function-relevant output. | |
Pointer< ostream > | out_func_log_p |
A Pointer to an ostream to print function-relevant logging-information. | |
Protected Member Functions | |
virtual SparsityInfo & | get_sparsity () |
Protected Attributes | |
int | dim_ |
The dimension. | |
Pointer< SparsityInfo > | sparsity |
Friends | |
class | VariableIterator |
class | MinusFunc |
class | SumFunc |
ostream & | operator<< (ostream &out, const Func &a) |
Prints some status information. | |
ostream & | operator<< (ostream &out, const CurvatureType &ct) |
The abstract base class for a function.
You need to implement the following methods:
Definition at line 221 of file func.h.
enum Func::CurvatureType |
Gets the convex shift parameter.
lower | Lower bound of the box. | |
upper | Upper bound of the box. | |
lev | The level. | |
offset | Will be added to the shift, if not convex. |
Func::Func | ( | int | n = 0 , |
|
Pointer< ostream > | out_func_p_ = out_out_p , |
|||
Pointer< ostream > | out_func_log_p_ = out_log_p | |||
) | [inline] |
(Standard-)Constructor for optional dimension.
n | The dimension, default is 0. | |
out_func_p_ | An ostream to print function-related output to, default is out_out_p. | |
out_func_log_p_ | An ostream to print function-related logging-output to, default is out_func_p. |
virtual Func::~Func | ( | ) | [inline, virtual] |
virtual SparsityInfo& Func::get_sparsity | ( | ) | [inline, protected, virtual] |
int Func::dim | ( | ) | const [inline] |
virtual bool Func::sparsity_available | ( | ) | const [inline, virtual] |
virtual const SparsityInfo& Func::get_sparsity | ( | ) | const [inline, virtual] |
virtual bool Func::compute_sparsity_pattern | ( | const vector< dvector > & | sample_set | ) | [inline, virtual] |
virtual double Func::eval | ( | const UserVector< double > & | x | ) | const [pure virtual] |
Computes the value of this function for a UserVector<double>.
Abstract.
x | The UserVector<double> to compute the value for. |
Implemented in amplObj, amplCon, SplitFunc, QqpDualFunc, MinusFunc, SumFunc, SepQcFunc, gamsFunc, Monom, and MinlpPenaltyFunc.
virtual void Func::grad | ( | UserVector< double > & | g, | |
const UserVector< double > & | x | |||
) | const [pure virtual] |
Computes the (sub)gradient for a UserVector<double>.
Abstract.
g | The UserVector<double> to store the result in. | |
x | The UserVector<double> to compute the gradient for. |
Implemented in amplObj, amplCon, SplitFunc, QqpDualFunc, MinusFunc, SumFunc, SepQcFunc, gamsFunc, Monom, and MinlpPenaltyFunc.
Computes the (sub)gradient for a UserVector<double>.
x | The UserVector<double> to compute. |
Reimplemented in MinusFunc.
virtual void Func::HessMult | ( | UserVector< double > & | y, | |
const UserVector< double > & | x, | |||
const UserVector< double > & | z | |||
) | const [pure virtual] |
Evaluates the product of the Hessian and a UserVector<double>.
Abstract.
y | The UserVector<double> to store the result in: ![]() | |
x | The UserVector<double> to evaluate the Hessian for. | |
z | The UserVector<double> to multiply with the Hessian. |
Implemented in amplObj, amplCon, SplitFunc, QqpDualFunc, MinusFunc, SumFunc, SepQcFunc, gamsFunc, Monom, and MinlpPenaltyFunc.
Evaluates the product of the Hessian and a dvector.
x | The dvector to evaluate the Hessian for. | |
z | The dvector to multiply with the Hessian. |
Reimplemented in MinusFunc.
virtual int Func::valgrad | ( | double & | val, | |
UserVector< double > & | g, | |||
const UserVector< double > & | x | |||
) | const [inline, virtual] |
Computes the (sub)gradient and the value of this function for a UserVector<double>.
val | The double to store the value this(x). | |
g | The UserVector<double> to store the gradient. | |
x | The UserVector<double> to compute the gradient and value for. |
Reimplemented in QqpDualFunc, SumFunc, SepQcFunc, gamsFunc, and MinlpPenaltyFunc.
virtual void Func::add_grad | ( | UserVector< double > & | g, | |
const UserVector< double > & | x | |||
) | const [inline, virtual] |
Add's the (sub)gradient of this function to a UserVector<double>.
g | The UserVector<double> to add the gradient to. | |
x | The UserVector<double> to compute the gradient for. |
virtual void Func::add_valgrad | ( | double & | val, | |
UserVector< double > & | g, | |||
const UserVector< double > & | x | |||
) | const [inline, virtual] |
Add's the (sub)gradient and the value of this function to a UserVector<double> and a double.
val | The double to add the value to. | |
g | The UserVector<double> to add the gradient to. | |
x | The UserVector<double> to compute the value and the gradient for. |
virtual double Func::min_eig_hess | ( | const UserVector< double > & | x, | |
Param * | param = NULL | |||
) | const [virtual] |
Gives the minimum eigenvector of the Hessian in point x.
x | The dvector to compute the Hessian for. | |
param | Optional parameters for eigenvalue computation. |
virtual void Func::set_curvature | ( | CurvatureType | ct | ) | [pure virtual] |
virtual CurvatureType Func::get_curvature | ( | ) | const [pure virtual] |
static CurvatureType Func::add_curvatures | ( | double | a1, | |
CurvatureType | ct1, | |||
double | a2, | |||
CurvatureType | ct2 | |||
) | [static] |
static CurvatureType Func::mult_curvature | ( | double | a, | |
CurvatureType | ct | |||
) | [static] |
virtual void Func::print | ( | ostream & | out | ) | const [inline, virtual] |
friend class VariableIterator [friend] |
ostream& operator<< | ( | ostream & | out, | |
const Func & | a | |||
) | [friend] |
ostream& operator<< | ( | ostream & | out, | |
const CurvatureType & | ct | |||
) | [friend] |
int Func::dim_ [protected] |
Pointer<SparsityInfo> Func::sparsity [protected] |
Pointer<ostream> Func::out_func_p |
Pointer<ostream> Func::out_func_log_p |
A Pointer to an ostream to print function-relevant logging-information.
Set in the constructor, default is out_log_p.