Toggle navigation
SCIP Optimization Suite
SCIP
SoPlex
ZIMPL
UG
GCG
Documentation
SoPlex 6.0.3
SoPlex 5.0.2
SoPlex 4.0.2
SoPlex 3.1.0
SoPlex 3.0.1
SoPlex 2.2.1
SoPlex
Sequential object-oriented simPlex
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
soplex-repo
src
slufactor.h
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2
/* */
3
/* This file is part of the class library */
4
/* SoPlex --- the Sequential object-oriented simPlex. */
5
/* */
6
/* Copyright (C) 1996-2015 Konrad-Zuse-Zentrum */
7
/* fuer Informationstechnik Berlin */
8
/* */
9
/* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10
/* */
11
/* You should have received a copy of the ZIB Academic License */
12
/* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13
/* */
14
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16
/**@file slufactor.h
17
* @brief Implementation of Sparse Linear Solver.
18
*/
19
#ifndef _SLUFACTOR_H_
20
#define _SLUFACTOR_H_
21
22
#include <assert.h>
23
24
#include "
spxdefines.h
"
25
#include "
timerfactory.h
"
26
#include "
dvector.h
"
27
#include "
slinsolver.h
"
28
#include "
clufactor.h
"
29
30
namespace
soplex
31
{
32
/// maximum nr. of factorization updates allowed before refactorization.
33
#define MAXUPDATES 1000
34
35
/**@brief Implementation of Sparse Linear Solver.
36
* @ingroup Algo
37
*
38
* This class implements a #SLinSolver interface by using the sparse LU
39
* factorization implementet in #CLUFactor.
40
*/
41
class
SLUFactor
:
public
SLinSolver
,
protected
CLUFactor
42
{
43
public
:
44
45
//--------------------------------
46
/**@name Types */
47
//@{
48
/// Specifies how to perform \ref soplex::SLUFactor::change "change" method.
49
enum
UpdateType
50
{
51
ETA
= 0,
///<
52
FOREST_TOMLIN
///<
53
};
54
/// for convenience
55
typedef
SLinSolver::Status
Status
;
56
//@}
57
58
private
:
59
60
//--------------------------------
61
/**@name Private data */
62
//@{
63
DVector
vec
;
///< Temporary vector
64
SSVector
ssvec
;
///< Temporary semi-sparse vector
65
//@}
66
67
protected
:
68
69
//--------------------------------
70
/**@name Protected data */
71
//@{
72
bool
usetup
;
///< TRUE iff update vector has been setup
73
UpdateType
uptype
;
///< the current \ref soplex::SLUFactor::UpdateType "UpdateType".
74
SSVector
eta
;
///<
75
SSVector
forest
;
///< ? Update vector set up by solveRight4update() and solve2right4update()
76
Real
lastThreshold
;
///< pivoting threshold of last factorization
77
//@}
78
79
//--------------------------------
80
/**@name Control Parameters */
81
//@{
82
/// minimum threshold to use.
83
Real
minThreshold
;
84
/// minimum stability to achieve by setting threshold.
85
Real
minStability
;
86
/// |x| < epsililon is considered to be 0.
87
Real
epsilon
;
88
/// Time spent in solves
89
Timer
*
solveTime
;
90
Timer::TYPE
timerType
;
91
/// Number of solves
92
int
solveCount
;
93
//@}
94
95
protected
:
96
97
//--------------------------------
98
/**@name Protected helpers */
99
//@{
100
///
101
void
freeAll
();
102
///
103
void
changeEta
(
int
idx,
SSVector
&
eta
);
104
//@}
105
106
107
public
:
108
109
//--------------------------------
110
/**@name Update type */
111
//@{
112
/// returns the current update type uptype.
113
UpdateType
utype
()
const
114
{
115
return
uptype
;
116
}
117
118
/// sets update type.
119
/** The new UpdateType becomes valid only after the next call to
120
method load().
121
*/
122
void
setUtype
(
UpdateType
tp)
123
{
124
uptype
= tp;
125
}
126
127
/// sets minimum Markowitz threshold.
128
void
setMarkowitz
(
Real
m)
129
{
130
if
( m < 0.01 )
131
m = 0.01;
132
133
if
( m > 0.99 )
134
m = 0.99;
135
136
minThreshold
= m;
137
lastThreshold
= m;
138
}
139
140
/// returns Markowitz threshold.
141
Real
markowitz
()
142
{
143
return
lastThreshold
;
144
}
145
//@}
146
147
//--------------------------------
148
/**@name Derived from SLinSolver
149
See documentation of \ref soplex::SLinSolver "SLinSolver" for a
150
documentation of these methods.
151
*/
152
//@{
153
///
154
void
clear
();
155
///
156
int
dim
()
const
157
{
158
return
thedim
;
159
}
160
///
161
int
memory
()
const
162
{
163
return
nzCnt
+
l
.
start
[
l
.
firstUnused
];
164
}
165
///
166
const
char
*
getName
()
const
167
{
168
return
(
uptype
==
SLUFactor::ETA
) ?
"SLU-Eta"
:
"SLU-Forest-Tomlin"
;
169
}
170
///
171
Status
status
()
const
172
{
173
return
Status
(
stat
);
174
}
175
///
176
Real
stability
()
const
;
177
///
178
std::string
statistics
()
const
;
179
///
180
Status
load
(
const
SVector
*
vec
[],
int
dim
);
181
//@}
182
183
public
:
184
185
//--------------------------------
186
/**@name Solve */
187
//@{
188
/// Solves \f$Ax=b\f$.
189
void
solveRight
(
Vector
& x,
const
Vector
& b);
190
/// Solves \f$Ax=b\f$.
191
void
solveRight
(
SSVector
& x,
const
SVector
& b);
192
/// Solves \f$Ax=b\f$.
193
void
solveRight4update
(
SSVector
& x,
const
SVector
& b);
194
/// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
195
void
solve2right4update
(
SSVector
& x,
Vector
& y,
const
SVector
& b,
SSVector
& d);
196
/// Sparse version of solving two systems of equations
197
void
solve2right4update
(
SSVector
& x,
SSVector
& y,
const
SVector
& b,
SSVector
& d);
198
/// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
199
void
solve3right4update
(
SSVector
& x,
Vector
& y,
Vector
& z,
200
const
SVector
& b,
SSVector
& d,
SSVector
& e);
201
/// sparse version of solving three systems of equations
202
void
solve3right4update
(
SSVector
& x,
SSVector
& y,
SSVector
& z,
203
const
SVector
& b,
SSVector
& d,
SSVector
& e);
204
/// sparse version of solving one system of equations with transposed basis matrix
205
void
solveLeft
(
Vector
& x,
const
Vector
& b);
206
/// Solves \f$Ax=b\f$.
207
void
solveLeft
(
SSVector
& x,
const
SVector
& b);
208
/// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
209
void
solveLeft
(
SSVector
& x,
Vector
& y,
const
SVector
& b,
SSVector
& d);
210
/// sparse version of solving two systems of equations with transposed basis matrix
211
void
solveLeft
(
SSVector
& x,
SSVector
& two,
const
SVector
& b,
SSVector
& rhs2);
212
/// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
213
void
solveLeft
(
SSVector
& x,
Vector
& y,
Vector
& z,
214
const
SVector
& b,
SSVector
& d,
SSVector
& e);
215
/// sparse version of solving three systems of equations with transposed basis matrix
216
void
solveLeft
(
SSVector
& x,
SSVector
& y,
SSVector
& z,
217
const
SVector
& b,
SSVector
& d,
SSVector
& e);
218
///
219
Status
change
(
int
idx,
const
SVector
& subst,
const
SSVector
*
eta
= 0);
220
//@}
221
222
//--------------------------------
223
/**@name Miscellaneous */
224
//@{
225
/// time spent in factorizations
226
Real
getFactorTime
()
const
227
{
228
return
factorTime
->
time
();
229
}
230
/// reset FactorTime
231
void
resetFactorTime
()
232
{
233
factorTime
->
reset
();
234
}
235
/// number of factorizations performed
236
int
getFactorCount
()
const
237
{
238
return
factorCount
;
239
}
240
/// time spent in solves
241
Real
getSolveTime
()
const
242
{
243
return
solveTime
->
time
();
244
}
245
/// reset SolveTime
246
void
resetSolveTime
()
247
{
248
solveTime
->
reset
();
249
}
250
/// number of solves performed
251
int
getSolveCount
()
const
252
{
253
return
solveCount
;
254
}
255
/// reset timers and counters
256
void
resetCounters
()
257
{
258
factorTime
->
reset
();
259
solveTime
->
reset
();
260
factorCount
= 0;
261
solveCount
= 0;
262
}
263
/// prints the LU factorization to stdout.
264
void
dump
()
const
;
265
266
/// consistency check.
267
bool
isConsistent
()
const
;
268
//@}
269
270
//------------------------------------
271
/**@name Constructors / Destructors */
272
//@{
273
/// default constructor.
274
SLUFactor
();
275
/// assignment operator.
276
SLUFactor
&
operator=
(
const
SLUFactor
& old);
277
/// copy constructor.
278
SLUFactor
(
const
SLUFactor
& old);
279
/// destructor.
280
virtual
~SLUFactor
();
281
/// clone function for polymorphism
282
inline
virtual
SLinSolver
*
clone
()
const
283
{
284
return
new
SLUFactor
(*
this
);
285
}
286
//@}
287
288
private
:
289
290
//------------------------------------
291
/**@name Private helpers */
292
//@{
293
/// used to implement the assignment operator
294
void
assign
(
const
SLUFactor
& old);
295
//@}
296
};
297
298
}
// namespace soplex
299
#endif // _SLUFACTOR_H_