ConicBundle
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ConicBundle::SumBundleHandler Class Reference

routines for updating and handling SumBundle components, possibly by cooperating over several recursive levels More...

#include <SumBundleHandler.hxx>

Inheritance diagram for ConicBundle::SumBundleHandler:
ConicBundle::CBout

Classes

class  BundleInformation
 allows to store organizational information for each FunctionTask type of bundle More...
 

Public Member Functions

 SumBundleHandler (SumBundle &sb, const std::map< FunctionTask, CH_Matrix_Classes::Real > &factor_map, const BundleParameters *bp=0)
 initialize the handler to handle sb and therein the parts for which factor_map sets the (initial) function factors; all of them get the same bundle parameters if specified; otherwise default values are used
 
const SumBundleget_sumbundle () const
 returns the sumbundle
 
bool handles (FunctionTask ft)
 returns true if this FunctionTask is handled
 
CH_Matrix_Classes::Integer get_new_index (FunctionTask ft) const
 returns the index of the newest subgradient in the bundle
 
bool initialization_needed (FunctionTask ft) const
 returns true if the corresponding part is root with contributions but has bundle_size 0
 
bool initialization_needed () const
 returns true if one of the parts is root with contributions but has bundle_size 0
 
int set_parent_information (SumBundleHandler *parent_sbh, const AffineFunctionTransformation *aft, SumBundle::Mode in_mode)
 sets a parent handler, an aft and prepares for the next in_mode. If the respective pointers are null and in_mode is active, a part in child mode is changed to root. More...
 
int reset_function_factor (FunctionTask ft, CH_Matrix_Classes::Real factor)
 resets the value of the function factor for this part of sumbundle
 
int set_bundle_parameters (const BundleParameters &bp)
 sets max_bundle_size and max_model_size for all parts; this may be increased internally if the mode and/or the parent handler require this
 
CH_Matrix_Classes::Real get_increase_factor () const
 returns the increase factor for the unbounded part of sumbundle, otherwise 1.
 
int update_model (BundleModel::ModelUpdate model_update, CH_Matrix_Classes::Integer center_id, const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, CH_Matrix_Classes::Real model_maxviol, BundleProxObject &H)
 updates the sumbundle maybe even if not active; in this it tries to do the same as bh, storing the aggregate at the same place and providing new room at the same place; the new subgradient is not entered here but in set_cand_minorant()
 
int eval_model (CH_Matrix_Classes::Real &lb, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y) const
 evaluate the model value
 
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 model value
 
int normalize_sumbundle ()
 
int contribute_new_minorants ()
 once all new minorants have been collected at this level, they are passed to the next if required
 
int remove_contributions ()
 remove own contributions to the parent and set the states correspondingly
 
int add_contributions ()
 add root parts of this sumbundle to the parent's sumbundle and set the states correspondingly More...
 
int start_augmodel (QPModelDataPointer &bp, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, const CH_Matrix_Classes::Indexmatrix *indices, FunctionTask ft)
 start the augmented model block for FunctionTask ft if to be handled here and increase xdim correspondingly; if there are several, use start_augmodel(QP_SumBlock&,Integer&) instead
 
int start_augmodel (QPModelDataPointer &bp, QPSumModelDataObject &sumblock, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, const CH_Matrix_Classes::Indexmatrix *indices=0)
 add augmented model blocks to the sumblock for parts to be handled here and increase xdim correspondingly
 
int make_model_aggregate (bool &increased, bool fixed)
 see SumBlockModel::make_model_aggregate
 
int provide_model_aggregate ()
 see SumBlockModel::provide_model_aggregate
 
int adjust_multiplier (bool &values_may_have_changed)
 see SumBlockModel::adjust_multiplier
 
int contribute_initial_bundle (FunctionTask ft, const MinorantBundle &bundle_minorants, const CH_Matrix_Classes::Matrix &coeff)
 (re)initialize the bundle of the respective part More...
 
int install_external_aggregate (FunctionTask ft, const MinorantPointer &aggr, CH_Matrix_Classes::Real aggr_coeff)
 replace the aggregate by one from outside More...
 
