35 #ifndef _BLAZE_MATH_SOLVERS_CPG_H_
36 #define _BLAZE_MATH_SOLVERS_CPG_H_
85 template<
typename CP >
bool solve( CP& cp );
119 template<
typename CP >
122 const size_t n( cp.size() );
124 const VecN& b( cp.b_ );
126 bool converged(
false );
128 size_t activeSetChanges( 0 );
129 real alpha( 0 ), alpha_nom( 0 ), alpha_denom( 1 );
130 real beta( 0 ), beta_nom( 0 ), beta_denom( 0 );
142 for(
size_t i=0; i<n; ++i ) {
143 if( x[i] <= cp.lbound( i ) ) {
144 x[i] = cp.lbound( i );
148 else if( x[i] >= cp.ubound( i ) ) {
149 x[i] = cp.ubound( i );
175 beta_denom = alpha_denom;
177 for(
size_t i=0; i<n; ++i ) {
181 p_[i] = max(
p_[i], 0 );
185 p_[i] = min(
p_[i], 0 );
187 beta_nom +=
w_[i] * tmp;
191 if( beta_denom == 0 ) {
196 beta = -beta_nom / beta_denom;
206 alpha_denom =
trans(p_) * A *
p_;
208 if( alpha_denom == 0 )
213 alpha = alpha_nom / alpha_denom;
228 activeSetChanges = 0;
230 for(
size_t i=0; i<n; ++i ) {
235 x[i] = cp.lbound( i );
237 x[i] = cp.ubound( i );
240 x[i] += alpha * p_[i];
242 if( x[i] <= cp.lbound( i ) ) {
243 x[i] = cp.lbound( i );
248 else if( x[i] >= cp.ubound( i ) ) {
249 x[i] = cp.ubound( i );
270 log <<
" Solved the quadratic program in " << it <<
" CPG iterations.";
292 #if !defined(_MSC_VER)
293 extern template bool CPG::solve<LCP>(
LCP& );
294 extern template bool CPG::solve<BoxLCP>(
BoxLCP& );
295 extern template bool CPG::solve<ContactLCP>(
ContactLCP& );
Header file for the isnan shim.
A data structure for box linear complementarity problems.
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:751
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:720
real lastPrecision_
The precision of the solution after the solution process.
Definition: Solver.h:99
Header file for color macros.
Header file for the log debug section.
bool isnan(const DenseMatrix< MT, SO > &dm)
Checks the given dense matrix for not-a-number elements.
Definition: DenseMatrix.h:637
A box linear complementarity problem (BLCP) data structure.The BoxLCP class represent a box linear co...
Definition: BoxLCP.h:66
#define BLAZE_YELLOW
Switches the text color to yellow in case the BLAZE_COLOR_OUTPUT macro is set.
Definition: ColorMacros.h:147
void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: DynamicVector.h:1156
size_t maxIterations_
The maximum number of iterations.
Definition: Solver.h:95
DynamicVector< int > activity_
TODO.
Definition: CPG.h:96
Implementation of the conjugate projected gradient algorithm.TODO: description of the CPG solver TODO...
Definition: CPG.h:72
#define BLAZE_LOG_DEBUG_SECTION(NAME)
Logging section for debug information.This macro starts a log section for debug information. These messages are written to the log file(s) in case the blaze::loglevel has been set to debug or higher. The following example demonstrates how this log section is used:
Definition: DebugSection.h:96
bool solve(CP &cp)
TODO.
Definition: CPG.h:120
VecN r_
TODO.
Definition: CPG.h:93
Header file for the complete DynamicVector implementation.
CPG()
The default constructor for the CPG class.
Definition: CPG.cpp:54
Header file for the base class of all solvers.
#define BLAZE_OLDCOLOR
Switches the text color back to the default color.
Definition: ColorMacros.h:162
Header file for run time assertion macros.
A data structure for linear complementarity problems.
VecN w_
TODO.
Definition: CPG.h:94
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
Header file for the complete CompressedMatrix implementation.
real threshold_
Precision threshold for the solution.
Definition: Solver.h:100
Header file for basic type definitions.
size_t lastIterations_
The number of iterations spent in the last solution process.
Definition: Solver.h:98
A linear complementarity problem (LCP) data structure.The LCP class represent a linear complementarit...
Definition: LCP.h:67
Base class for all solver classes.TODO: description of the Solver class TODO: description of its func...
Definition: Solver.h:63
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
VecN p_
TODO.
Definition: CPG.h:95