- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2006 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpIpoptData.hpp 759 2006-07-07 03:07:08Z 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
    00033   class IpoptData : public ReferencedObject
    00034   {
    00035   public:
    00039     IpoptData();
    00040
    00042     ~IpoptData();
    00044
    00046     bool InitializeDataStructures(IpoptNLP& ip_nlp,
    00047                                   bool want_x,
    00048                                   bool want_y_c,
    00049                                   bool want_y_d,
    00050                                   bool want_z_L,
    00051                                   bool want_z_U);
    00052
    00056     bool Initialize(const Journalist& jnlst,
    00057                     const OptionsList& options,
    00058                     const std::string& prefix);
    00059
    00063     SmartPtr<const IteratesVector> curr() const;
    00064
    00069     //    SmartPtr<IteratesVector> curr_container() const;
    00070
    00072     SmartPtr<const IteratesVector> trial() const;
    00073
    00078     //SmartPtr<IteratesVector> trial_container() const;
    00079
    00084     void set_trial(SmartPtr<IteratesVector>& trial);
    00085
    00089     void SetTrialPrimalVariablesFromStep(Number alpha,
    00090                                          const Vector& delta_x,
    00091                                          const Vector& delta_s);
    00096     void SetTrialEqMultipliersFromStep(Number alpha,
    00097                                        const Vector& delta_y_c,
    00098                                        const Vector& delta_y_d);
    00103     void SetTrialBoundMultipliersFromStep(Number alpha,
    00104                                           const Vector& delta_z_L,
    00105                                           const Vector& delta_z_U,
    00106                                           const Vector& delta_v_L,
    00107                                           const Vector& delta_v_U);
    00108
    00112     // void set_trial(const SmartPtr<IteratesVector>& trial_iterates);
    00113     // void set_trial(SmartPtr<const IteratesVector>& trial_iterates);
    00114
    00116     SmartPtr<const IteratesVector> delta() const;
    00117
    00122     void set_delta(SmartPtr<IteratesVector>& delta);
    00123
    00125     SmartPtr<const IteratesVector> delta_aff() const;
    00126
    00131     void set_delta_aff(SmartPtr<IteratesVector>& delta_aff);
    00132
    00133
    00135     SmartPtr<const SymMatrix> W()
    00136     {
    00137       DBG_ASSERT(IsValid(W_));
    00138       return W_;
    00139     }
    00140
    00142     void Set_W(SmartPtr<const SymMatrix> W)
    00143     {
    00144       W_ = W;
    00145     }
    00146
    00153
    00161     bool HaveDeltas() const
    00162     {
    00163       return have_deltas_;
    00164     }
    00165
    00171     void SetHaveDeltas(bool have_deltas)
    00172     {
    00173       have_deltas_ = have_deltas;
    00174     }
    00176
    00183
    00191     bool HaveAffineDeltas() const
    00192     {
    00193       return have_affine_deltas_;
    00194     }
    00195
    00201     void SetHaveAffineDeltas(bool have_affine_deltas)
    00202     {
    00203       have_affine_deltas_ = have_affine_deltas;
    00204     }
    00206
    00207
    00211     void CopyTrialToCurrent();
    00212
    00215     void AcceptTrialPoint();
    00217
    00220     Index iter_count() const
    00221     {
    00222       return iter_count_;
    00223     }
    00224     void Set_iter_count(Index iter_count)
    00225     {
    00226       iter_count_ = iter_count;
    00227     }
    00228
    00229     Number curr_mu() const
    00230     {
    00231       DBG_ASSERT(mu_initialized_);
    00232       return curr_mu_;
    00233     }
    00234     void Set_mu(Number mu)
    00235     {
    00236       curr_mu_ = mu;
    00237       mu_initialized_ = true;
    00238     }
    00239     bool MuInitialized() const
    00240     {
    00241       return mu_initialized_;
    00242     }
    00243
    00244     Number curr_tau() const
    00245     {
    00246       DBG_ASSERT(tau_initialized_);
    00247       return curr_tau_;
    00248     }
    00249     void Set_tau(Number tau)
    00250     {
    00251       curr_tau_ = tau;
    00252       tau_initialized_ = true;
    00253     }
    00254     bool TauInitialized() const
    00255     {
    00256       return tau_initialized_;
    00257     }
    00258
    00259     void SetFreeMuMode(bool free_mu_mode)
    00260     {
    00261       free_mu_mode_ = free_mu_mode;
    00262     }
    00263     bool FreeMuMode() const
    00264     {
    00265       return free_mu_mode_;
    00266     }
    00267
    00270     void Set_tiny_step_flag(bool flag)
    00271     {
    00272       tiny_step_flag_ = flag;
    00273     }
    00274     bool tiny_step_flag()
    00275     {
    00276       return tiny_step_flag_;
    00277     }
    00279
    00286     Number tol() const
    00287     {
    00288       DBG_ASSERT(initialize_called_);
    00289       return tol_;
    00290     }
    00298     void Set_tol(Number tol)
    00299     {
    00300       tol_ = tol;
    00301     }
    00303
    00306     Number info_regu_x() const
    00307     {
    00308       return info_regu_x_;
    00309     }
    00310     void Set_info_regu_x(Number regu_x)
    00311     {
    00312       info_regu_x_ = regu_x;
    00313     }
    00314     Number info_alpha_primal() const
    00315     {
    00316       return info_alpha_primal_;
    00317     }
    00318     void Set_info_alpha_primal(Number alpha_primal)
    00319     {
    00320       info_alpha_primal_ = alpha_primal;
    00321     }
    00322     char info_alpha_primal_char() const
    00323     {
    00324       return info_alpha_primal_char_;
    00325     }
    00326     void Set_info_alpha_primal_char(char info_alpha_primal_char)
    00327     {
    00328       info_alpha_primal_char_ = info_alpha_primal_char;
    00329     }
    00330     Number info_alpha_dual() const
    00331     {
    00332       return info_alpha_dual_;
    00333     }
    00334     void Set_info_alpha_dual(Number alpha_dual)
    00335     {
    00336       info_alpha_dual_ = alpha_dual;
    00337     }
    00338     Index info_ls_count() const
    00339     {
    00340       return info_ls_count_;
    00341     }
    00342     void Set_info_ls_count(Index ls_count)
    00343     {
    00344       info_ls_count_ = ls_count;
    00345     }
    00346     bool info_skip_output() const
    00347     {
    00348       return info_skip_output_;
    00349     }
    00350     void Append_info_string(const std::string& add_str)
    00351     {
    00352       info_string_ += add_str;
    00353     }
    00354     const std::string& info_string() const
    00355     {
    00356       return info_string_;
    00357     }
    00360     void Set_info_skip_output(bool info_skip_output)
    00361     {
    00362       info_skip_output_ = info_skip_output;
    00363     }
    00364
    00366     void ResetInfo()
    00367     {
    00368       info_regu_x_ = 0;
    00369       info_alpha_primal_ = 0;
    00370       info_alpha_dual_ = 0.;
    00371       info_alpha_primal_char_ = ' ';
    00372       info_ls_count_ = 0;
    00373       info_skip_output_ = false;
    00374       info_string_.clear();
    00375     }
    00377
    00379     TimingStatistics& TimingStats()
    00380     {
    00381       return timing_statistics_;
    00382     }
    00383
    00386     static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions);
    00388
    00389   private:
    00394     SmartPtr<const IteratesVector> curr_;
    00395
    00398     SmartPtr<const IteratesVector> trial_;
    00399
    00401     SmartPtr<const SymMatrix> W_;
    00402
    00405     SmartPtr<const IteratesVector> delta_;
    00413     bool have_deltas_;
    00415
    00421     SmartPtr<const IteratesVector> delta_aff_;
    00428     bool have_affine_deltas_;
    00430
    00432     Index iter_count_;
    00433
    00435     Number curr_mu_;
    00436     bool mu_initialized_;
    00437
    00439     Number curr_tau_;
    00440     bool tau_initialized_;
    00441
    00444     bool initialize_called_;
    00445
    00448     bool have_prototypes_;
    00449
    00456     Number tol_;
    00458
    00462     bool free_mu_mode_;
    00464     bool tiny_step_flag_;
    00466
    00470     Number info_regu_x_;
    00472     Number info_alpha_primal_;
    00474     char info_alpha_primal_char_;
    00476     Number info_alpha_dual_;
    00478     Index info_ls_count_;
    00481     bool info_skip_output_;
    00483     std::string info_string_;
    00485
    00487     SmartPtr<IteratesVectorSpace> iterates_space_;
    00488
    00491     TimingStatistics timing_statistics_;
    00492
    00502     IpoptData(const IpoptData&);
    00503
    00505     void operator=(const IpoptData&);
    00507
    00508 #ifdef IP_DEBUG
    00509
    00513     TaggedObject::Tag debug_curr_tag_;
    00514     TaggedObject::Tag debug_trial_tag_;
    00515     TaggedObject::Tag debug_delta_tag_;
    00516     TaggedObject::Tag debug_delta_aff_tag_;
    00517     TaggedObject::Tag debug_curr_tag_sum_;
    00518     TaggedObject::Tag debug_trial_tag_sum_;
    00519     TaggedObject::Tag debug_delta_tag_sum_;
    00520     TaggedObject::Tag debug_delta_aff_tag_sum_;
    00522 #endif
    00523
    00524   };
    00525
    00526   inline
    00527   SmartPtr<const IteratesVector> IpoptData::curr() const
    00528   {
    00529 #ifdef IP_DEBUG
    00530     DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
    00531 #endif
    00532
    00533     return curr_;
    00534   }
    00535
    00536   inline
    00537   SmartPtr<const IteratesVector> IpoptData::trial() const
    00538   {
    00539 #ifdef IP_DEBUG
    00540     DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
    00541 #endif
    00542
    00543     return trial_;
    00544   }
    00545
    00546   inline
    00547   SmartPtr<const IteratesVector> IpoptData::delta() const
    00548   {
    00549 #   ifdef IP_DEBUG
    00550     DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
    00551 #   endif
    00552
    00553     return delta_;
    00554   }
    00555
    00556   inline
    00557   SmartPtr<const IteratesVector> IpoptData::delta_aff() const
    00558   {
    00559 #   ifdef IP_DEBUG
    00560     DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
    00561 #   endif
    00562
    00563     return delta_aff_;
    00564   }
    00565
    00566   inline
    00567   void IpoptData::CopyTrialToCurrent()
    00568   {
    00569     curr_ = trial_;
    00570 #ifdef IP_DEBUG
    00571
    00572     if (IsValid(curr_)) {
    00573       debug_curr_tag_ = curr_->GetTag();
    00574       debug_curr_tag_sum_ = curr_->GetTagSum();
    00575     }
    00576     else {
    00577       debug_curr_tag_ = 0;
    00578       debug_curr_tag_sum_ = 0;
    00579     }
    00580 #endif
    00581
    00582   }
    00583
    00584   inline
    00585   void IpoptData::set_trial(SmartPtr<IteratesVector>& trial)
    00586   {
    00587     trial_ = ConstPtr(trial);
    00588
    00589 #ifdef IP_DEBUG
    00590     // verify the correct space
    00591     DBG_ASSERT(trial_->OwnerSpace() == (VectorSpace*)GetRawPtr(iterates_space_));
    00592     if (IsValid(trial)) {
    00593       debug_trial_tag_ = trial->GetTag();
    00594       debug_trial_tag_sum_ = trial->GetTagSum();
    00595     }
    00596     else {
    00597       debug_trial_tag_ = 0;
    00598       debug_trial_tag_sum_ = 0;
    00599     }
    00600 #endif
    00601
    00602     trial = NULL;
    00603   }
    00604
    00605   inline
    00606   void IpoptData::set_delta(SmartPtr<IteratesVector>& delta)
    00607   {
    00608     delta_ = ConstPtr(delta);
    00609 #ifdef IP_DEBUG
    00610
    00611     if (IsValid(delta)) {
    00612       debug_delta_tag_ = delta->GetTag();
    00613       debug_delta_tag_sum_ = delta->GetTagSum();
    00614     }
    00615     else {
    00616       debug_delta_tag_ = 0;
    00617       debug_delta_tag_sum_ = 0;
    00618     }
    00619 #endif
    00620
    00621     delta = NULL;
    00622   }
    00623
    00624   inline
    00625   void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff)
    00626   {
    00627     delta_aff_ = ConstPtr(delta_aff);
    00628 #ifdef IP_DEBUG
    00629
    00630     if (IsValid(delta_aff)) {
    00631       debug_delta_aff_tag_ = delta_aff->GetTag();
    00632       debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
    00633     }
    00634     else {
    00635       debug_delta_aff_tag_ = 0;
    00636       debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
    00637     }
    00638 #endif
    00639
    00640     delta_aff = NULL;
    00641   }
    00642
    00643 } // namespace Ipopt
    00644
    00645 #endif