ConicBundle
AFTModification.hxx
Go to the documentation of this file.
1 
2 
3 
4 #ifndef CONICBUNDLE_AFTMODIFICATION_HXX
5 #define CONICBUNDLE_AFTMODIFICATION_HXX
6 
7 
15 #include "Modification.hxx"
16 
17 namespace ConicBundle {
18 
22 
32 {
33 protected:
36 
41 
44 
45  mutable int preserves_id_flag;
46 
47 public:
48  //-----------------------------------------------------------------------
52 
53 
56  virtual ~AFTModification();
57 
60 
62 
63  //-----------------------------------------------------------------------
67 
68 
71  const CH_Matrix_Classes::Sparsemat* append_cols,
72  const CH_Matrix_Classes::Matrix* linear_costs)
73  {preserves_id_flag=-1;return mdf.add_append_vars(append_dim,0,0,append_cols,0,linear_costs);}
74 
77  {preserves_id_flag=-1;return mdf.add_reassign_vars(map_to_old);}
78 
82  {preserves_id_flag=-1;return mdf.add_delete_vars(del_ind,map_to_old);}
83 
86  const CH_Matrix_Classes::Sparsemat* append_rows,
87  const CH_Matrix_Classes::Matrix* append_rhs)
88  {preserves_id_flag=-1;return mdf.add_append_rows(append_dim,append_rows,append_rhs,0);}
89 
92  {preserves_id_flag=-1;return mdf.add_reassign_rows(map_to_old);}
93 
96  CH_Matrix_Classes::Indexmatrix& rows_map_to_old)
97  {preserves_id_flag=-1;return mdf.add_delete_rows(rows_del_ind,rows_map_to_old);}
98 
100  virtual int add_apply_factor(CH_Matrix_Classes::Real times_factor)
101  {if (times_factor<0.) return 1; factor*=times_factor; return 0;}
102 
105  {offset+=delta; return 0;}
106 
107 
109  int incorporate(const AFTModification& m);
110 
112 
113  //-----------------------------------------------------------------------
118 
120  int apply_to_costs(CH_Matrix_Classes::Matrix*& linear_cost) const;
121 
124  CH_Matrix_Classes::Matrix*& rhs) const;
125 
128  {f*=factor;return 0;}
129 
132  {o+=offset;return 0;}
133 
136  const CH_Matrix_Classes::Matrix &in_y,
137  const CH_Matrix_Classes::Sparsemat* arg_trafo,
138  const CH_Matrix_Classes::Matrix* arg_offset) const;
140 
141  //-----------------------------------------------------------------------
146 
148  virtual bool no_modification() const
149  { return ((offset==0)&&(factor==1.)&&(mdf.no_modification())); }
150 
152  int set_append_to_old(bool append_only)
153  {return mdf.set_append_to_old(append_only);}
155  bool append_to_old() const
156  {return mdf.append_to_old();}
157 
159  virtual bool only_scalars_change() const
160  {return mdf.no_modification();}
161 
163  virtual bool ignore_groundset_modification() const
164  {return ignore_gs_mdf;}
165 
168 
170  bool preserves_identity() const;
171 
172 
175 
178 
181  {return mdf.deleted_variables_are_zero(oldpoint);}
182 
185  {return mdf.new_variables_are_zero(newpoint);}
186 
189  const CH_Matrix_Classes::Matrix& oldpoint) const
190  {return mdf.mapped_variables_are_equal(newpoint,oldpoint);}
191 
193 
194  //-----------------------------------------------------------------------
199 
201  int get_old_vardim() const {return mdf.old_vardim();}
203  int get_new_vardim() const {return mdf.new_vardim();}
205  int get_appended_vardim() const {return mdf.appended_vardim();}
206 
208  const int* get_map_to_old_variables() const
209  {return (mdf.map_to_old_variables())==0?0:(const int*)(mdf.map_to_old_variables()->get_store());}
210 
213  {
214  const AFTModification* aftm=dynamic_cast<const AFTModification*>(&m);
215  if (aftm) return incorporate(*aftm);
216  return 1;
217  }
218 
221  {return new AFTModification(old_var_dim,old_rowdim());}
222 
224  int add_append_variables(int append_dim)
225  {return add_append_vars(CH_Matrix_Classes::Integer(append_dim),0,0);}
226 
228  virtual int add_reassign_variables(int new_dim,const int* map_to_old_indices)
229  { CH_Matrix_Classes::Indexmatrix maptoold(CH_Matrix_Classes::Integer(new_dim),1,map_to_old_indices);
230  return add_reassign_vars(maptoold);}
231 
233 
234  //-----------------------------------------------------------------------
239 
242  {return mdf.old_vardim();}
245  {return mdf.new_vardim();}
248  {return mdf.appended_vardim();}
249 
252  {return mdf.old_rowdim();}
255  {return mdf.new_rowdim();}
258  {return mdf.appended_rowdim();}
259 
262  {return mdf.map_to_old_variables();}
263 
266  {return mdf.deleted_var_indices();}
267 
270  {return mdf.new_var_indices();}
271 
274  {return mdf.map_to_old_rows();}
275 
278  {return mdf.deleted_row_indices();}
279 
282  {return mdf.new_row_indices();}
283 
286  {return offset;}
287 
290  {return factor;}
291 
294  {return mdf.get_var_append_cols();}
295 
298  {return mdf.get_var_append_costs();}
299 
302  {return mdf.get_row_append_mat();}
303 
306  {return mdf.get_row_append_rhslb();}
307 
309 
310  //-----------------------------------------------------------------------
315 
317  void set_out(std::ostream* out=0,int print_level=1)
319 
321 
322 };
323 
324 
325 
327 
328 }
329 
330 #endif
331 
const CH_Matrix_Classes::Indexmatrix * map_to_old_variables() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: AFTModification.hxx:261
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
Base class for informing oracles (or the solver) about dynamic changes in the number and sorting of t...
Definition: CBSolver.hxx:544
CH_Matrix_Classes::Real factor
multiply the factor by this value
Definition: AFTModification.hxx:38
bool no_additions_or_deletions_in_vars() const
returns true if no columns/variables were added or deleted (allows permutations), false otherwise ...
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: Modification.hxx:671
CH_Matrix_Classes::Real get_additional_factor() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: AFTModification.hxx:289
virtual bool only_scalars_change() const
returns true if linear_cost, matrix and affine rhs offset are not changed
Definition: AFTModification.hxx:159
const CH_Matrix_Classes::Matrix & apply_modified_transform(CH_Matrix_Classes::Matrix &out_y, const CH_Matrix_Classes::Matrix &in_y, const CH_Matrix_Classes::Sparsemat *arg_trafo, const CH_Matrix_Classes::Matrix *arg_offset) const
transform the vector as if the Modification had been carried out
const CH_Matrix_Classes::Sparsemat * get_var_append_cols() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: Modification.hxx:716
Modification mdf
this class provides a restricted interface to this Modification instance where all modifications are ...
Definition: AFTModification.hxx:35
const CH_Matrix_Classes::Indexmatrix * new_var_indices() const
returns null if no variables were added, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: AFTModification.hxx:269
bool append_to_old() const
returns true if this only contains appending operations and incorporating this is done with respect t...
Definition: Modification.hxx:650
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
const CH_Matrix_Classes::Indexmatrix * map_to_old_rows() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: AFTModification.hxx:273
int add_append_variables(int append_dim)
append append_dim further variables at the end of the argument vector (without specifying their effec...
Definition: AFTModification.hxx:224
int add_delete_rows(const CH_Matrix_Classes::Indexmatrix &del_ind, CH_Matrix_Classes::Indexmatrix &map_to_old)
delete the rows indexed by the vector del_ind and return the index changes of the others in a vector ...
bool ignore_gs_mdf
if *this does not explicitly change the transformation, usually the groundset modifications will be a...
Definition: AFTModification.hxx:43
const CH_Matrix_Classes::Indexmatrix * map_to_old_rows() const
returns null if there are index changes, otherwise the Indexmatrix pointed to is a vector whose i-th ...
Definition: Modification.hxx:696
const CH_Matrix_Classes::Matrix * get_append_rhs() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: AFTModification.hxx:305
const CH_Matrix_Classes::Matrix * get_row_append_rhslb() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:742
OracleModification * new_initial_oraclemodification(int old_var_dim) const
returns a new object on the heap, that allows to incorporate this but starts off from a function whos...
Definition: AFTModification.hxx:220
const CH_Matrix_Classes::Indexmatrix * deleted_var_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: AFTModification.hxx:265
const CH_Matrix_Classes::Sparsemat * get_append_cols() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: AFTModification.hxx:293
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
base class for collecting and organizing a sequence of changes to linear data so that it can be carri...
Definition: Modification.hxx:207
CH_Matrix_Classes::Integer appended_rowdim() const
returns the number of rows that are appended (due to later reassignments they may no longer be locate...
Definition: Modification.hxx:680
int add_offset(CH_Matrix_Classes::Real delta)
add to the currecnt offset the value delta
Definition: AFTModification.hxx:104
int apply_to_offset(CH_Matrix_Classes::Real &o) const
add to o the offset
Definition: AFTModification.hxx:131
int add_reassign_rows(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the current row indices (with modifications) as specified by map_to_old
virtual int add_reassign_variables(int new_dim, const int *map_to_old_indices)
reorder and resize the variables as given by the first new_dim entries of map_to_old_indices; each fo...
Definition: AFTModification.hxx:228
bool new_variables_are_zero(const CH_Matrix_Classes::Matrix &newpoint) const
returns true if all entries in newpoint (must be a vector of length new_vardim()) that correspond to ...
int add_append_rows(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Sparsemat *append_rows, const CH_Matrix_Classes::Matrix *append_rhs)
append append_dim new rows as in append_rows (if NULL, use default value) with affine offset append_r...
Definition: AFTModification.hxx:85
const CH_Matrix_Classes::Sparsemat * get_append_rows() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: AFTModification.hxx:301
const CH_Matrix_Classes::Indexmatrix * map_to_old_variables() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: Modification.hxx:684
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
CH_Matrix_Classes::Real offset
add this value to the offset
Definition: AFTModification.hxx:40
bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if all entries deleted in oldpoint (must be a vector of length old_vardim()) are 0 and f...
bool new_variables_are_zero(const CH_Matrix_Classes::Matrix &newpoint) const
returns true if all entries in newpoint (must be a vector of length new_vardim()) that correspond to ...
Definition: AFTModification.hxx:184
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
int add_delete_vars(const CH_Matrix_Classes::Indexmatrix &del_ind, CH_Matrix_Classes::Indexmatrix &map_to_old)
delete the variables indexed by the vector del_ind and return the index changes of the others in a ve...
int incorporate(const AFTModification &m)
incorporate the AFTModification m into this one; after factor and offset are dealt with it calls Modi...
bool append_to_old() const
returns true if this only contains appending operations and incorporating this is done with respect t...
Definition: AFTModification.hxx:155
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: Modification.hxx:669
Header declaring the class ConicBundle::ModificationBase.
int add_reassign_rows(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the rows as given in map_to_old, calls Modification::add_reassign_vars
Definition: AFTModification.hxx:91
CH_Matrix_Classes::Integer appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: Modification.hxx:673
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: AFTModification.hxx:241
const CH_Matrix_Classes::Sparsemat * get_row_append_mat() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: Modification.hxx:739
CH_Matrix_Classes::Integer old_rowdim() const
returns the number of rows before modification (given on initialization)
Definition: AFTModification.hxx:251
const CH_Matrix_Classes::Matrix * get_var_append_costs() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:736
int apply_to_costs(CH_Matrix_Classes::Matrix *&linear_cost) const
carry out the collected modifications on the given vector by calling Modification::apply_to_vars ...
CH_Matrix_Classes::Integer appended_rowdim() const
returns the number of rows that are appended (due to later reassignments they may no longer be locate...
Definition: AFTModification.hxx:257
bool no_additions_or_deletions_in_rows() const
returns true if no rows were added or deleted (allows permutations), false otherwise ...
int add_reassign_vars(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the current variable indices (with modifications) as specified by map_to_old ...
bool mapped_variables_are_equal(const CH_Matrix_Classes::Matrix &newpoint, const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if the values in newpoint (must be a vector of length new_vardim()) that correspond to o...
Definition: AFTModification.hxx:188
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...
virtual int add_apply_factor(CH_Matrix_Classes::Real times_factor)
multiply the current factor by the value times_factor (>=0, returns 1 if <0.)
Definition: AFTModification.hxx:100
virtual bool groundset_changes_suffice_for_identity()
returns true if for an AFT with argtrafo==0 the changes in the ground set reflect all modifications ...
const CH_Matrix_Classes::Indexmatrix * new_row_indices() const
returns null if no rows were added, otherwise the Indexmatrix pointed ato is a vector holding the new...
Definition: Modification.hxx:704
const CH_Matrix_Classes::Indexmatrix * deleted_row_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: Modification.hxx:700
int set_append_to_old(bool append_only)
if set to true, no deletions/reassignments may be present or specified in the future, only appensions are allowed
collects modifications for an AffineFunctionTransformation for the scaling and offset constants as we...
Definition: AFTModification.hxx:31
CH_Matrix_Classes::Real get_additional_offset() const
returns the value to be added to the offset
Definition: AFTModification.hxx:285
int apply_to_rows(CH_Matrix_Classes::Sparsemat *&rows, CH_Matrix_Classes::Matrix *&rhs) const
carry out the collected modifications on the given data by calling Modification::apply_to_rows (with ...
Matrix class for real values of type Real
Definition: matrix.hxx:74
const CH_Matrix_Classes::Matrix * get_append_costs() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: AFTModification.hxx:297
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
int add_delete_vars(const CH_Matrix_Classes::Indexmatrix &del_ind, CH_Matrix_Classes::Indexmatrix &map_to_old)
delete the variables indexed by del_ind; for each new index map_to_old returns the old one; calls Mod...
Definition: AFTModification.hxx:80
Matrix class of sparse matrices with real values of type Real
Definition: sparsmat.hxx:74
int get_appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: AFTModification.hxx:205
const CH_Matrix_Classes::Indexmatrix * new_row_indices() const
returns null if no variables were added, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: AFTModification.hxx:281
virtual bool no_modification() const
returns true if no modifications need to be executed
Definition: AFTModification.hxx:148
const int * get_map_to_old_variables() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: AFTModification.hxx:208
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: AFTModification.hxx:244
int print_level
nonnegative level of output, 0 should mean WARNINGS and ERRORS only, 1 should represent normal output...
Definition: CBout.hxx:37
virtual bool ignore_groundset_modification() const
returns true if groundset_modifications should be ignored
Definition: AFTModification.hxx:163
const CH_Matrix_Classes::Indexmatrix * deleted_var_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: Modification.hxx:688
int add_reassign_vars(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the variables/columns as given in map_to_old, calls Modification::add_reassign_vars ...
Definition: AFTModification.hxx:76
int add_append_vars(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Sparsemat *append_cols, const CH_Matrix_Classes::Matrix *linear_costs)
append append_dim new variables/columns with values specified by append_cols (NULL: default value) an...
Definition: AFTModification.hxx:70
bool no_modification() const
returns true if no modifications need to be executed
bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if all entries deleted in oldpoint (must be a vector of length old_vardim()) are 0...
Definition: AFTModification.hxx:180
Integer * get_store()
returns the current address of the internal value array; use cautiously, do not use delete! ...
Definition: indexmat.hxx:427
int preserves_id_flag
for lazy evaulation, -1 if not yet determined, 0 if false, 1 if true
Definition: AFTModification.hxx:45
CH_Matrix_Classes::Integer old_rowdim() const
returns the number of rows before modification (given on initialization)
Definition: Modification.hxx:676
int add_delete_rows(const CH_Matrix_Classes::Indexmatrix &rows_del_ind, CH_Matrix_Classes::Indexmatrix &rows_map_to_old)
delete the rows indexed by rows_del_ind; for each new index rows_map_to_old returns the old one; call...
Definition: AFTModification.hxx:95
CH_Matrix_Classes::Integer new_rowdim() const
returns the number of rows once all stored modifications have been performed
Definition: AFTModification.hxx:254
int set_append_to_old(bool append_only)
if set to true, no deletions/reassignments may be present or specified in the future, only appensions are allowed
Definition: AFTModification.hxx:152
int add_append_rows(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Sparsemat *append_rows, const CH_Matrix_Classes::Matrix *append_rhslb, const CH_Matrix_Classes::Matrix *append_rhsub)
append information on new rows at the respective ends
const CH_Matrix_Classes::Indexmatrix * new_var_indices() const
returns null if no variables were added, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: Modification.hxx:692
const CH_Matrix_Classes::Indexmatrix * deleted_row_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: AFTModification.hxx:277
int incorporate(const OracleModification &m)
incorporate the OracleModification m (it should only contain variable changes, but this is not checke...
Definition: AFTModification.hxx:212
int get_new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: AFTModification.hxx:203
CH_Matrix_Classes::Integer appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: AFTModification.hxx:247
bool preserves_identity() const
returns true if the modifications are consistent with the AffineFunctionTransformation matrix staying...
int apply_to_factor(CH_Matrix_Classes::Real &f) const
multiply f by the factor
Definition: AFTModification.hxx:127
void set_out(std::ostream *out=0, int print_level=1)
see CBout::set_out
Definition: AFTModification.hxx:317
int add_append_vars(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Matrix *append_lb, const CH_Matrix_Classes::Matrix *append_ub, const CH_Matrix_Classes::Sparsemat *append_cols, const CH_Matrix_Classes::Matrix *append_start_val, const CH_Matrix_Classes::Matrix *append_linear_costs)
append information on new variables at the respective ends
void clear(CH_Matrix_Classes::Integer var_olddim, CH_Matrix_Classes::Integer row_olddim)
reset modifications to an unmodified object currently having var_olddim columns and row_olddim rows...
bool mapped_variables_are_equal(const CH_Matrix_Classes::Matrix &newpoint, const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if the values in newpoint (must be a vector of length new_vardim()) that correspond to o...
CH_Matrix_Classes::Integer new_rowdim() const
returns the number of rows once all stored modifications have been performed
Definition: Modification.hxx:678
AFTModification(CH_Matrix_Classes::Integer var_olddim=0, CH_Matrix_Classes::Integer row_olddim=0, bool ignore_groundset_modification=false)
initialize and reset to an unmodified object currently having var_olddim columns and row_olddim rows ...
int get_old_vardim() const
returns the number of variables before modification
Definition: AFTModification.hxx:201