Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpSymScaledMatrix.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: IpSymScaledMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPSYMSCALEDMATRIX_HPP__
10 #define __IPSYMSCALEDMATRIX_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpSymMatrix.hpp"
14
15 namespace Ipopt
16 {
17
18 /* forward declarations */
19 class SymScaledMatrixSpace;
20
26 class SymScaledMatrix : public SymMatrix
27 {
28 public:
29
32
35 SymScaledMatrix(const SymScaledMatrixSpace* owner_space);
36
38 ~SymScaledMatrix();
40
42 void SetUnscaledMatrix(const SmartPtr<const SymMatrix> unscaled_matrix);
43
45 void SetUnscaledMatrixNonConst(const SmartPtr<SymMatrix>& unscaled_matrix);
46
48 SmartPtr<const SymMatrix> GetUnscaledMatrix() const;
49
51 SmartPtr<SymMatrix> GetUnscaledMatrixNonConst();
52
54 SmartPtr<const Vector> RowColScaling() const;
55
56 protected:
59 virtual void MultVectorImpl(Number alpha, const Vector& x,
60 Number beta, Vector& y) const;
61
65 virtual bool HasValidNumbersImpl() const;
66
67 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
68
69 virtual void PrintImpl(const Journalist& jnlst,
70 EJournalLevel level,
71 EJournalCategory category,
72 const std::string& name,
73 Index indent,
74 const std::string& prefix) const;
76
77 private:
87 SymScaledMatrix();
88
90 SymScaledMatrix(const SymScaledMatrix&);
91
93 void operator=(const SymScaledMatrix&);
95
97 SmartPtr<const SymMatrix> matrix_;
99 SmartPtr<SymMatrix> nonconst_matrix_;
100
102 SmartPtr<const SymScaledMatrixSpace> owner_space_;
103 };
104
107 class SymScaledMatrixSpace : public SymMatrixSpace
108 {
109 public:
115 SymScaledMatrixSpace(const SmartPtr<const Vector>& row_col_scaling,
116 bool row_col_scaling_reciprocal,
117 const SmartPtr<const SymMatrixSpace>& unscaled_matrix_space)
118 :
119 SymMatrixSpace(unscaled_matrix_space->Dim()),
120 unscaled_matrix_space_(unscaled_matrix_space)
121 {
122 scaling_ = row_col_scaling->MakeNewCopy();
123 if (row_col_scaling_reciprocal) {
124 scaling_->ElementWiseReciprocal();
125 }
126 }
127
129 ~SymScaledMatrixSpace()
130 {}
132
134 SymScaledMatrix* MakeNewSymScaledMatrix(bool allocate_unscaled_matrix = false) const
135 {
136 SymScaledMatrix* ret = new SymScaledMatrix(this);
137 if (allocate_unscaled_matrix) {
138 SmartPtr<SymMatrix> unscaled_matrix = unscaled_matrix_space_->MakeNewSymMatrix();
139 ret->SetUnscaledMatrixNonConst(unscaled_matrix);
140 }
141 return ret;
142 }
143
145 virtual SymMatrix* MakeNewSymMatrix() const
146 {
147 return MakeNewSymScaledMatrix();
148 }
151 virtual Matrix* MakeNew() const
152 {
153 return MakeNewSymScaledMatrix();
154 }
155
157 SmartPtr<const Vector> RowColScaling() const
158 {
159 return ConstPtr(scaling_);
160 }
161
163 SmartPtr<const SymMatrixSpace> UnscaledMatrixSpace() const
164 {
165 return unscaled_matrix_space_;
166 }
167
168 private:
178 SymScaledMatrixSpace();
179
181 SymScaledMatrixSpace(const SymScaledMatrixSpace&);
182
184 SymScaledMatrixSpace& operator=(const SymScaledMatrixSpace&);
186
188 SmartPtr<Vector> scaling_;
190 SmartPtr<const SymMatrixSpace> unscaled_matrix_space_;
191 };
192
193 inline
194 void SymScaledMatrix::SetUnscaledMatrix(const SmartPtr<const SymMatrix> unscaled_matrix)
195 {
196 matrix_ = unscaled_matrix;
197 nonconst_matrix_ = NULL;
198 ObjectChanged();
199 }
200
201 inline
202 void SymScaledMatrix::SetUnscaledMatrixNonConst(const SmartPtr<SymMatrix>& unscaled_matrix)
203 {
204 nonconst_matrix_ = unscaled_matrix;
205 matrix_ = GetRawPtr(unscaled_matrix);
206 ObjectChanged();
207 }
208
209 inline
210 SmartPtr<const SymMatrix> SymScaledMatrix::GetUnscaledMatrix() const
211 {
212 return matrix_;
213 }
214
215 inline
216 SmartPtr<SymMatrix> SymScaledMatrix::GetUnscaledMatrixNonConst()
217 {
218 DBG_ASSERT(IsValid(nonconst_matrix_));
219 ObjectChanged();
220 return nonconst_matrix_;
221 }
222
223 inline SmartPtr<const Vector> SymScaledMatrix::RowColScaling() const
224 {
225 return ConstPtr(owner_space_->RowColScaling());
226 }
227
228 } // namespace Ipopt
229
230 #endif
Ipopt::SymScaledMatrixSpace::RowColScaling
SmartPtr< const Vector > RowColScaling() const
return the vector for the row and column scaling
Definition: IpSymScaledMatrix.hpp:157
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::SymScaledMatrix::ComputeRowAMaxImpl
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
IpUtils.hpp
Ipopt::SymScaledMatrixSpace::SymScaledMatrixSpace
SymScaledMatrixSpace()
Default constructor.
Ipopt::SymScaledMatrix::nonconst_matrix_
SmartPtr< SymMatrix > nonconst_matrix_
non-const version of the unscaled matrix
Definition: IpSymScaledMatrix.hpp:99
Ipopt::SymScaledMatrixSpace::operator=
SymScaledMatrixSpace & operator=(const SymScaledMatrixSpace &)
Overloaded Equals Operator.
IpSymMatrix.hpp
Ipopt::SymScaledMatrix::GetUnscaledMatrix
SmartPtr< const SymMatrix > GetUnscaledMatrix() const
Return the unscaled matrix in const form.
Definition: IpSymScaledMatrix.hpp:210
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::SymScaledMatrix::HasValidNumbersImpl
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Ipopt::Vector
Vector Base Class.
Definition: IpVector.hpp:47
Ipopt::SymScaledMatrix
Class for a Matrix in conjunction with its scaling factors for row and column scaling.
Definition: IpSymScaledMatrix.hpp:26
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:51
Ipopt::SymScaledMatrix::SetUnscaledMatrix
void SetUnscaledMatrix(const SmartPtr< const SymMatrix > unscaled_matrix)
Set the unscaled matrix.
Definition: IpSymScaledMatrix.hpp:194
Ipopt::SymMatrix
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:23
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::SymScaledMatrixSpace::scaling_
SmartPtr< Vector > scaling_
Row scaling vector.
Definition: IpSymScaledMatrix.hpp:188
Ipopt::SymScaledMatrixSpace::MakeNew
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
Definition: IpSymScaledMatrix.hpp:151
Ipopt::GetRawPtr
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:560
Ipopt::SymScaledMatrix::MultVectorImpl
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
Ipopt::SymScaledMatrixSpace::MakeNewSymMatrix
virtual SymMatrix * MakeNewSymMatrix() const
Overloaded method from SymMatrixSpace.
Definition: IpSymScaledMatrix.hpp:145
Ipopt::Matrix
Matrix Base Class.
Definition: IpMatrix.hpp:27
Ipopt::SymScaledMatrixSpace::SymScaledMatrixSpace
SymScaledMatrixSpace(const SmartPtr< const Vector > &row_col_scaling, bool row_col_scaling_reciprocal, const SmartPtr< const SymMatrixSpace > &unscaled_matrix_space)
Constructor, given the number of row and columns blocks, as well as the totel number of rows and colu...
Definition: IpSymScaledMatrix.hpp:115
Ipopt::SymMatrixSpace::Dim
Index Dim() const
Accessor method for the dimension of the matrices in this matrix space.
Definition: IpSymMatrix.hpp:113
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Ipopt::SymScaledMatrix::matrix_
SmartPtr< const SymMatrix > matrix_
const version of the unscaled matrix
Definition: IpSymScaledMatrix.hpp:97
DBG_ASSERT
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Ipopt::SymScaledMatrixSpace
This is the matrix space for SymScaledMatrix.
Definition: IpSymScaledMatrix.hpp:107
Ipopt::SymScaledMatrix::RowColScaling
SmartPtr< const Vector > RowColScaling() const
return the vector for the row and column scaling
Definition: IpSymScaledMatrix.hpp:223
Ipopt::ConstPtr
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:572
Ipopt::SymScaledMatrix::SymScaledMatrix
SymScaledMatrix()
Default Constructor.
Ipopt::SymMatrixSpace
SymMatrixSpace base class, corresponding to the SymMatrix base class.
Definition: IpSymMatrix.hpp:81
Ipopt::SymScaledMatrixSpace::MakeNewSymScaledMatrix
SymScaledMatrix * MakeNewSymScaledMatrix(bool allocate_unscaled_matrix=false) const
Method for creating a new matrix of this specific type.
Definition: IpSymScaledMatrix.hpp:134
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:134
Ipopt::SymScaledMatrix::GetUnscaledMatrixNonConst
SmartPtr< SymMatrix > GetUnscaledMatrixNonConst()
Return the unscaled matrix in non-const form.
Definition: IpSymScaledMatrix.hpp:216
Ipopt::SymScaledMatrixSpace::~SymScaledMatrixSpace
~SymScaledMatrixSpace()
Destructor.
Definition: IpSymScaledMatrix.hpp:129
Ipopt::SymScaledMatrixSpace::unscaled_matrix_space_
SmartPtr< const SymMatrixSpace > unscaled_matrix_space_
unscaled matrix space
Definition: IpSymScaledMatrix.hpp:190
Ipopt::SymScaledMatrix::~SymScaledMatrix
~SymScaledMatrix()
Destructor.
Ipopt::SymScaledMatrix::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::SymScaledMatrix::operator=
void operator=(const SymScaledMatrix &)
Overloaded Equals Operator.
Ipopt::SymScaledMatrixSpace::UnscaledMatrixSpace
SmartPtr< const SymMatrixSpace > UnscaledMatrixSpace() const
return the matrix space for the unscaled matrix
Definition: IpSymScaledMatrix.hpp:163
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:70
Ipopt::SymScaledMatrix::owner_space_
SmartPtr< const SymScaledMatrixSpace > owner_space_
Matrix space stored as a SymScaledMatrixSpace.
Definition: IpSymScaledMatrix.hpp:102
Ipopt::SymScaledMatrix::SetUnscaledMatrixNonConst
void SetUnscaledMatrixNonConst(const SmartPtr< SymMatrix > &unscaled_matrix)
Set the unscaled matrix in a non-const version.
Definition: IpSymScaledMatrix.hpp:202