/home/coin/SVN-release/Ipopt-3.3.3/Ipopt/src/Algorithm/IpIpoptData.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2004, 2007 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpIpoptData.hpp 1060 2007-08-03 01:31:56Z andreasw $
00006 //
00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
00008 
00009 #ifndef __IPIPOPTDATA_HPP__
00010 #define __IPIPOPTDATA_HPP__
00011 
00012 #include "IpSymMatrix.hpp"
00013 #include "IpOptionsList.hpp"
00014 #include "IpIteratesVector.hpp"
00015 #include "IpRegOptions.hpp"
00016 #include "IpTimingStatistics.hpp"
00017 
00018 namespace Ipopt
00019 {
00020 
00021   /* Forward declaration */
00022   class IpoptNLP;
00023   class CGPenaltyData;
00024 
00034   class IpoptData : public ReferencedObject
00035   {
00036   public:
00040     IpoptData();
00041 
00043     ~IpoptData();
00045 
00047     bool InitializeDataStructures(IpoptNLP& ip_nlp,
00048                                   bool want_x,
00049                                   bool want_y_c,
00050                                   bool want_y_d,
00051                                   bool want_z_L,
00052                                   bool want_z_U);
00053 
00057     bool Initialize(const Journalist& jnlst,
00058                     const OptionsList& options,
00059                     const std::string& prefix);
00060 
00064     SmartPtr<const IteratesVector> curr() const;
00065 
00070     //    SmartPtr<IteratesVector> curr_container() const;
00071 
00073     SmartPtr<const IteratesVector> trial() const;
00074 
00079     //SmartPtr<IteratesVector> trial_container() const;
00080 
00085     void set_trial(SmartPtr<IteratesVector>& trial);
00086 
00090     void SetTrialPrimalVariablesFromStep(Number alpha,
00091                                          const Vector& delta_x,
00092                                          const Vector& delta_s);
00097     void SetTrialEqMultipliersFromStep(Number alpha,
00098                                        const Vector& delta_y_c,
00099                                        const Vector& delta_y_d);
00104     void SetTrialBoundMultipliersFromStep(Number alpha,
00105                                           const Vector& delta_z_L,
00106                                           const Vector& delta_z_U,
00107                                           const Vector& delta_v_L,
00108                                           const Vector& delta_v_U);
00109 
00113     // void set_trial(const SmartPtr<IteratesVector>& trial_iterates);
00114     // void set_trial(SmartPtr<const IteratesVector>& trial_iterates);
00115 
00117     SmartPtr<const IteratesVector> delta() const;
00118 
00123     void set_delta(SmartPtr<IteratesVector>& delta);
00124 
00131     void set_delta(SmartPtr<const IteratesVector>& delta);
00132 
00134     SmartPtr<const IteratesVector> delta_aff() const;
00135 
00140     void set_delta_aff(SmartPtr<IteratesVector>& delta_aff);
00141 
00143     SmartPtr<const SymMatrix> W()
00144     {
00145       DBG_ASSERT(IsValid(W_));
00146       return W_;
00147     }
00148 
00150     void Set_W(SmartPtr<const SymMatrix> W)
00151     {
00152       W_ = W;
00153     }
00154 
00161 
00169     bool HaveDeltas() const
00170     {
00171       return have_deltas_;
00172     }
00173 
00179     void SetHaveDeltas(bool have_deltas)
00180     {
00181       have_deltas_ = have_deltas;
00182     }
00184 
00191 
00199     bool HaveAffineDeltas() const
00200     {
00201       return have_affine_deltas_;
00202     }
00203 
00209     void SetHaveAffineDeltas(bool have_affine_deltas)
00210     {
00211       have_affine_deltas_ = have_affine_deltas;
00212     }
00214 
00218     void CopyTrialToCurrent();
00219 
00222     void AcceptTrialPoint();
00224 
00227     Index iter_count() const
00228     {
00229       return iter_count_;
00230     }
00231     void Set_iter_count(Index iter_count)
00232     {
00233       iter_count_ = iter_count;
00234     }
00235 
00236     Number curr_mu() const
00237     {
00238       DBG_ASSERT(mu_initialized_);
00239       return curr_mu_;
00240     }
00241     void Set_mu(Number mu)
00242     {
00243       curr_mu_ = mu;
00244       mu_initialized_ = true;
00245     }
00246     bool MuInitialized() const
00247     {
00248       return mu_initialized_;
00249     }
00250 
00251     Number curr_tau() const
00252     {
00253       DBG_ASSERT(tau_initialized_);
00254       return curr_tau_;
00255     }
00256     void Set_tau(Number tau)
00257     {
00258       curr_tau_ = tau;
00259       tau_initialized_ = true;
00260     }
00261     bool TauInitialized() const
00262     {
00263       return tau_initialized_;
00264     }
00265 
00266     void SetFreeMuMode(bool free_mu_mode)
00267     {
00268       free_mu_mode_ = free_mu_mode;
00269     }
00270     bool FreeMuMode() const
00271     {
00272       return free_mu_mode_;
00273     }
00274 
00277     void Set_tiny_step_flag(bool flag)
00278     {
00279       tiny_step_flag_ = flag;
00280     }
00281     bool tiny_step_flag()
00282     {
00283       return tiny_step_flag_;
00284     }
00286 
00293     Number tol() const
00294     {
00295       DBG_ASSERT(initialize_called_);
00296       return tol_;
00297     }
00305     void Set_tol(Number tol)
00306     {
00307       tol_ = tol;
00308     }
00310 
00313     Number info_regu_x() const
00314     {
00315       return info_regu_x_;
00316     }
00317     void Set_info_regu_x(Number regu_x)
00318     {
00319       info_regu_x_ = regu_x;
00320     }
00321     Number info_alpha_primal() const
00322     {
00323       return info_alpha_primal_;
00324     }
00325     void Set_info_alpha_primal(Number alpha_primal)
00326     {
00327       info_alpha_primal_ = alpha_primal;
00328     }
00329     char info_alpha_primal_char() const
00330     {
00331       return info_alpha_primal_char_;
00332     }
00333     void Set_info_alpha_primal_char(char info_alpha_primal_char)
00334     {
00335       info_alpha_primal_char_ = info_alpha_primal_char;
00336     }
00337     Number info_alpha_dual() const
00338     {
00339       return info_alpha_dual_;
00340     }
00341     void Set_info_alpha_dual(Number alpha_dual)
00342     {
00343       info_alpha_dual_ = alpha_dual;
00344     }
00345     Index info_ls_count() const
00346     {
00347       return info_ls_count_;
00348     }
00349     void Set_info_ls_count(Index ls_count)
00350     {
00351       info_ls_count_ = ls_count;
00352     }
00353     bool info_skip_output() const
00354     {
00355       return info_skip_output_;
00356     }
00357     void Append_info_string(const std::string& add_str)
00358     {
00359       info_string_ += add_str;
00360     }
00361     const std::string& info_string() const
00362     {
00363       return info_string_;
00364     }
00367     void Set_info_skip_output(bool info_skip_output)
00368     {
00369       info_skip_output_ = info_skip_output;
00370     }
00371 
00373     void ResetInfo()
00374     {
00375       info_regu_x_ = 0;
00376       info_alpha_primal_ = 0;
00377       info_alpha_dual_ = 0.;
00378       info_alpha_primal_char_ = ' ';
00379       info_ls_count_ = 0;
00380       info_skip_output_ = false;
00381       info_string_.clear();
00382     }
00384 
00386     TimingStatistics& TimingStats()
00387     {
00388       return timing_statistics_;
00389     }
00390 
00392     CGPenaltyData& CGPenData()
00393     {
00394       return *cgpen_data_;
00395     }
00396 
00399     static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions);
00401 
00402   private:
00407     SmartPtr<const IteratesVector> curr_;
00408 
00411     SmartPtr<const IteratesVector> trial_;
00412 
00414     SmartPtr<const SymMatrix> W_;
00415 
00418     SmartPtr<const IteratesVector> delta_;
00426     bool have_deltas_;
00428 
00434     SmartPtr<const IteratesVector> delta_aff_;
00441     bool have_affine_deltas_;
00443 
00445     Index iter_count_;
00446 
00448     Number curr_mu_;
00449     bool mu_initialized_;
00450 
00452     Number curr_tau_;
00453     bool tau_initialized_;
00454 
00457     bool initialize_called_;
00458 
00461     bool have_prototypes_;
00462 
00469     Number tol_;
00471 
00475     bool free_mu_mode_;
00477     bool tiny_step_flag_;
00479 
00483     Number info_regu_x_;
00485     Number info_alpha_primal_;
00487     char info_alpha_primal_char_;
00489     Number info_alpha_dual_;
00491     Index info_ls_count_;
00494     bool info_skip_output_;
00496     std::string info_string_;
00498 
00500     SmartPtr<IteratesVectorSpace> iterates_space_;
00501 
00504     TimingStatistics timing_statistics_;
00505 
00508     CGPenaltyData* const cgpen_data_;
00509 
00519     IpoptData(const IpoptData&);
00520 
00522     void operator=(const IpoptData&);
00524 
00525 #if COIN_IPOPT_CHECKLEVEL > 0
00526 
00530     TaggedObject::Tag debug_curr_tag_;
00531     TaggedObject::Tag debug_trial_tag_;
00532     TaggedObject::Tag debug_delta_tag_;
00533     TaggedObject::Tag debug_delta_aff_tag_;
00534     TaggedObject::Tag debug_curr_tag_sum_;
00535     TaggedObject::Tag debug_trial_tag_sum_;
00536     TaggedObject::Tag debug_delta_tag_sum_;
00537     TaggedObject::Tag debug_delta_aff_tag_sum_;
00539 #endif
00540 
00541   };
00542 
00543   inline
00544   SmartPtr<const IteratesVector> IpoptData::curr() const
00545   {
00546     DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
00547 
00548     return curr_;
00549   }
00550 
00551   inline
00552   SmartPtr<const IteratesVector> IpoptData::trial() const
00553   {
00554     DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
00555 
00556     return trial_;
00557   }
00558 
00559   inline
00560   SmartPtr<const IteratesVector> IpoptData::delta() const
00561   {
00562     DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
00563 
00564     return delta_;
00565   }
00566 
00567   inline
00568   SmartPtr<const IteratesVector> IpoptData::delta_aff() const
00569   {
00570     DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
00571 
00572     return delta_aff_;
00573   }
00574 
00575   inline
00576   void IpoptData::CopyTrialToCurrent()
00577   {
00578     curr_ = trial_;
00579 #if COIN_IPOPT_CHECKLEVEL > 0
00580 
00581     if (IsValid(curr_)) {
00582       debug_curr_tag_ = curr_->GetTag();
00583       debug_curr_tag_sum_ = curr_->GetTagSum();
00584     }
00585     else {
00586       debug_curr_tag_ = 0;
00587       debug_curr_tag_sum_ = 0;
00588     }
00589 #endif
00590 
00591   }
00592 
00593   inline
00594   void IpoptData::set_trial(SmartPtr<IteratesVector>& trial)
00595   {
00596     trial_ = ConstPtr(trial);
00597 
00598 #if COIN_IPOPT_CHECKLEVEL > 0
00599     // verify the correct space
00600     DBG_ASSERT(trial_->OwnerSpace() == (VectorSpace*)GetRawPtr(iterates_space_));
00601     if (IsValid(trial)) {
00602       debug_trial_tag_ = trial->GetTag();
00603       debug_trial_tag_sum_ = trial->GetTagSum();
00604     }
00605     else {
00606       debug_trial_tag_ = 0;
00607       debug_trial_tag_sum_ = 0;
00608     }
00609 #endif
00610 
00611     trial = NULL;
00612   }
00613 
00614   inline
00615   void IpoptData::set_delta(SmartPtr<IteratesVector>& delta)
00616   {
00617     delta_ = ConstPtr(delta);
00618 #if COIN_IPOPT_CHECKLEVEL > 0
00619 
00620     if (IsValid(delta)) {
00621       debug_delta_tag_ = delta->GetTag();
00622       debug_delta_tag_sum_ = delta->GetTagSum();
00623     }
00624     else {
00625       debug_delta_tag_ = 0;
00626       debug_delta_tag_sum_ = 0;
00627     }
00628 #endif
00629 
00630     delta = NULL;
00631   }
00632 
00633   inline
00634   void IpoptData::set_delta(SmartPtr<const IteratesVector>& delta)
00635   {
00636     delta_ = delta;
00637 #if COIN_IPOPT_CHECKLEVEL > 0
00638 
00639     if (IsValid(delta)) {
00640       debug_delta_tag_ = delta->GetTag();
00641       debug_delta_tag_sum_ = delta->GetTagSum();
00642     }
00643     else {
00644       debug_delta_tag_ = 0;
00645       debug_delta_tag_sum_ = 0;
00646     }
00647 #endif
00648 
00649     delta = NULL;
00650   }
00651 
00652   inline
00653   void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff)
00654   {
00655     delta_aff_ = ConstPtr(delta_aff);
00656 #if COIN_IPOPT_CHECKLEVEL > 0
00657 
00658     if (IsValid(delta_aff)) {
00659       debug_delta_aff_tag_ = delta_aff->GetTag();
00660       debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
00661     }
00662     else {
00663       debug_delta_aff_tag_ = 0;
00664       debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
00665     }
00666 #endif
00667 
00668     delta_aff = NULL;
00669   }
00670 
00671 } // namespace Ipopt
00672 
00673 #endif

Generated on Thu May 15 22:29:56 2008 by  doxygen 1.4.7