All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MixedLCP.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROBLEMS_MIXEDLCP_H_
36 #define _BLAZE_MATH_PROBLEMS_MIXEDLCP_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <cmath>
46 #include <blaze/math/Functions.h>
47 #include <blaze/math/Infinity.h>
48 #include <blaze/util/Types.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // CLASS DEFINITION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
97 struct MixedLCP
98 {
99  //**Utility functions***************************************************************************
102  inline size_t size () const;
103  inline size_t equations () const;
104  inline size_t constraints() const;
105  inline void project ( size_t index );
106  inline real lbound ( size_t index ) const;
107  inline real ubound ( size_t index ) const;
108  inline real residual ( size_t index ) const;
109  inline real residual () const;
111  //**********************************************************************************************
112 
113  //**Member variables****************************************************************************
124 
125  //**********************************************************************************************
126 };
127 //*************************************************************************************************
128 
129 
130 
131 
132 //=================================================================================================
133 //
134 // UTILITY FUNCTIONS
135 //
136 //=================================================================================================
137 
138 //*************************************************************************************************
143 inline size_t MixedLCP::size() const
144 {
145  return x1_.size() + x2_.size();
146 }
147 //*************************************************************************************************
148 
149 
150 //*************************************************************************************************
155 inline size_t MixedLCP::equations() const
156 {
157  return x1_.size();
158 }
159 //*************************************************************************************************
160 
161 
162 //*************************************************************************************************
167 inline size_t MixedLCP::constraints() const
168 {
169  return x2_.size();
170 }
171 //*************************************************************************************************
172 
173 
174 //*************************************************************************************************
180 inline void MixedLCP::project( size_t index )
181 {
182  if( index < x1_.size() )
183  return;
184 
185  index -= x1_.size();
186  x2_[index] = max( real(0), x2_[index] );
187 }
188 //*************************************************************************************************
189 
190 
191 //*************************************************************************************************
197 inline real MixedLCP::lbound( size_t index ) const
198 {
199  if( index < x1_.size() )
200  return -inf;
201  else return real(0);
202 }
203 //*************************************************************************************************
204 
205 
206 //*************************************************************************************************
212 inline real MixedLCP::ubound( size_t /*index*/ ) const
213 {
214  return inf;
215 }
216 //*************************************************************************************************
217 
218 
219 //*************************************************************************************************
225 inline real MixedLCP::residual( size_t index ) const
226 {
227  // Calculating the LSE residual by Ax+b
228  if( index < x1_.size() )
229  return ( A11_ * x1_ )[index] + ( A12_, x2_ )[index];
230 
231  index -= x1_.size();
232 
233  // Calculating the LCP residual by max( x - xmax, min( x - xmin, Ax+b ) )
234  return min( x2_[index],
235  ( A21_ * x1_ )[index] + ( A22_ * x2_ )[index] );
236 }
237 //*************************************************************************************************
238 
239 
240 //*************************************************************************************************
245 inline real MixedLCP::residual() const
246 {
247  real rmax( 0 );
248 
249  for( size_t i=0; i<size(); ++i )
250  rmax = max( rmax, std::fabs( residual( i ) ) );
251 
252  return rmax;
253 }
254 //*************************************************************************************************
255 
256 } // namespace blaze
257 
258 #endif
Header file for mathematical functions.
VecN x2_
The lower part of the vector of unknowns .
Definition: MixedLCP.h:123
const StaticMatrix< Type, 3UL, 3UL, false > fabs(const RotationMatrix< Type > &m)
Returns a matrix containing the absolute values of each single element of m.
Definition: RotationMatrix.h:1102
size_t size() const
Returns the size of the mixed linear complementarity problem.
Definition: MixedLCP.h:143
VecN b1_
The upper part of the right-hand side vector .
Definition: MixedLCP.h:120
CMatMxN A12_
The upper right part of the system matrix .
Definition: MixedLCP.h:117
size_t equations() const
Returns the number of equations of the MLCP.
Definition: MixedLCP.h:155
CMatMxN A21_
The lower left part of the system matrix .
Definition: MixedLCP.h:118
Numerical infinity for built-in data types.
size_t size() const
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1050
Header file for the complete DynamicVector implementation.
CMatMxN A22_
The lower right part of the system matrix .
Definition: MixedLCP.h:119
real ubound(size_t index) const
Returns the upper bound of the unknown at the given index.
Definition: MixedLCP.h:212
VecN b2_
The lower part of the right-hand side vector .
Definition: MixedLCP.h:121
const Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1098
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
real residual() const
Calculates the maximum norm of the residual of the mixed LCP.
Definition: MixedLCP.h:245
void project(size_t index)
Projects the unknown at the given index on the solution range.
Definition: MixedLCP.h:180
Header file for the complete CompressedMatrix implementation.
A mixed linear complementarity problem (MLCP) data structure.The LCP class represent a mixed linear c...
Definition: MixedLCP.h:97
Header file for basic type definitions.
real lbound(size_t index) const
Returns the lower bound of the unknown at the given index.
Definition: MixedLCP.h:197
VecN x1_
The upper part of the vector of unknowns .
Definition: MixedLCP.h:122
size_t constraints() const
Returns the number of constraints of the MLCP.
Definition: MixedLCP.h:167
CMatMxN A11_
The upper left part of the system matrix .
Definition: MixedLCP.h:116