ConicBundle
UQPSolver.hxx
Go to the documentation of this file.
1 
2 #ifndef CONICBUNDLE_UQPSOLVER_HXX
3 #define CONICBUNDLE_UQPSOLVER_HXX
4 
12 #include <vector>
13 #include "QPSolverObject.hxx"
14 #include "UQPModelBlock.hxx"
15 #include "clock.hxx"
16 #include "Groundset.hxx"
17 
18 namespace ConicBundle {
19 
106 
138  class UQPSolver: public virtual UQPModelPointer, public virtual QPSolverObject
139 {
140  private:
147 
148  //--- problem desription
152 
155 
156  //--- termination parameters
161 
162  //--- global variables
167 
170 
174 
176 
179 
180  //--- temporary variables, global only for memory managment purposes
189 
190 
191  //--- statistics
198 
199 
200  //--- private routines
203  const CH_Matrix_Classes::Matrix& dy,
204  const CH_Matrix_Classes::Matrix& rhs_residual);
208  int iterate();
209 
210  public:
212  void clear();
213 
215  void set_defaults();
216 
218  UQPSolver(CBout* cb=0,int cbinc=-1):UQPModelPointer(cb,cbinc)
219  {clear();set_defaults();}
222 
223 
224  //---- proper own routines
226  void init_size(CH_Matrix_Classes::Integer maxdim){Q.newsize(maxdim); x.newsize(maxdim,1);}
227 
229  const CH_Matrix_Classes::Symmatrix& get_Q(void) const {return Q;}
231  const CH_Matrix_Classes::Matrix& get_c(void) const {return c;}
234 
236  void set_termbounds(CH_Matrix_Classes::Real lb,CH_Matrix_Classes::Real ub){lowerbound=lb;upperbound=ub;}
238  void set_termeps(CH_Matrix_Classes::Real te){termeps=te;}
241 
250 
255 
257  const CH_Matrix_Classes::Matrix& get_x() {return x;}
259  const CH_Matrix_Classes::Matrix& get_y() {return y;}
260 
263  // returns status
264  // 0 ... if solve terminated correctly for the standard stopping criterion
265  // 1 ... if terminated by maxiter or precision tolerances
266  // 2 ... if the factorization of the system failed
267  // 3 ... if one of the blocks failed
268 
270  int resolve();
271  // returns status
272  // 0 ... if solve terminated correctly for the standard stopping criterion
273  // 1 ... if terminated by maxiter or precision tolerances
274  // 2 ... if the factorization of the system failed
275  // 3 ... if one of the blocks failed
276 
279  // solves the system for c+=dc offset+=doffset and returns status
280  // 0 ... if solve terminated correctly for the standard stopping criterion
281  // 1 ... if terminated by maxiter or precision tolerances
282  // 2 ... if the factorization of the system failed
283  // 3 ... if one of the blocks failed
284 
286  std::ostream& print_statistics(std::ostream& out) const;
287 
289  std::ostream& save(std::ostream& out) const;
290 
292  std::istream& restore(std::istream& in);
293 
294  //------------ QPSolverOject routines
295 
297  void QPclear(){clear();}
298 
301  {
302  //not used here
303  return 0;
304  }
305 
306 
309  {return 0;}
310 
313  { return true; }
314 
317  virtual bool QPsupports_updates()
318  { return true;}
319 
322  { return get_primalval(); }
323 
325  int QPsolve(const CH_Matrix_Classes::Matrix& center_y,
326  CH_Matrix_Classes::Real lower_bound,
327  CH_Matrix_Classes::Real upper_bound,
328  CH_Matrix_Classes::Real relprec,
329  QPSolverProxObject* Hp,
330  const MinorantPointer& gs_aggr,
332 
334  int QPupdate(const CH_Matrix_Classes::Matrix& center_y,
335  CH_Matrix_Classes::Real lower_bound,
336  CH_Matrix_Classes::Real upper_bound,
337  CH_Matrix_Classes::Real relprec,
338  QPSolverProxObject* Hp,
339  const MinorantPointer& gs_aggr,
341  const MinorantPointer& delta_gs_subg,
342  const CH_Matrix_Classes::Indexmatrix& delta_index);
343 
345  int QPresolve(CH_Matrix_Classes::Real lower_bound,
346  CH_Matrix_Classes::Real upper_bound,
347  CH_Matrix_Classes::Real relprec);
348 
351  CH_Matrix_Classes::Real& augval_ub,
352  CH_Matrix_Classes::Matrix& new_point,
353  CH_Matrix_Classes::Real& gsaggr_offset,
354  CH_Matrix_Classes::Matrix& gsaggr_gradient);
355 
358  { return true; }
359 
361  bool QPconstrained() const
362  {return false;}
363 
366  {return 0;}
367 
370  {return 0;}
371 
374  CH_Matrix_Classes::Real /* relprec */=1e-10)
375  {return true;}
376 
379  bool& ychanged,
380  QPSolverProxObject* /* Hp */,
381  CH_Matrix_Classes::Real /* relprec */=1e-10)
382  { ychanged=false; return 0;}
383 
386  const CH_Matrix_Classes::Matrix*& ub,
387  const CH_Matrix_Classes::Indexmatrix*& lbind,
388  const CH_Matrix_Classes::Indexmatrix*& ubind) const
389  { lb=ub=0; lbind=ubind=0; return false;}
390 
392  std::ostream& QPprint_statistics(std::ostream& out,int /* printlevel */ =0)
393  {return print_statistics(out);}
394 
395 
396 };
397 
399 
400 
401 }
402 
403 #endif
404 
bool QPboxconstrained(const CH_Matrix_Classes::Matrix *&lb, const CH_Matrix_Classes::Matrix *&ub, const CH_Matrix_Classes::Indexmatrix *&lbind, const CH_Matrix_Classes::Indexmatrix *&ubind) const
the unconstrained solver does not have this inforamion and does not know about it, so it returns NULL pointers and false
Definition: UQPSolver.hxx:385
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
bool run_starting_point
in restarting go back to the starting point
Definition: UQPSolver.hxx:175
abstract interface for a QPSolver
Definition: QPSolverObject.hxx:105
CH_Tools::Microseconds sum_choltime
sum of time spent in Cholesky
Definition: UQPSolver.hxx:195
CH_Matrix_Classes::Symmatrix Q
quadratic cost matrix (positive definite)
Definition: UQPSolver.hxx:149
std::ostream & save(std::ostream &out) const
save the current settings and values
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
bool QPsupports_yfixing()
no difficulty if the BundleProxObject does it
Definition: UQPSolver.hxx:312
CH_Matrix_Classes::Integer get_maxiter() const
return the upper bound on interior point interations
Definition: UQPSolver.hxx:249
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
CH_Matrix_Classes::Matrix x
current model x as one joint vector
Definition: UQPSolver.hxx:163
const CH_Matrix_Classes::Matrix & get_x()
return the joint model vector (primal solution) produced by the last solve
Definition: UQPSolver.hxx:257
bool QPis_feasible(const CH_Matrix_Classes::Matrix &, CH_Matrix_Classes::Real=1e-10)
for the unconstrained solver any point is feasible, because it cannot even check the dimension of the...
Definition: UQPSolver.hxx:373
CH_Matrix_Classes::Real lowerbound
lower bound on the final objective value
Definition: UQPSolver.hxx:157
virtual int QPensure_feasibility(CH_Matrix_Classes::Matrix &, bool &ychanged, QPSolverProxObject *, CH_Matrix_Classes::Real=1e-10)
for the unconstrained solver any point is feasible, because it cannot even check the dimension of the...
Definition: UQPSolver.hxx:378
CH_Matrix_Classes::Real termeps
termination precision
Definition: UQPSolver.hxx:159
int resolve()
resolve the QP for the same cost function as last time with slightly modified feasible set ...
CH_Matrix_Classes::Integer get_status() const
return the status of the last solve
Definition: UQPSolver.hxx:245
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
std::ostream & print_statistics(std::ostream &out) const
output some statistical information on performance
CH_Matrix_Classes::Real upperbound
upper bound on the final objective value
Definition: UQPSolver.hxx:158
CH_Matrix_Classes::Real get_primalval() const
return the primal objective value (lower bound) of the last solve
Definition: UQPSolver.hxx:252
virtual bool QPsupports_updates()
return true iff the code supports QPupdate(), i.e., it supports external updates of the groundset agg...
Definition: UQPSolver.hxx:317
int update(const CH_Matrix_Classes::Symmatrix &dQ, const CH_Matrix_Classes::Matrix &dc, CH_Matrix_Classes::Real doffset)
resolve the QP for the same feasible set but update the cost terms by the given argumetns first ...
MinorantPointer gs_aggr
the current/latest groundset aggeregate, mainly needed for computing the QP cost matrices and possibl...
Definition: UQPSolver.hxx:146
CH_Matrix_Classes::Integer sum_choliter
sum over Cholesky facotrizations
Definition: UQPSolver.hxx:193
void set_defaults()
reset parameters to default values
Header declaring the abstract class ConicBundle::QPSolverObject.
int QPsolve(const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Real lower_bound, CH_Matrix_Classes::Real upper_bound, CH_Matrix_Classes::Real relprec, QPSolverProxObject *Hp, const MinorantPointer &gs_aggr, CH_Matrix_Classes::Indexmatrix *yfixed)
see QPSolverObject::QPsolve() and Internal QP Solver for unconstrained groundsets ...
int solve(const CH_Matrix_Classes::Symmatrix &Q, const CH_Matrix_Classes::Matrix &c, CH_Matrix_Classes::Real offset)
solve the QP for this cost function from scratch
void select_new_mu(const CH_Matrix_Classes::Matrix &dx, const CH_Matrix_Classes::Matrix &dy, const CH_Matrix_Classes::Matrix &rhs_residual)
chooses the next value of the barrier parameter
CH_Matrix_Classes::Matrix y
current dual variable to constraints
Definition: UQPSolver.hxx:164
Matrix class of symmetric matrices with real values of type Real
Definition: symmat.hxx:43
const CH_Matrix_Classes::Matrix & get_y()
return the joint dual vector (dual solution) produced by the last solve
Definition: UQPSolver.hxx:259
allows measuring time difference to its initialization time in Microseconds
Definition: clock.hxx:282
CH_Matrix_Classes::Matrix tmpvec
temporary vector for reducing reallocations
Definition: UQPSolver.hxx:186
unconstrained QP solver combining the properties of a QPModelDataPointer and QPSolverObject ...
Definition: UQPSolver.hxx:138
in order to pass parameters to a customized QPSolverObject, derive the parameters from this object; n...
Definition: QPSolverObject.hxx:46
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
void QPclear()
calls clear(), i.e. reinitialize completely
Definition: UQPSolver.hxx:297
CH_Matrix_Classes::Real primalval
primal objective value
Definition: UQPSolver.hxx:168
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
extra long integer number for expressing and computing time measurements in microseconds.
Definition: clock.hxx:46
CH_Matrix_Classes::Matrix dy
step for y
Definition: UQPSolver.hxx:166
virtual GroundsetModification * QPstart_modification()
returns 0 because no modifications are applicable
Definition: UQPSolver.hxx:365
int QPresolve(CH_Matrix_Classes::Real lower_bound, CH_Matrix_Classes::Real upper_bound, CH_Matrix_Classes::Real relprec)
see QPSolverObject::QPresolve() and Internal QP Solver for unconstrained groundsets ...
int apply_modification(const GroundsetModification &)
does nothing here (unconstrained case)
Definition: UQPSolver.hxx:308
CH_Matrix_Classes::Matrix xcorr
correction value for x
Definition: UQPSolver.hxx:185
UQPSolver(CBout *cb=0, int cbinc=-1)
default constructor
Definition: UQPSolver.hxx:218
CH_Matrix_Classes::Matrix b
right hand side to A, it is collected by calling model_block
Definition: UQPSolver.hxx:154
CH_Matrix_Classes::Matrix dx
step for x
Definition: UQPSolver.hxx:165
int predcorr_step(CH_Matrix_Classes::Real &alpha)
carry out a predictor corrector step
CH_Tools::Microseconds QPcoeff_time
time spent in computing the QP coefficients
Definition: UQPSolver.hxx:196
void newsize(Integer nr, Integer nc)
resize the matrix to nr x nc elements but WITHOUT initializing the memory
CH_Matrix_Classes::Integer status
termination status of last call to solve or update
Definition: UQPSolver.hxx:178
CH_Matrix_Classes::Matrix rhs
right hand side of the KKT system
Definition: UQPSolver.hxx:173
int QPapply_modification(const GroundsetModification &)
no modifications need to be carried out here as there is no data to be modified, so any modification ...
Definition: UQPSolver.hxx:369
bool QPconstrained() const
it is always unconstrained
Definition: UQPSolver.hxx:361
Interface in BundelSolver for generating the correct type of blocks for UQPSolver and for setting the...
Definition: UQPModelBlock.hxx:235
int iterate()
calls predcorr_step interatively until termination
CH_Matrix_Classes::Matrix LinvAt
=L^-1*A^T
Definition: UQPSolver.hxx:182
bool QPprefer_UQPSolver(QPSolverProxObject *) const
as this IS the internal UQPSolver, the answer doesn&#39;t matter, but the solver would certainly say yes ...
Definition: UQPSolver.hxx:357
void init_size(CH_Matrix_Classes::Integer maxdim)
reserve memory for this size
Definition: UQPSolver.hxx:226
Matrix class for real values of type Real
Definition: matrix.hxx:74
CH_Matrix_Classes::Matrix A
a (full) blockmatrix mainly for the trace constraints, it is collected by calling model_block ...
Definition: UQPSolver.hxx:153
CH_Matrix_Classes::Matrix rd
dual slack rd=c-Qx-At*y (=-z if feasible)
Definition: UQPSolver.hxx:184
const CH_Matrix_Classes::Matrix * center_yp
the current/latest center point, mainly needed for computint the QP cost matrices and possibly recons...
Definition: UQPSolver.hxx:144
CH_Tools::Microseconds QPsolve_time
time spent in solving the QP
Definition: UQPSolver.hxx:197
int QPset_parameters(QPSolverParametersObject *)
does nothing here
Definition: UQPSolver.hxx:300
CH_Matrix_Classes::Real offset
constant added to objective
Definition: UQPSolver.hxx:151
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
const CH_Matrix_Classes::Matrix & get_c(void) const
returns the linear cost vector
Definition: UQPSolver.hxx:231
CH_Matrix_Classes::Matrix tmpxvec
temporary vector for reducing reallocations
Definition: UQPSolver.hxx:187
BundleProxObject * Hp
the current/latest prox term, mainly needed for computing the QP cost matrices and possibly for deliv...
Definition: UQPSolver.hxx:142
CH_Matrix_Classes::Integer iter
counts number o iterations
Definition: UQPSolver.hxx:177
CH_Matrix_Classes::Real get_dualval() const
return the dual objective value (upper bound) of the last solve
Definition: UQPSolver.hxx:254
CH_Matrix_Classes::Integer maxiter
upper limit on the number of interior poitn iterations (none if <0)
Definition: UQPSolver.hxx:160
CH_Matrix_Classes::Real dualval
dual objective value
Definition: UQPSolver.hxx:169
CH_Matrix_Classes::Real QPget_lower_bound()
return the lower bound on the objective value of the bundle subproblem
Definition: UQPSolver.hxx:321
CH_Matrix_Classes::Integer sum_iter
sum over all interior point iterations
Definition: UQPSolver.hxx:192
void clear()
reset to "empty/no" model
CH_Matrix_Classes::Integer get_iter() const
return the number of iterations of the last solve
Definition: UQPSolver.hxx:243
CH_Matrix_Classes::Real get_termeps() const
return the termination precision
Definition: UQPSolver.hxx:247
CH_Matrix_Classes::Matrix c
linear cost matrix
Definition: UQPSolver.hxx:150
CH_Matrix_Classes::Real get_offset(void) const
returns the constant cost offset value
Definition: UQPSolver.hxx:233
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
std::istream & restore(std::istream &in)
restore the settings and values
Header declaring and (inline) implementing the classes CH_Tools::Microseconds and CH_Tools::Clock as ...
void set_maxiter(CH_Matrix_Classes::Integer mi)
sets the upper bound on the number of interior point iterations (<0 means no bound) ...
Definition: UQPSolver.hxx:240
CH_Matrix_Classes::Matrix Qx
holds Q*x for current x
Definition: UQPSolver.hxx:172
CH_Matrix_Classes::Symmatrix Qplus
L*L^T factorization of Q+blockdiag.
Definition: UQPSolver.hxx:181
int QPget_solution(CH_Matrix_Classes::Real &augval_lb, CH_Matrix_Classes::Real &augval_ub, CH_Matrix_Classes::Matrix &new_point, CH_Matrix_Classes::Real &gsaggr_offset, CH_Matrix_Classes::Matrix &gsaggr_gradient)
the unconstrained solver can only provide this information if the references to the input data of QPs...
void set_termbounds(CH_Matrix_Classes::Real lb, CH_Matrix_Classes::Real ub)
sets the termination lower and upper bounds
Definition: UQPSolver.hxx:236
void set_termeps(CH_Matrix_Classes::Real te)
sets the termination precision
Definition: UQPSolver.hxx:238
CH_Matrix_Classes::Real mu
barrier parameter
Definition: UQPSolver.hxx:171
CH_Matrix_Classes::Matrix tmpyvec
temporary vector for reducing reallocations
Definition: UQPSolver.hxx:188
int QPupdate(const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Real lower_bound, CH_Matrix_Classes::Real upper_bound, CH_Matrix_Classes::Real relprec, QPSolverProxObject *Hp, const MinorantPointer &gs_aggr, CH_Matrix_Classes::Indexmatrix *yfixed, const MinorantPointer &delta_gs_subg, const CH_Matrix_Classes::Indexmatrix &delta_index)
see QPSolverObject::QPupdate() and Internal QP Solver for unconstrained groundsets ...
~UQPSolver()
destructor
Definition: UQPSolver.hxx:221
void newsize(Integer n)
resize the matrix to nr x nr elements but WITHOUT initializing the memory
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
CH_Tools::Clock clock
for timing
Definition: UQPSolver.hxx:194
const CH_Matrix_Classes::Symmatrix & get_Q(void) const
returns the quadratic cost matrix
Definition: UQPSolver.hxx:229
Header declaring the classes ConicBundle::UQPModelBlock, ConicBundle::UQPModelPointer.
CH_Matrix_Classes::Symmatrix sysdy
system matrix for dy
Definition: UQPSolver.hxx:183
std::ostream & QPprint_statistics(std::ostream &out, int=0)
outputs some statistical data about solver performance
Definition: UQPSolver.hxx:392
Header declaring the class ConicBundle::Groundset.
in order to pass a ConicBundle::BundleProxObject, see Quadratic Proximal Terms, to a custzomized QPSo...
Definition: QPSolverObject.hxx:55