Ipopt  3.12.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 2472 2014-04-05 17:47:20Z 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 
14 namespace 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 
76  {
78  }
79 
81  inline
83 
87  {
88  SmartPtr<const Vector> curr_x = GetComp(0);
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 
118  {
119  return GetNonConstIterateFromComp(1);
120  }
121 
123  inline
125 
129  {
130  SmartPtr<const Vector> curr_s = GetComp(1);
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 
160  {
161  return GetNonConstIterateFromComp(2);
162  }
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 
202  {
203  return GetNonConstIterateFromComp(3);
204  }
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 
244  {
245  return GetNonConstIterateFromComp(4);
246  }
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 
286  {
287  return GetNonConstIterateFromComp(5);
288  }
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 
328  {
329  return GetNonConstIterateFromComp(6);
330  }
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 
370  {
371  return GetNonConstIterateFromComp(7);
372  }
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  }
423  {
424  SetCompNonConst(2, y_c);
425  SetCompNonConst(3, y_d);
426  }
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  }
438  {
439  SetCompNonConst(4, z_L);
440  SetCompNonConst(5, z_U);
441  SetCompNonConst(6, v_L);
442  SetCompNonConst(7, v_U);
443  }
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:
492  IteratesVector();
493 
496 
498  void operator=(const IteratesVector&);
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 
546  virtual ~IteratesVectorSpace();
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
641  {
642  Set_x_NonConst(*owner_space_->GetCompSpace(0)->MakeNew());
643  return x_NonConst();
644  }
645  inline
647  {
648  Set_s_NonConst(*owner_space_->GetCompSpace(1)->MakeNew());
649  return s_NonConst();
650  }
651  inline
653  {
654  Set_y_c_NonConst(*owner_space_->GetCompSpace(2)->MakeNew());
655  return y_c_NonConst();
656  }
657  inline
659  {
660  Set_y_d_NonConst(*owner_space_->GetCompSpace(3)->MakeNew());
661  return y_d_NonConst();
662  }
663  inline
665  {
666  Set_z_L_NonConst(*owner_space_->GetCompSpace(4)->MakeNew());
667  return z_L_NonConst();
668  }
669  inline
671  {
672  Set_z_U_NonConst(*owner_space_->GetCompSpace(5)->MakeNew());
673  return z_U_NonConst();
674  }
675  inline
677  {
678  Set_v_L_NonConst(*owner_space_->GetCompSpace(6)->MakeNew());
679  return v_L_NonConst();
680  }
681  inline
683  {
684  Set_v_U_NonConst(*owner_space_->GetCompSpace(7)->MakeNew());
685  return v_U_NonConst();
686  }
687 } // namespace Ipopt
688 
689 #endif
SmartPtr< Vector > create_new_v_U()
Create a new vector in the v_U entry.
SmartPtr< const VectorSpace > y_d_space_
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:579
void Set_primal_NonConst(Vector &x, Vector &s)
Number * x
Input: Starting point Output: Optimal solution.
void SetComp(Index icomp, const Vector &vec)
Method for setting the pointer for a component that is a const Vector.
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< const Vector > v_U() const
Get the v_U iterate (const)
const IteratesVectorSpace * owner_space_
Specialized CompoundVector class specifically for the algorithm iterates.
SmartPtr< IteratesVector > MakeNewIteratesVectorCopy() const
Use this method to create a new iterates vector with a copy of all the data.
SmartPtr< Vector > create_new_z_L_copy()
Create a new vector in the z_L entry and copy the current values into it.
SmartPtr< Vector > create_new_y_c_copy()
Create a new vector in the y_c entry and copy the current values into it.
void Set_x(const Vector &vec)
Set the x iterate (const).
SmartPtr< Vector > create_new_z_U_copy()
Create a new vector in the z_U entry and copy the current values into it.
SmartPtr< Vector > create_new_y_d()
Create a new vector in the y_d entry.
void Set_z_U_NonConst(Vector &vec)
Set the z_U iterate (non-const).
IteratesVectorSpace & operator=(const IteratesVectorSpace &)
Overloaded Equals Operator.
void Set_x_NonConst(Vector &vec)
Set the x iterate (non-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< Vector > GetCompNonConst(Index i)
Return a particular component (non-const version).
void Set_y_d(const Vector &vec)
Set the y_d iterate (const).
Vector Base Class.
Definition: IpVector.hpp:47
SmartPtr< Vector > create_new_x_copy()
Create a new vector in the x entry and copy the current values into it.
SmartPtr< const VectorSpace > y_c_space_
SmartPtr< Vector > create_new_s_copy()
Create a new vector in the s entry and copy the current values into it.
SmartPtr< const Vector > z_L() const
Get the z_L iterate (const)
SmartPtr< const Vector > GetIterateFromComp(Index i) const
private method to return the const element from the compound vector.
SmartPtr< Vector > s_NonConst()
Get the s iterate (non-const) - this can only be called if the vector was created intenally...
void Set_y_c_NonConst(Vector &vec)
Set the y_c iterate (non-const).
SmartPtr< const Vector > y_d() const
Get the y_d iterate (const)
virtual void SetCompSpace(Index icomp, const VectorSpace &vec_space)
This method hides the CompoundVectorSpace::SetCompSpace method since the components of the Iterates a...
SmartPtr< const VectorSpace > x_space_
Contained Spaces.
void Set_primal(const Vector &x, const Vector &s)
Set the primal variables all in one shot.
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).
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
IteratesVectorSpace()
Default constructor.
SmartPtr< const VectorSpace > v_U_space_
SmartPtr< Vector > create_new_y_d_copy()
Create a new vector in the y_d entry and copy the current values into it.
VectorSpace base class, corresponding to the Vector base class.
Definition: IpVector.hpp:390
SmartPtr< Vector > v_U_NonConst()
Get the v_U iterate (non-const) - this can only be called if the vector was created intenally...
SmartPtr< const VectorSpace > s_space_
SmartPtr< const Vector > v_L() const
Get the v_L iterate (const)
SmartPtr< const VectorSpace > v_L_space_
SmartPtr< Vector > x_NonConst()
Get the x iterate (non-const) - this can only be called if the vector was created intenally...
virtual IteratesVector * MakeNewIteratesVector(bool create_new=true) const
Method for creating vectors .
void Set_v_U(const Vector &vec)
Set the v_U iterate (const).
void Set_z_U(const Vector &vec)
Set the z_U iterate (const).
TaggedObject::Tag GetTagSum() const
Get a sum of the tags of the contained items.
SmartPtr< Vector > create_new_s()
Create a new vector in the s entry.
SmartPtr< const VectorSpace > z_L_space_
SmartPtr< const VectorSpace > GetCompSpace(Index icomp) const
Method for obtaining an individual component VectorSpace.
virtual CompoundVector * MakeNewCompoundVector(bool create_new=true) const
This method overloads ComooundVectorSpace::MakeNewCompoundVector to make sure that we get a vector of...
void Set_s(const Vector &vec)
Set the s iterate (const).
void Set_y_c(const Vector &vec)
Set the y_c iterate (const).
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
SmartPtr< Vector > GetNonConstIterateFromComp(Index i)
private method to return the non-const element from the compound vector.
void SetCompNonConst(Index icomp, Vector &vec)
Method for setting the pointer for a component that is a non-const Vector.
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
SmartPtr< const Vector > y_c() const
Get the y_c iterate (const)
SmartPtr< Vector > y_c_NonConst()
Get the y_c iterate (non-const) - this can only be called if the vector was created intenally...
unsigned int Tag
Type for the Tag values.
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.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:572
void Set_z_L(const Vector &vec)
Set the z_L iterate (const).
void Set_z_L_NonConst(Vector &vec)
Set the z_L iterate (non-const).
void Set_y_d_NonConst(Vector &vec)
Set the y_d iterate (non-const).
void Set_s_NonConst(Vector &vec)
Set the s iterate (non-const).
SmartPtr< const Vector > GetComp(Index i) const
Return a particular component (const version)
SmartPtr< const Vector > z_U() const
Get the z_U iterate (const)
SmartPtr< IteratesVector > MakeNewIteratesVector(bool create_new=true) const
Make New methods.
SmartPtr< Vector > create_new_y_c()
Create a new vector in the y_c entry.
Vector Space for the IteratesVector class.
bool IsCompNull(Index i) const
Check if a particular component is null or not.
SmartPtr< Vector > v_L_NonConst()
Get the v_L iterate (non-const) - this can only be called if the vector was created intenally...
This vectors space is the vector space for CompoundVector.
SmartPtr< Vector > create_new_z_U()
Create a new vector in the z_U entry.
virtual Vector * MakeNew() const
This method creates a new vector (and allocates space in all the contained vectors.
void Set_v_L(const Vector &vec)
Set the v_L iterate (const).
SmartPtr< const Vector > s() const
Get the s iterate (const)
void Set_eq_mult_NonConst(Vector &y_c, Vector &y_d)
void Set_v_L_NonConst(Vector &vec)
Set the v_L iterate (non-const).
SmartPtr< IteratesVector > MakeNewContainer() const
Use this method to create a new iterates vector container.
SmartPtr< const Vector > x() const
Iterates Set/Get Methods.
SmartPtr< Vector > z_L_NonConst()
Get the z_L iterate (non-const) - this can only be called if the vector was created intenally...
IteratesVector()
Default Constructor.
SmartPtr< const VectorSpace > z_U_space_
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_x()
Create a new vector in the x entry.
void Set_eq_mult(const Vector &y_c, const Vector &y_d)
Set the eq multipliers all in one shot.
Class of Vectors consisting of other vectors.
void Set_bound_mult_NonConst(Vector &z_L, Vector &z_U, Vector &v_L, Vector &v_U)
SmartPtr< Vector > z_U_NonConst()
Get the z_U iterate (non-const) - this can only be called if the vector was created intenally...
void operator=(const IteratesVector &)
Overloaded Equals Operator.
SmartPtr< Vector > create_new_z_L()
Create a new vector in the z_L entry.
SmartPtr< Vector > create_new_v_L()
Create a new vector in the v_L entry.