Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpMultiVectorMatrix.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005, 2008 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpMultiVectorMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $
6 //
7 // Authors: Andreas Waechter IBM 2005-12-24
8
9 #ifndef __IPMULTIVECTORMATRIX_HPP__
10 #define __IPMULTIVECTORMATRIX_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpMatrix.hpp"
14
15 namespace Ipopt
16 {
17
19 class MultiVectorMatrixSpace;
20
25 class MultiVectorMatrix : public Matrix
26 {
27 public:
28
31
34 MultiVectorMatrix(const MultiVectorMatrixSpace* owner_space);
35
37 ~MultiVectorMatrix();
39
41 SmartPtr<MultiVectorMatrix> MakeNewMultiVectorMatrix() const;
42
48 void SetVector(Index i, const Vector& vec);
49 /* For the non-const version, keep in mind that operations that
50 * change this matrix also change the Vector that has been given
51 * here. */
52 void SetVectorNonConst(Index i, Vector& vec);
54
56 inline SmartPtr<const Vector> GetVector(Index i) const
57 {
58 return ConstVec(i);
59 }
60
64 inline SmartPtr<Vector> GetVectorNonConst(Index i)
65 {
66 ObjectChanged();
67 return Vec(i);
68 }
69
72 void ScaleRows(const Vector& scal_vec);
73
76 void ScaleColumns(const Vector& scal_vec);
77
80 void AddOneMultiVectorMatrix(Number a, const MultiVectorMatrix& mv1,
81 Number c);
82
87 void AddRightMultMatrix(Number a, const MultiVectorMatrix& U,
88 const Matrix& C, Number b);
89
92 void FillWithNewVectors();
93
97 void LRMultVector(Number alpha, const Vector &x,
98 Number beta, Vector &y) const;
99
101 SmartPtr<const VectorSpace> ColVectorSpace() const;
102
104 SmartPtr<const MultiVectorMatrixSpace> MultiVectorMatrixOwnerSpace() const;
105
106 protected:
109 virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta,
110 Vector &y) const;
111
112 virtual void TransMultVectorImpl(Number alpha, const Vector& x,
113 Number beta, Vector& y) const;
114
117 virtual bool HasValidNumbersImpl() const;
118
119 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
120
121 virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
122
123 virtual void PrintImpl(const Journalist& jnlst,
124 EJournalLevel level,
125 EJournalCategory category,
126 const std::string& name,
127 Index indent,
128 const std::string& prefix) const;
130
131
132 private:
142 MultiVectorMatrix();
143
145 MultiVectorMatrix(const MultiVectorMatrix&);
146
148 void operator=(const MultiVectorMatrix&);
150
151 const MultiVectorMatrixSpace* owner_space_;
152
154 std::vector<SmartPtr<const Vector> > const_vecs_;
155
157 std::vector<SmartPtr<Vector> > non_const_vecs_;
158
161 inline const Vector* ConstVec(Index i) const
162 {
163 DBG_ASSERT(i < NCols());
164 DBG_ASSERT(IsValid(const_vecs_[i]) || IsValid(non_const_vecs_[i]));
165 if (IsValid(non_const_vecs_[i])) {
166 return GetRawPtr(non_const_vecs_[i]);
167 }
168 else {
169 return GetRawPtr(const_vecs_[i]);
170 }
171 }
172
173 inline Vector* Vec(Index i)
174 {
175 DBG_ASSERT(i < NCols());
176 DBG_ASSERT(IsValid(non_const_vecs_[i]));
177 return GetRawPtr(non_const_vecs_[i]);
178 }
180 };
181
184 class MultiVectorMatrixSpace : public MatrixSpace
185 {
186 public:
192 MultiVectorMatrixSpace(Index ncols,
193 const VectorSpace& vec_space);
194
196 ~MultiVectorMatrixSpace()
197 {}
199
201 MultiVectorMatrix* MakeNewMultiVectorMatrix() const
202 {
203 return new MultiVectorMatrix(this);
204 }
205
208 virtual Matrix* MakeNew() const
209 {
210 return MakeNewMultiVectorMatrix();
211 }
212
214 SmartPtr<const VectorSpace> ColVectorSpace() const
215 {
216 return vec_space_;
217 }
218
219 private:
220 SmartPtr<const VectorSpace> vec_space_;
221
222 };
223
224 inline
225 MultiVectorMatrix::~MultiVectorMatrix()
226 {}
227
228 inline
229 SmartPtr<MultiVectorMatrix> MultiVectorMatrix::MakeNewMultiVectorMatrix() const
230 {
231 return owner_space_->MakeNewMultiVectorMatrix();
232 }
233
234 inline
235 SmartPtr<const VectorSpace> MultiVectorMatrix::ColVectorSpace() const
236 {
237 return owner_space_->ColVectorSpace();
238 }
239
240 inline
241 SmartPtr<const MultiVectorMatrixSpace>
242 MultiVectorMatrix::MultiVectorMatrixOwnerSpace() const
243 {
244 return owner_space_;
245 }
246
247 } // namespace Ipopt
248 #endif
Ipopt::IsValid
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:579
x
Number * x
Input: Starting point Output: Optimal solution.
Definition: IpStdCInterface.h:238
Ipopt::MultiVectorMatrix::ComputeRowAMaxImpl
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
Ipopt::MultiVectorMatrixSpace::MakeNew
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
Definition: IpMultiVectorMatrix.hpp:208
Ipopt::MultiVectorMatrixSpace::MakeNewMultiVectorMatrix
MultiVectorMatrix * MakeNewMultiVectorMatrix() const
Method for creating a new matrix of this specific type.
Definition: IpMultiVectorMatrix.hpp:201
IpUtils.hpp
Ipopt::MultiVectorMatrix::~MultiVectorMatrix
~MultiVectorMatrix()
Destructor.
Definition: IpMultiVectorMatrix.hpp:225
Ipopt::MultiVectorMatrix::MultVectorImpl
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
Ipopt::MultiVectorMatrix::ComputeColAMaxImpl
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
Ipopt::MultiVectorMatrix::ScaleColumns
void ScaleColumns(const Vector &scal_vec)
Method for scaling the columns of the matrix, using the Scal method for each column vector...
Ipopt::MultiVectorMatrix::SetVector
void SetVector(Index i, const Vector &vec)
Set a particular Vector at a given column position, replacing another vector if there has been one...
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Ipopt::TaggedObject::ObjectChanged
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Definition: IpTaggedObject.hpp:117
Ipopt::Vector
Vector Base Class.
Definition: IpVector.hpp:47
Ipopt::MultiVectorMatrix::HasValidNumbersImpl
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Ipopt::MultiVectorMatrix::PrintImpl
virtual void PrintImpl(const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix) const
Print detailed information about the matrix.
IpMatrix.hpp
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:51
Ipopt::MultiVectorMatrix::const_vecs_
std::vector< SmartPtr< const Vector > > const_vecs_
space for storing the const Vector&#39;s
Definition: IpMultiVectorMatrix.hpp:154
Ipopt::MultiVectorMatrix::ScaleRows
void ScaleRows(const Vector &scal_vec)
Method for scaling the rows of the matrix, using the ElementWiseMultiply method for each column vecto...
Ipopt::MultiVectorMatrixSpace::MultiVectorMatrixSpace
MultiVectorMatrixSpace(Index ncols, const VectorSpace &vec_space)
Constructor, given the number of columns (i.e., Vectors to be stored) and given the VectorSpace for t...
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::VectorSpace
VectorSpace base class, corresponding to the Vector base class.
Definition: IpVector.hpp:390
Ipopt::GetRawPtr
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:560
Ipopt::MultiVectorMatrix::GetVector
SmartPtr< const Vector > GetVector(Index i) const
Get a Vector in a particular column as a const Vector.
Definition: IpMultiVectorMatrix.hpp:56
Ipopt::Matrix
Matrix Base Class.
Definition: IpMatrix.hpp:27
Ipopt::MultiVectorMatrix::owner_space_
const MultiVectorMatrixSpace * owner_space_
Definition: IpMultiVectorMatrix.hpp:151
Ipopt::MultiVectorMatrix::AddRightMultMatrix
void AddRightMultMatrix(Number a, const MultiVectorMatrix &U, const Matrix &C, Number b)
Multiplying a Matrix C (for now assumed to be a DenseGenMatrix) from the right to a MultiVectorMatrix...
Ipopt::MultiVectorMatrixSpace::vec_space_
SmartPtr< const VectorSpace > vec_space_
Definition: IpMultiVectorMatrix.hpp:220
Ipopt::MultiVectorMatrix
Class for Matrices with few columns that consists of Vectors.
Definition: IpMultiVectorMatrix.hpp:25
Ipopt::MatrixSpace
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:239
Ipopt::MultiVectorMatrix::LRMultVector
void LRMultVector(Number alpha, const Vector &x, Number beta, Vector &y) const
Method for adding the low-rank update matrix corresponding to this matrix to a vector.
Ipopt::MultiVectorMatrixSpace::~MultiVectorMatrixSpace
~MultiVectorMatrixSpace()
Destructor.
Definition: IpMultiVectorMatrix.hpp:196
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Ipopt::MultiVectorMatrix::ConstVec
const Vector * ConstVec(Index i) const
Method for accessing the internal Vectors internally.
Definition: IpMultiVectorMatrix.hpp:161
Ipopt::MultiVectorMatrix::AddOneMultiVectorMatrix
void AddOneMultiVectorMatrix(Number a, const MultiVectorMatrix &mv1, Number c)
Adding another MultiVectorMatrix, using the AddOneVector methods for the individual column vectors...
DBG_ASSERT
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Ipopt::MultiVectorMatrixSpace::ColVectorSpace
SmartPtr< const VectorSpace > ColVectorSpace() const
Accessor method for the VectorSpace for the columns.
Definition: IpMultiVectorMatrix.hpp:214
Ipopt::Matrix::NCols
Index NCols() const
Number of columns.
Definition: IpMatrix.hpp:316
Ipopt::MultiVectorMatrix::MultiVectorMatrixOwnerSpace
SmartPtr< const MultiVectorMatrixSpace > MultiVectorMatrixOwnerSpace() const
Return the MultiVectorMatrixSpace.
Definition: IpMultiVectorMatrix.hpp:242
Ipopt::MultiVectorMatrix::SetVectorNonConst
void SetVectorNonConst(Index i, Vector &vec)
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:134
Ipopt::MultiVectorMatrix::TransMultVectorImpl
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
Ipopt::MultiVectorMatrix::non_const_vecs_
std::vector< SmartPtr< Vector > > non_const_vecs_
space for storing the non-const Vector&#39;s
Definition: IpMultiVectorMatrix.hpp:157
Ipopt::MultiVectorMatrixSpace
This is the matrix space for MultiVectorMatrix.
Definition: IpMultiVectorMatrix.hpp:184
Ipopt::MultiVectorMatrix::MultiVectorMatrix
MultiVectorMatrix()
Default Constructor.
Ipopt::MultiVectorMatrix::ColVectorSpace
SmartPtr< const VectorSpace > ColVectorSpace() const
Vector space for the columns.
Definition: IpMultiVectorMatrix.hpp:235
Ipopt::MultiVectorMatrix::FillWithNewVectors
void FillWithNewVectors()
Method for initializing all Vectors with new (uninitialized) Vectors.
Ipopt::MultiVectorMatrix::Vec
Vector * Vec(Index i)
Definition: IpMultiVectorMatrix.hpp:173
Ipopt::MultiVectorMatrix::MakeNewMultiVectorMatrix
SmartPtr< MultiVectorMatrix > MakeNewMultiVectorMatrix() const
Create a new MultiVectorMatrix from same MatrixSpace.
Definition: IpMultiVectorMatrix.hpp:229
Ipopt::MultiVectorMatrix::operator=
void operator=(const MultiVectorMatrix &)
Overloaded Equals Operator.
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:70
Ipopt::MultiVectorMatrix::GetVectorNonConst
SmartPtr< Vector > GetVectorNonConst(Index i)
Get a Vector in a particular column as a non-const Vector.
Definition: IpMultiVectorMatrix.hpp:64