int set_cand_minorant (FunctionTask ft, const MinorantPointer &minorant)
 set the new minorant information of the candidate More...
 
void clear_model ()
 first calls remove_contributions(), then discards all current models
 
void clear_aggregates ()
 first calls remove_contributions(), then discards all aggregate minorants in the current model
 
void clear_cand_minorants ()
 before contributing the new evaluation results, the candidates have to be cleared
 
int append_vars (FunctionTask ft, const CH_Matrix_Classes::Matrix &append_mat)
 first calls remove_contributions(), then appends the data to the bundle of minorants
 
int reassign_vars (FunctionTask ft, const CH_Matrix_Classes::Indexmatrix &map_to_old)
 first calls remove_contributions(), then reassigns the rows of the bundle of minorants according to map_to_old
 
int add_variable_metric (FunctionTask ft, VariableMetric &H, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y, bool descent_step, CH_Matrix_Classes::Real weightu, CH_Matrix_Classes::Real model_maxviol, const CH_Matrix_Classes::Indexmatrix *indices=0)
 see DynamicScaling
 
int add_variable_metric (VariableMetric &H, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &center_y, bool descent_step, CH_Matrix_Classes::Real weightu, CH_Matrix_Classes::Real model_maxviol, const CH_Matrix_Classes::Indexmatrix *indices=0)
 see DynamicScaling
 
CH_Matrix_Classes::Real guess_curvature (const MinorantBundle &mnrts, const CH_Matrix_Classes::Indexmatrix &selected_indices, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, CH_Matrix_Classes::Real model_maxviol) const
 computes an estimate of the current curvature to support SumModel in the selection of submodles
 
- 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< BundleInformation * > BundleInformationVector
 for storing separate data for ObjectiveFunciton, ConstantPenaltyFunction, AdaptivePenaltyFunction
 

Private Member Functions

int init (FunctionTask ft, CH_Matrix_Classes::Real funfactor, const BundleParameters *bp)
 called by the constructor; initializes the bundleinfo depending on whether as sumbundle part exists already or not
 
int set_bundle_parameters (FunctionTask ft, const BundleParameters &bp)
 sets max_bundle_size and max_model_size for this FunctionTask; this may be increased internally if the mode and/or the parent handler require this
 
int store_aggregate (FunctionTask ft)
 store the (normalized) aggregate for FunctionTask ft in its position in the bundle, potentially with forming its primal and update coeff to reflect this (the aggregate is assumed to be available in sumbundle->get_aggregate(ft), but not its primal)
 
int reassign_minorants (const CH_Matrix_Classes::Indexmatrix &map_to_old, FunctionTask ft)
 afterwars position i is held by the minorant the had position map_to_old(i) before; the current bundle size is reduced to map_to_old.dim(); More...
 
int make_model_aggregate (FunctionTask ft)
 the only change to SumBlockModel::make_model_aggregate() is that FunctionTask refers to the part for which the aggregate should be formed
 
