Scippy

SoPlex

Sequential object-oriented simPlex

UpdateVector< R > Class Template Reference

Dense Vector with semi-sparse Vector for updates. More...

#include <updatevector.h>

Public Member Functions

Constructors / destructors
 UpdateVector (int p_dim, std::shared_ptr< Tolerances > tols=nullptr)
 default constructor. More...
 
 ~UpdateVector ()
 
 UpdateVector (const UpdateVector< R > &)
 copy constructor More...
 
UpdateVector< R > & operator= (const VectorBase< R > &rhs)
 assignment from VectorBase<R> More...
 
UpdateVector< R > & operator= (const UpdateVector< R > &rhs)
 assignment More...
 
Access
R & value ()
 update multiplicator \(\alpha\), writeable More...
 
value () const
 update multiplicator \(\alpha\) More...
 
SSVectorBase< R > & delta ()
 update VectorBase<R> \(\delta\), writeable More...
 
const SSVectorBase< R > & delta () const
 update VectorBase<R> \(\delta\) More...
 
const IdxSetidx () const
 nonzero indices of update VectorBase<R> \(\delta\) More...
 
Modification
void update ()
 Perform the update. More...
 
void clear ()
 clear VectorBase<R> and update vector More...
 
void clearUpdate ()
 clear \(\delta\), \(\alpha\) More...
 
void reDim (int newdim)
 reset dimension More...
 
void setTolerances (std::shared_ptr< Tolerances > &tolerances)
 set tolerances More...
 
Consistency check
bool isConsistent () const
 
- Public Member Functions inherited from VectorBase< R >
bool isConsistent () const
 Consistency check. More...
 
Rational operator* (const VectorBase< Rational > &vec) const
 Inner product. More...
 
 VectorBase ()
 Constructor. More...
 
 VectorBase (int dimen, R *p_val)
 
 VectorBase (int p_dimen)
 
template<typename S >
 VectorBase (const VectorBase< S > &vec)
 
 VectorBase (const VectorBase< R > &&vec) noexcept
 
 VectorBase (const VectorBase< R > &vec)
 
template<class S >
VectorBase< R > & operator= (const VectorBase< S > &vec)
 Assignment operator. More...
 
VectorBase< R > & operator= (const VectorBase< R > &vec)
 Assignment operator. More...
 
VectorBase< R > & operator= (const VectorBase< R > &&vec)
 Move assignment operator. More...
 
VectorBase< R > & scaleAssign (int scaleExp, const VectorBase< R > &vec)
 scale and assign More...
 
VectorBase< R > & scaleAssign (const int *scaleExp, const VectorBase< R > &vec, bool negateExp=false)
 scale and assign More...
 
template<class S >
VectorBase< R > & operator= (const SVectorBase< S > &vec)
 Assignment operator. More...
 
template<class S >
VectorBase< R > & operator= (const SSVectorBase< S > &vec)
 Assignment operator. More...
 
template<class S >
VectorBase< R > & assign (const SVectorBase< S > &vec)
 Assign values of vec. More...
 
template<class S >
VectorBase< R > & assign (const SSVectorBase< S > &vec)
 Assign values of vec. More...
 
void clear ()
 Set vector to contain all-zeros (keeping the same length) More...
 
template<class S >
VectorBase< R > & operator+= (const VectorBase< S > &vec)
 Addition. More...
 
template<class S >
VectorBase< R > & operator+= (const SVectorBase< S > &vec)
 Addition. More...
 
template<class S >
VectorBase< R > & operator+= (const SSVectorBase< S > &vec)
 Addition. More...
 
template<class S >
VectorBase< R > & operator-= (const VectorBase< S > &vec)
 Subtraction. More...
 
template<class S >
VectorBase< R > & operator-= (const SVectorBase< S > &vec)
 Subtraction. More...
 
template<class S >
VectorBase< R > & operator-= (const SSVectorBase< S > &vec)
 Subtraction. More...
 
template<class S >
VectorBase< R > & operator*= (const S &x)
 Scaling. More...
 
template<class S >
VectorBase< R > & operator/= (const S &x)
 Division. More...
 
operator* (const VectorBase< R > &vec) const
 Inner product. More...
 
operator* (const SVectorBase< R > &vec) const
 Inner product. More...
 
operator* (const SSVectorBase< R > &vec) const
 Inner product. More...
 
maxAbs () const
 Maximum absolute value, i.e., infinity norm. More...
 
minAbs () const
 Minimum absolute value. More...
 
length () const
 Floating point approximation of euclidian norm (without any approximation guarantee). More...
 
length2 () const
 Squared norm. More...
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const VectorBase< T > &vec)
 Addition of scaled vector. More...
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const SVectorBase< T > &vec)
 Addition of scaled vector. More...
 
template<class S , class T >
VectorBase< R > & multSub (const S &x, const SVectorBase< T > &vec)
 Subtraction of scaled vector. More...
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const SSVectorBase< T > &vec)
 Addition of scaled vector. More...
 
int dim () const
 Dimension of vector. More...
 
R & operator[] (int n)
 Return n 'th value by reference. More...
 
const R & operator[] (int n) const
 Return n 'th value. More...
 
const std::vector< R > & vec ()
 Return underlying std::vector. More...
 
