SepQcFunc Class Reference

A class for a separable QC-function. More...

#include <func.h>

Inheritance diagram for SepQcFunc:
Inheritance graph
[legend]
Collaboration diagram for SepQcFunc:
Collaboration graph
[legend]

List of all members.

Classes

class  VariableIterator

Public Types

enum  ftype { CONSTANT, LINEAR, QUADRATIC, NONQUAD }
 

Types of functions.

More...

Public Member Functions

 SepQcFunc (int n, Pointer< ostream > out_func_p_=out_out_p, Pointer< ostream > out_func_log_p_=out_log_p)
 Constructor for one block.
 SepQcFunc (const vector< ivector > &block_, Pointer< ostream > out_func_p_=out_out_p, Pointer< ostream > out_func_log_p_=out_log_p)
 Constructor for a block-structure.
 SepQcFunc (Pointer< UserMatrix > A_, Pointer< UserVector< double > > b_=NULL, Pointer< Func > s_=NULL, double c_=0, Pointer< SparsityInfo > sparsity_=NULL, Pointer< ostream > out_func_p_=out_out_p, Pointer< ostream > out_func_log_p_=out_log_p)
 SepQcFunc (const SepQcFunc &f, bool minus_func)
 Copy Constructor with (optional) minus.
 SepQcFunc (const SepQcFunc &f, const UserVector< double > &point, const int degree=2)
 Computes a Taylor approximation.
virtual bool sparsity_available (int k) const
virtual bool sparsity_available () const
 To check, whether the sparsity information is set.
virtual SparsityInfoget_sparsity (int k)
virtual const SparsityInfoget_sparsity (int k) const
virtual SparsityInfoget_sparsity ()
virtual void set_sparsity (int k, Pointer< SparsityInfo > si)
virtual void set_sparsity ()
bool compute_sparsity (int block_nr, const vector< dvector > &sample_set, bool replace_if_quadratic=false)
virtual ftype type (int k)
 The type of the a block of this function.
void add_var (int index, int bnum)
 Increasing the dimension by adding a variable.
void addmult (const SepQcFunc &f, double a_=1., double b_=1.)
 Multiplies this function with a double and adds another function, multiplied with another double.
double eval (const UserVector< double > &x) const
 Computes the value for a UserVector<double>.
double eval (const UserVector< double > &x, int k) const
 Computes the value of one block for a UserVector<double>, without the constant part.
void grad (UserVector< double > &g, const UserVector< double > &x) const
 Computes the gradient of this function.
void grad (UserVector< double > &g, const UserVector< double > &x, int bnum) const
 Computes the gradient of one block for a UserVector<double>.
dvector grad (const UserVector< double > &x, int bnum) const
int valgrad (double &val, UserVector< double > &g, const UserVector< double > &x) const
 Computes the value and the gradient for a UserVector<double>.
void HessMult (UserVector< double > &y, const UserVector< double > &x, const UserVector< double > &z) const
 Computes the product of the Hessian and a UserVector<double>.
void HessMult (UserVector< double > &y, const UserVector< double > &x, const UserVector< double > &z, int k) const
 Compute the product of one block of the Hessian and a UserVector<double>.
Func::CurvatureType get_curvature (int k) const
Func::CurvatureType get_curvature () const
void set_curvature (int k, Func::CurvatureType ct)
void set_curvature (Func::CurvatureType ct)
void print (ostream &out) const
 Prints information about this function.
void print (ostream &out, vector< Pointer< char > > var_names) const
 Prints this function in a nicer format than the other print.

Public Attributes

vector< Pointer< UserMatrix > > A
 The matrices of each block.
vector< Pointer< UserVector
< double > > > 
b
 The vector's of each block.
vector< Pointer< Func > > s
 The nonlinear, nonquadratic part's of each block.
vector< Func::CurvatureTypecurv_type
 The curvature types of each block.
double c
 The constant part.

Private Attributes

vector< Pointer< SparsityInfo > > sparsity_block

Friends

class Decomposition
ostream & operator<< (ostream &out, const ftype &ft)

Detailed Description

A class for a separable QC-function.

$f(x)=\sum_i (x_i*A_i*x_i+2b_i*x_i+s_i(x_i)) + c$.

Definition at line 800 of file func.h.


Member Enumeration Documentation

Types of functions.

Enumerator:
CONSTANT 
LINEAR 
QUADRATIC 
NONQUAD 

Definition at line 835 of file func.h.


Constructor & Destructor Documentation

SepQcFunc::SepQcFunc ( int  n,
Pointer< ostream >  out_func_p_ = out_out_p,
Pointer< ostream >  out_func_log_p_ = out_log_p 
) [inline]

Constructor for one block.

Parameters:
n The size of the first block.
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.

Definition at line 863 of file func.h.

SepQcFunc::SepQcFunc ( const vector< ivector > &  block_,
Pointer< ostream >  out_func_p_ = out_out_p,
Pointer< ostream >  out_func_log_p_ = out_log_p 
) [inline]

Constructor for a block-structure.

Parameters:
block_ The block-structure to copy.
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.

Definition at line 872 of file func.h.

SepQcFunc::SepQcFunc ( Pointer< UserMatrix A_,
Pointer< UserVector< double > >  b_ = NULL,
Pointer< Func s_ = NULL,
double  c_ = 0,
Pointer< SparsityInfo sparsity_ = NULL,
Pointer< ostream >  out_func_p_ = out_out_p,
Pointer< ostream >  out_func_log_p_ = out_log_p 
) [inline]

Definition at line 876 of file func.h.

SepQcFunc::SepQcFunc ( const SepQcFunc f,
bool  minus_func 
)

Copy Constructor with (optional) minus.

Parameters:
f The SepQcFunc to copy.
minus_func_ Indicates, if the function should be multiplied by -1.
SepQcFunc::SepQcFunc ( const SepQcFunc f,
const UserVector< double > &  point,
const int  degree = 2 
)

Computes a Taylor approximation.


Member Function Documentation

virtual bool SepQcFunc::sparsity_available ( int  k  )  const [inline, virtual]

Definition at line 891 of file func.h.

virtual bool SepQcFunc::sparsity_available (  )  const [inline, virtual]

To check, whether the sparsity information is set.

Returns:
True, if sparsity information is available. False, else.

Reimplemented from Func.

Definition at line 896 of file func.h.

virtual SparsityInfo& SepQcFunc::get_sparsity ( int  k  )  [inline, virtual]

Definition at line 898 of file func.h.

virtual const SparsityInfo& SepQcFunc::get_sparsity ( int  k  )  const [inline, virtual]

Definition at line 902 of file func.h.

virtual SparsityInfo& SepQcFunc::get_sparsity (  )  [inline, virtual]

Reimplemented from Func.

Definition at line 906 of file func.h.

virtual void SepQcFunc::set_sparsity ( int  k,
Pointer< SparsityInfo si 
) [inline, virtual]

Definition at line 910 of file func.h.

virtual void SepQcFunc::set_sparsity (  )  [virtual]
bool SepQcFunc::compute_sparsity ( int  block_nr,
const vector< dvector > &  sample_set,
bool  replace_if_quadratic = false 
)
virtual ftype SepQcFunc::type ( int  k  )  [inline, virtual]

The type of the a block of this function.

Parameters:
k The block number.
Returns:
NONQUAD, if s[k] is set, QUADRATIC if only A[k] is set, LINEAR if only b[k] is set, CONSTANT else.

Definition at line 921 of file func.h.

void SepQcFunc::add_var ( int  index,
int  bnum 
)

Increasing the dimension by adding a variable.

If you add a variable to an existing block, A and s must be NULL for this block.

Parameters:
index Index of variable.
bnum The block, where we add the variable to.
void SepQcFunc::addmult ( const SepQcFunc f,
double  a_ = 1.,
double  b_ = 1. 
)

Multiplies this function with a double and adds another function, multiplied with another double.

So this function will be a*this + b*f.

Parameters:
f The function to add.
a_ The double to multiply this function with, default is 1.
b_ The double to multiply the given function with, default is 1.
double SepQcFunc::eval ( const UserVector< double > &  x  )  const [virtual]

