A class for a separable QC-function. More...
#include <func.h>
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 SparsityInfo & | get_sparsity (int k) |
virtual const SparsityInfo & | get_sparsity (int k) const |
virtual SparsityInfo & | get_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::CurvatureType > | curv_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) |
A class for a separable QC-function.
.
Definition at line 800 of file func.h.
enum SepQcFunc::ftype |
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] |
SepQcFunc::SepQcFunc | ( | const SepQcFunc & | f, | |
bool | minus_func | |||
) |
Copy Constructor with (optional) minus.
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.
virtual bool SepQcFunc::sparsity_available | ( | int | k | ) | const [inline, virtual] |
virtual bool SepQcFunc::sparsity_available | ( | ) | const [inline, virtual] |
virtual SparsityInfo& SepQcFunc::get_sparsity | ( | int | k | ) | [inline, virtual] |
virtual const SparsityInfo& SepQcFunc::get_sparsity | ( | int | k | ) | const [inline, virtual] |
virtual SparsityInfo& SepQcFunc::get_sparsity | ( | ) | [inline, virtual] |
virtual void SepQcFunc::set_sparsity | ( | int | k, | |
Pointer< SparsityInfo > | si | |||
) | [inline, virtual] |
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] |
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.
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.
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>.
x | The UserVector<double> to compute the value for. |
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.
x | The UserVector<double> of k'th block to evaluate. | |
k | The block number. |
void SepQcFunc::grad | ( | UserVector< double > & | g, | |
const UserVector< double > & | x | |||
) | const [virtual] |
Computes the gradient of this function.
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>.
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] |
int SepQcFunc::valgrad | ( | double & | val, | |
UserVector< double > & | g, | |||
const UserVector< double > & | x | |||
) | const [virtual] |
Computes the value and the gradient for a UserVector<double>.
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. |
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>.
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>.
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] |
Func::CurvatureType SepQcFunc::get_curvature | ( | ) | const [virtual] |
Implements Func.
void SepQcFunc::set_curvature | ( | int | k, | |
Func::CurvatureType | ct | |||
) | [inline] |
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.
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.
out | The ostream to print to. | |
var_names | The variable names. |
friend class Decomposition [friend] |
ostream& operator<< | ( | ostream & | out, | |
const ftype & | ft | |||
) | [friend] |
vector<Pointer<SparsityInfo> > SepQcFunc::sparsity_block [private] |
vector<Pointer<UserMatrix> > SepQcFunc::A |
vector<Pointer<UserVector<double> > > SepQcFunc::b |
vector<Pointer<Func> > SepQcFunc::s |
double SepQcFunc::c |