Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
blaze
math
problems
MixedLCP.h
Go to the documentation of this file.
1
//=================================================================================================
20
//=================================================================================================
21
22
#ifndef _BLAZE_MATH_PROBLEMS_MIXEDLCP_H_
23
#define _BLAZE_MATH_PROBLEMS_MIXEDLCP_H_
24
25
26
//*************************************************************************************************
27
// Includes
28
//*************************************************************************************************
29
30
#include <cmath>
31
#include <
blaze/math/CompressedMatrix.h
>
32
#include <
blaze/math/DynamicVector.h
>
33
#include <
blaze/math/Functions.h
>
34
#include <
blaze/math/Infinity.h
>
35
#include <
blaze/util/Types.h
>
36
37
38
namespace
blaze {
39
40
//=================================================================================================
41
//
42
// CLASS DEFINITION
43
//
44
//=================================================================================================
45
46
//*************************************************************************************************
84
struct
MixedLCP
85
{
86
//**Utility functions***************************************************************************
89
inline
size_t
size
()
const
;
90
inline
size_t
equations
()
const
;
91
inline
size_t
constraints
()
const
;
92
inline
void
project
(
size_t
index );
93
inline
real
lbound
(
size_t
index )
const
;
94
inline
real
ubound
(
size_t
index )
const
;
95
inline
real
residual
(
size_t
index )
const
;
96
inline
real
residual
()
const
;
98
//**********************************************************************************************
99
100
//**Member variables****************************************************************************
103
CMatMxN
A11_
;
104
CMatMxN
A12_
;
105
CMatMxN
A21_
;
106
CMatMxN
A22_
;
107
VecN
b1_
;
108
VecN
b2_
;
109
VecN
x1_
;
110
VecN
x2_
;
111
112
//**********************************************************************************************
113
};
114
//*************************************************************************************************
115
116
117
118
119
//=================================================================================================
120
//
121
// UTILITY FUNCTIONS
122
//
123
//=================================================================================================
124
125
//*************************************************************************************************
130
inline
size_t
MixedLCP::size
()
const
131
{
132
return
x1_
.
size
() +
x2_
.
size
();
133
}
134
//*************************************************************************************************
135
136
137
//*************************************************************************************************
142
inline
size_t
MixedLCP::equations
()
const
143
{
144
return
x1_
.
size
();
145
}
146
//*************************************************************************************************
147
148
149
//*************************************************************************************************
154
inline
size_t
MixedLCP::constraints
()
const
155
{
156
return
x2_
.
size
();
157
}
158
//*************************************************************************************************
159
160
161
//*************************************************************************************************
167
inline
void
MixedLCP::project
(
size_t
index )
168
{
169
if
( index <
x1_
.
size
() )
170
return
;
171
172
index -=
x1_
.
size
();
173
x2_
[index] =
max
(
real
(0),
x2_
[index] );
174
}
175
//*************************************************************************************************
176
177
178
//*************************************************************************************************
184
inline
real
MixedLCP::lbound
(
size_t
index )
const
185
{
186
if
( index <
x1_
.
size
() )
187
return
-
inf
;
188
else
return
real
(0);
189
}
190
//*************************************************************************************************
191
192
193
//*************************************************************************************************
199
inline
real
MixedLCP::ubound
(
size_t
/*index*/
)
const
200
{
201
return
inf
;
202
}
203
//*************************************************************************************************
204
205
206
//*************************************************************************************************
212
inline
real
MixedLCP::residual
(
size_t
index )
const
213
{
214
// Calculating the LSE residual by Ax+b
215
if
( index <
x1_
.
size
() )
216
return
(
A11_
*
x1_
)[index] + (
A12_
,
x2_
)[index];
217
218
index -= x1_.size();
219
220
// Calculating the LCP residual by max( x - xmax, min( x - xmin, Ax+b ) )
221
return
min
(
x2_
[index],
222
(
A21_
* x1_ )[index] + (
A22_
*
x2_
)[index] );
223
}
224
//*************************************************************************************************
225
226
227
//*************************************************************************************************
232
inline
real
MixedLCP::residual
()
const
233
{
234
real
rmax( 0 );
235
236
for
(
size_t
i=0; i<
size
(); ++i )
237
rmax =
max
( rmax,
std::fabs
(
residual
( i ) ) );
238
239
return
rmax;
240
}
241
//*************************************************************************************************
242
243
}
// namespace blaze
244
245
#endif
Generated on Sun Jul 28 2013 17:06:06 by
1.8.3.1