R * get_ptr ()
 Conversion to C-style pointer. More...
 
const R * get_const_ptr () const
 Conversion to C-style pointer. More...
 
std::vector< R >::const_iterator begin () const
 
std::vector< R >::iterator begin ()
 
std::vector< R >::const_iterator end () const
 
std::vector< R >::iterator end ()
 
int memSize () const
 
void reDim (int newdim, const bool setZero=true)
 Resets VectorBase's dimension to newdim. More...
 
void reSize (int newsize)
 Resets VectorBase's memory size to newsize. More...
 
const VectorBase< R > operator- (const VectorBase< R > &vec) const
 
const VectorBase< R > operator+ (const VectorBase< R > &v) const
 

Private Attributes

Data
theval
 update multiplicator More...
 
SSVectorBase< R > thedelta
 update vector More...
 

Additional Inherited Members

- Protected Attributes inherited from VectorBase< R >
std::vector< R > val
 Values of vector. More...
 

Detailed Description

template<class R>
class soplex::UpdateVector< R >

Dense Vector with semi-sparse Vector for updates.

In many algorithms vectors are updated in every iteration, by adding a multiple of another VectorBase<R> to it, i.e., given a VectorBase<R> x, a scalar \(\alpha\) and another VectorBase<R> \(\delta\), the update to x constists of substituting it by \(x \leftarrow x + \alpha\cdot\delta\).

While the update itself can easily be expressed with methods of the class VectorBase<R>, it is often desirable to save the last update VectorBase<R> \(\delta\) and value \(\alpha\). This is provided by class UpdateVector<R>.

UpdateVectors are derived from VectorBase<R> and provide additional methods for saving and setting the multiplicator \(\alpha\) and the update Vector \(\delta\). Further, it allows for efficient sparse updates, by providing an IdxSet idx() containing the nonzero indices of \(\delta\).

Definition at line 62 of file updatevector.h.

Constructor & Destructor Documentation

◆ UpdateVector() [1/2]

UpdateVector ( int  p_dim,
std::shared_ptr< Tolerances tols = nullptr 
)
explicit

default constructor.

Definition at line 80 of file updatevector.h.

References UpdateVector< R >::isConsistent().

◆ ~UpdateVector()

Definition at line 88 of file updatevector.h.

◆ UpdateVector() [2/2]

UpdateVector ( const UpdateVector< R > &  )

copy constructor

Member Function Documentation

◆ clear()

void clear ( )

clear VectorBase<R> and update vector

Definition at line 153 of file updatevector.h.

References VectorBase< R >::clear(), and UpdateVector< R >::clearUpdate().

◆ clearUpdate()

void clearUpdate ( )

clear \(\delta\), \(\alpha\)

Definition at line 160 of file updatevector.h.

References UpdateVector< R >::thedelta, and UpdateVector< R >::theval.

Referenced by UpdateVector< R >::clear().

◆ delta() [1/2]

SSVectorBase< R > & delta ( )

update VectorBase<R> \(\delta\), writeable

Definition at line 122 of file updatevector.h.

References UpdateVector< R >::thedelta.

◆ delta() [2/2]

const SSVectorBase< R > & delta ( ) const

update VectorBase<R> \(\delta\)

Definition at line 127 of file updatevector.h.

References UpdateVector< R >::thedelta.

◆ idx()

const IdxSet & idx ( ) const

nonzero indices of update VectorBase<R> \(\delta\)

Definition at line 133 of file updatevector.h.

References UpdateVector< R >::thedelta.

◆ isConsistent()

bool isConsistent ( ) const

◆ operator=() [1/2]

UpdateVector< R > & operator= ( const UpdateVector< R > &  rhs)

assignment

◆ operator=() [2/2]

UpdateVector< R > & operator= ( const VectorBase< R > &  rhs)

assignment from VectorBase<R>

Definition at line 93 of file updatevector.h.

References UpdateVector< R >::isConsistent(), and VectorBase< R >::operator=().

◆ reDim()

void reDim ( int  newdim)

reset dimension

Definition at line 167 of file updatevector.h.

References VectorBase< R >::reDim(), and UpdateVector< R >::thedelta.

◆ setTolerances()

void setTolerances ( std::shared_ptr< Tolerances > &  tolerances)

set tolerances

Definition at line 174 of file updatevector.h.

References UpdateVector< R >::thedelta.

Referenced by SPxSolverBase< R >::setTolerances().

◆ update()

void update ( )

Perform the update.

Add value() * delta() to the UpdateVector<R>. Only the indices in idx() are affected. For all other indices, delta() is asumed to be 0.

Definition at line 147 of file updatevector.h.

References VectorBase< R >::multAdd(), and UpdateVector< R >::thedelta.

◆ value() [1/2]

R & value ( )

update multiplicator \(\alpha\), writeable

Definition at line 111 of file updatevector.h.

References UpdateVector< R >::theval.

◆ value() [2/2]

R value ( ) const

update multiplicator \(\alpha\)

Definition at line 116 of file updatevector.h.

References UpdateVector< R >::theval.

Member Data Documentation

◆ thedelta

◆ theval

R theval
private

update multiplicator

Definition at line 69 of file updatevector.h.

Referenced by UpdateVector< R >::clearUpdate(), and UpdateVector< R >::value().