ConicBundle
|
class for use with SumBlockModel and BundlData for storing and managing a common bundle describing (part of) the model More...
#include <SumBundle.hxx>
Classes | |
class | BData |
Public Types | |
enum | Mode { root, child, inactive, unavailable } |
specifies for different parts of the sumbundle whether it is active and who is responsible for handling it More... | |
Public Member Functions | |
SumBundle (const SumBundle &sb) | |
copy constructor | |
void | init (const SumBundle &sb) |
initialize | |
void | synchronize_ids (CH_Matrix_Classes::Integer new_modification_id, CH_Matrix_Classes::Integer new_center_id, CH_Matrix_Classes::Integer old_center_id, CH_Matrix_Classes::Integer new_cand_id, CH_Matrix_Classes::Integer old_cand_id, CH_Matrix_Classes::Integer new_prex_id=0) |
sets the modification_id to id | |
bool | has_bundle_for (FunctionTask ft) const |
returns true if BData exists for this mode | |
bool | has_bundle_data () const |
returns true if BData exists | |
int | bundle_size (FunctionTask ft) const |
if BData exists for this mode it returns its bundle_size (possibly 0), otherwise 0 | |
bool | has_roots () const |
returns true if one of its parts is a root | |
bool | has_working_roots () const |
returns true if one of its parts is a root with n_contributors>0 | |
bool | active () const |
returns true if one of its parts is not inactive | |
bool | has_contributions () const |
returns true if one of its parts is a child | |
Mode | get_mode (FunctionTask ft) const |
gets the corresponding mode (call only if a has_bundle_for(ft)==true) | |
CH_Matrix_Classes::Real | get_function_factor (FunctionTask ft) const |
gets the corresponding function factor (call only if a has_bundle_for(ft)==true) | |
CH_Matrix_Classes::Integer | get_n_contributors (FunctionTask ft) const |
gets the corresponding n_contributors (call only if a has_bundle_for(ft)==true) | |
const MinorantBundle & | get_bundle (FunctionTask ft) const |
gets the corresponding minorants (call only if a has_bundle_for(ft)==true) | |
const CH_Matrix_Classes::Matrix & | get_coeff (FunctionTask ft) const |
gets the corresponding aggregation coefficients (call only if a has_bundle_for(ft)==true) | |
const MinorantPointer & | get_aggregate (FunctionTask ft) const |
gets the corresponding aggregate (call only if a has_bundle_for(ft)==true) | |
const MinorantPointer & | get_cand_minorant (FunctionTask ft) const |
gets the corresponding candidate minorant (call only if a has_bundle_for(ft)==true) | |
int | eval_model (CH_Matrix_Classes::Real &lb, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y, CH_Matrix_Classes::Real nullstep_bound, CH_Matrix_Classes::Real relprec) const |
evaluate the model values for all root parts, it may only be called if there are such because otherwise lb would need to be -infty | |
CH_Matrix_Classes::Real | lb_model (CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y) const |
returns a quick lower bound for the root parts, it may only be called if there are such because otherwise lb would need to be -infty | |
int | get_local_model_aggregate (MinorantPointer &aggregate, CH_Matrix_Classes::Real factor=1., const AffineFunctionTransformation *aft=0) const |
get the aggregate that is due to root sumbundle parts handled here | |
int | get_contributed_model_aggregate (MinorantPointer &aggregate, CH_Matrix_Classes::Real factor=1., const AffineFunctionTransformation *aft=0) const |
get the aggregate that is due to child parts of the sumbundle, which are contributed to parents | |
int | call_primal_extender (PrimalExtender &prex, CH_Matrix_Classes::Integer prex_id, FunctionTask ft) |
call this primal extender for the primals; if there minorants but no primals or if it fails, return 1 | |
int | apply_modification (const GroundsetModification &gsmdf, CH_Matrix_Classes::Integer mod_id, MinorantExtender *mex, FunctionTask ft) |
rearrange/extend the minorants according to the given groundset modifications | |
Public Member Functions inherited from ConicBundle::CBout | |
virtual void | set_out (std::ostream *out=0, int print_level=1) |
Specifies the output level (out==NULL: no output at all, out!=NULL and level=0: errors and warnings, level>0 increasingly detailed information) More... | |
virtual void | set_cbout (const CBout *cb, int incr=-1) |
Specifies the output level relative to the given CBout class. More... | |
void | clear_cbout () |
reset to default settings (out=0,print_level=1) | |
CBout (const CBout *cb=0, int incr=-1) | |
calls set_cbout | |
CBout (std::ostream *outp, int pl=1) | |
initialize correspondingly | |
CBout (const CBout &cb, int incr=0) | |
copy constructor | |
virtual bool | cb_out (int pl=-1) const |
Returns true if out!=0 and (pl<print_level), pl<0 should be used for WARNINGS and ERRORS only, pl==0 for usual output. | |
std::ostream & | get_out () const |
If cb_out() returned true, this returns the output stream, but it will abort if called with out==0. | |
std::ostream * | get_out_ptr () const |
returns the pointer to the output stream | |
int | get_print_level () const |
returns the print_level | |
virtual int | mfile_data (std::ostream &out) const |
writes problem data to the given outstream | |
Private Types | |
typedef std::vector< BData > | BDataVector |
for storing separate data for ObjectiveFunciton, ConstantPenaltyFunction, AdaptivePenaltyFunction | |
Private Member Functions | |
void | clear () |
clear all data and set the mode of all parts to inactive | |
void | clear (FunctionTask ft) |
clear all data and remove this part | |
SumBundle & | operator= (const SumBundle &sb) |
copy by calling initialize(const SumBundle&) | |
void | init (FunctionTask ft, CH_Matrix_Classes::Real fun_factor=1.) |
reset an existing or create a new BData entry for ft | |
void | take_control (Mode mode) |
if mode==root or mode==child and *this has a part marked as child, switch the mode to root; if mode==inactive, deactivate child and root parts | |
Mode & | set_mode (FunctionTask ft) |
allows to set the corresponding mode (call only if a has_bundle_for(ft)==true) | |
CH_Matrix_Classes::Real & | set_function_factor (FunctionTask ft) |
allows to set the corresponding function factor (call only if a has_bundle_for(ft)==true) | |
CH_Matrix_Classes::Integer & | set_n_contributors (FunctionTask ft) |
allows to set the corresponding n_contributors (call only if a has_bundle_for(ft)==true) | |
MinorantBundle & | set_bundle (FunctionTask ft) |
allows to set the corresponding minorants (call only if a has_bundle_for(ft)==true) | |
CH_Matrix_Classes::Matrix & | set_coeff (FunctionTask ft) |
allows to set the corresponding aggregation coefficients (call only if a has_bundle_for(ft)==true) | |
MinorantPointer & | set_aggregate (FunctionTask ft) |
allows to set the corresponding aggregate (call only if a has_bundle_for(ft)==true) | |
MinorantPointer & | set_cand_minorant (FunctionTask ft) |
allows to set the corresponding aggregate (call only if a has_bundle_for(ft)==true) | |
const PrimalData * | get_approximate_primal (FunctionTask ft) const |
if active, get the approximate primal (if add==false, initialize if possible and set add=true in this case) | |
Private Attributes | |
BDataVector | bdata |
stores separate bundle data for ObjectiveFunciton, ConstantPenaltyFunction, AdaptivePenaltyFunction | |
Friends | |
class | SumBundleHandler |
class for use with SumBlockModel and BundlData for storing and managing a common bundle describing (part of) the model
Organizing a common bundle for a selection of functions in a sum of functions may be split into three mayor parts
The SumModel plays the role of the initiator to the model deciding part if its SumBundle has a part set to a socalled root mode (see below). Right before setting up the next quadratic subproblem, it tries to determine dynamically for which of its submodels (each a SumBlockModel) it might be more efficient to include them in its common SumBundle and suggests this to the submodels. Each submodel may still decide on its own whether it is willing to contribute to the common SumBundle (maybe also only in part) or not. Because a submodel may choose to contribute or not, each submodel has to supply the information that it wants to be taken care of in the common model by itself. Thus the minorants to be used in forming the common SumBundle must be fed to the SumBundleHandler by the SumBundleHandler of the submodel. Furthermore, if the submodel decides to change its state of contributing, it has to communicate this information accordingly via its SumBundleHandler and it has to be able to extract the necessary information from its global part in order to continue without loosing the aggregate. The potential splitting of the model into a local and a global part also requires some care in computing the model value itself so that no parts are counted twice.
In order to be able to switch between local and global model frequently without much loss in quality of the model, each submodel keeps updating its own potential contribution to the sumbundle by its SumBundleHandler even if it is currently not included in the SumBundle of the caller. Whenever it switches to the global model, it has to communicate its global model contribution's aggregate to its SumBundleHandler and the bundle handler has to be able to incorporate that in the common SumBundle's aggregate, so the local SumBundleHandler has to know the SumBundleHandler of the parent. In order to allow proper updating of the aggregate of the global model, the parent's bundle handler always has to keep the aggregate explicitly as a separate minorant in the SumBundle. The submodel itself requires no information on who uses its global model or how it is used, but it must always be aware of whether it is used or not. The submodel is informed whether it may choose its global model part to be used or not by a caller via calling SumBlockModel::sumbundle_contribution() with a SumBundleHandler or with a NULL pointer respectively. Between two calls of this routine the local SumBundleHandler will always interact with this as the parent's SumBundleHandler, so the parent's SumBundleHandler may not change or be deleted during two calls. If a radical change is desired, this always requires a new call of SumBlockModel::sumbundle_contribution(). Whenever the external use of the global model is switched off, the submodel is responsible for including the global part of the model in its local model again. In particular, the submodel may do so by extracting the aggregate or by setting up its own handler and the interface to the global model part ensures that it will always be able to do so. If the function itself changes, the model first removes its contribution by calling the parent's bundlhandler and changes its data only afterwards, so that the parent's model stays correct.
Because of the three different kinds of FunctionTask and their different uses in the quadratic subproblem, the SumBundle of SumModel needs to handle three different parts, one for each FunctionTask. In contrast, in FunctionModel only one FunctionTask is active each time and so FunctionModel will only make use of one of them at each time. As the contributions of the SumBlockModel classes to the SumBundle may change dynamically, each part will only be fully active if there are contributions to it by some function. Each part can be in three modes:
specifies for different parts of the sumbundle whether it is active and who is responsible for handling it