source: branches/dev/Algorithm/IpIpoptData.cpp @ 567

Last change on this file since 567 was 567, checked in by andreasw, 15 years ago

adapted for Portland compilers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1// Copyright (C) 2004, 2005 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// $Id: IpIpoptData.cpp 567 2005-11-01 23:27:11Z andreasw $
6//
7// Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
8
9#include "IpIpoptData.hpp"
10#include "IpIpoptNLP.hpp"
11
12namespace Ipopt
13{
14
15  IpoptData::IpoptData()
16  {}
17
18  IpoptData::~IpoptData()
19  {}
20
21  void IpoptData::RegisterOptions(const SmartPtr<RegisteredOptions>& roptions)
22  {
23    roptions->SetRegisteringCategory("Convergence");
24    roptions->AddLowerBoundedNumberOption(
25      "tol",
26      "Desired convergence tolerance (relative).",
27      0.0, true,  1e-8,
28      "Determines the convergence tolerance for the algorithm.  The "
29      "algorithm terminates successfully, if the (scaled) NLP error "
30      "becomes smaller than this value, and if the (absolute) criteria "
31      "according to \"dual_inf_tol\", \"primal_inf_tol\", and "
32      "\"cmpl_inf_tol\" are met.  (This is epsilon_tol in Eqn. (6) in "
33      "implementation paper).  See also \"acceptable_tol\" as a second "
34      "termination criterion.  Note, some other algorithmic features also use "
35      "this quantity.");
36  }
37
38  bool IpoptData::Initialize(const Journalist& jnlst,
39                             const OptionsList& options,
40                             const std::string& prefix)
41  {
42    options.GetNumericValue("tol", tol_, prefix);
43
44    iter_count_ = 0;
45    curr_mu_ = -1.;
46    mu_initialized_ = false;
47    curr_tau_ = -1.;
48    tau_initialized_ = false;
49    initialize_called_ = false;
50    have_prototypes_ = false;
51    have_deltas_ = false;
52    have_affine_deltas_ = false;
53
54    free_mu_mode_ = false;
55    tiny_step_flag_ = false;
56
57    ResetInfo();
58
59    initialize_called_ = true;
60
61    return true;
62  }
63
64  bool IpoptData::InitializeDataStructures(IpoptNLP& ip_nlp,
65      bool want_x,
66      bool want_y_c,
67      bool want_y_d,
68      bool want_z_L,
69      bool want_z_U)
70  {
71    DBG_ASSERT(initialize_called_);
72    /*
73     * Allocate space for all the required linear algebra
74     * structures
75     */
76
77    SmartPtr<Vector> new_x;
78    SmartPtr<Vector> new_s;
79    SmartPtr<Vector> new_y_c;
80    SmartPtr<Vector> new_y_d;
81    SmartPtr<Vector> new_z_L;
82    SmartPtr<Vector> new_z_U;
83    SmartPtr<Vector> new_v_L;
84    SmartPtr<Vector> new_v_U;
85
86    // Get the required linear algebra structures from the model
87    bool retValue
88    = ip_nlp.InitializeStructures(new_x, want_x,
89                                  new_y_c, want_y_c,
90                                  new_y_d, want_y_d,
91                                  new_z_L, want_z_L,
92                                  new_z_U, want_z_U,
93                                  new_v_L, new_v_U);
94    if (!retValue) {
95      return false;
96    }
97
98    new_s = new_y_d->MakeNew(); // same dimension as d
99
100    iterates_space_ = new IteratesVectorSpace(*(new_x->OwnerSpace()), *(new_s->OwnerSpace()),
101                      *(new_y_c->OwnerSpace()), *(new_y_d->OwnerSpace()),
102                      *(new_z_L->OwnerSpace()), *(new_z_U->OwnerSpace()),
103                      *(new_v_L->OwnerSpace()), *(new_v_U->OwnerSpace())
104                                             );
105
106    curr_ = iterates_space_->MakeNewIteratesVector(*new_x,
107            *new_s,
108            *new_y_c,
109            *new_y_d,
110            *new_z_L,
111            *new_z_U,
112            *new_v_L,
113            *new_v_U);
114#ifdef IP_DEBUG
115
116    debug_curr_tag_ = curr_->GetTag();
117    debug_curr_tag_sum_ = curr_->GetTagSum();
118    debug_trial_tag_ = 0;
119    debug_trial_tag_sum_ = 0;
120    debug_delta_tag_ = 0;
121    debug_delta_tag_sum_ = 0;
122    debug_delta_aff_tag_ = 0;
123    debug_delta_aff_tag_sum_ = 0;
124#endif
125
126    trial_ = NULL;
127
128    // Set the pointers for storing steps to NULL
129    delta_ = NULL;
130
131    // Set the pointers for storing steps to NULL
132    delta_aff_ = NULL;
133
134    have_prototypes_ = true;
135    have_deltas_ = false;
136
137    return true;
138  }
139
140  void IpoptData::SetTrialPrimalVariablesFromStep(Number alpha,
141      const Vector& delta_x,
142      const Vector& delta_s)
143  {
144    DBG_ASSERT(have_prototypes_);
145
146    if (IsNull(trial_)) {
147      trial_ = iterates_space_->MakeNewIteratesVector(false);
148    }
149
150    SmartPtr<IteratesVector> newvec = trial_->MakeNewContainer();
151    newvec->create_new_x();
152    newvec->x_NonConst()->AddTwoVectors(1., *curr_->x(), alpha, delta_x, 0.);
153
154    newvec->create_new_s();
155    newvec->s_NonConst()->AddTwoVectors(1., *curr_->s(), alpha, delta_s, 0.);
156
157    set_trial(newvec);
158  }
159
160  void IpoptData::SetTrialEqMultipliersFromStep(Number alpha,
161      const Vector& delta_y_c,
162      const Vector& delta_y_d)
163  {
164    DBG_ASSERT(have_prototypes_);
165
166    SmartPtr<IteratesVector> newvec = trial()->MakeNewContainer();
167    newvec->create_new_y_c();
168    newvec->y_c_NonConst()->AddTwoVectors(1., *curr()->y_c(), alpha, delta_y_c, 0.);
169
170    newvec->create_new_y_d();
171    newvec->y_d_NonConst()->AddTwoVectors(1., *curr()->y_d(), alpha, delta_y_d, 0.);
172
173    set_trial(newvec);
174  }
175
176  void IpoptData::SetTrialBoundMultipliersFromStep(Number alpha,
177      const Vector& delta_z_L,
178      const Vector& delta_z_U,
179      const Vector& delta_v_L,
180      const Vector& delta_v_U)
181  {
182    DBG_ASSERT(have_prototypes_);
183
184    SmartPtr<IteratesVector> newvec = trial()->MakeNewContainer();
185    newvec->create_new_z_L();
186    newvec->z_L_NonConst()->AddTwoVectors(1., *curr()->z_L(), alpha, delta_z_L, 0.);
187
188    newvec->create_new_z_U();
189    newvec->z_U_NonConst()->AddTwoVectors(1., *curr()->z_U(), alpha, delta_z_U, 0.);
190
191    newvec->create_new_v_L();
192    newvec->v_L_NonConst()->AddTwoVectors(1., *curr()->v_L(), alpha, delta_v_L, 0.);
193
194    newvec->create_new_v_U();
195    newvec->v_U_NonConst()->AddTwoVectors(1., *curr()->v_U(), alpha, delta_v_U, 0.);
196
197    set_trial(newvec);
198  }
199
200  void IpoptData::AcceptTrialPoint()
201  {
202    DBG_ASSERT(IsValid(trial_));
203    DBG_ASSERT(IsValid(trial_->x()));
204    DBG_ASSERT(IsValid(trial_->s()));
205    DBG_ASSERT(IsValid(trial_->y_c()));
206    DBG_ASSERT(IsValid(trial_->y_d()));
207    DBG_ASSERT(IsValid(trial_->z_L()));
208    DBG_ASSERT(IsValid(trial_->z_U()));
209    DBG_ASSERT(IsValid(trial_->v_L()));
210    DBG_ASSERT(IsValid(trial_->v_U()));
211
212    CopyTrialToCurrent();
213
214    // Set trial pointers to Null (frees memory unless someone else is
215    // still referring to it, and it makes sure that indeed all trial
216    // values are set before a new trial point is accepted)
217    trial_ = NULL;
218
219    // Free the memory for the affine-scaling step
220    delta_aff_ = NULL;
221
222    have_deltas_ = false;
223    have_affine_deltas_ = false;
224  }
225
226} // namespace Ipopt
Note: See TracBrowser for help on using the repository browser.