• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/build/buildd/coinor-ipopt-3.8.3/Ipopt/src/Algorithm/IpIpoptData.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2004, 2009 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpIpoptData.hpp 1456 2009-05-17 21:33:53Z 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 
00028   class IpoptAdditionalData : public ReferencedObject
00029   {
00030   public:
00034     IpoptAdditionalData()
00035     {}
00036 
00038     virtual ~IpoptAdditionalData()
00039     {}
00041 
00045     virtual bool Initialize(const Journalist& jnlst,
00046                             const OptionsList& options,
00047                             const std::string& prefix) = 0;
00048 
00050     virtual bool InitializeDataStructures() = 0;
00051 
00055     virtual void AcceptTrialPoint() = 0;
00056 
00057   private:
00067     IpoptAdditionalData(const IpoptAdditionalData&);
00068 
00070     void operator=(const IpoptAdditionalData&);
00072   };
00073 
00083   class IpoptData : public ReferencedObject
00084   {
00085   public:
00089     IpoptData(SmartPtr<IpoptAdditionalData> add_data = NULL,
00090               Number cpu_time_start = -1.);
00091 
00093     virtual ~IpoptData();
00095 
00097     bool InitializeDataStructures(IpoptNLP& ip_nlp,
00098                                   bool want_x,
00099                                   bool want_y_c,
00100                                   bool want_y_d,
00101                                   bool want_z_L,
00102                                   bool want_z_U);
00103 
00107     bool Initialize(const Journalist& jnlst,
00108                     const OptionsList& options,
00109                     const std::string& prefix);
00110 
00114     SmartPtr<const IteratesVector> curr() const;
00115 
00120     //    SmartPtr<IteratesVector> curr_container() const;
00121 
00123     SmartPtr<const IteratesVector> trial() const;
00124 
00129     //SmartPtr<IteratesVector> trial_container() const;
00130 
00135     void set_trial(SmartPtr<IteratesVector>& trial);
00136 
00140     void SetTrialPrimalVariablesFromStep(Number alpha,
00141                                          const Vector& delta_x,
00142                                          const Vector& delta_s);
00147     void SetTrialEqMultipliersFromStep(Number alpha,
00148                                        const Vector& delta_y_c,
00149                                        const Vector& delta_y_d);
00154     void SetTrialBoundMultipliersFromStep(Number alpha,
00155                                           const Vector& delta_z_L,
00156                                           const Vector& delta_z_U,
00157                                           const Vector& delta_v_L,
00158                                           const Vector& delta_v_U);
00159 
00163     // void set_trial(const SmartPtr<IteratesVector>& trial_iterates);
00164     // void set_trial(SmartPtr<const IteratesVector>& trial_iterates);
00165 
00167     SmartPtr<const IteratesVector> delta() const;
00168 
00173     void set_delta(SmartPtr<IteratesVector>& delta);
00174 
00181     void set_delta(SmartPtr<const IteratesVector>& delta);
00182 
00184     SmartPtr<const IteratesVector> delta_aff() const;
00185 
00190     void set_delta_aff(SmartPtr<IteratesVector>& delta_aff);
00191 
00193     SmartPtr<const SymMatrix> W()
00194     {
00195       DBG_ASSERT(IsValid(W_));
00196       return W_;
00197     }
00198 
00200     void Set_W(SmartPtr<const SymMatrix> W)
00201     {
00202       W_ = W;
00203     }
00204 
00211 
00219     bool HaveDeltas() const
00220     {
00221       return have_deltas_;
00222     }
00223 
00229     void SetHaveDeltas(bool have_deltas)
00230     {
00231       have_deltas_ = have_deltas;
00232     }
00234 
00241 
00249     bool HaveAffineDeltas() const
00250     {
00251       return have_affine_deltas_;
00252     }
00253 
00259     void SetHaveAffineDeltas(bool have_affine_deltas)
00260     {
00261       have_affine_deltas_ = have_affine_deltas;
00262     }
00264 
00268     void CopyTrialToCurrent();
00269 
00272     void AcceptTrialPoint();
00274 
00277     Index iter_count() const
00278     {
00279       return iter_count_;
00280     }
00281     void Set_iter_count(Index iter_count)
00282     {
00283       iter_count_ = iter_count;
00284     }
00285 
00286     Number curr_mu() const
00287     {
00288       DBG_ASSERT(mu_initialized_);
00289       return curr_mu_;
00290     }
00291     void Set_mu(Number mu)
00292     {
00293       curr_mu_ = mu;
00294       mu_initialized_ = true;
00295     }
00296     bool MuInitialized() const
00297     {
00298       return mu_initialized_;
00299     }
00300 
00301     Number curr_tau() const
00302     {
00303       DBG_ASSERT(tau_initialized_);
00304       return curr_tau_;
00305     }
00306     void Set_tau(Number tau)
00307     {
00308       curr_tau_ = tau;
00309       tau_initialized_ = true;
00310     }
00311     bool TauInitialized() const
00312     {
00313       return tau_initialized_;
00314     }
00315 
00316     void SetFreeMuMode(bool free_mu_mode)
00317     {
00318       free_mu_mode_ = free_mu_mode;
00319     }
00320     bool FreeMuMode() const
00321     {
00322       return free_mu_mode_;
00323     }
00324 
00327     void Set_tiny_step_flag(bool flag)
00328     {
00329       tiny_step_flag_ = flag;
00330     }
00331     bool tiny_step_flag()
00332     {
00333       return tiny_step_flag_;
00334     }
00336 
00343     Number tol() const
00344     {
00345       DBG_ASSERT(initialize_called_);
00346       return tol_;
00347     }
00355     void Set_tol(Number tol)
00356     {
00357       tol_ = tol;
00358     }
00360 
00364     Number cpu_time_start() const
00365     {
00366       return cpu_time_start_;
00367     }
00368 
00371     Number info_regu_x() const
00372     {
00373       return info_regu_x_;
00374     }
00375     void Set_info_regu_x(Number regu_x)
00376     {
00377       info_regu_x_ = regu_x;
00378     }
00379     Number info_alpha_primal() const
00380     {
00381       return info_alpha_primal_;
00382     }
00383     void Set_info_alpha_primal(Number alpha_primal)
00384     {
00385       info_alpha_primal_ = alpha_primal;
00386     }
00387     char info_alpha_primal_char() const
00388     {
00389       return info_alpha_primal_char_;
00390     }
00391     void Set_info_alpha_primal_char(char info_alpha_primal_char)
00392     {
00393       info_alpha_primal_char_ = info_alpha_primal_char;
00394     }
00395     Number info_alpha_dual() const
00396     {
00397       return info_alpha_dual_;
00398     }
00399     void Set_info_alpha_dual(Number alpha_dual)
00400     {
00401       info_alpha_dual_ = alpha_dual;
00402     }
00403     Index info_ls_count() const
00404     {
00405       return info_ls_count_;
00406     }
00407     void Set_info_ls_count(Index ls_count)
00408     {
00409       info_ls_count_ = ls_count;
00410     }
00411     bool info_skip_output() const
00412     {
00413       return info_skip_output_;
00414     }
00415     void Append_info_string(const std::string& add_str)
00416     {
00417       info_string_ += add_str;
00418     }
00419     const std::string& info_string() const
00420     {
00421       return info_string_;
00422     }
00425     void Set_info_skip_output(bool info_skip_output)
00426     {
00427       info_skip_output_ = info_skip_output;
00428     }
00429 
00431     void ResetInfo()
00432     {
00433       info_regu_x_ = 0;
00434       info_alpha_primal_ = 0;
00435       info_alpha_dual_ = 0.;
00436       info_alpha_primal_char_ = ' ';
00437       info_skip_output_ = false;
00438       info_string_.erase();
00439     }
00441 
00443     TimingStatistics& TimingStats()
00444     {
00445       return timing_statistics_;
00446     }
00447 
00449     bool HaveAddData()
00450     {
00451       return IsValid(add_data_);
00452     }
00453 
00455     IpoptAdditionalData& AdditionalData()
00456     {
00457       return *add_data_;
00458     }
00459 
00461     void SetAddData(SmartPtr<IpoptAdditionalData> add_data)
00462     {
00463       DBG_ASSERT(!HaveAddData());
00464       add_data_ = add_data;
00465     }
00466 
00468     void setPDPert(Number pd_pert_x, Number pd_pert_s,
00469                    Number pd_pert_c, Number pd_pert_d)
00470     {
00471       pd_pert_x_ = pd_pert_x;
00472       pd_pert_s_ = pd_pert_s;
00473       pd_pert_c_ = pd_pert_c;
00474       pd_pert_d_ = pd_pert_d;
00475     }
00476 
00478     void getPDPert(Number& pd_pert_x, Number& pd_pert_s,
00479                    Number& pd_pert_c, Number& pd_pert_d)
00480     {
00481       pd_pert_x = pd_pert_x_;
00482       pd_pert_s = pd_pert_s_;
00483       pd_pert_c = pd_pert_c_;
00484       pd_pert_d = pd_pert_d_;
00485     }
00486 
00489     static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions);
00491 
00492   private:
00497     SmartPtr<const IteratesVector> curr_;
00498 
00501     SmartPtr<const IteratesVector> trial_;
00502 
00504     SmartPtr<const SymMatrix> W_;
00505 
00508     SmartPtr<const IteratesVector> delta_;
00516     bool have_deltas_;
00518 
00524     SmartPtr<const IteratesVector> delta_aff_;
00531     bool have_affine_deltas_;
00533 
00535     Index iter_count_;
00536 
00538     Number curr_mu_;
00539     bool mu_initialized_;
00540 
00542     Number curr_tau_;
00543     bool tau_initialized_;
00544 
00547     bool initialize_called_;
00548 
00551     bool have_prototypes_;
00552 
00559     Number tol_;
00561 
00565     bool free_mu_mode_;
00567     bool tiny_step_flag_;
00569 
00573     Number info_regu_x_;
00575     Number info_alpha_primal_;
00577     char info_alpha_primal_char_;
00579     Number info_alpha_dual_;
00581     Index info_ls_count_;
00584     bool info_skip_output_;
00586     std::string info_string_;
00588 
00590     SmartPtr<IteratesVectorSpace> iterates_space_;
00591 
00594     TimingStatistics timing_statistics_;
00595 
00597     Number cpu_time_start_;
00598 
00601     SmartPtr<IpoptAdditionalData> add_data_;
00602 
00606     Number pd_pert_x_;
00607     Number pd_pert_s_;
00608     Number pd_pert_c_;
00609     Number pd_pert_d_;
00611 
00621     IpoptData(const IpoptData&);
00622 
00624     void operator=(const IpoptData&);
00626 
00627 #if COIN_IPOPT_CHECKLEVEL > 0
00628 
00632     TaggedObject::Tag debug_curr_tag_;
00633     TaggedObject::Tag debug_trial_tag_;
00634     TaggedObject::Tag debug_delta_tag_;
00635     TaggedObject::Tag debug_delta_aff_tag_;
00636     TaggedObject::Tag debug_curr_tag_sum_;
00637     TaggedObject::Tag debug_trial_tag_sum_;
00638     TaggedObject::Tag debug_delta_tag_sum_;
00639     TaggedObject::Tag debug_delta_aff_tag_sum_;
00641 #endif
00642 
00643   };
00644 
00645   inline
00646   SmartPtr<const IteratesVector> IpoptData::curr() const
00647   {
00648     DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
00649 
00650     return curr_;
00651   }
00652 
00653   inline
00654   SmartPtr<const IteratesVector> IpoptData::trial() const
00655   {
00656     DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
00657 
00658     return trial_;
00659   }
00660 
00661   inline
00662   SmartPtr<const IteratesVector> IpoptData::delta() const
00663   {
00664     DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
00665 
00666     return delta_;
00667   }
00668 
00669   inline
00670   SmartPtr<const IteratesVector> IpoptData::delta_aff() const
00671   {
00672     DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
00673 
00674     return delta_aff_;
00675   }
00676 
00677   inline
00678   void IpoptData::CopyTrialToCurrent()
00679   {
00680     curr_ = trial_;
00681 #if COIN_IPOPT_CHECKLEVEL > 0
00682 
00683     if (IsValid(curr_)) {
00684       debug_curr_tag_ = curr_->GetTag();
00685       debug_curr_tag_sum_ = curr_->GetTagSum();
00686     }
00687     else {
00688       debug_curr_tag_ = 0;
00689       debug_curr_tag_sum_ = 0;
00690     }
00691 #endif
00692 
00693   }
00694 
00695   inline
00696   void IpoptData::set_trial(SmartPtr<IteratesVector>& trial)
00697   {
00698     trial_ = ConstPtr(trial);
00699 
00700 #if COIN_IPOPT_CHECKLEVEL > 0
00701     // verify the correct space
00702     DBG_ASSERT(trial_->OwnerSpace() == (VectorSpace*)GetRawPtr(iterates_space_));
00703     if (IsValid(trial)) {
00704       debug_trial_tag_ = trial->GetTag();
00705       debug_trial_tag_sum_ = trial->GetTagSum();
00706     }
00707     else {
00708       debug_trial_tag_ = 0;
00709       debug_trial_tag_sum_ = 0;
00710     }
00711 #endif
00712 
00713     trial = NULL;
00714   }
00715 
00716   inline
00717   void IpoptData::set_delta(SmartPtr<IteratesVector>& delta)
00718   {
00719     delta_ = ConstPtr(delta);
00720 #if COIN_IPOPT_CHECKLEVEL > 0
00721 
00722     if (IsValid(delta)) {
00723       debug_delta_tag_ = delta->GetTag();
00724       debug_delta_tag_sum_ = delta->GetTagSum();
00725     }
00726     else {
00727       debug_delta_tag_ = 0;
00728       debug_delta_tag_sum_ = 0;
00729     }
00730 #endif
00731 
00732     delta = NULL;
00733   }
00734 
00735   inline
00736   void IpoptData::set_delta(SmartPtr<const IteratesVector>& delta)
00737   {
00738     delta_ = delta;
00739 #if COIN_IPOPT_CHECKLEVEL > 0
00740 
00741     if (IsValid(delta)) {
00742       debug_delta_tag_ = delta->GetTag();
00743       debug_delta_tag_sum_ = delta->GetTagSum();
00744     }
00745     else {
00746       debug_delta_tag_ = 0;
00747       debug_delta_tag_sum_ = 0;
00748     }
00749 #endif
00750 
00751     delta = NULL;
00752   }
00753 
00754   inline
00755   void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff)
00756   {
00757     delta_aff_ = ConstPtr(delta_aff);
00758 #if COIN_IPOPT_CHECKLEVEL > 0
00759 
00760     if (IsValid(delta_aff)) {
00761       debug_delta_aff_tag_ = delta_aff->GetTag();
00762       debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
00763     }
00764     else {
00765       debug_delta_aff_tag_ = 0;
00766       debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
00767     }
00768 #endif
00769 
00770     delta_aff = NULL;
00771   }
00772 
00773 } // namespace Ipopt
00774 
00775 #endif

Generated on Sat Oct 16 2010 02:54:50 by  doxygen 1.7.1