Ipopt  3.11.4
 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