Computes the value for a UserVector<double>.

Parameters:
x The UserVector<double> to compute the value for.
Returns:
The value as double.

Implements Func.

double SepQcFunc::eval ( const UserVector< double > &  x,
int  k 
) const [inline]

Computes the value of one block for a UserVector<double>, without the constant part.

Parameters:
x The UserVector<double> of k'th block to evaluate.
k The block number.
Returns:
The value as double.

Definition at line 954 of file func.h.

void SepQcFunc::grad ( UserVector< double > &  g,
const UserVector< double > &  x 
) const [virtual]

Computes the gradient of this function.

Parameters:
g The UserVector<double> to store the result in.
x The UserVector<double> to compute the gradient for.

Implements Func.

void SepQcFunc::grad ( UserVector< double > &  g,
const UserVector< double > &  x,
int  bnum 
) const

Computes the gradient of one block for a UserVector<double>.

Parameters:
g The UserVector<double> to store the gradient in.
x The UserVector<double> of the k'th block to compute.
bnum The block-number.
dvector SepQcFunc::grad ( const UserVector< double > &  x,
int  bnum 
) const [inline]

Definition at line 973 of file func.h.

int SepQcFunc::valgrad ( double &  val,
UserVector< double > &  g,
const UserVector< double > &  x 
) const [virtual]

Computes the value and the gradient for a UserVector<double>.

Parameters:
val The double to store the value in.
g The UserVector<double> to store the gradient in.
x The UserVector<double> to compute the value and the gradient for.
Returns:
The sum of the return codes over the blocks.

Reimplemented from Func.

void SepQcFunc::HessMult ( UserVector< double > &  y,
const UserVector< double > &  x,
const UserVector< double > &  z 
) const [virtual]

Computes the product of the Hessian and a UserVector<double>.

Parameters:
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.

Implements Func.

void SepQcFunc::HessMult ( UserVector< double > &  y,
const UserVector< double > &  x,
const UserVector< double > &  z,
int  k 
) const

Compute the product of one block of the Hessian and a UserVector<double>.

Parameters:
y The UserVector<double> to store the result in.
x The UserVector<double> to evaluate the k-th block of the Hessian for.
z The UserVector<double> to multiply with the Hessian.
k The block number.
Func::CurvatureType SepQcFunc::get_curvature ( int  k  )  const [inline]

Definition at line 1016 of file func.h.

Func::CurvatureType SepQcFunc::get_curvature (  )  const [virtual]

Implements Func.

void SepQcFunc::set_curvature ( int  k,
Func::CurvatureType  ct 
) [inline]

Definition at line 1018 of file func.h.

void SepQcFunc::set_curvature ( Func::CurvatureType  ct  )  [virtual]

Implements Func.

void SepQcFunc::print ( ostream &  out  )  const [virtual]

Prints information about this function.

Prints the dimension, constant part, block-structure and linear, quadratic and nonquadratic parts.

Parameters:
out The ostream to print to.

Reimplemented from SepFunc.

void SepQcFunc::print ( ostream &  out,
vector< Pointer< char > >  var_names 
) const

Prints this function in a nicer format than the other print.

Parameters:
out The ostream to print to.
var_names The variable names.

Friends And Related Function Documentation

friend class Decomposition [friend]

Definition at line 801 of file func.h.

ostream& operator<< ( ostream &  out,
const ftype ft 
) [friend]

Member Data Documentation

Definition at line 803 of file func.h.

The matrices of each block.

Definition at line 840 of file func.h.

vector<Pointer<UserVector<double> > > SepQcFunc::b

The vector's of each block.

Definition at line 844 of file func.h.

The nonlinear, nonquadratic part's of each block.

Definition at line 848 of file func.h.

The curvature types of each block.

Definition at line 852 of file func.h.

double SepQcFunc::c

The constant part.

Definition at line 856 of file func.h.


The documentation for this class was generated from the following file:

Generated on 10 Mar 2013 for LaGO by  doxygen 1.6.1