ConicBundle
PSCAffineModification.hxx
Go to the documentation of this file.
1 
2 
3 
4 #ifndef CONICBUNDLE_PSCAffineMODIFICATION_HXX
5 #define CONICBUNDLE_PSCAffineMODIFICATION_HXX
6 
7 
15 #include <map>
16 #include "CBout.hxx"
17 #include "CBSolver.hxx"
18 #include "SparseCoeffmatMatrix.hxx"
19 #include "ModificationBase.hxx"
20 
21 namespace ConicBundle {
22 
23  class PSCPrimal;
24 
29 
30 
31 
96 {
97 private:
98 
101 
102 
103  //first execute the changes in the variables then in the constrains
104 
105  //------ changes in variable space
106  //first carry out the append step, afterwards the delete/reassign step
107 
108  //-----------------------------------------------------------------------
112 
117 
120 
123 
130 
132 
133  //------ changes in the block (the rows)
134  //first carry out the append step, afterwards the reassign/delete step
135 
136  //-----------------------------------------------------------------------
140 
145 
158 
160 
161  //-----------------------------------------------------------------------
165  bool reset_primal;
171 
173 
174 public:
175 
176  //-----------------------------------------------------------------------
180 
182  virtual ~PSCAffineModification();
183 
184 
187  const CH_Matrix_Classes::Indexmatrix& block_olddim,
188  const CBout* cb=0,int incr=0);
189 
217  int clear(CH_Matrix_Classes::Integer var_olddim,
218  const CH_Matrix_Classes::Indexmatrix& block_olddim);
219 
221 
222  //-----------------------------------------------------------------------
226 
227 
242  const SparseCoeffmatMatrix* append_cols);
243 
254  int add_reassign_vars(const CH_Matrix_Classes::Indexmatrix& map_to_old);
255 
268  CH_Matrix_Classes::Indexmatrix& map_to_old);
269 
270 
271 
272 
293  const SparseCoeffmatMatrix* append_offsets,
294  const SparseCoeffmatMatrix* append_blocks);
295 
308 
321  CH_Matrix_Classes::Indexmatrix& map_to_old);
322 
323 
333  int add_reset_generating_primal(PSCPrimal* new_generating_primal);
334 
338  int set_skip_extension(bool skip);
339 
341 
342  //-----------------------------------------------------------------------
347 
375 
377 
378  //-----------------------------------------------------------------------
383 
385  bool no_modification() const;
387  int set_append_to_old(bool append_only);
389  bool append_to_old() const
390  {return append_only;}
392  bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix& oldpoint,const SparseCoeffmatMatrix& oldmat) const;
394  bool new_variables_are_zero(const CH_Matrix_Classes::Matrix& newpoint,const SparseCoeffmatMatrix& newmat) const;
397  const CH_Matrix_Classes::Matrix& oldpoint) const;
400  {return ((var_append_dim>0)||(var_map_to_old));}
402  bool block_modifications() const
403  {return ((block_append_dim.dim()>0)||(block_map_to_old));}
404 
406 
407  //-----------------------------------------------------------------------
412 
419 
426 
427 
430  {return var_map_to_old;}
431 
434  {return var_del_ind;}
435 
438  {return var_new_ind;}
439 
442  {return block_map_to_old;}
443 
446  {return block_del_ind;}
447 
450  {return block_new_ind;}
451 
454  {return var_append;}
457  {return block_append;}
460  {return offset_append;}
462  bool get_reset_primal() const
463  {return reset_primal;}
466  {return generating_primal;}
467 
469  bool get_skip_extension() const
470  {return skip_extension;}
471 
473 
474 
475  //-----------------------------------------------------------------------
480 
482  int get_old_vardim() const {return old_vardim();}
484  int get_new_vardim() const {return new_vardim();}
486  int get_appended_vardim() const {return appended_vardim();}
487 
489  const int* get_map_to_old_variables() const
490  {return (map_to_old_variables())==0?0:(const int*)(map_to_old_variables()->get_store());}
491 
507  int incorporate(const OracleModification& m);
508 
511  {return new PSCAffineModification(CH_Matrix_Classes::Integer(old_var_dim),block_olddim,this,0);}
512 
514  int add_append_variables(int append_dim)
515  {return add_append_vars(CH_Matrix_Classes::Integer(append_dim),0);}
516 
518  virtual int add_reassign_variables(int new_dim,const int* map_to_old_indices)
519  { CH_Matrix_Classes::Indexmatrix maptoold(CH_Matrix_Classes::Integer(new_dim),1,map_to_old_indices);
520  return add_reassign_vars(maptoold);}
521 
523 
524  //-----------------------------------------------------------------------
529 
531  void set_cbout(const CBout* out,int incr=-1)
532  {CBout::set_cbout(out,incr);var_append.set_cbout(this);block_append.set_cbout(this);}
533 
535  void set_out(std::ostream* out=0,int print_level=1)
537 
539 
540 };
541 
542 
543 
544 
545 
547 
548 }
549 
550 #endif
551 
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::Integer var_newdim
number (or dimension) of variables after all listed modifications have been applied ...
Definition: PSCAffineModification.hxx:116
const SparseCoeffmatMatrix & get_offset_append() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: PSCAffineModification.hxx:459
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...
int add_append_blocks(const CH_Matrix_Classes::Indexmatrix &append_dim, const SparseCoeffmatMatrix *append_offsets, const SparseCoeffmatMatrix *append_blocks)
append information on new rows at the respective ends
SparseCoeffmatMatrix var_append
columns to be appended for these new variables
Definition: PSCAffineModification.hxx:122
CH_Matrix_Classes::Indexmatrix * var_map_to_old
the variables are rearranged so that the new index i had previously (after additions and before delet...
Definition: PSCAffineModification.hxx:127
CH_Matrix_Classes::Integer var_olddim
initial number (or dimension) of variables
Definition: PSCAffineModification.hxx:114
bool new_variables_are_zero(const CH_Matrix_Classes::Matrix &newpoint, const SparseCoeffmatMatrix &newmat) const
returns true if for all indices of new variables the entries in newpoint (must be a vector of length ...
int incorporate(const OracleModification &m)
add the modification specified in m on top of the modifications collected so far
PSCPrimal * generating_primal
primal to reset to
Definition: PSCAffineModification.hxx:168
bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix &oldpoint, const SparseCoeffmatMatrix &oldmat) const
returns true if all entries deleted in oldpoint (must be a vector of length old_vardim()) or the corr...
int add_reassign_blocks(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the current row indices (with modifications) as specified by map_to_old
CH_Matrix_Classes::Indexmatrix * var_del_ind
indices of variables that will be deleted by the reassignment of indices by map_to_old after all addi...
Definition: PSCAffineModification.hxx:125
const SparseCoeffmatMatrix & get_block_append() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: PSCAffineModification.hxx:456
class for collecting and organizing a sequence of changes to block diagonal symmetric affine matrix f...
Definition: PSCAffineModification.hxx:95
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
int add_append_vars(CH_Matrix_Classes::Integer append_dim, const SparseCoeffmatMatrix *append_cols)
append information on new variables at the respective ends
CH_Matrix_Classes::Indexmatrix * block_new_ind
in the end the appended new rows have these positions
Definition: PSCAffineModification.hxx:157
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: PSCAffineModification.hxx:418
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
const CH_Matrix_Classes::Indexmatrix & appended_blockdim() const
returns the number of rows that are appended (due to later reassignments they may no longer be locate...
Definition: PSCAffineModification.hxx:425
PSCAffineModification(CH_Matrix_Classes::Integer var_olddim, const CH_Matrix_Classes::Indexmatrix &block_olddim, const CBout *cb=0, int incr=0)
calls clear() with these parameters
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: PSCAffineModification.hxx:416
bool block_modifications() const
returns true if some modifications are performed on the block structure
Definition: PSCAffineModification.hxx:402
bool get_skip_extension() const
returns true if the generating primal is to be replaced by the one stored here
Definition: PSCAffineModification.hxx:469
CH_Matrix_Classes::Integer var_append_dim
number of variables appended
Definition: PSCAffineModification.hxx:119
const CH_Matrix_Classes::Indexmatrix * deleted_block_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: PSCAffineModification.hxx:445
basic routines for the base classes for reorganizing maps
Definition: ModificationBase.hxx:28
bool get_reset_primal() const
returns true if the generating primal is to be replaced by the one stored here
Definition: PSCAffineModification.hxx:462
int add_reset_generating_primal(PSCPrimal *new_generating_primal)
replace the current generating primal by new_generating_primal (on the heap, will be deleted here)...
SparseCoeffmatMatrix block_append
rows to be appended;
Definition: PSCAffineModification.hxx:151
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
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: PSCAffineModification.hxx:518
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
stores/organizes the CoeffmatPointer pointers to Coeffmat matrices with the purpose of describing the...
Definition: SparseCoeffmatMatrix.hxx:50
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: PSCAffineModification.hxx:429
int add_delete_blocks(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 ...
Header declaring the classes ConicBundle::CBSolver, ConicBundle::FunctionOracle and ConicBundle::Prim...
int add_append_variables(int append_dim)
append append_dim further variables at the end of the argument vector (without specifying their effec...
Definition: PSCAffineModification.hxx:514
bool append_to_old() const
returns true if this only contains appending operations and incorporating this is done with respect t...
Definition: PSCAffineModification.hxx:389
void set_cbout(const CBout *out, int incr=-1)
see CBout::set_cbout
Definition: PSCAffineModification.hxx:531
Header declaring the output class CBout.
int apply_to_PSCAffine(SparseCoeffmatMatrix *offset, SparseCoeffmatMatrix *matrix) const
carry out the collected modifications on the data describing the PSCAffineFunction ...
const CH_Matrix_Classes::Indexmatrix & new_blockdim() const
returns the number of rows once all stored modifications have been performed
Definition: PSCAffineModification.hxx:423
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...
SparseCoeffmatMatrix offset_append
offset blocks to be appended;
Definition: PSCAffineModification.hxx:149
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...
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: PSCAffineModification.hxx:510
Matrix class for real values of type Real
Definition: matrix.hxx:74
bool append_only
if true, only appending operations are allowed and incorporating this has a different effect ...
Definition: PSCAffineModification.hxx:100
const CH_Matrix_Classes::Indexmatrix * map_to_old_blocks() const
returns null if there are index changes, otherwise the Indexmatrix pointed to is a vector whose i-th ...
Definition: PSCAffineModification.hxx:441
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
CH_Matrix_Classes::Indexmatrix block_newdim
number of blocks and their dimension after all listed modifications have been applied ...
Definition: PSCAffineModification.hxx:144
CH_Matrix_Classes::Indexmatrix block_append_dim
number of blocks appended with their dimension
Definition: PSCAffineModification.hxx:147
const CH_Matrix_Classes::Indexmatrix & old_blockdim() const
returns the number of rows before modification (given on initialization)
Definition: PSCAffineModification.hxx:421
int print_level
nonnegative level of output, 0 should mean WARNINGS and ERRORS only, 1 should represent normal output...
Definition: CBout.hxx:37
int clear(CH_Matrix_Classes::Integer var_olddim, const CH_Matrix_Classes::Indexmatrix &block_olddim)
resets all variables so that the object to be modified has starting size var_olddim (number of variab...
CH_Matrix_Classes::Indexmatrix * var_new_ind
in the end the appended new variables have these positions
Definition: PSCAffineModification.hxx:129
Integer * get_store()
returns the current address of the internal value array; use cautiously, do not use delete! ...
Definition: indexmat.hxx:427
Header declaring the classes ConicBundle::SparseCoeffmatMatrix (needed for ConicBundle::PSCAffineFunc...
int set_skip_extension(bool skip)
if this time no extension is possible for newly added variables with the availabel generating primal...
CH_Matrix_Classes::Indexmatrix block_olddim
initial number of blocks and their dimension
Definition: PSCAffineModification.hxx:142
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: PSCAffineModification.hxx:489
const CH_Matrix_Classes::Indexmatrix * new_block_indices() const
returns null if no rows were added, otherwise the Indexmatrix pointed ato is a vector holding the new...
Definition: PSCAffineModification.hxx:449
int get_new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: PSCAffineModification.hxx:484
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: PSCAffineModification.hxx:437
const SparseCoeffmatMatrix & get_var_append() const
returns null if nothing or default values have to be appended, otherwise it points to a sparse matrix...
Definition: PSCAffineModification.hxx:453
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: PSCAffineModification.hxx:414
void dim(Integer &_nr, Integer &_nc) const
returns the number of rows in _nr and the number of columns in _nc
Definition: indexmat.hxx:315
bool variable_modifications() const
returns true if some modifications are performed on the block structure
Definition: PSCAffineModification.hxx:399
int get_appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: PSCAffineModification.hxx:486
bool skip_extension
if set to true, no extension is performed on newly added variables
Definition: PSCAffineModification.hxx:170
void set_out(std::ostream *out=0, int print_level=1)
see CBout::set_out
Definition: PSCAffineModification.hxx:535
int get_old_vardim() const
returns the number of variables before modification
Definition: PSCAffineModification.hxx:482
const PSCPrimal * get_generating_primal() const
returns the generating primal pointer stored here (may be NULL); if get_reset_primal() is true...
Definition: PSCAffineModification.hxx:465
bool no_modification() const
returns true if no modifications need to be executed
CH_Matrix_Classes::Indexmatrix * block_map_to_old
the rows are rearranged so that the new index i had previously (after additions and before deletions)...
Definition: PSCAffineModification.hxx:155
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: PSCAffineModification.hxx:433
PSCPrimal is the corresponding positive semidefinite object for PSCOracle like PrimalMatrix for a Mat...
Definition: PSCPrimal.hxx:46
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 ...
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.
CH_Matrix_Classes::Indexmatrix * block_del_ind
indices of rows that will be deleted by the reassignment of indices by map_to_old after all additions...
Definition: PSCAffineModification.hxx:153