Ipopt
3.12.12
|
Dense Vector Implementation. More...
#include <IpDenseVector.hpp>
Public Member Functions | |
Constructors / Destructors | |
DenseVector (const DenseVectorSpace *owner_space) | |
Default Constructor. More... | |
virtual | ~DenseVector () |
Destructor. More... | |
Additional public methods not in Vector base class. | |
SmartPtr< DenseVector > | MakeNewDenseVector () const |
Create a new DenseVector from same VectorSpace. More... | |
void | SetValues (const Number *x) |
Set elements in the vector to the Number array x. More... | |
Number * | Values () |
Obtain pointer to the internal Number array with vector elements with the indention to change the vector data (USE WITH CARE!). More... | |
const Number * | Values () const |
Obtain pointer to the internal Number array with vector elements without the intention to change the vector data (USE WITH CARE!). More... | |
const Number * | ExpandedValues () const |
The same as the const version of Values, but we ensure that we always return a valid array, even if IsHomogeneous returns true. More... | |
Number * | ExpandedValues () |
This is the same as Values, but we add it here so that ExpandedValues can also be used for the non-const case. More... | |
bool | IsHomogeneous () const |
Indicates if the vector is homogeneous (i.e., all entries have the value Scalar() More... | |
Number | Scalar () const |
Scalar value of all entries in a homogeneous vector. More... | |
Modifying subranges of the vector. | |
void | CopyToPos (Index Pos, const Vector &x) |
Copy the data in x into the subrange of this vector starting at position Pos in this vector. More... | |
void | CopyFromPos (Index Pos, const Vector &x) |
Copy a subrange of x, starting at Pos, into the full data of this vector. More... | |
![]() | |
Vector * | MakeNew () const |
Create new Vector of the same type with uninitialized data. More... | |
Vector * | MakeNewCopy () const |
Create new Vector of the same type and copy the data over. More... | |
bool | HasValidNumbers () const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). More... | |
Vector (const VectorSpace *owner_space) | |
Constructor. More... | |
virtual | ~Vector () |
Destructor. More... | |
void | Copy (const Vector &x) |
Copy the data of the vector x into this vector (DCOPY). More... | |
void | Scal (Number alpha) |
Scales the vector by scalar alpha (DSCAL) More... | |
void | Axpy (Number alpha, const Vector &x) |
Add the multiple alpha of vector x to this vector (DAXPY) More... | |
Number | Dot (const Vector &x) const |
Computes inner product of vector x with this (DDOT) More... | |
Number | Nrm2 () const |
Computes the 2-norm of this vector (DNRM2) More... | |
Number | Asum () const |
Computes the 1-norm of this vector (DASUM) More... | |
Number | Amax () const |
Computes the max-norm of this vector (based on IDAMAX) More... | |
void | Set (Number alpha) |
Set each element in the vector to the scalar alpha. More... | |
void | ElementWiseDivide (const Vector &x) |
Element-wise division ![]() | |
void | ElementWiseMultiply (const Vector &x) |
Element-wise multiplication ![]() | |
void | ElementWiseMax (const Vector &x) |
Element-wise max against entries in x. More... | |
void | ElementWiseMin (const Vector &x) |
Element-wise min against entries in x. More... | |
void | ElementWiseReciprocal () |
Reciprocates the entries in the vector. More... | |
void | ElementWiseAbs () |
Absolute values of the entries in the vector. More... | |
void | ElementWiseSqrt () |
Element-wise square root of the entries in the vector. More... | |
void | ElementWiseSgn () |
Replaces the vector values with their sgn values ( -1 if x_i < 0, 0 if x_i == 0, and 1 if x_i > 0) More... | |
void | AddScalar (Number scalar) |
Add scalar to every vector component. More... | |
Number | Max () const |
Returns the maximum value in the vector. More... | |
Number | Min () const |
Returns the minimum value in the vector. More... | |
Number | Sum () const |
Returns the sum of the vector entries. More... | |
Number | SumLogs () const |
Returns the sum of the logs of each vector entry. More... | |
void | AddOneVector (Number a, const Vector &v1, Number c) |
Add one vector, y = a * v1 + c * y. More... | |
void | AddTwoVectors (Number a, const Vector &v1, Number b, const Vector &v2, Number c) |
Add two vectors, y = a * v1 + b * v2 + c * y. More... | |
Number | FracToBound (const Vector &delta, Number tau) const |
Fraction to the boundary parameter. More... | |
void | AddVectorQuotient (Number a, const Vector &z, const Vector &s, Number c) |
Add the quotient of two vectors, y = a * z/s + c * y. More... | |
Index | Dim () const |
Dimension of the Vector. More... | |
SmartPtr< const VectorSpace > | OwnerSpace () const |
Return the owner VectorSpace. More... | |
void | Print (SmartPtr< const Journalist > jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent=0, const std::string &prefix="") const |
Print the entire vector. More... | |
void | Print (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent=0, const std::string &prefix="") const |
![]() | |
TaggedObject () | |
Constructor. More... | |
virtual | ~TaggedObject () |
Destructor. More... | |
Tag | GetTag () const |
Users of TaggedObjects call this to update their own internal tags every time they perform the expensive operation. More... | |
bool | HasChanged (const Tag comparison_tag) const |
Users of TaggedObjects call this to check if the object HasChanged since they last updated their own internal tag. More... | |
![]() | |
ReferencedObject () | |
virtual | ~ReferencedObject () |
Index | ReferenceCount () const |
void | AddRef (const Referencer *referencer) const |
void | ReleaseRef (const Referencer *referencer) const |
![]() | |
Subject () | |
Default Constructor. More... | |
virtual | ~Subject () |
Default destructor. More... | |
void | AttachObserver (Observer::NotifyType notify_type, Observer *observer) const |
Attach the specified observer (i.e., begin recieving notifications). More... | |
void | DetachObserver (Observer::NotifyType notify_type, Observer *observer) const |
Detach the specified observer (i.e., no longer recieve notifications). More... | |
Protected Member Functions | |
Overloaded methods from Vector base class | |
virtual void | CopyImpl (const Vector &x) |
Copy the data of the vector x into this vector (DCOPY). More... | |
virtual void | ScalImpl (Number alpha) |
Scales the vector by scalar alpha (DSCAL) More... | |
virtual void | AxpyImpl (Number alpha, const Vector &x) |
Add the multiple alpha of vector x to this vector (DAXPY) More... | |
virtual Number | DotImpl (const Vector &x) const |
Computes inner product of vector x with this (DDOT) More... | |
virtual Number | Nrm2Impl () const |
Computes the 2-norm of this vector (DNRM2) More... | |
virtual Number | AsumImpl () const |
Computes the 1-norm of this vector (DASUM) More... | |
virtual Number | AmaxImpl () const |
Computes the max-norm of this vector (based on IDAMAX) More... | |
virtual void | SetImpl (Number value) |
Set each element in the vector to the scalar alpha. More... | |
virtual void | ElementWiseDivideImpl (const Vector &x) |
Element-wise division ![]() | |
virtual void | ElementWiseMultiplyImpl (const Vector &x) |
Element-wise multiplication ![]() | |
virtual void | ElementWiseMaxImpl (const Vector &x) |
Set entry to max of itself and the corresponding element in x. More... | |
virtual void | ElementWiseMinImpl (const Vector &x) |
Set entry to min of itself and the corresponding element in x. More... | |
virtual void | ElementWiseReciprocalImpl () |
reciprocates the elements of the vector More... | |
virtual void | ElementWiseAbsImpl () |
take abs of the elements of the vector More... | |
virtual void | ElementWiseSqrtImpl () |
take square-root of the elements of the vector More... | |
virtual void | ElementWiseSgnImpl () |
Changes each entry in the vector to its sgn value. More... | |
virtual void | AddScalarImpl (Number scalar) |
Add scalar to every component of the vector. More... | |
virtual Number | MaxImpl () const |
Max value in the vector. More... | |
virtual Number | MinImpl () const |
Min value in the vector. More... | |
virtual Number | SumImpl () const |
Computes the sum of the lements of vector. More... | |
virtual Number | SumLogsImpl () const |
Computes the sum of the logs of the elements of vector. More... | |
Implemented specialized functions | |
void | AddTwoVectorsImpl (Number a, const Vector &v1, Number b, const Vector &v2, Number c) |
Add two vectors (a * v1 + b * v2). More... | |
Number | FracToBoundImpl (const Vector &delta, Number tau) const |
Fraction to the boundary parameter. More... | |
void | AddVectorQuotientImpl (Number a, const Vector &z, const Vector &s, Number c) |
Add the quotient of two vectors, y = a * z/s + c * y. More... | |
Output methods | |
virtual void | PrintImpl (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix) const |
Print the entire vector. More... | |
void | PrintImplOffset (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix, Index offset) const |
![]() | |
virtual bool | HasValidNumbersImpl () const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). More... | |
![]() | |
void | ObjectChanged () |
Objects derived from TaggedObject MUST call this method every time their internal state changes to update the internal tag for comparison. More... | |
![]() | |
void | Notify (Observer::NotifyType notify_type) const |
Private Member Functions | |
Number * | values_allocated () |
Method of getting the internal values array, making sure that memory has been allocated. More... | |
void | set_values_from_scalar () |
Auxilliary method for setting explicitly all elements in values_ to the current scalar value. More... | |
Default Compiler Generated Methods | |
(Hidden to avoid implicit creation/calling). These methods are not implemented and we do not want the compiler to implement them for us, so we declare them private and do not define them. This ensures that they will not be implicitly created/called. | |
DenseVector () | |
Default Constructor. More... | |
DenseVector (const DenseVector &) | |
Copy Constructor. More... | |
void | operator= (const DenseVector &) |
Overloaded Equals Operator. More... | |
Private Attributes | |
const DenseVectorSpace * | owner_space_ |
Copy of the owner_space ptr as a DenseVectorSpace instead of a VectorSpace. More... | |
Number * | values_ |
Dense Number array of vector values. More... | |
Number * | expanded_values_ |
Dense Number array pointer that is used for ExpandedValues. More... | |
bool | initialized_ |
Flag for Initialization. More... | |
bool | homogeneous_ |
Flag indicating whether the vector is currently homogeneous (that is, all elements have the same value). More... | |
Number | scalar_ |
Homogeneous value of all elements if the vector is currently homogenous. More... | |
Friends | |
class | ParVector |
Additional Inherited Members | |
![]() | |
typedef unsigned int | Tag |
Type for the Tag values. More... | |
Dense Vector Implementation.
This is the default Vector class in Ipopt. It stores vectors in contiguous Number arrays, unless the vector has the same value in all entires. In the latter case, we call the vector "homogeneous", and we store only the values that is repeated in all elements. If you want to obtain the values of vector, use the IsHomogeneous() method to find out what status the vector is in, and then use either Values() const or Scalar() const methods to get the values. To set the values of a homogeneous method, use the Set method. To set the values of a non-homogeneous vector, use the SetValues method, or use the non-const Values method to get an array that you can overwrite. In the latter case, storage is ensured.
Definition at line 40 of file IpDenseVector.hpp.
Ipopt::DenseVector::DenseVector | ( | const DenseVectorSpace * | owner_space | ) |
Default Constructor.
|
virtual |
Destructor.
|
private |
Default Constructor.
|
private |
Copy Constructor.
|
inline |
Create a new DenseVector from same VectorSpace.
Definition at line 442 of file IpDenseVector.hpp.
void Ipopt::DenseVector::SetValues | ( | const Number * | x | ) |
Set elements in the vector to the Number array x.
|
inline |
Obtain pointer to the internal Number array with vector elements with the indention to change the vector data (USE WITH CARE!).
This does not produce a copy, and lifetime is not guaranteed!.
Definition at line 393 of file IpDenseVector.hpp.
|
inline |
Obtain pointer to the internal Number array with vector elements without the intention to change the vector data (USE WITH CARE!).
This does not produce a copy, and lifetime is not guaranteed! IMPORTANT: If this method is currently homogeneous (i.e. IsHomogeneous returns true), then you cannot call this method. Instead, you need to use the Scalar() method.
Definition at line 410 of file IpDenseVector.hpp.
const Number* Ipopt::DenseVector::ExpandedValues | ( | ) | const |
The same as the const version of Values, but we ensure that we always return a valid array, even if IsHomogeneous returns true.
|
inline |
This is the same as Values, but we add it here so that ExpandedValues can also be used for the non-const case.
Definition at line 87 of file IpDenseVector.hpp.
|
inline |
Indicates if the vector is homogeneous (i.e., all entries have the value Scalar()
Definition at line 94 of file IpDenseVector.hpp.
|
inline |
Scalar value of all entries in a homogeneous vector.
Definition at line 100 of file IpDenseVector.hpp.
Copy the data in x into the subrange of this vector starting at position Pos in this vector.
Position count starts at 0.
Copy a subrange of x, starting at Pos, into the full data of this vector.
Position count starts at 0.
|
protectedvirtual |
Copy the data of the vector x into this vector (DCOPY).
Implements Ipopt::Vector.
|
protectedvirtual |
Scales the vector by scalar alpha (DSCAL)
Implements Ipopt::Vector.
Add the multiple alpha of vector x to this vector (DAXPY)
Implements Ipopt::Vector.
Computes inner product of vector x with this (DDOT)
Implements Ipopt::Vector.
|
protectedvirtual |
Computes the 2-norm of this vector (DNRM2)
Implements Ipopt::Vector.
|
protectedvirtual |
Computes the 1-norm of this vector (DASUM)
Implements Ipopt::Vector.
|
protectedvirtual |
Computes the max-norm of this vector (based on IDAMAX)
Implements Ipopt::Vector.
|
protectedvirtual |
Set each element in the vector to the scalar alpha.
Implements Ipopt::Vector.
|
protectedvirtual |
Element-wise division .
Implements Ipopt::Vector.
|
protectedvirtual |
Element-wise multiplication .
Implements Ipopt::Vector.
|
protectedvirtual |
Set entry to max of itself and the corresponding element in x.
Implements Ipopt::Vector.
|
protectedvirtual |
Set entry to min of itself and the corresponding element in x.
Implements Ipopt::Vector.
|
protectedvirtual |
reciprocates the elements of the vector
Implements Ipopt::Vector.
|
protectedvirtual |
take abs of the elements of the vector
Implements Ipopt::Vector.
|
protectedvirtual |
take square-root of the elements of the vector
Implements Ipopt::Vector.
|
protectedvirtual |
Changes each entry in the vector to its sgn value.
Implements Ipopt::Vector.
|
protectedvirtual |
Add scalar to every component of the vector.
Implements Ipopt::Vector.
|
protectedvirtual |
Max value in the vector.
Implements Ipopt::Vector.
|
protectedvirtual |
Min value in the vector.
Implements Ipopt::Vector.
|
protectedvirtual |
Computes the sum of the lements of vector.
Implements Ipopt::Vector.
|
protectedvirtual |
Computes the sum of the logs of the elements of vector.
Implements Ipopt::Vector.
|
protectedvirtual |
Add two vectors (a * v1 + b * v2).
Result is stored in this vector.
Reimplemented from Ipopt::Vector.
|
protectedvirtual |
Fraction to the boundary parameter.
Reimplemented from Ipopt::Vector.
|
protectedvirtual |
Add the quotient of two vectors, y = a * z/s + c * y.
Reimplemented from Ipopt::Vector.
|
inlineprotectedvirtual |
Print the entire vector.
Implements Ipopt::Vector.
Definition at line 201 of file IpDenseVector.hpp.
|
protected |
|
private |
Overloaded Equals Operator.
|
inlineprivate |
Method of getting the internal values array, making sure that memory has been allocated.
Definition at line 416 of file IpDenseVector.hpp.
|
private |
Auxilliary method for setting explicitly all elements in values_ to the current scalar value.
|
friend |
Definition at line 220 of file IpDenseVector.hpp.
|
private |
Copy of the owner_space ptr as a DenseVectorSpace instead of a VectorSpace.
Definition at line 244 of file IpDenseVector.hpp.
|
private |
Dense Number array of vector values.
Definition at line 247 of file IpDenseVector.hpp.
|
mutableprivate |
Dense Number array pointer that is used for ExpandedValues.
Definition at line 250 of file IpDenseVector.hpp.
|
private |
Flag for Initialization.
This flag is false, if the data has not yet been initialized.
Definition at line 259 of file IpDenseVector.hpp.
|
private |
Flag indicating whether the vector is currently homogeneous (that is, all elements have the same value).
This flag is used to determine whether the elements of the vector are stored in values_ or in scalar_
Definition at line 265 of file IpDenseVector.hpp.
|
private |
Homogeneous value of all elements if the vector is currently homogenous.
Definition at line 269 of file IpDenseVector.hpp.