- Main Page
- Classes
- Files

- File List
- File Members

# src/contrib/CGPenalty/IpCGPenaltyData.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2007, 2008 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Eclipse Public License.
    00004 //
    00005 // $Id: IpCGPenaltyData.hpp 2476 2014-04-08 09:41:07Z stefan $
    00006 //
    00007 // Authors:  Andreas Waechter           IBM     2007-06-04
    00008 //                   based on IpIpoptData.hpp
    00009
    00010 #ifndef __IPCGPENALTYDATA_HPP__
    00011 #define __IPCGPENALTYDATA_HPP__
    00012
    00013 #include "IpIteratesVector.hpp"
    00014 #include "IpOptionsList.hpp"
    00015 #include "IpIpoptData.hpp"
    00016
    00017 namespace Ipopt
    00018 {
    00019
    00022   class CGPenaltyData : public IpoptAdditionalData
    00023   {
    00024   public:
    00028     CGPenaltyData();
    00029
    00031     ~CGPenaltyData();
    00033
    00037     bool Initialize(const Journalist& jnlst,
    00038                     const OptionsList& options,
    00039                     const std::string& prefix);
    00040
    00042     bool InitializeDataStructures();
    00043
    00045     SmartPtr<const IteratesVector> delta_cgpen() const;
    00046
    00051     void set_delta_cgpen(SmartPtr<IteratesVector>& delta_pen);
    00052
    00059     void set_delta_cgpen(SmartPtr<const IteratesVector>& delta_pen);
    00060
    00062     SmartPtr<const IteratesVector> delta_cgfast() const;
    00063
    00068     void set_delta_cgfast(SmartPtr<IteratesVector>& delta_fast);
    00069
    00073     bool HaveCgPenDeltas() const
    00074     {
    00075       return have_cgpen_deltas_;
    00076     }
    00077     void SetHaveCgPenDeltas(bool have_cgpen_deltas)
    00078     {
    00079       have_cgpen_deltas_ = have_cgpen_deltas;
    00080     }
    00081
    00082     bool HaveCgFastDeltas() const
    00083     {
    00084       return have_cgfast_deltas_;
    00085     }
    00086     void SetHaveCgFastDeltas(bool have_cgfast_deltas)
    00087     {
    00088       have_cgfast_deltas_ = have_cgfast_deltas;
    00089     }
    00091
    00096     void AcceptTrialPoint();
    00098
    00099     Number CurrPenaltyPert()
    00100     {
    00101       return curr_penalty_pert_;
    00102     }
    00103     void SetCurrPenaltyPert(Number curr_penalty_pert)
    00104     {
    00105       curr_penalty_pert_ = curr_penalty_pert;
    00106     }
    00107
    00108     void SetNeverTryPureNewton(bool never_try_pure_Newton)
    00109     {
    00110       never_try_pure_Newton_ = never_try_pure_Newton;
    00111     }
    00112     Index NeverTryPureNewton()
    00113     {
    00114       return never_try_pure_Newton_;
    00115     }
    00116
    00117     Index restor_iter()
    00118     {
    00119       return restor_iter_;
    00120     }
    00121
    00122     void SetRestorIter(Index restor_iter)
    00123     {
    00124       restor_iter_ = restor_iter;
    00125     }
    00126     Number restor_counter()
    00127     {
    00128       return restor_counter_;
    00129     }
    00130     void SetRestorCounter(Number restor_counter)
    00131     {
    00132       restor_counter_ = restor_counter;
    00133     }
    00134
    00135     void SetPrimalStepSize(Number max_alpha_x)
    00136     {
    00137       max_alpha_x_ = max_alpha_x;
    00138     }
    00139     Number PrimalStepSize()
    00140     {
    00141       return max_alpha_x_;
    00142     }
    00143
    00144     Number curr_penalty() const
    00145     {
    00146       DBG_ASSERT(penalty_initialized_);
    00147       return curr_penalty_;
    00148     }
    00149     void Set_penalty(Number penalty)
    00150     {
    00151       curr_penalty_ = penalty;
    00152       penalty_initialized_ = true;
    00153     }
    00154     void SetPenaltyUninitialized()
    00155     {
    00156       penalty_initialized_ = false;
    00157     }
    00158     bool PenaltyInitialized() const
    00159     {
    00160       return penalty_initialized_;
    00161     }
    00162     Number curr_kkt_penalty() const
    00163     {
    00164       DBG_ASSERT(kkt_penalty_initialized_);
    00165       return curr_kkt_penalty_;
    00166     }
    00167     void Set_kkt_penalty(Number kkt_penalty)
    00168     {
    00169       curr_kkt_penalty_ = kkt_penalty;
    00170       kkt_penalty_initialized_ = true;
    00171     }
    00172     void SetKKTPenaltyUninitialized()
    00173     {
    00174       kkt_penalty_initialized_ = false;
    00175     }
    00176     bool KKTPenaltyInitialized() const
    00177     {
    00178       return kkt_penalty_initialized_;
    00179     }
    00180
    00181
    00182   private:
    00183
    00189     SmartPtr<const IteratesVector> delta_cgpen_;
    00195     bool have_cgpen_deltas_;
    00197
    00203     SmartPtr<const IteratesVector> delta_cgfast_;
    00209     bool have_cgfast_deltas_;
    00211
    00215     bool never_try_pure_Newton_;
    00216
    00218     Index restor_iter_;
    00219     Number restor_counter_;
    00220
    00222     Number curr_penalty_;
    00223     bool penalty_initialized_;
    00224     Number curr_kkt_penalty_;
    00225     bool kkt_penalty_initialized_;
    00226     Number curr_penalty_pert_;
    00227     Number max_alpha_x_;
    00229
    00232     bool initialize_called_;
    00233
    00243     CGPenaltyData(const CGPenaltyData&);
    00244
    00246     void operator=(const CGPenaltyData&);
    00248
    00249 #if COIN_IPOPT_CHECKLEVEL > 0
    00250
    00254     TaggedObject::Tag debug_delta_cgpen_tag_;
    00255     TaggedObject::Tag debug_delta_cgfast_tag_;
    00256     TaggedObject::Tag debug_delta_cgpen_tag_sum_;
    00257     TaggedObject::Tag debug_delta_cgfast_tag_sum_;
    00259 #endif
    00260
    00261   };
    00262
    00263   inline
    00264   SmartPtr<const IteratesVector> CGPenaltyData::delta_cgpen() const
    00265   {
    00266     DBG_ASSERT(IsNull(delta_cgpen_) || (delta_cgpen_->GetTag() == debug_delta_cgpen_tag_ && delta_cgpen_->GetTagSum() == debug_delta_cgpen_tag_sum_) );
    00267
    00268     return delta_cgpen_;
    00269   }
    00270
    00271   inline
    00272   SmartPtr<const IteratesVector> CGPenaltyData::delta_cgfast() const
    00273   {
    00274     DBG_ASSERT(IsNull(delta_cgfast_) || (delta_cgfast_->GetTag() == debug_delta_cgfast_tag_ && delta_cgfast_->GetTagSum() == debug_delta_cgfast_tag_sum_) );
    00275
    00276     return delta_cgfast_;
    00277   }
    00278
    00279   inline
    00280   void CGPenaltyData::set_delta_cgpen(SmartPtr<IteratesVector>& delta_cgpen)
    00281   {
    00282     delta_cgpen_ = ConstPtr(delta_cgpen);
    00283 #if COIN_IPOPT_CHECKLEVEL > 0
    00284
    00285     if (IsValid(delta_cgpen)) {
    00286       debug_delta_cgpen_tag_ = delta_cgpen->GetTag();
    00287       debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
    00288     }
    00289     else {
    00290       debug_delta_cgpen_tag_ = 0;
    00291       debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
    00292     }
    00293 #endif
    00294
    00295     delta_cgpen = NULL;
    00296   }
    00297
    00298   inline
    00299   void CGPenaltyData::set_delta_cgpen(SmartPtr<const IteratesVector>& delta_cgpen)
    00300   {
    00301     delta_cgpen_ = delta_cgpen;
    00302 #if COIN_IPOPT_CHECKLEVEL > 0
    00303
    00304     if (IsValid(delta_cgpen)) {
    00305       debug_delta_cgpen_tag_ = delta_cgpen->GetTag();
    00306       debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
    00307     }
    00308     else {
    00309       debug_delta_cgpen_tag_ = 0;
    00310       debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
    00311     }
    00312 #endif
    00313
    00314     delta_cgpen = NULL;
    00315   }
    00316
    00317   inline
    00318   void CGPenaltyData::set_delta_cgfast(SmartPtr<IteratesVector>& delta_cgfast)
    00319   {
    00320     delta_cgfast_ = ConstPtr(delta_cgfast);
    00321 #if COIN_IPOPT_CHECKLEVEL > 0
    00322
    00323     if (IsValid(delta_cgfast)) {
    00324       debug_delta_cgfast_tag_ = delta_cgfast->GetTag();
    00325       debug_delta_cgfast_tag_sum_ = delta_cgfast->GetTagSum();
    00326     }
    00327     else {
    00328       debug_delta_cgfast_tag_ = 0;
    00329       debug_delta_cgfast_tag_sum_ = delta_cgfast->GetTagSum();
    00330     }
    00331 #endif
    00332
    00333     delta_cgfast = NULL;
    00334   }
    00335
    00336 } // namespace Ipopt
    00337
    00338 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines