ConicBundle
UQPModelBlock.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_UQPBLOCK_HXX
4 #define CONICBUNDLE_UQPBLOCK_HXX
5 
13 #include "symmat.hxx"
14 #include "UQPModelBlockObject.hxx"
15 #include "QPModelDataObject.hxx"
16 
17 namespace ConicBundle {
18 
23 
43 {
44 protected:
45 
47  std::vector<MinorantPointer> constant_minorant;
49  std::vector<MinorantBundle> bundle;
50 
51 public:
52 
54  void clear()
55  { constant_minorant.clear(); bundle.clear();}
56 
58  UQPModelBlock(CBout* cb=0,int cbinc=-1):QPModelDataObject(cb,cbinc),UQPModelBlockObject(){}
59 
61  virtual ~UQPModelBlock();
62 
64  virtual const MinorantPointer& get_constant_minorant() const
65  { return constant_minorant.back(); }
66 
68  virtual const MinorantBundle& get_bundle() const
69  { return bundle.back();}
70 
73  { return constant_minorant.back(); }
74 
77  { return bundle.back();}
78 
80  virtual int push_aft(const AffineFunctionTransformation* inaft,
81  const CH_Matrix_Classes::Indexmatrix* global_indices,
82  const CH_Matrix_Classes::Indexmatrix* local_indices,
83  std::map<MinorantPointer,MinorantPointer>* precomputed=0);
84 
86  virtual int pop_aft();
87 
88  //virtual CH_Matrix_Classes::Integer xdim() const =0; //dimension of externally visible primal variables
89  //virtual CH_Matrix_Classes::Integer ydim() const =0; //dimension of externally visible dual variables
90 
91  //virtual int set_qp_xstart(CH_Matrix_Classes::Integer x_start_index)=0;
92  //the indices of the local variables correspond to the indices
93  //of the qp variables x and z starting with this index
94  //returns 0 on success, 1 on failure
95 
96  //virtual int set_qp_ystart(CH_Matrix_Classes::Integer y_start_index)=0;
97  //the indices of the local variables correspond to the indices
98  //of the qp variables y starting with this index
99  //returns 0 on success, 1 on failure
100 
101  //virtual int starting_x(CH_Matrix_Classes::Matrix& qp_x)=0;
102  //generate a strictly feasible primal starting point
103  //store it in the qpx_range of x
104  //returns 0 on success, 1 on failure
105 
106  // virtual int starting_y(CH_Matrix_Classes::Matrix& qp_y,
107  // const CH_Matrix_Classes::Matrix& qp_Qx,
108  // const CH_Matrix_Classes::Matrix& qp_c)=0;
109  //generate a strictly feasible dual starting point
110  //store it in the qpy_range of y
111  //x is fixed already by a previous call to starting_x and Qx=Q*x
112  //returns 0 on success, 1 on failure
113 
114  //virtual CH_Matrix_Classes::Real get_local_primalcost() const=0;
115  //returns the current local primal cost contribution <d,s>
116 
117  //virtual CH_Matrix_Classes::Real get_local_dualcost() const=0;
118  //returns the current local dual cost contribution
119 
120  //virtual int get_Ab(CH_Matrix_Classes::Matrix& qp_A,CH_Matrix_Classes::Matrix &qp_b) const=0;
121  //store the local coefficients of matrices A and b in the positions
122  //corresponding to qpy_range (rows) and qpx_range (columns)
123  //returns 0 on success, 1 on failure
124 
125  // virtual int restart_x(CH_Matrix_Classes::Matrix& qp_x,
126  // const CH_Matrix_Classes::Matrix& qp_c,
127  // const CH_Matrix_Classes::Matrix& qp_dc)=0;
128  //it is assumed that the problem was solved already once and is now
129  //resolved for a new linear cost term qp_c that resulted from the old
130  //one by adding qp_dc.
131  //on input qp_x holds the old optimal solution and on output
132  //the coorespoind qpx_range should be replaced by a reasonable
133  //strictly feasible solution for x suitable for restarting
134  //(see also restart_yz)
135  //returns 0 on success, 1 on failure
136 
137  // virtual int restart_y(CH_Matrix_Classes::Matrix& qp_y,
138  // const CH_Matrix_Classes::Matrix& qp_Qx,
139  // const CH_Matrix_Classes::Matrix& qp_c,
140  // const CH_Matrix_Classes::Matrix& qp_dc)=0;
141  //this is called after restart_x (see there)
142  //on input qp_y and qp_z hold the old optimal solution and on output
143  //the coorespoind qpy/qpx_range should be replaced by a reasonable
144  //strictly feasible solution for y/z suitable for restarting
145  //returns 0 on success, 1 on failure
146 
147  //virtual int add_xinv_kron_z(CH_Matrix_Classes::Symmatrix& barQ)=0;
148  //add the system term corresponding to (xinv kron z)
149  //(that arises from solving the linearized perturbed complementarity system
150  // x*z =0 or =mu*I for dx in the preferred search direction)
151  //to the diagonal block corresponding to qpx_range x qpx_range
152 
153  //virtual int add_local_sys(CH_Matrix_Classes::Symmatrix& sysdy,CH_Matrix_Classes::Matrix& rhs)=0;
154  //on input: sysdy= A*barQ^{-1}*A^T (barQ as returned in add_xinv_kron_z)
155  // rhs= A*barQ^{-1}*(c-Q*x-A^T*y)-(b-A*x)
156  //if the block uses additional internal variables
157  //(like an additional term + B*s with s>=0 in the primal feasibility constr)
158  //then the corresponding block terms have now to be added to sysdy and rhs,
159  //eg,
160  // sysdy += B*(t^{-1} kron s)*B^T (if t is the dual variable to s)
161  // rhs += B*s - B*(t^{-1} kron s)*B^T*y
162 
163  // virtual int suggest_mu(CH_Matrix_Classes::Real& ip_xz,
164  // CH_Matrix_Classes::Integer& mu_dim,
165  // CH_Matrix_Classes::Real& sigma,
166  // const CH_Matrix_Classes::Matrix& qp_dx,
167  // const CH_Matrix_Classes::Matrix& qp_dy,
168  // const CH_Matrix_Classes::Matrix& rhs_residual)=0;
169  //dx, dy is the predictor direction giving rise to the rhs_residual -(c-At(y+dy)-Q(x+dx)).
170  //Compute the direction dz and local step and based on the predictor
171  //(x+dx,y+dy,z+dz) suggest a value for mu by specifying the
172  //inner product of the dual cone variables ip_xz=ip(x,z)+ip(s,t),
173  //the dimension of the conic variable space mu_dim= cone_x.dim+cone_s.dim
174  //a value for the factor on mu to obtain the new target
175 
176  // virtual int get_corr(CH_Matrix_Classes::Matrix& xcorr,
177  // CH_Matrix_Classes::Matrix& rhs,
178  // CH_Matrix_Classes::Real mu)=0;
179  //on input (w.r.t. corresponding positions)
180  // xcorr = 0
181  // rhs as on output of add_local_sys
182  //on output the corresponding positions of xcorr should hold the corrector
183  //term of the search direction, eg, xcorr = mu*x^{-1} - x^{-1}*dx*dz,
184  //and if the block holds additional local variables as in add_local_sys then
185  // rhs += B*(mu * t^{-1}- t^{-1}*dt*ds)
186  //has to be called after suggest_mu which computes the other directions
187 
188  // virtual int line_search(CH_Matrix_Classes::Real& alpha,
189  // const CH_Matrix_Classes::Matrix& qp_dx,
190  // const CH_Matrix_Classes::Matrix& qp_dy,
191  // const CH_Matrix_Classes::Matrix& rhs_residual)=0;
192  //dx,dy give the final step direction, alpha is on input
193  //an upper bound on the step size.
194  //On output alpha has to be no larger than on input and
195  //has to guarantee strict feasibility of the primal/dual step on
196  //the local variables.
197  //The block has to compute the step direction dz as well as
198  //for additional internal variables now and to choose alpha so
199  // that strict feasibility is guaranteed for the internal
200  // variables as well
201 
202  // virtual int set_point(const CH_Matrix_Classes::Matrix& qp_x,
203  // const CH_Matrix_Classes::Matrix& qp_y,
204  // CH_Matrix_Classes::Real alpha)=0;
205  //x,y,z is the new point and has to be stored
206  //alpha is the step size used in the step, it is passed so that
207  //the block can take the same step for internal variables if needed.
208 
209 
210  //---------------- for debugging purposes
211 
212  //virtual CH_Matrix_Classes::Matrix& add_Bs(CH_Matrix_Classes::Matrix& qp_vec) const=0;
213  //add the local product of matrices B and s in the positions
214  //corresponding to qpy_range (rows) and return qp_vec
215  //returns 0 on success, 1 on failure
216 
217  //virtual CH_Matrix_Classes::Matrix& subtract_z(CH_Matrix_Classes::Matrix& dual_residual,bool with_step=false) const=0;
218  //add the contributions of the dual slacks and return dual_residual
219  //returns 0 on success, 1 on failure
220 
221 };
222 
223 
235 class UQPModelPointer: public virtual QPModelDataPointer
236 {
237 protected:
239 
240 public:
241 
243  UQPModelPointer(CBout* cb=0,int cbinc=-1):QPModelDataPointer(cb,cbinc),model_block(0){}
244 
246  virtual ~UQPModelPointer();
247 
250  {model_block=0;}
251 
254  { model_block=dynamic_cast<UQPModelBlock*>(inbp); return (model_block==0);}
255 
257  QPSumModelDataObject* generate_summodel_data(BundleModel* bmp=0);
258 
260  QPConeModelDataObject* generate_conemodel_data(BundleModel* bmp=0);
261 
263  QPModelDataObject* get_model_data_ptr() const {return model_block;}
264 };
265 
267 
268 }
269 
270 #endif
271 
std::vector< MinorantBundle > bundle
the minorants forming the cutting model; how to combine them is described in derived classes ...
Definition: UQPModelBlock.hxx:49
abstract interface for automatically generating and retrieving the qp blocks with the model data that...
Definition: QPModelDataObject.hxx:298
QPModelDataObject * get_model_data_ptr() const
returns the pointer value
Definition: UQPModelBlock.hxx:263
UQPModelPointer(CBout *cb=0, int cbinc=-1)
default constructor
Definition: UQPModelBlock.hxx:243
std::vector< MinorantPointer > constant_minorant
constant offset minorant (fixed affine function to be added to the model)
Definition: UQPModelBlock.hxx:47
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
abstract interface extension of QPModelDataObject to allow uniform generation of tuned quadratic solv...
Definition: QPModelDataObject.hxx:144
abstract interface declaring the uniform outer appearance of general cutting models produced by the v...
Definition: QPModelDataObject.hxx:44
virtual const MinorantPointer & get_constant_minorant() const
gives reading access to a constant offset minorant
Definition: UQPModelBlock.hxx:64
virtual int push_aft(const AffineFunctionTransformation *inaft, const CH_Matrix_Classes::Indexmatrix *global_indices, const CH_Matrix_Classes::Indexmatrix *local_indices, std::map< MinorantPointer, MinorantPointer > *precomputed=0)
applies the AffineFunctionTransformation to constant_minorant and bundle, where (if given) only the g...
virtual MinorantBundle & get_bundle()
gives access to the bundle minorants of the cutting model
Definition: UQPModelBlock.hxx:76
Header declaring the class CH_Matrix_Classes::Symmatrix for symmetric matrices with Real elements...
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
virtual MinorantPointer & get_constant_minorant()
gives access to a constant offset minorant
Definition: UQPModelBlock.hxx:72
UQPModelBlock(CBout *cb=0, int cbinc=-1)
default constructor
Definition: UQPModelBlock.hxx:58
abstract interface for model blocks in the unconstrained UQPSolver
Definition: UQPModelBlockObject.hxx:70
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
virtual int pop_aft()
undo the last push_aft
Interface in BundelSolver for generating the correct type of blocks for UQPSolver and for setting the...
Definition: UQPModelBlock.hxx:235
Header declaring the class ConicBundle::QPModelDataObject, ConicBundle::QPSumModelDataObject, ConicBundle::QPConeModelDataObject, ConicBundle::QPModelDataPointer.
combines and provides basic functionalities of QPModelDataObject and UQPModelBlockObject, but is still abstract
Definition: UQPModelBlock.hxx:42
void clear_model_data_ptr()
set the pointer to NULL
Definition: UQPModelBlock.hxx:249
virtual ~UQPModelBlock()
vritual destructor
abstract interface for BundleSolver giving access to all objective function specific bundle routines ...
Definition: BundleModel.hxx:140
std::vector< MinorantPointer > MinorantBundle
a bundle is a vector with MinorantPointer entries
Definition: MinorantPointer.hxx:24
virtual const MinorantBundle & get_bundle() const
gives reading access to the bundle minorants of the cutting model
Definition: UQPModelBlock.hxx:68
Header declaring the classes ConicBundle::UQPModelBlockObject.
abstract interface extension of QPModelDataObject for use in SumModel where several blocks are concat...
Definition: QPModelDataObject.hxx:105
int set_model_data(QPModelDataObject *inbp)
store the pointer to the object if it matches the required type for the QP solver, otherwise return a nonzero value as error; this is used in the models to return the local qp model data
Definition: UQPModelBlock.hxx:253
void clear()
reset to "empty/no" model information
Definition: UQPModelBlock.hxx:54
transform a function f(z) to fun_coeff*f(arg_offset+arg_trafo*y)+linear_cost*y+fun_offset (scales the...
Definition: AffineFunctionTransformation.hxx:68
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
UQPModelBlock * model_block
stores a pointer to the current starting block giving access to the cutting model(s) [it does not own...
Definition: UQPModelBlock.hxx:238