Ipopt  3.11.7
 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 2276 2013-05-05 12:33:44Z 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;
453 
454  if (IsValid(x()))
455  tag = x()->GetTag() + tag;
456 
457  if (IsValid(s()))
458  tag = s()->GetTag() + tag;
459 
460  if (IsValid(y_c()))
461  tag = y_c()->GetTag() + tag;
462 
463  if (IsValid(y_d()))
464  tag = y_d()->GetTag() + tag;
465 
466  if (IsValid(z_L()))
467  tag = z_L()->GetTag() + tag;
468 
469  if (IsValid(z_U()))
470  tag = z_U()->GetTag() + tag;
471 
472  if (IsValid(v_L()))
473  tag = v_L()->GetTag() + tag;
474 
475  if (IsValid(v_U()))
476  tag = v_U()->GetTag() + tag;
477 
478  return tag;
479  }
481 
482  private:
491  IteratesVector();
492 
495 
497  void operator=(const IteratesVector&);
499 
501 
507  {
508  if (IsCompNull(i)) {
509  return NULL;
510  }
511  return GetComp(i);
512  }
513 
519  {
520  if (IsCompNull(i)) {
521  return NULL;
522  }
523  return GetCompNonConst(i);
524  }
525 
526  };
527 
532  {
533  public:
539  IteratesVectorSpace(const VectorSpace& x_space, const VectorSpace& s_space,
540  const VectorSpace& y_c_space, const VectorSpace& y_d_space,
541  const VectorSpace& z_L_space, const VectorSpace& z_U_space,
542  const VectorSpace& v_L_space, const VectorSpace& v_U_space
543  );
544 
545  virtual ~IteratesVectorSpace();
547 
554  virtual IteratesVector* MakeNewIteratesVector(bool create_new = true) const
555  {
556  return new IteratesVector(this, create_new);
557  }
558 
563  const Vector& y_c, const Vector& y_d,
564  const Vector& z_L, const Vector& z_U,
565  const Vector& v_L, const Vector& v_U)
566  {
568  newvec->Set_x(x);
569  newvec->Set_s(s);
570  newvec->Set_y_c(y_c);
571  newvec->Set_y_d(y_d);
572  newvec->Set_z_L(z_L);
573  newvec->Set_z_U(z_U);
574  newvec->Set_v_L(v_L);
575  newvec->Set_v_U(v_U);
576  return ConstPtr(newvec);
577  }
578 
579 
584  virtual CompoundVector* MakeNewCompoundVector(bool create_new = true) const
585  {
586  return MakeNewIteratesVector(create_new);
587  }
588 
594  virtual Vector* MakeNew() const
595  {
596  return MakeNewIteratesVector();
597  }
599 
604  virtual void SetCompSpace(Index icomp, const VectorSpace& vec_space)
605  {
606  DBG_ASSERT(false && "This is an IteratesVectorSpace - a special compound vector for Ipopt iterates. The contained spaces should not be modified.");
607  }
608 
609  private:
618 
621 
625 
635  };
636 
637 
638  inline
640  {
641  Set_x_NonConst(*owner_space_->GetCompSpace(0)->MakeNew());
642  return x_NonConst();
643  }
644  inline
646  {
647  Set_s_NonConst(*owner_space_->GetCompSpace(1)->MakeNew());
648  return s_NonConst();
649  }
650  inline
652  {
653  Set_y_c_NonConst(*owner_space_->GetCompSpace(2)->MakeNew());
654  return y_c_NonConst();
655  }
656  inline
658  {
659  Set_y_d_NonConst(*owner_space_->GetCompSpace(3)->MakeNew());
660  return y_d_NonConst();
661  }
662  inline
664  {
665  Set_z_L_NonConst(*owner_space_->GetCompSpace(4)->MakeNew());
666  return z_L_NonConst();
667  }
668  inline
670  {
671  Set_z_U_NonConst(*owner_space_->GetCompSpace(5)->MakeNew());
672  return z_U_NonConst();
673  }
674  inline
676  {
677  Set_v_L_NonConst(*owner_space_->GetCompSpace(6)->MakeNew());
678  return v_L_NonConst();
679  }
680  inline
682  {
683  Set_v_U_NonConst(*owner_space_->GetCompSpace(7)->MakeNew());
684  return v_U_NonConst();
685  }
686 } // namespace Ipopt
687 
688 #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:589
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:182
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...
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:582
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).
std::pair< const TaggedObject *, unsigned int > Tag
Type for the Tag values.
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.