ConicBundle
Modification.hxx
Go to the documentation of this file.
1 
2 
3 
4 #ifndef CONICBUNDLE_MODIFICATION_HXX
5 #define CONICBUNDLE_MODIFICATION_HXX
6 
7 
15 #include <map>
16 #include "ModificationBase.hxx"
17 #include "CBSolver.hxx"
18 #include "sparsmat.hxx"
19 
20 namespace ConicBundle {
21 
117 
208 {
209 private:
211  typedef std::map<CH_Matrix_Classes::Integer,CH_Matrix_Classes::Real> Realmap;
212 
215 
216  //first execute the changes in the variables then in the constrains
217 
218  //------ changes in variable space
219  //first carry out the append step, afterwards the delete/reassign step, finally the bound changes
220 
221  //-----------------------------------------------------------------------
225 
230 
232  Realmap* var_set_lb;
234  Realmap* var_set_ub;
253 
255 
256  //------ changes in row space
257  //first carry out the append step, afterwards the reassign/delete step
258 
259  //-----------------------------------------------------------------------
263 
268 
270  Realmap* row_set_rhslb;
272  Realmap* row_set_rhsub;
287 
289 
290  //-----------------------------------------------------------------------
302 
303 
304 
305 public:
306 
307  //-----------------------------------------------------------------------
311 
313  virtual ~Modification();
314 
315 
318  CH_Matrix_Classes::Integer row_olddim,
319  const CBout* cb=0,
320  int incr=-1,
321  bool ensure_start_val_box_feasibility=false,
322  bool ensure_bounds_consistency=true,
323  CH_Matrix_Classes::Real start_val_def=0.,
324  CH_Matrix_Classes::Real bounds_minus_infty=CB_minus_infinity,
325  CH_Matrix_Classes::Real bounds_plus_infty=CB_plus_infinity,
328  CH_Matrix_Classes::Real cost_def=0.);
329 
357  int clear(CH_Matrix_Classes::Integer var_olddim,
358  CH_Matrix_Classes::Integer row_olddim,
359  bool ensure_start_val_box_feasibility=false,
360  bool ensure_bounds_consistency=true,
361  CH_Matrix_Classes::Real start_val_def=0.,
362  CH_Matrix_Classes::Real bounds_minus_infty=CB_minus_infinity,
363  CH_Matrix_Classes::Real bounds_plus_infty=CB_plus_infinity,
366  CH_Matrix_Classes::Real cost_def=0.);
367 
369 
370  //-----------------------------------------------------------------------
374 
382 
390 
436  const CH_Matrix_Classes::Matrix* append_lb,
437  const CH_Matrix_Classes::Matrix* append_ub,
438  const CH_Matrix_Classes::Sparsemat* append_cols,
439  const CH_Matrix_Classes::Matrix* append_start_val,
440  const CH_Matrix_Classes::Matrix* append_linear_costs);
441 
452  int add_reassign_vars(const CH_Matrix_Classes::Indexmatrix& map_to_old);
453 
466  CH_Matrix_Classes::Indexmatrix& map_to_old);
467 
468 
469 
477 
485 
509  const CH_Matrix_Classes::Sparsemat* append_rows,
510  const CH_Matrix_Classes::Matrix* append_rhslb,
511  const CH_Matrix_Classes::Matrix* append_rhsub);
512 
524  int add_reassign_rows(const CH_Matrix_Classes::Indexmatrix& map_to_old);
525 
538  CH_Matrix_Classes::Indexmatrix& map_to_old);
539 
550  virtual int incorporate(const Modification& m);
551 
553 
554  //-----------------------------------------------------------------------
559 
595  CH_Matrix_Classes::Matrix* cost) const;
596 
635  CH_Matrix_Classes::Matrix* rhsub) const;
636 
638 
639  //-----------------------------------------------------------------------
644 
646  bool no_modification() const;
648  int set_append_to_old(bool append_only);
650  bool append_to_old() const
651  {return append_only;}
653  bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix& oldpoint) const;
655  bool new_variables_are_zero(const CH_Matrix_Classes::Matrix& newpoint) const;
658  const CH_Matrix_Classes::Matrix& oldpoint) const;
659 
661 
662  //-----------------------------------------------------------------------
667 
674 
681 
682 
685  {return var_map_to_old;}
686 
689  {return var_del_ind;}
690 
693  {return var_new_ind;}
694 
697  {return row_map_to_old;}
698 
701  {return row_del_ind;}
702 
705  {return row_new_ind;}
706 
708  const std::map<CH_Matrix_Classes::Integer,CH_Matrix_Classes::Real>*
710  {return var_set_lb;}
712  const std::map<CH_Matrix_Classes::Integer,CH_Matrix_Classes::Real>*
714  {return var_set_ub;}
717  {return var_append_cols;}
720  {return var_append_lb;}
723  {return var_append_ub;}
726  {return var_start_val;}
728  const std::map<CH_Matrix_Classes::Integer,CH_Matrix_Classes::Real>*
730  {return row_set_rhslb;}
732  const std::map<CH_Matrix_Classes::Integer,CH_Matrix_Classes::Real>*
734  {return row_set_rhsub;}
737  {return var_append_costs;}
740  {return row_append_mat;}
743  {return row_append_rhslb;}
746  {return row_append_rhsub;}
747 
749 
750 };
751 
752 
753 
754 
755 
757 
758 }
759 
760 #endif
761 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
int add_set_ub(CH_Matrix_Classes::Integer ind, CH_Matrix_Classes::Real ub)
set the upper bound on variable with index ind to value ub
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::Indexmatrix * row_new_ind
in the end the appended new rows have these positions
Definition: Modification.hxx:286
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: Modification.hxx:250
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
const std::map< CH_Matrix_Classes::Integer, CH_Matrix_Classes::Real > * get_var_set_lb() const
returns null if no variable lower bounds change, otherwise it points to the map holding the (index...
Definition: Modification.hxx:709
const std::map< CH_Matrix_Classes::Integer, CH_Matrix_Classes::Real > * get_var_set_ub() const
returns null if no variable upper bounds change, otherwise it points to the map holding the (index...
Definition: Modification.hxx:713
CH_Matrix_Classes::Real bounds_minus_infinity
default value for variable lower bounds, default CB_minus_infinity, must be not greater than bounds_p...
Definition: Modification.hxx:297
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
CH_Matrix_Classes::Sparsemat * var_append_cols
columns to be appended for these new variables; if NULL, use zero
Definition: Modification.hxx:242
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
const std::map< CH_Matrix_Classes::Integer, CH_Matrix_Classes::Real > * get_row_set_rhsub() const
returns null if no right hand side upper bounds change, otherwise it points to the map holding the (i...
Definition: Modification.hxx:733
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 ...
Realmap * var_set_lb
first set selected new values in variable lower bounds; if NULL there are no changes ...
Definition: Modification.hxx:232
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
CH_Matrix_Classes::Integer var_newdim
number of variables after all listed modifications have been applied
Definition: Modification.hxx:229
CH_Matrix_Classes::Matrix * row_append_rhsub
new upper bound on rhs values for these new rows; if NULL, use CB_plus_infintiy
Definition: Modification.hxx:280
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
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
bool append_only
if true, only appending operations are allowed and incorporating this has a different effect ...
Definition: Modification.hxx:214
CH_Matrix_Classes::Indexmatrix * var_new_ind
in the end the appended new variables have these positions
Definition: Modification.hxx:252
CH_Matrix_Classes::Real rhs_plus_infinity
default value for right hand side upper bound, default CB_plus_infinity, must be not smaller than rhs...
Definition: Modification.hxx:300
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
CH_Matrix_Classes::Integer var_olddim
initial number of variables
Definition: Modification.hxx:227
bool enforce_bounds_consistency
produce errors if bounds cause infeasibilities when used in apply_to_vars(), default true ...
Definition: Modification.hxx:294
int apply_to_rows(CH_Matrix_Classes::Sparsemat *rows, CH_Matrix_Classes::Matrix *rhslb, CH_Matrix_Classes::Matrix *rhsub) const
carry out the collected modifications on the given vectors
basic routines for the base classes for reorganizing maps
Definition: ModificationBase.hxx:28
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 ...
CH_Matrix_Classes::Integer var_append_dim
number of variables appended
Definition: Modification.hxx:236
Realmap * var_set_ub
and set selected new values in variable upper bounds; if NULL there are no changes ...
Definition: Modification.hxx:234
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 cost_default
default value for costs, default 0.
Definition: Modification.hxx:301
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...
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...
const std::map< CH_Matrix_Classes::Integer, CH_Matrix_Classes::Real > * get_row_set_rhslb() const
returns null if no right hand side lower bounds change, otherwise it points to the map holding the (i...
Definition: Modification.hxx:729
int add_set_rhsub(CH_Matrix_Classes::Integer ind, CH_Matrix_Classes::Real rhsub)
set the upper bound on row right hand side with index ind to value rhsub
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: Modification.hxx:669
int apply_to_vars(CH_Matrix_Classes::Matrix *vars, CH_Matrix_Classes::Matrix *lb, CH_Matrix_Classes::Matrix *ub, CH_Matrix_Classes::Matrix *cost) const
carry out the collected modifications on the given vectors
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::Matrix * var_append_ub
upper bounds on appended variables; if NULL, use CB_plus_infinity
Definition: Modification.hxx:240
bool enforce_start_val_box_feasibility
produce errors if given starting values violate bounds; in apply_to_vars() project default values ont...
Definition: Modification.hxx:295
Header declaring the classes ConicBundle::CBSolver, ConicBundle::FunctionOracle and ConicBundle::Prim...
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
int clear(CH_Matrix_Classes::Integer var_olddim, CH_Matrix_Classes::Integer row_olddim, bool ensure_start_val_box_feasibility=false, bool ensure_bounds_consistency=true, CH_Matrix_Classes::Real start_val_def=0., CH_Matrix_Classes::Real bounds_minus_infty=CB_minus_infinity, CH_Matrix_Classes::Real bounds_plus_infty=CB_plus_infinity, CH_Matrix_Classes::Real rhs_minus_infty=CB_minus_infinity, CH_Matrix_Classes::Real rhs_plus_infty=CB_plus_infinity, CH_Matrix_Classes::Real cost_def=0.)
resets all variables so that the object to be modified has starting size var_olddim (number of variab...
const CH_Matrix_Classes::Matrix * get_var_append_lb() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:719
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
CH_Matrix_Classes::Real rhs_minus_infinity
default value for right hand side lower bound, default CB_minus_infinity, must be not greater than rh...
Definition: Modification.hxx:299
CH_Matrix_Classes::Integer row_newdim
number of rows after all listed modifications have been applied
Definition: Modification.hxx:267
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 ...
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: Modification.hxx:248
CH_Matrix_Classes::Indexmatrix * row_map_to_old
the rows are rearranged so that the new index i had previously (after additions and before deletions)...
Definition: Modification.hxx:284
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
int add_set_rhslb(CH_Matrix_Classes::Integer ind, CH_Matrix_Classes::Real rhslb)
set the lower bound on row right hand side with index ind to value rhslb
CH_Matrix_Classes::Matrix * var_append_lb
lower bounds on appended variables; if NULL, use CB_minus_infinity
Definition: Modification.hxx:238
const double CB_minus_infinity
serves as the value "plus infinity", i.e., all bounds >= this value are set to this value and are reg...
CH_Matrix_Classes::Matrix * var_append_costs
linear costs for appended variables; if NULL, use zero
Definition: Modification.hxx:246
const CH_Matrix_Classes::Matrix * get_var_start_val() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:725
Matrix class for real values of type Real
Definition: matrix.hxx:74
CH_Matrix_Classes::Integer row_append_dim
number of rows appended
Definition: Modification.hxx:274
Matrix class of sparse matrices with real values of type Real
Definition: sparsmat.hxx:74
CH_Matrix_Classes::Real start_val_default
default value for starting point, default 0.
Definition: Modification.hxx:296
const CH_Matrix_Classes::Matrix * get_var_append_ub() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:722
const double CB_plus_infinity
serves as the value "minus infinity", i.e., all bounds <= this value are set to this value and are re...
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
bool no_modification() const
returns true if no modifications need to be executed
CH_Matrix_Classes::Matrix * var_start_val
starting values for appended variables; if NULL, use the projection of 0 on [lb,ub] ...
Definition: Modification.hxx:244
CH_Matrix_Classes::Integer old_rowdim() const
returns the number of rows before modification (given on initialization)
Definition: Modification.hxx:676
int add_set_lb(CH_Matrix_Classes::Integer ind, CH_Matrix_Classes::Real lb)
set the lower bound on variable with index ind to value lb
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
CH_Matrix_Classes::Integer row_olddim
initial number of rows
Definition: Modification.hxx:265
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
Realmap * row_set_rhslb
first set selected new values in rhs lower bounds; if NULL there are no changes
Definition: Modification.hxx:270
CH_Matrix_Classes::Sparsemat * row_append_mat
rows to be appended as these new rows; if NULL, use zero
Definition: Modification.hxx:276
CH_Matrix_Classes::Matrix * row_append_rhslb
new lower bound on rhs values for these new rows; if NULL, use CB_minus_inifinity ...
Definition: Modification.hxx:278
CH_Matrix_Classes::Real bounds_plus_infinity
default value for variable upper bounds, default CB_plus_infinity, must be not smaller than bounds_mi...
Definition: Modification.hxx:298
CH_Matrix_Classes::Indexmatrix * row_del_ind
indices of rows that will be deleted by the reassignment of indices by map_to_old after all additions...
Definition: Modification.hxx:282
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
Realmap * row_set_rhsub
and set selected new values in rhs upper bounds; if NULL there are no changes
Definition: Modification.hxx:272
Header declaring the class CH_Matrix_Classes::Sparsemat for sparse matrices with Real elements...
virtual int incorporate(const Modification &m)
add the modification specified in m on top of the modifications collected so far
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
const CH_Matrix_Classes::Matrix * get_row_append_rhsub() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:745
Modification(CH_Matrix_Classes::Integer var_olddim, CH_Matrix_Classes::Integer row_olddim, const CBout *cb=0, int incr=-1, bool ensure_start_val_box_feasibility=false, bool ensure_bounds_consistency=true, CH_Matrix_Classes::Real start_val_def=0., CH_Matrix_Classes::Real bounds_minus_infty=CB_minus_infinity, CH_Matrix_Classes::Real bounds_plus_infty=CB_plus_infinity, CH_Matrix_Classes::Real rhs_minus_infty=CB_minus_infinity, CH_Matrix_Classes::Real rhs_plus_infty=CB_plus_infinity, CH_Matrix_Classes::Real cost_def=0.)
calls clear() with these parameters and initializes CBout
std::map< CH_Matrix_Classes::Integer, CH_Matrix_Classes::Real > Realmap
for storing updates of bounds
Definition: Modification.hxx:211