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
updatevector.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 updatevector.h
17
* @brief Dense vector with semi-sparse vector for updates
18
*/
19
20
#ifndef _UPDATEVECTOR_H_
21
#define _UPDATEVECTOR_H_
22
23
#include <assert.h>
24
25
26
#include "
spxdefines.h
"
27
#include "
dvector.h
"
28
#include "
ssvector.h
"
29
30
namespace
soplex
31
{
32
33
/**@brief Dense vector with semi-sparse vector for updates
34
@ingroup Algebra
35
36
In many algorithms vectors are updated in every iteration, by
37
adding a multiple of another vector to it, i.e., given a vector \c
38
x, a scalar \f$\alpha\f$ and another vector \f$\delta\f$, the
39
update to \c x constists of substituting it by \f$x \leftarrow x +
40
\alpha\cdot\delta\f$.
41
42
While the update itself can easily be expressed with methods of
43
the class Vector, it is often desirable to save the last update
44
vector \f$\delta\f$ and value \f$\alpha\f$. This is provided by
45
class UpdateVector.
46
47
UpdateVectors are derived from DVector and provide additional
48
methods for saving and setting the multiplicator \f$\alpha\f$ and
49
the update vector \f$\delta\f$. Further, it allows for efficient
50
sparse updates, by providing an IdxSet idx() containing the
51
nonzero indices of \f$\delta\f$.
52
*/
53
class
UpdateVector
:
public
DVector
54
{
55
private
:
56
57
//------------------------------------
58
/**@name Data */
59
//@{
60
Real
theval
;
///< update multiplicator
61
SSVector
thedelta
;
///< update vector
62
//@}
63
64
public
:
65
66
//------------------------------------
67
/**@name Constructors / destructors */
68
//@{
69
/// default constructor.
70
explicit
71
UpdateVector
(
int
p_dim
/*=0*/
,
Real
p_eps
/*=1e-16*/
)
72
:
DVector
(p_dim)
73
,
theval
(0)
74
,
thedelta
(p_dim, p_eps)
75
{
76
assert(
isConsistent
());
77
}
78
///
79
~UpdateVector
()
80
{}
81
/// copy constructor
82
UpdateVector
(
const
UpdateVector
& );
83
/// assignment from DVector
84
UpdateVector
&
operator=
(
const
DVector
& rhs)
85
{
86
if
(
this
!= & rhs )
87
DVector::operator=
(rhs);
88
89
assert(
isConsistent
());
90
91
return
*
this
;
92
}
93
/// assignment from Vector
94
UpdateVector
&
operator=
(
const
Vector
& rhs)
95
{
96
if
(
this
!= & rhs )
97
DVector::operator=
(rhs);
98
99
assert(
isConsistent
());
100
101
return
*
this
;
102
}
103
/// assignment
104
UpdateVector
&
operator=
(
const
UpdateVector
& rhs);
105
//@}
106
107
//------------------------------------
108
/**@name Access */
109
//@{
110
/// update multiplicator \f$\alpha\f$, writeable
111
Real
&
value
()
112
{
113
return
theval
;
114
}
115
/// update multiplicator \f$\alpha\f$
116
Real
value
()
const
117
{
118
return
theval
;
119
}
120
121
/// update vector \f$\delta\f$, writeable
122
SSVector
&
delta
()
123
{
124
return
thedelta
;
125
}
126
/// update vector \f$\delta\f$
127
const
SSVector
&
delta
()
const
128
{
129
return
thedelta
;
130
}
131
132
/// nonzero indices of update vector \f$\delta\f$
133
const
IdxSet
&
idx
()
const
134
{
135
return
thedelta
.
indices
();
136
}
137
//@}
138
139
//------------------------------------
140
/**@name Modification */
141
//@{
142
/// Perform the update
143
/** Add \c value() * \c delta() to the UpdateVector. Only the indices
144
* in idx() are affected. For all other indices, delta() is asumed
145
* to be 0.
146
*/
147
void
update
()
148
{
149
multAdd
(
theval
,
thedelta
);
150
}
151
152
/// clear vector and update vector
153
void
clear
()
154
{
155
DVector::clear
();
156
clearUpdate
();
157
}
158
159
/// clear \f$\delta\f$, \f$\alpha\f$
160
void
clearUpdate
()
161
{
162
thedelta
.
clear
();
163
theval
= 0;
164
}
165
166
/// reset dimension
167
void
reDim
(
int
newdim)
168
{
169
DVector::reDim
(newdim);
170
thedelta
.
reDim
(newdim);
171
}
172
//@}
173
174
//------------------------------------
175
/**@name Consistency check */
176
//@{
177
///
178
bool
isConsistent
()
const
;
179
//@}
180
};
181
182
183
}
// namespace soplex
184
#endif // _UPDATEVECTOR_H_