A base class for evaluating the dual function. More...
#include <dualqqp.h>
Public Member Functions | |
QqpDualFunc (MinlpProblem &qqp_, Param ¶m_, Pointer< ostream > out_func_p_=out_out_p, Pointer< ostream > out_func_log_p_=out_log_p) | |
Constructor for a MinlpReform and a shift. | |
virtual int | valgrad (double &val, UserVector< double > &g, const UserVector< double > &z) const |
Evaluates the function value and computes the subgradient of the dual function. | |
double | eval (const UserVector< double > &z) const |
Evaluates this function for a dvector. | |
void | grad (UserVector< double > &g, const UserVector< double > &x) const |
Computes the gradient of this function. | |
virtual void | HessMult (UserVector< double > &y, const UserVector< double > &x, const UserVector< double > &z) const |
Does nothing. | |
dvector | get_dual_point () const |
Set the Lagrange multipliers of the quadratic box constraints. | |
dvector | get_dual_point (dvector &ext_dual_point) const |
The dual point of the original qqp for an extended dual point. | |
double | get_dual_val () const |
The last dual value. | |
double | get_dual_val (dvector &ext_dual_point) const |
The dual value for an extended dual point. | |
dvector | get_orig_point (int use_eig_vec=0) const |
Gives the solution point of the Lagrangian function. | |
dvector | get_orig_point (dvector &ext_dual_point, int use_eig_vec=0) const |
The dual value for an extended dual point. | |
int | nr_of_orig_points () const |
The number of eigenvectors, which are computed in each evaluation. | |
void | print (ostream &out) const |
Print's a lot of information about this function. | |
Public Attributes | |
int | num_matmult |
number of matrix vector multiplications | |
double | eig_time |
time spent by the eigenvalue calculation | |
dvector | dual_point |
The dual variables of the extended (!) dual function. | |
Protected Types | |
enum | b_type { LIN, QUAD, EXTQUAD } |
The different block-types. More... | |
Protected Member Functions | |
int | num_qbox () const |
The number of quadratic-box-constraints. | |
int | num_blocks () const |
The number of blocks. | |
void | init_ext () |
Check's, if partial Lagrange problem is extended Set ext[k] to true, if the bounds are not symmetric or no linear part exists. | |
void | init () |
Initialization of the dual function. | |
void | set_ball_con () |
Initialize the ball constraints. | |
void | get_bc (double &c_, dvector &b_, SepQcFunc &q) |
Compute's modified b,c values for a SepQcFunc. | |
void | set_bc () |
Initialize the modified b,c-values. | |
int | set_dual_val () const |
Compute the value of the dual function. | |
double | eval_mod_con (int con_nr) const |
Evaluates a modified constraint. | |
double | eval_mod_obj () const |
Evaluates the modified objective. | |
void | set_subgrad () const |
Compute a subgradient of the dual function. | |
Protected Attributes | |
vector< b_type > | block_type |
Indicates for each block, which type the block of the lagrange problem has. | |
ivector | i_ext |
The indices of the new quadratic box constraints. | |
int | num_ext |
The number of extended blocks. | |
ivector | i_q |
The index of the start of the quadratric box constraints for the k-th block. | |
int | n_q |
The number of quadratic variables. | |
dvector | mid_point |
The mid point of the box = 0.5*(lower+upper). | |
BlockMatrix | W |
The half-length of the edges of the box. | |
dvector | radius |
The radius of the ball-constraints. | |
vector< bool > | ball_con |
The type of the ball-constraints. | |
vector< dvector > | b_con |
The type of scaling (currently not used). | |
dvector | b_obj |
The modified b-value for the objective-function. | |
dvector | c_con |
The modified c-values for the constraints. | |
double | c_obj |
The modified c-value for the objective-function. | |
vector< Pointer< UserMatrix > > | A_lag |
The block matrices of the modified Lagrangian Set in init. | |
vector< dvector > | b_lag |
The linear part of the modified Lagrangian Set in init. | |
double | c_lag |
The constant part of the modified Lagrangian Set in init. | |
dvector | x_lag |
The Lagrange solution. | |
double | dual_val |
current value of the dual function. | |
dvector | subgrad |
The subgradient. | |
vector< vector< double > > | eig_val |
minimal eigenvalues of A_lag[k], k=0,. | |
vector< vector< dvector > > | eig_vec |
eigenvectors of A_lag[k], k=0,. | |
Friends | |
class | QqpMatrix |
class | QqpExtMatrix |
A base class for evaluating the dual function.
assignment of the dual variables:
0:n-1 quadratic box-constraints of original variables
n:n+block_size-1 quadratic box-constraints of the new variables
block_size+n:block_size+n+con_size-1 remaining constraints
Definition at line 100 of file dualqqp.h.
enum QqpDualFunc::b_type [protected] |
QqpDualFunc::QqpDualFunc | ( | MinlpProblem & | qqp_, | |
Param & | param_, | |||
Pointer< ostream > | out_func_p_ = out_out_p , |
|||
Pointer< ostream > | out_func_log_p_ = out_log_p | |||
) | [inline] |
Constructor for a MinlpReform and a shift.
qqp_ | The MinlpReform, the DualFunc consists of. | |
param_ | Parameters. | |
out_func_p_ | A pointer to an output stream for function output. | |
out_func_log_p_ | A pointer to an output stream for function logging output. |
int QqpDualFunc::num_qbox | ( | ) | const [inline, protected] |
int QqpDualFunc::num_blocks | ( | ) | const [inline, protected] |
void QqpDualFunc::init_ext | ( | ) | [protected] |
Check's, if partial Lagrange problem is extended Set ext[k] to true, if the bounds are not symmetric or no linear part exists.
Or you say: Check, if modified b_k's are zero.
void QqpDualFunc::init | ( | ) | [protected] |
Initialization of the dual function.
Allocating memory, setting counters to zero, computing u,W...
Check's, whether the Lagrange problem is extended by calling init_ext().
Set's the modified c,b-values by calling set_bc(). Set's the ball-constraint type by calling set_ball_con(lower, upper).
void QqpDualFunc::set_ball_con | ( | ) | [protected] |
Initialize the ball constraints.
Initialize the ball constraints for each block with the corresponding part of lower and upper. Set's the type of each ball-constraint to true, if it contains one not-discrete variable.
Compute's modified b,c values for a SepQcFunc.
Sums mid_point[k]*q.A[k]*mid_point[k] + q.b[k]*mid_point[k] over all blocks. Adds the constant part of q: q.c
c_ | The modified c-value. | |
b_ | The modified b-value. | |
q | The SepQcfunc to compute. |
void QqpDualFunc::set_bc | ( | ) | [protected] |
Initialize the modified b,c-values.
Computes for each constraint and the objective the modified b,c-values by calling get_bc.
int QqpDualFunc::set_dual_val | ( | ) | const [protected] |
Compute the value of the dual function.
The function value is stored in dual_val.
double QqpDualFunc::eval_mod_con | ( | int | con_nr | ) | const [protected] |
Evaluates a modified constraint.
con_nr | The number of the constraint to evaluate. |
double QqpDualFunc::eval_mod_obj | ( | ) | const [protected] |
Evaluates the modified objective.
void QqpDualFunc::set_subgrad | ( | ) | const [protected] |
Compute a subgradient of the dual function.
The subgradient is stored in subgrad.
virtual int QqpDualFunc::valgrad | ( | double & | val, | |
UserVector< double > & | g, | |||
const UserVector< double > & | z | |||
) | const [virtual] |
Evaluates the function value and computes the subgradient of the dual function.
val | A double to store the value in. | |
g | A dvector to store the subgradient in. | |
z | The dual value to compute the value and subgradient for. |
Reimplemented from Func.
double QqpDualFunc::eval | ( | const UserVector< double > & | z | ) | const [inline, virtual] |
Evaluates this function for a dvector.
Sets dual_point to given point and calls set_dual_val(). This method doesn't look at the return value from set_dual_val() !
z | The dvector to compute the value for. |
Implements Func.
void QqpDualFunc::grad | ( | UserVector< double > & | g, | |
const UserVector< double > & | x | |||
) | const [inline, virtual] |
Computes the gradient of this function.
Calls valgrad(). This method doesn't look at the return value from set_dual_val(), so use valgrad() instead !
g | The dvector to store the gradient in. | |
x | The dvector to compute the gradient for. |
Implements Func.
virtual void QqpDualFunc::HessMult | ( | UserVector< double > & | y, | |
const UserVector< double > & | x, | |||
const UserVector< double > & | z | |||
) | const [inline, virtual] |
dvector QqpDualFunc::get_dual_point | ( | ) | const [virtual] |
Set the Lagrange multipliers of the quadratic box constraints.
The last dual point of the original qqp.
Implements DualFunc.
The dual point of the original qqp for an extended dual point.
If the extended dual point (the one, you can use for eval()) is not equal to dual_point, eval(ext_dual_point) is called. Then get_dual_point() is called.
ext_dual_point | A dual point from the extended qqp. |
double QqpDualFunc::get_dual_val | ( | ) | const [inline, virtual] |
double QqpDualFunc::get_dual_val | ( | dvector & | ext_dual_point | ) | const [inline] |
The dual value for an extended dual point.
If the extended dual point (the one, you can use for eval()) is not equal to dual_point, eval(ext_dual_point) is called. Then get_dual_val() is called.
ext_dual_point | A dual point from the extended qqp. |
dvector QqpDualFunc::get_orig_point | ( | int | use_eig_vec = 0 |
) | const [virtual] |
Gives the solution point of the Lagrangian function.
use_eig_vec | The eigenvector to use to compute the lag-point. |
Implements DualFunc.
dvector QqpDualFunc::get_orig_point | ( | dvector & | ext_dual_point, | |
int | use_eig_vec = 0 | |||
) | const [inline] |
The dual value for an extended dual point.
If the extended dual point (the one, you can use for eval()) is not equal to dual_point, eval(ext_dual_point) is called. Then get_orig_point() is called.
ext_dual_point | A dual point from the extended qqp. |
int QqpDualFunc::nr_of_orig_points | ( | ) | const [inline, virtual] |
void QqpDualFunc::print | ( | ostream & | out | ) | const [virtual] |
Print's a lot of information about this function.
out | The ostream to print to. |
Reimplemented from Func.
friend class QqpExtMatrix [friend] |
vector<b_type> QqpDualFunc::block_type [protected] |
Indicates for each block, which type the block of the lagrange problem has.
QUAD, EXTQUAD or LIN. Initialized in init_ext.
ivector QqpDualFunc::i_ext [protected] |
int QqpDualFunc::num_ext [protected] |
ivector QqpDualFunc::i_q [protected] |
int QqpDualFunc::n_q [protected] |
dvector QqpDualFunc::mid_point [protected] |
BlockMatrix QqpDualFunc::W [protected] |
The half-length of the edges of the box.
Initialized in init as BlockMatrix of DiagMatrix-blocks.
dvector QqpDualFunc::radius [protected] |
vector<bool> QqpDualFunc::ball_con [protected] |
The type of the ball-constraints.
False if equality constraint and true if inequality constraint. Initialized in set_ball_con.
vector<dvector> QqpDualFunc::b_con [protected] |
dvector QqpDualFunc::b_obj [protected] |
dvector QqpDualFunc::c_con [protected] |
double QqpDualFunc::c_obj [protected] |
vector<Pointer<UserMatrix> > QqpDualFunc::A_lag [protected] |
vector<dvector> QqpDualFunc::b_lag [mutable, protected] |
The linear part of the modified Lagrangian Set in init.
double QqpDualFunc::c_lag [mutable, protected] |
The constant part of the modified Lagrangian Set in init.
dvector QqpDualFunc::x_lag [mutable, protected] |
double QqpDualFunc::dual_val [mutable, protected] |
dvector QqpDualFunc::subgrad [mutable, protected] |
vector<vector<double> > QqpDualFunc::eig_val [mutable, protected] |
vector<vector<dvector> > QqpDualFunc::eig_vec [mutable, protected] |
double QqpDualFunc::eig_time [mutable] |
dvector QqpDualFunc::dual_point [mutable] |
The dual variables of the extended (!) dual function.
This is the dual point, which was last used to evaluate the function.