int provide_model_aggregate (FunctionTask ft)
 see SumBlockModel::provide_model_aggregate)(, do this for this FunctionTask
 
int update_model (BundleModel::ModelUpdate model_update, CH_Matrix_Classes::Integer center_id, const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, CH_Matrix_Classes::Real model_maxviol, BundleProxObject &H, FunctionTask ft)
 updates the sumbundle even if not active for that FunctionTask; in this it tries to do the same as the parent handler bh. It stores the aggregate at the same place and provides new room at the same place; the new subgradient is not entered here but in a subsequent call to set_cand_minorant() More...
 
int eval_model (CH_Matrix_Classes::Real &lb, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y, FunctionTask ft) const
 evaluate the model value for this FunctionTask
 
CH_Matrix_Classes::Real lb_model (CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y, FunctionTask ft) const
 returns a quick lower bound for the model value for this FunctionTask
 
int contribute_new_minorants (FunctionTask ft)
 once all new minorants have been collected at this level, they are passed to the next if required for the FunctionTask
 
int remove_contributions (FunctionTask ft)
 remove valid contributions and set the states correspondingly for the FunctionTasks
 
int add_contributions (FunctionTask ft)
 add valid contributions and set the states correspondingly for the FunctionTask
 
int align_bundle (bool use_parent_update, FunctionTask ft)
 align the bundle to the parent handler bh for this FunctionTask so that contributing to it is possible
 
int align_bundle (bool use_parent_update)
 align the bundle to the parent handler bh so that conributing to it is possible
 
void clear_model (FunctionTask ft)
 first calls remove_contributions(), then discards all current models
 
void clear_aggregates (FunctionTask ft)
 first calls remove_contributions(), then discard all aggregate minorants in the current model
 

Private Attributes

SumBundlesumbundle
 this is the bundle this handler works on
 
SumBundleHandlerparent_handler
 if there is a parent sumbundle (that this might contribute to or not), this is its handler
 
const AffineFunctionTransformationaft
 use this transformation when writing back to the parent bundle
 
BundleInformationVector bundleinfo
 stores separate BundleInformation for ObjectiveFunciton, ConstantPenaltyFunction, AdaptivePenaltyFunction
 

Detailed Description

routines for updating and handling SumBundle components, possibly by cooperating over several recursive levels

On construction the handler is initialized with the sumbundle it works on with a map that informs the handler on which parts of the sumbundle it has to work on, and if so with which function factor. The bundle handler will only treat these parts and ignore the ones not listed. If it also gets a set of bundle parameters it will use this same set for all relevant parts.

The mode stored in the SumBundle (and lateron the information stored in the bundle handler) governs what the handler has to do with the sumbundle. ... Whether the bundle handler actually does something with the parts depends on the SumBundle mode root, child, inactive, and also on whether there is a SumBundleHandler of the parent model that it has to cooperate with.

Member Function Documentation

◆ add_contributions()

int ConicBundle::SumBundleHandler::add_contributions ( )

add root parts of this sumbundle to the parent's sumbundle and set the states correspondingly

If the current mode is child, nothing is done, because it is assumed that the sumbundle is already part of the parent. Thus, only root parts are considerd new and are added. This is only done, if the parenhandler accepts these kind of parts.

When a contribution is added to a parent that is currently inactive or child, any respective parent's contributions to the parent's parent are first removed and then the mode of the parent is set to root. Thus, the parent has to call add_contributions afterwards, if it still wants to contribute to its own parent.

add_contribution should only be called from SumBlockModel::sumbundle_contribution() with a normalized bundle, i.e., normalize_sumbundle() should have been called before.

Referenced by get_new_index().

◆ contribute_initial_bundle()

int ConicBundle::SumBundleHandler::contribute_initial_bundle ( FunctionTask  ft,
const MinorantBundle bundle_minorants,
const CH_Matrix_Classes::Matrix coeff 
)

(re)initialize the bundle of the respective part

This is only possible, if the handler handles a bundle for this. If not this causes an error. The main purpose is really to start the bundle on the fly if a parent starts a sumbundle in the middle of the computation. The information in coeff is assumed to yield the current aggregate.

If this bundle part has been contributed berfore (its mode is child), the contribution is first removed from the parent. Then any existing information except for the function factor is discarded and replaced by the new bundle information with the number of contributions set to 1.

If the size of primals is not zero, it must have one nonzero entry per column of minorants and all future calls via set_cand_minorant() also have to provide exactly one primal for each update.

Referenced by get_new_index().

◆ install_external_aggregate()

int ConicBundle::SumBundleHandler::install_external_aggregate ( FunctionTask  ft,
const MinorantPointer aggr,
CH_Matrix_Classes::Real  aggr_coeff 
)

replace the aggregate by one from outside

This is only possible, if the handler handles a bundle for this and the bundle is not active. The main purpose is to switch from an external model to a newly contributing sumbundle that has been updated all along but not been in use. Installing the external aggregate then ensures convergence.

If primal is not zero, it must already have one nonzero entry per column of existing minorants and all future calls via set_cand_minorant() also have to provide exactly one primal for each update.

Referenced by get_new_index().

◆ normalize_sumbundle()

int ConicBundle::SumBundleHandler::normalize_sumbundle ( )

brief bring the bundle into a normal form so that contributions may be added and subtracted consistently

The normal form has the aggregate w.r.t. to the last bundle cofficients stored in column aggr->index in scaled form so that in coeff all weight is set to it. No other columns are modified.

When add_contributions is called, it is assumed that parent bundle and contributing bundle are in this form. Some care has to be taken that this normalization is happening for parent and children in coordinated form so that remove_contribution() does not cause havoc. For this, the sumbundle should always be normalized in (or right before) calling SumBlockModel::sumbundle_contribution() before starting any interaction with the parent or the children.

Referenced by get_new_index().

◆ reassign_minorants()

int ConicBundle::SumBundleHandler::reassign_minorants ( const CH_Matrix_Classes::Indexmatrix map_to_old,
FunctionTask  ft 
)
private

afterwars position i is held by the minorant the had position map_to_old(i) before; the current bundle size is reduced to map_to_old.dim();

This also updates coeff. If a minorant appears multiple times, the value of coeff is only copied for the first occurence, later ones get value 0.; If a minorant with a positive coeff is not copied, this results in an error. Without errors sum(coeff) will keep its value. The values of aggr_index and new_index are not changed.

◆ set_cand_minorant()

int ConicBundle::SumBundleHandler::set_cand_minorant ( FunctionTask  ft,
const MinorantPointer minorant 
)

set the new minorant information of the candidate

Only one minorant can take this position. This is mainly due to that only one primal information can be associated with each minorant. Thus adding must involve compatible primals and this is easiest to guarantee if there is only one inital type at the lowest level. Contributions to parents will not care about the primals.

Referenced by get_new_index().

◆ set_parent_information()

int ConicBundle::SumBundleHandler::set_parent_information ( SumBundleHandler parent_sbh,
const AffineFunctionTransformation aft,
SumBundle::Mode  in_mode 
)

sets a parent handler, an aft and prepares for the next in_mode. If the respective pointers are null and in_mode is active, a part in child mode is changed to root.

If the parent pointer is not null, the routine calls align_bundle in order to match the existing bundle to the parent's. Therefore, if the parent pointer is not null and the parent has a positive bundle size, set_parent_information may only be called if all parts that have contributors also have a bundle containing an aggregate, i.e. they need a bundlesize of at least one.

If in_mode==root, the handler has to perpare the sumbundle to serve as root.

If in_mode==inactive, the handler has to remove any relevant contributions and to deactivate the sumbundle

If in_mode==child, the action depends on the the current mode. If the mode is child or root already, no changes are required. In particular, if the mode is root and the in_mode child is desired, this needs to be achieved later by a call to add_contributions() (once all bundle components have been collected). If the current mode is inactive, the sumbundle's mode is changed to root and again an add_contributions() will be needed to change that to child.

Referenced by get_new_index().

◆ update_model()

int ConicBundle::SumBundleHandler::update_model ( BundleModel::ModelUpdate  model_update,
CH_Matrix_Classes::Integer  center_id,
const CH_Matrix_Classes::Matrix center_y,
CH_Matrix_Classes::Integer  cand_id,
const CH_Matrix_Classes::Matrix cand_y,
CH_Matrix_Classes::Real  model_maxviol,
BundleProxObject H,
FunctionTask  ft 
)
private

updates the sumbundle even if not active for that FunctionTask; in this it tries to do the same as the parent handler bh. It stores the aggregate at the same place and provides new room at the same place; the new subgradient is not entered here but in a subsequent call to set_cand_minorant()

Whenever the sumbundle has no contributors, update_model just makes sure that the update rules of an existing parent are stored so that they can be communicated to subbundles if needed. If there is no parent, it uses the default rules to update an imaginary empty bundle and provides an imaginary location for the new information and by doing so it may enlarge the imaginary bundle.

The only situation in which a sumbundle may have a contributor but the bundlesize is zero is when a model is started. In this case the update just makes room for a first minorant which must then be added by set_cand_minorant();

Referenced by get_new_index().


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