Ipopt 3.11.9
Loading...
Searching...
No Matches
IpIteratesVector.hpp
Go to the documentation of this file.
1// Copyright (C) 2004, 2006 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// $Id: IpIteratesVector.hpp 2476 2014-04-08 09:41:07Z stefan $
6//
7// Authors: Carl Laird, Andreas Waechter IBM 2004-06-06
8
9#ifndef __IPITERATESVECTOR_HPP__
10#define __IPITERATESVECTOR_HPP__
11
12#include "IpCompoundVector.hpp"
13
14namespace Ipopt
15{
16 /* forward declarations */
17 class IteratesVectorSpace;
18
28 {
29 public:
32 IteratesVector(const IteratesVectorSpace* owner_space, bool create_new);
33
34 virtual ~IteratesVector();
36
43 SmartPtr<IteratesVector> MakeNewIteratesVector(bool create_new = true) const;
44
49 {
51 ret->Copy(*this);
52 return ret;
53 }
54
63
68 {
69 return GetIterateFromComp(0);
70 }
71
79
81 inline
83
87 {
89 Set_x_NonConst(*curr_x->MakeNew());
90 x_NonConst()->Copy(*curr_x);
91 return x_NonConst();
92 }
93
96 void Set_x(const Vector& vec)
97 {
98 SetComp(0, vec);
99 }
100
104 {
105 SetCompNonConst(0, vec);
106 }
107
110 {
111 return GetIterateFromComp(1);
112 }
113
121
123 inline
125
129 {
131 Set_s_NonConst(*curr_s->MakeNew());
132 s_NonConst()->Copy(*curr_s);
133 return s_NonConst();
134 }
135
138 void Set_s(const Vector& vec)
139 {
140 SetComp(1, vec);
141 }
142
146 {
147 SetCompNonConst(1, vec);
148 }
149
152 {
153 return GetIterateFromComp(2);
154 }
155
163
165 inline
167
171 {
172 SmartPtr<const Vector> curr_y_c = GetComp(2);
173 Set_y_c_NonConst(*curr_y_c->MakeNew());
174 y_c_NonConst()->Copy(*curr_y_c);
175 return y_c_NonConst();
176 }
177
180 void Set_y_c(const Vector& vec)
181 {
182 SetComp(2, vec);
183 }
184
188 {
189 SetCompNonConst(2, vec);
190 }
191
194 {
195 return GetIterateFromComp(3);
196 }
197
205
207 inline
209
213 {
214 SmartPtr<const Vector> curr_y_d = GetComp(3);
215 Set_y_d_NonConst(*curr_y_d->MakeNew());
216 y_d_NonConst()->Copy(*curr_y_d);
217 return y_d_NonConst();
218 }
219
222 void Set_y_d(const Vector& vec)
223 {
224 SetComp(3, vec);
225 }
226
230 {
231 SetCompNonConst(3, vec);
232 }
233
236 {
237 return GetIterateFromComp(4);
238 }
239
247
249 inline
251
255 {
256 SmartPtr<const Vector> curr_z_L = GetComp(4);
257 Set_z_L_NonConst(*curr_z_L->MakeNew());
258 z_L_NonConst()->Copy(*curr_z_L);
259 return z_L_NonConst();
260 }
261
264 void Set_z_L(const Vector& vec)
265 {
266 SetComp(4, vec);
267 }
268
272 {
273 SetCompNonConst(4, vec);
274 }
275
278 {
279 return GetIterateFromComp(5);
280 }
281
289
291 inline
293
297 {
298 SmartPtr<const Vector> curr_z_U = GetComp(5);
299 Set_z_U_NonConst(*curr_z_U->MakeNew());
300 z_U_NonConst()->Copy(*curr_z_U);
301 return z_U_NonConst();
302 }
303
306 void Set_z_U(const Vector& vec)
307 {
308 SetComp(5, vec);
309 }
310
314 {
315 SetCompNonConst(5, vec);
316 }
317
320 {
321 return GetIterateFromComp(6);
322 }
323
331
333 inline
335
339 {
340 SmartPtr<const Vector> curr_v_L = GetComp(6);
341 Set_v_L_NonConst(*curr_v_L->MakeNew());
342 v_L_NonConst()->Copy(*curr_v_L);
343 return v_L_NonConst();
344 }
345
348 void Set_v_L(const Vector& vec)
349 {
350 SetComp(6, vec);
351 }
352
356 {
357 SetCompNonConst(6, vec);
358 }
359
362 {
363 return GetIterateFromComp(7);
364 }
365
373
375 inline
377
381 {
382 SmartPtr<const Vector> curr_v_U = GetComp(7);
383 Set_v_U_NonConst(*curr_v_U->MakeNew());
384 v_U_NonConst()->Copy(*curr_v_U);
385 return v_U_NonConst();
386 }
387
390 void Set_v_U(const Vector& vec)
391 {
392 SetComp(7, vec);
393 }
394
398 {
399 SetCompNonConst(7, vec);
400 }
401
404 void Set_primal(const Vector& x, const Vector& s)
405 {
406 SetComp(0, x);
407 SetComp(1, s);
408 }
410 {
411 SetCompNonConst(0, x);
412 SetCompNonConst(1, s);
413 }
414
417 void Set_eq_mult(const Vector& y_c, const Vector& y_d)
418 {
419 SetComp(2, y_c);
420 SetComp(3, y_d);
421 }
427
430 void Set_bound_mult(const Vector& z_L, const Vector& z_U, const Vector& v_L, const Vector& v_U)
431 {
432 SetComp(4, z_L);
433 SetComp(5, z_U);
434 SetComp(6, v_L);
435 SetComp(7, v_U);
436 }
444
451 {
452 TaggedObject::Tag tag = 0;
453
454 if (IsValid(x())) {
455 tag += x()->GetTag();
456 }
457 if (IsValid(s())) {
458 tag += s()->GetTag();
459 }
460 if (IsValid(y_c())) {
461 tag += y_c()->GetTag();
462 }
463 if (IsValid(y_d())) {
464 tag += y_d()->GetTag();
465 }
466 if (IsValid(z_L())) {
467 tag += z_L()->GetTag();
468 }
469 if (IsValid(z_U())) {
470 tag += z_U()->GetTag();
471 }
472 if (IsValid(v_L())) {
473 tag += v_L()->GetTag();
474 }
475 if (IsValid(v_U())) {
476 tag += v_U()->GetTag();
477 }
478
479 return tag;
480 }
482
483 private:
493
496
500
502
508 {
509 if (IsCompNull(i)) {
510 return NULL;
511 }
512 return GetComp(i);
513 }
514
520 {
521 if (IsCompNull(i)) {
522 return NULL;
523 }
524 return GetCompNonConst(i);
525 }
526
527 };
528
533 {
534 public:
540 IteratesVectorSpace(const VectorSpace& x_space, const VectorSpace& s_space,
541 const VectorSpace& y_c_space, const VectorSpace& y_d_space,
542 const VectorSpace& z_L_space, const VectorSpace& z_U_space,
543 const VectorSpace& v_L_space, const VectorSpace& v_U_space
544 );
545
548
555 virtual IteratesVector* MakeNewIteratesVector(bool create_new = true) const
556 {
557 return new IteratesVector(this, create_new);
558 }
559
564 const Vector& y_c, const Vector& y_d,
565 const Vector& z_L, const Vector& z_U,
566 const Vector& v_L, const Vector& v_U)
567 {
569 newvec->Set_x(x);
570 newvec->Set_s(s);
571 newvec->Set_y_c(y_c);
572 newvec->Set_y_d(y_d);
573 newvec->Set_z_L(z_L);
574 newvec->Set_z_U(z_U);
575 newvec->Set_v_L(v_L);
576 newvec->Set_v_U(v_U);
577 return ConstPtr(newvec);
578 }
579
580
585 virtual CompoundVector* MakeNewCompoundVector(bool create_new = true) const
586 {
587 return MakeNewIteratesVector(create_new);
588 }
589
595 virtual Vector* MakeNew() const
596 {
597 return MakeNewIteratesVector();
598 }
600
605 virtual void SetCompSpace(Index icomp, const VectorSpace& vec_space)
606 {
607 DBG_ASSERT(false && "This is an IteratesVectorSpace - a special compound vector for Ipopt iterates. The contained spaces should not be modified.");
608 }
609
610 private:
619
622
626
636 };
637
638
639 inline
645 inline
651 inline
657 inline
663 inline
669 inline
675 inline
681 inline
687} // namespace Ipopt
688
689#endif
#define DBG_ASSERT(test)
Definition IpDebug.hpp:38
Number * x
Input: Starting point Output: Optimal solution.
This vectors space is the vector space for CompoundVector.
SmartPtr< const VectorSpace > GetCompSpace(Index icomp) const
Method for obtaining an individual component VectorSpace.
Class of Vectors consisting of other vectors.
void SetComp(Index icomp, const Vector &vec)
Method for setting the pointer for a component that is a const Vector.
SmartPtr< const Vector > GetComp(Index i) const
Return a particular component (const version)
bool IsCompNull(Index i) const
Check if a particular component is null or not.
SmartPtr< Vector > GetCompNonConst(Index i)
Return a particular component (non-const version).
void SetCompNonConst(Index icomp, Vector &vec)
Method for setting the pointer for a component that is a non-const Vector.
Vector Space for the IteratesVector class.
virtual Vector * MakeNew() const
This method creates a new vector (and allocates space in all the contained vectors.
SmartPtr< const VectorSpace > y_d_space_
SmartPtr< const VectorSpace > x_space_
Contained Spaces.
SmartPtr< const VectorSpace > y_c_space_
virtual void SetCompSpace(Index icomp, const VectorSpace &vec_space)
This method hides the CompoundVectorSpace::SetCompSpace method since the components of the Iterates a...
virtual CompoundVector * MakeNewCompoundVector(bool create_new=true) const
This method overloads ComooundVectorSpace::MakeNewCompoundVector to make sure that we get a vector of...
IteratesVectorSpace & operator=(const IteratesVectorSpace &)
Overloaded Equals Operator.
SmartPtr< const VectorSpace > z_L_space_
IteratesVectorSpace(const VectorSpace &x_space, const VectorSpace &s_space, const VectorSpace &y_c_space, const VectorSpace &y_d_space, const VectorSpace &z_L_space, const VectorSpace &z_U_space, const VectorSpace &v_L_space, const VectorSpace &v_U_space)
Constructor that takes the spaces for each of the iterates.
SmartPtr< const VectorSpace > v_U_space_
virtual IteratesVector * MakeNewIteratesVector(bool create_new=true) const
Method for creating vectors .
IteratesVectorSpace()
Default constructor.
SmartPtr< const VectorSpace > s_space_
SmartPtr< const VectorSpace > z_U_space_
SmartPtr< const VectorSpace > v_L_space_
IteratesVectorSpace(const IteratesVectorSpace &)
Copy Constructor.
const SmartPtr< const IteratesVector > MakeNewIteratesVector(const Vector &x, const Vector &s, const Vector &y_c, const Vector &y_d, const Vector &z_L, const Vector &z_U, const Vector &v_L, const Vector &v_U)
Use this method to create a new const IteratesVector.
Specialized CompoundVector class specifically for the algorithm iterates.
SmartPtr< Vector > create_new_y_c_copy()
Create a new vector in the y_c entry and copy the current values into it.
SmartPtr< Vector > create_new_z_U_copy()
Create a new vector in the z_U entry and copy the current values into it.
SmartPtr< const Vector > v_U() const
Get the v_U iterate (const)
SmartPtr< const Vector > v_L() const
Get the v_L iterate (const)
SmartPtr< Vector > v_U_NonConst()
Get the v_U iterate (non-const) - this can only be called if the vector was created intenally,...
SmartPtr< Vector > v_L_NonConst()
Get the v_L iterate (non-const) - this can only be called if the vector was created intenally,...
SmartPtr< Vector > create_new_v_L_copy()
Create a new vector in the v_L entry and copy the current values into it.
SmartPtr< Vector > create_new_v_L()
Create a new vector in the v_L entry.
SmartPtr< const Vector > x() const
Iterates Set/Get Methods.
SmartPtr< Vector > create_new_y_d()
Create a new vector in the y_d entry.
TaggedObject::Tag GetTagSum() const
Get a sum of the tags of the contained items.
SmartPtr< const Vector > z_U() const
Get the z_U iterate (const)
SmartPtr< Vector > create_new_z_L()
Create a new vector in the z_L entry.
SmartPtr< const Vector > z_L() const
Get the z_L iterate (const)
void Set_z_U_NonConst(Vector &vec)
Set the z_U iterate (non-const).
void Set_y_d(const Vector &vec)
Set the y_d iterate (const).
SmartPtr< Vector > y_d_NonConst()
Get the y_d iterate (non-const) - this can only be called if the vector was created intenally,...
SmartPtr< const Vector > y_d() const
Get the y_d iterate (const)
SmartPtr< const Vector > y_c() const
Get the y_c iterate (const)
SmartPtr< Vector > create_new_z_U()
Create a new vector in the z_U entry.
SmartPtr< Vector > create_new_x()
Create a new vector in the x entry.
SmartPtr< Vector > y_c_NonConst()
Get the y_c iterate (non-const) - this can only be called if the vector was created intenally,...
void Set_eq_mult(const Vector &y_c, const Vector &y_d)
Set the eq multipliers all in one shot.
void Set_y_c_NonConst(Vector &vec)
Set the y_c iterate (non-const).
SmartPtr< Vector > GetNonConstIterateFromComp(Index i)
private method to return the non-const element from the compound vector.
void Set_x_NonConst(Vector &vec)
Set the x iterate (non-const).
SmartPtr< Vector > x_NonConst()
Get the x iterate (non-const) - this can only be called if the vector was created intenally,...
SmartPtr< Vector > z_L_NonConst()
Get the z_L iterate (non-const) - this can only be called if the vector was created intenally,...
void Set_bound_mult_NonConst(Vector &z_L, Vector &z_U, Vector &v_L, Vector &v_U)
SmartPtr< Vector > create_new_s()
Create a new vector in the s entry.
void Set_primal(const Vector &x, const Vector &s)
Set the primal variables all in one shot.
void Set_bound_mult(const Vector &z_L, const Vector &z_U, const Vector &v_L, const Vector &v_U)
Set the bound multipliers all in one shot.
SmartPtr< Vector > create_new_y_c()
Create a new vector in the y_c entry.
SmartPtr< Vector > s_NonConst()
Get the s iterate (non-const) - this can only be called if the vector was created intenally,...
IteratesVector(const IteratesVector &)
Copy Constructor.
SmartPtr< Vector > create_new_s_copy()
Create a new vector in the s entry and copy the current values into it.
SmartPtr< const Vector > GetIterateFromComp(Index i) const
private method to return the const element from the compound vector.
void operator=(const IteratesVector &)
Overloaded Equals Operator.
void Set_primal_NonConst(Vector &x, Vector &s)
SmartPtr< Vector > create_new_v_U()
Create a new vector in the v_U entry.
SmartPtr< Vector > create_new_x_copy()
Create a new vector in the x entry and copy the current values into it.
SmartPtr< Vector > create_new_y_d_copy()
Create a new vector in the y_d entry and copy the current values into it.
void Set_y_c(const Vector &vec)
Set the y_c iterate (const).
void Set_s_NonConst(Vector &vec)
Set the s iterate (non-const).
void Set_x(const Vector &vec)
Set the x iterate (const).
SmartPtr< Vector > create_new_v_U_copy()
Create a new vector in the v_U entry and copy the current values into it.
void Set_v_U_NonConst(Vector &vec)
Set the v_U iterate (non-const).
void Set_z_U(const Vector &vec)
Set the z_U iterate (const).
SmartPtr< Vector > create_new_z_L_copy()
Create a new vector in the z_L entry and copy the current values into it.
void Set_z_L_NonConst(Vector &vec)
Set the z_L iterate (non-const).
void Set_eq_mult_NonConst(Vector &y_c, Vector &y_d)
SmartPtr< IteratesVector > MakeNewIteratesVectorCopy() const
Use this method to create a new iterates vector with a copy of all the data.
void Set_z_L(const Vector &vec)
Set the z_L iterate (const).
SmartPtr< IteratesVector > MakeNewIteratesVector(bool create_new=true) const
Make New methods.
void Set_s(const Vector &vec)
Set the s iterate (const).
const IteratesVectorSpace * owner_space_
void Set_v_L(const Vector &vec)
Set the v_L iterate (const).
SmartPtr< IteratesVector > MakeNewContainer() const
Use this method to create a new iterates vector container.
SmartPtr< const Vector > s() const
Get the s iterate (const)
SmartPtr< Vector > z_U_NonConst()
Get the z_U iterate (non-const) - this can only be called if the vector was created intenally,...
IteratesVector(const IteratesVectorSpace *owner_space, bool create_new)
Constructors / Destructors.
void Set_v_L_NonConst(Vector &vec)
Set the v_L iterate (non-const).
IteratesVector()
Default Constructor.
void Set_y_d_NonConst(Vector &vec)
Set the y_d iterate (non-const).
void Set_v_U(const Vector &vec)
Set the v_U iterate (const).
Template class for Smart Pointers.
unsigned int Tag
Type for the Tag values.
VectorSpace base class, corresponding to the Vector base class.
Definition IpVector.hpp:391
Vector Base Class.
Definition IpVector.hpp:48
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
bool IsValid(const SmartPtr< U > &smart_ptr)
int Index
Type of all indices of vectors, matrices etc.
Definition IpTypes.hpp:19