Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpScaledMatrix.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2008 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpScaledMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPSCALEDMATRIX_HPP__
10 #define __IPSCALEDMATRIX_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpMatrix.hpp"
14
15 namespace Ipopt
16 {
17
18 /* forward declarations */
19 class ScaledMatrixSpace;
20
26 class ScaledMatrix : public Matrix
27 {
28 public:
29
32
35 ScaledMatrix(const ScaledMatrixSpace* owner_space);
36
38 ~ScaledMatrix();
40
42 void SetUnscaledMatrix(const SmartPtr<const Matrix> unscaled_matrix);
43
45 void SetUnscaledMatrixNonConst(const SmartPtr<Matrix>& unscaled_matrix);
46
48 SmartPtr<const Matrix> GetUnscaledMatrix() const;
49
51 SmartPtr<Matrix> GetUnscaledMatrixNonConst();
52
54 SmartPtr<const Vector> RowScaling() const;
55
57 SmartPtr<const Vector> ColumnScaling() const;
58
59 protected:
62 virtual void MultVectorImpl(Number alpha, const Vector& x,
63 Number beta, Vector& y) const;
64
65 virtual void TransMultVectorImpl(Number alpha, const Vector& x,
66 Number beta, Vector& y) const;
67
71 virtual bool HasValidNumbersImpl() const;
72
73 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
74
75 virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
76
77 virtual void PrintImpl(const Journalist& jnlst,
78 EJournalLevel level,
79 EJournalCategory category,
80 const std::string& name,
81 Index indent,
82 const std::string& prefix) const;
83
87 virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z,
88 Vector& X) const;
89
93 virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector& S,
94 const Vector& R, const Vector& Z,
95 const Vector& D, Vector& X) const;
97
98 private:
108 ScaledMatrix();
109
111 ScaledMatrix(const ScaledMatrix&);
112
114 void operator=(const ScaledMatrix&);
116
118 SmartPtr<const Matrix> matrix_;
120 SmartPtr<Matrix> nonconst_matrix_;
121
123 SmartPtr<const ScaledMatrixSpace> owner_space_;
124 };
125
128 class ScaledMatrixSpace : public MatrixSpace
129 {
130 public:
136 ScaledMatrixSpace(const SmartPtr<const Vector>& row_scaling,
137 bool row_scaling_reciprocal,
138 const SmartPtr<const MatrixSpace>& unscaled_matrix_space,
139 const SmartPtr<const Vector>& column_scaling,
140 bool column_scaling_reciprocal);
141
143 ~ScaledMatrixSpace()
144 {}
146
148 ScaledMatrix* MakeNewScaledMatrix(bool allocate_unscaled_matrix = false) const
149 {
150 ScaledMatrix* ret = new ScaledMatrix(this);
151 if (allocate_unscaled_matrix) {
152 SmartPtr<Matrix> unscaled_matrix = unscaled_matrix_space_->MakeNew();
153 ret->SetUnscaledMatrixNonConst(unscaled_matrix);
154 }
155 return ret;
156 }
157
160 virtual Matrix* MakeNew() const
161 {
162 return MakeNewScaledMatrix();
163 }
164
166 SmartPtr<const Vector> RowScaling() const
167 {
168 return ConstPtr(row_scaling_);
169 }
170
172 SmartPtr<const MatrixSpace> UnscaledMatrixSpace() const
173 {
174 return unscaled_matrix_space_;
175 }
176
178 SmartPtr<const Vector> ColumnScaling() const
179 {
180 return ConstPtr(column_scaling_);
181 }
182
183 private:
193 ScaledMatrixSpace();
194
196 ScaledMatrixSpace(const ScaledMatrixSpace&);
197
199 ScaledMatrixSpace& operator=(const ScaledMatrixSpace&);
201
203 SmartPtr<Vector> row_scaling_;
205 SmartPtr<const MatrixSpace> unscaled_matrix_space_;
207 SmartPtr<Vector> column_scaling_;
208 };
209
210 inline
211 void ScaledMatrix::SetUnscaledMatrix(const SmartPtr<const Matrix> unscaled_matrix)
212 {
213 matrix_ = unscaled_matrix;
214 nonconst_matrix_ = NULL;
215 ObjectChanged();
216 }
217
218 inline
219 void ScaledMatrix::SetUnscaledMatrixNonConst(const SmartPtr<Matrix>& unscaled_matrix)
220 {
221 nonconst_matrix_ = unscaled_matrix;
222 matrix_ = GetRawPtr(unscaled_matrix);
223 ObjectChanged();
224 }
225
226 inline
227 SmartPtr<const Matrix> ScaledMatrix::GetUnscaledMatrix() const
228 {
229 return matrix_;
230 }
231
232 inline
233 SmartPtr<Matrix> ScaledMatrix::GetUnscaledMatrixNonConst()
234 {
235 DBG_ASSERT(IsValid(nonconst_matrix_));
236 ObjectChanged();
237 return nonconst_matrix_;
238 }
239
240 inline
241 SmartPtr<const Vector> ScaledMatrix::RowScaling() const
242 {
243 return ConstPtr(owner_space_->RowScaling());
244 }
245
246 inline
247 SmartPtr<const Vector> ScaledMatrix::ColumnScaling() const
248 {
249 return ConstPtr(owner_space_->ColumnScaling());
250 }
251
252 } // namespace Ipopt
253
254 #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
IpUtils.hpp
Ipopt::ScaledMatrix::owner_space_
SmartPtr< const ScaledMatrixSpace > owner_space_
Matrix space stored as a ScaledMatrixSpace.
Definition: IpScaledMatrix.hpp:123
Ipopt::ScaledMatrix::MultVectorImpl
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
Ipopt::ScaledMatrixSpace::UnscaledMatrixSpace
SmartPtr< const MatrixSpace > UnscaledMatrixSpace() const
return the matrix space for the unscaled matrix
Definition: IpScaledMatrix.hpp:172
Ipopt::ScaledMatrix::ScaledMatrix
ScaledMatrix()
Default Constructor.
Ipopt::ScaledMatrix
Class for a Matrix in conjunction with its scaling factors for row and column scaling.
Definition: IpScaledMatrix.hpp:26
Ipopt::ScaledMatrixSpace::row_scaling_
SmartPtr< Vector > row_scaling_
Row scaling vector.
Definition: IpScaledMatrix.hpp:203
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::ScaledMatrix::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.
Ipopt::ScaledMatrix::ColumnScaling
SmartPtr< const Vector > ColumnScaling() const
return the vector for the column scaling
Definition: IpScaledMatrix.hpp:247
Ipopt::ScaledMatrixSpace::MakeNew
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
Definition: IpScaledMatrix.hpp:160
Ipopt::ScaledMatrixSpace::ColumnScaling
SmartPtr< const Vector > ColumnScaling() const
return the vector for the column scaling
Definition: IpScaledMatrix.hpp:178
IpMatrix.hpp
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:51
Ipopt::ScaledMatrixSpace::RowScaling
SmartPtr< const Vector > RowScaling() const
return the vector for the row scaling
Definition: IpScaledMatrix.hpp:166
Ipopt::ScaledMatrix::TransMultVectorImpl
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
Ipopt::ScaledMatrix::GetUnscaledMatrix
SmartPtr< const Matrix > GetUnscaledMatrix() const
Return the unscaled matrix in const form.
Definition: IpScaledMatrix.hpp:227
Ipopt::ScaledMatrixSpace::MakeNewScaledMatrix
ScaledMatrix * MakeNewScaledMatrix(bool allocate_unscaled_matrix=false) const
Method for creating a new matrix of this specific type.
Definition: IpScaledMatrix.hpp:148
Ipopt::ScaledMatrixSpace::~ScaledMatrixSpace
~ScaledMatrixSpace()
Destructor.
Definition: IpScaledMatrix.hpp:143
Ipopt::ScaledMatrixSpace
This is the matrix space for ScaledMatrix.
Definition: IpScaledMatrix.hpp:128
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::ScaledMatrixSpace::ScaledMatrixSpace
ScaledMatrixSpace()
Default constructor.
Ipopt::ScaledMatrix::ComputeRowAMaxImpl
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
Ipopt::GetRawPtr
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:560
Ipopt::ScaledMatrix::SetUnscaledMatrixNonConst
void SetUnscaledMatrixNonConst(const SmartPtr< Matrix > &unscaled_matrix)
Set the unscaled matrix in a non-const version.
Definition: IpScaledMatrix.hpp:219
Ipopt::Matrix
Matrix Base Class.
Definition: IpMatrix.hpp:27
Ipopt::ScaledMatrix::AddMSinvZImpl
virtual void AddMSinvZImpl(Number alpha, const Vector &S, const Vector &Z, Vector &X) const
X = beta*X + alpha*(Matrix S^{-1} Z).
Ipopt::ScaledMatrix::GetUnscaledMatrixNonConst
SmartPtr< Matrix > GetUnscaledMatrixNonConst()
Return the unscaled matrix in non-const form.
Definition: IpScaledMatrix.hpp:233
Ipopt::MatrixSpace
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:239
Ipopt::ScaledMatrix::operator=
void operator=(const ScaledMatrix &)
Overloaded Equals Operator.
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
DBG_ASSERT
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Ipopt::ScaledMatrixSpace::unscaled_matrix_space_
SmartPtr< const MatrixSpace > unscaled_matrix_space_
unscaled matrix space
Definition: IpScaledMatrix.hpp:205
Ipopt::ConstPtr
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:572
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:134
Ipopt::ScaledMatrix::SinvBlrmZMTdBrImpl
virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector &S, const Vector &R, const Vector &Z, const Vector &D, Vector &X) const
X = S^{-1} (r + alpha*Z*M^Td).
Ipopt::ScaledMatrixSpace::operator=
ScaledMatrixSpace & operator=(const ScaledMatrixSpace &)
Overloaded Equals Operator.
Ipopt::ScaledMatrix::nonconst_matrix_
SmartPtr< Matrix > nonconst_matrix_
non-const version of the unscaled matrix
Definition: IpScaledMatrix.hpp:120
Ipopt::ScaledMatrix::~ScaledMatrix
~ScaledMatrix()
Destructor.
Ipopt::ScaledMatrix::SetUnscaledMatrix
void SetUnscaledMatrix(const SmartPtr< const Matrix > unscaled_matrix)
Set the unscaled matrix.
Definition: IpScaledMatrix.hpp:211
Ipopt::ScaledMatrix::matrix_
SmartPtr< const Matrix > matrix_
const version of the unscaled matrix
Definition: IpScaledMatrix.hpp:118
Ipopt::ScaledMatrix::ComputeColAMaxImpl
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
Ipopt::ScaledMatrix::HasValidNumbersImpl
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:70
Ipopt::ScaledMatrixSpace::column_scaling_
SmartPtr< Vector > column_scaling_
column scaling vector
Definition: IpScaledMatrix.hpp:207
Ipopt::ScaledMatrix::RowScaling
SmartPtr< const Vector > RowScaling() const
return the vector for the row scaling
Definition: IpScaledMatrix.hpp:241