Ipopt Documentation  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IpCGPenaltyData.hpp
Go to the documentation of this file.
1 // Copyright (C) 2007, 2008 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors: Andreas Waechter IBM 2007-06-04
6 // based on IpIpoptData.hpp
7 
8 #ifndef __IPCGPENALTYDATA_HPP__
9 #define __IPCGPENALTYDATA_HPP__
10 
11 #include "IpIteratesVector.hpp"
12 #include "IpOptionsList.hpp"
13 #include "IpIpoptData.hpp"
14 
15 namespace Ipopt
16 {
17 
22 {
23 public:
25 
27  CGPenaltyData();
28 
32 
38  bool Initialize(
39  const Journalist& jnlst,
40  const OptionsList& options,
41  const std::string& prefix);
42 
45 
48 
55  void set_delta_cgpen(
56  SmartPtr<IteratesVector>& delta_pen
57  );
58 
67  void set_delta_cgpen(
69  );
70 
73 
80  void set_delta_cgfast(
81  SmartPtr<IteratesVector>& delta_fast
82  );
83 
89  bool HaveCgPenDeltas() const
91  {
92  return have_cgpen_deltas_;
93  }
94 
96  bool have_cgpen_deltas
97  )
98  {
99  have_cgpen_deltas_ = have_cgpen_deltas;
100  }
101 
102  bool HaveCgFastDeltas() const
103  {
104  return have_cgfast_deltas_;
105  }
106 
108  bool have_cgfast_deltas
109  )
110  {
111  have_cgfast_deltas_ = have_cgfast_deltas;
112  }
114 
116 
118  void AcceptTrialPoint();
120 
122  {
123  return curr_penalty_pert_;
124  }
125 
127  Number curr_penalty_pert)
128  {
129  curr_penalty_pert_ = curr_penalty_pert;
130  }
131 
133  bool never_try_pure_Newton
134  )
135  {
136  never_try_pure_Newton_ = never_try_pure_Newton;
137  }
138 
140  {
141  return never_try_pure_Newton_;
142  }
143 
145  {
146  return restor_iter_;
147  }
148 
151  )
152  {
154  }
155 
157  {
158  return restor_counter_;
159  }
160 
163  )
164  {
166  }
167 
169  Number max_alpha_x
170  )
171  {
172  max_alpha_x_ = max_alpha_x;
173  }
174 
176  {
177  return max_alpha_x_;
178  }
179 
181  {
183  return curr_penalty_;
184  }
185 
187  Number penalty
188  )
189  {
190  curr_penalty_ = penalty;
191  penalty_initialized_ = true;
192  }
193 
195  {
196  penalty_initialized_ = false;
197  }
198 
199  bool PenaltyInitialized() const
200  {
201  return penalty_initialized_;
202  }
203 
205  {
207  return curr_kkt_penalty_;
208  }
209 
211  Number kkt_penalty
212  )
213  {
214  curr_kkt_penalty_ = kkt_penalty;
216  }
217 
219  {
220  kkt_penalty_initialized_ = false;
221  }
222 
224  {
226  }
227 
228 private:
229 
238 
246 
255 
264 
266 
269 
273 
282 
285 
295 
298  const CGPenaltyData&
299  );
300 
302  void operator=(
303  const CGPenaltyData&
304  );
306 
307 #if IPOPT_CHECKLEVEL > 0
308 
311  TaggedObject::Tag debug_delta_cgpen_tag_;
313  TaggedObject::Tag debug_delta_cgfast_tag_;
314  TaggedObject::Tag debug_delta_cgpen_tag_sum_;
315  TaggedObject::Tag debug_delta_cgfast_tag_sum_;
317 #endif
318 
319 };
320 
322 {
323  DBG_ASSERT(IsNull(delta_cgpen_) || (delta_cgpen_->GetTag() == debug_delta_cgpen_tag_ && delta_cgpen_->GetTagSum() == debug_delta_cgpen_tag_sum_) );
324 
325  return delta_cgpen_;
326 }
327 
329 {
330  DBG_ASSERT(IsNull(delta_cgfast_) || (delta_cgfast_->GetTag() == debug_delta_cgfast_tag_ && delta_cgfast_->GetTagSum() == debug_delta_cgfast_tag_sum_) );
331 
332  return delta_cgfast_;
333 }
334 
335 inline
337  SmartPtr<IteratesVector>& delta_cgpen
338 )
339 {
340  delta_cgpen_ = ConstPtr(delta_cgpen);
341 #if IPOPT_CHECKLEVEL > 0
342 
343  if (IsValid(delta_cgpen))
344  {
345  debug_delta_cgpen_tag_ = delta_cgpen->GetTag();
346  debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
347  }
348  else
349  {
350  debug_delta_cgpen_tag_ = 0;
351  debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
352  }
353 #endif
354 
355  delta_cgpen = NULL;
356 }
357 
358 inline
360  SmartPtr<const IteratesVector>& delta_cgpen
361 )
362 {
364 #if IPOPT_CHECKLEVEL > 0
365 
366  if (IsValid(delta_cgpen))
367  {
368  debug_delta_cgpen_tag_ = delta_cgpen->GetTag();
369  debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
370  }
371  else
372  {
373  debug_delta_cgpen_tag_ = 0;
374  debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
375  }
376 #endif
377 
378  delta_cgpen = NULL;
379 }
380 
381 inline
383  SmartPtr<IteratesVector>& delta_cgfast
384 )
385 {
386  delta_cgfast_ = ConstPtr(delta_cgfast);
387 #if IPOPT_CHECKLEVEL > 0
388 
389  if (IsValid(delta_cgfast))
390  {
391  debug_delta_cgfast_tag_ = delta_cgfast->GetTag();
392  debug_delta_cgfast_tag_sum_ = delta_cgfast->GetTagSum();
393  }
394  else
395  {
396  debug_delta_cgfast_tag_ = 0;
397  debug_delta_cgfast_tag_sum_ = delta_cgfast->GetTagSum();
398  }
399 #endif
400 
401  delta_cgfast = NULL;
402 }
403 
404 } // namespace Ipopt
405 
406 #endif
bool initialize_called_
flag indicating if Initialize method has been called (for debugging)
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:674
bool never_try_pure_Newton_
Flag indicating whether the pure Newton method is used.
void SetPrimalStepSize(Number max_alpha_x)
void SetRestorIter(Index restor_iter)
bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
This method must be called to initialize the global algorithmic parameters.
void AcceptTrialPoint()
Set the current iterate values from the trial values.
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
SmartPtr< const IteratesVector > delta_cgfast() const
Delta for the fast Chen-Goldfarb search direction.
SmartPtr< const IteratesVector > delta_cgfast_
bool IsNull(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:682
void SetHaveCgFastDeltas(bool have_cgfast_deltas)
Number curr_penalty() const
bool PenaltyInitialized() const
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:171
This class stores a list of user set options.
Class to organize all the additional data required by the Chen-Goldfarb penalty function algorithm...
void Set_penalty(Number penalty)
void set_delta_cgfast(SmartPtr< IteratesVector > &delta_fast)
Set the delta_cgfast.
bool have_cgpen_deltas_
The following flag is set to true, if some other part of the algorithm has already computed the Chen-...
SmartPtr< const IteratesVector > delta_cgpen_
void SetRestorCounter(Number restor_counter)
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
void SetCurrPenaltyPert(Number curr_penalty_pert)
SmartPtr< const IteratesVector > delta_cgpen() const
Delta for the Chen-Goldfarb search direction.
bool KKTPenaltyInitialized() const
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
void set_delta_cgpen(SmartPtr< IteratesVector > &delta_pen)
Set the delta_cgpen.
unsigned int Tag
Type for the Tag values.
~CGPenaltyData()
Destructor.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:665
Number curr_kkt_penalty() const
bool HaveCgFastDeltas() const
Class responsible for all message output.
bool InitializeDataStructures()
Initialize Data Structures.
bool HaveCgPenDeltas() const
void SetNeverTryPureNewton(bool never_try_pure_Newton)
Index restor_iter_
The iteration at which pure Newton method is given up.
bool have_cgfast_deltas_
The following flag is set to true, if some other part of the algorithm has already computed the fast ...
void SetHaveCgPenDeltas(bool have_cgpen_deltas)
Base class for additional data that is special to a particular type of algorithm, such as the CG pena...
Definition: IpIpoptData.hpp:29
void operator=(const CGPenaltyData &)
Default Assignment Operator.
void Set_kkt_penalty(Number kkt_penalty)
CGPenaltyData()
Constructor.