00001
00002
00003
00004
00005
00006
00007
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
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
00071
00073 SmartPtr<const IteratesVector> trial() const;
00074
00079
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
00114
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_.erase();
00382 }
00384
00386 TimingStatistics& TimingStats()
00387 {
00388 return timing_statistics_;
00389 }
00390
00392 CGPenaltyData& CGPenData()
00393 {
00394 return *cgpen_data_;
00395 }
00396
00398 void setPDPert(Number pd_pert_x, Number pd_pert_s,
00399 Number pd_pert_c, Number pd_pert_d)
00400 {
00401 pd_pert_x_ = pd_pert_x;
00402 pd_pert_s_ = pd_pert_s;
00403 pd_pert_c_ = pd_pert_c;
00404 pd_pert_d_ = pd_pert_d;
00405 }
00406
00408 void getPDPert(Number& pd_pert_x, Number& pd_pert_s,
00409 Number& pd_pert_c, Number& pd_pert_d)
00410 {
00411 pd_pert_x = pd_pert_x_;
00412 pd_pert_s = pd_pert_s_;
00413 pd_pert_c = pd_pert_c_;
00414 pd_pert_d = pd_pert_d_;
00415 }
00416
00419 static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions);
00421
00422 private:
00427 SmartPtr<const IteratesVector> curr_;
00428
00431 SmartPtr<const IteratesVector> trial_;
00432
00434 SmartPtr<const SymMatrix> W_;
00435
00438 SmartPtr<const IteratesVector> delta_;
00446 bool have_deltas_;
00448
00454 SmartPtr<const IteratesVector> delta_aff_;
00461 bool have_affine_deltas_;
00463
00465 Index iter_count_;
00466
00468 Number curr_mu_;
00469 bool mu_initialized_;
00470
00472 Number curr_tau_;
00473 bool tau_initialized_;
00474
00477 bool initialize_called_;
00478
00481 bool have_prototypes_;
00482
00489 Number tol_;
00491
00495 bool free_mu_mode_;
00497 bool tiny_step_flag_;
00499
00503 Number info_regu_x_;
00505 Number info_alpha_primal_;
00507 char info_alpha_primal_char_;
00509 Number info_alpha_dual_;
00511 Index info_ls_count_;
00514 bool info_skip_output_;
00516 std::string info_string_;
00518
00520 SmartPtr<IteratesVectorSpace> iterates_space_;
00521
00524 TimingStatistics timing_statistics_;
00525
00528 CGPenaltyData* const cgpen_data_;
00529
00533 Number pd_pert_x_;
00534 Number pd_pert_s_;
00535 Number pd_pert_c_;
00536 Number pd_pert_d_;
00538
00548 IpoptData(const IpoptData&);
00549
00551 void operator=(const IpoptData&);
00553
00554 #if COIN_IPOPT_CHECKLEVEL > 0
00555
00559 TaggedObject::Tag debug_curr_tag_;
00560 TaggedObject::Tag debug_trial_tag_;
00561 TaggedObject::Tag debug_delta_tag_;
00562 TaggedObject::Tag debug_delta_aff_tag_;
00563 TaggedObject::Tag debug_curr_tag_sum_;
00564 TaggedObject::Tag debug_trial_tag_sum_;
00565 TaggedObject::Tag debug_delta_tag_sum_;
00566 TaggedObject::Tag debug_delta_aff_tag_sum_;
00568 #endif
00569
00570 };
00571
00572 inline
00573 SmartPtr<const IteratesVector> IpoptData::curr() const
00574 {
00575 DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
00576
00577 return curr_;
00578 }
00579
00580 inline
00581 SmartPtr<const IteratesVector> IpoptData::trial() const
00582 {
00583 DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
00584
00585 return trial_;
00586 }
00587
00588 inline
00589 SmartPtr<const IteratesVector> IpoptData::delta() const
00590 {
00591 DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
00592
00593 return delta_;
00594 }
00595
00596 inline
00597 SmartPtr<const IteratesVector> IpoptData::delta_aff() const
00598 {
00599 DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
00600
00601 return delta_aff_;
00602 }
00603
00604 inline
00605 void IpoptData::CopyTrialToCurrent()
00606 {
00607 curr_ = trial_;
00608 #if COIN_IPOPT_CHECKLEVEL > 0
00609
00610 if (IsValid(curr_)) {
00611 debug_curr_tag_ = curr_->GetTag();
00612 debug_curr_tag_sum_ = curr_->GetTagSum();
00613 }
00614 else {
00615 debug_curr_tag_ = 0;
00616 debug_curr_tag_sum_ = 0;
00617 }
00618 #endif
00619
00620 }
00621
00622 inline
00623 void IpoptData::set_trial(SmartPtr<IteratesVector>& trial)
00624 {
00625 trial_ = ConstPtr(trial);
00626
00627 #if COIN_IPOPT_CHECKLEVEL > 0
00628
00629 DBG_ASSERT(trial_->OwnerSpace() == (VectorSpace*)GetRawPtr(iterates_space_));
00630 if (IsValid(trial)) {
00631 debug_trial_tag_ = trial->GetTag();
00632 debug_trial_tag_sum_ = trial->GetTagSum();
00633 }
00634 else {
00635 debug_trial_tag_ = 0;
00636 debug_trial_tag_sum_ = 0;
00637 }
00638 #endif
00639
00640 trial = NULL;
00641 }
00642
00643 inline
00644 void IpoptData::set_delta(SmartPtr<IteratesVector>& delta)
00645 {
00646 delta_ = ConstPtr(delta);
00647 #if COIN_IPOPT_CHECKLEVEL > 0
00648
00649 if (IsValid(delta)) {
00650 debug_delta_tag_ = delta->GetTag();
00651 debug_delta_tag_sum_ = delta->GetTagSum();
00652 }
00653 else {
00654 debug_delta_tag_ = 0;
00655 debug_delta_tag_sum_ = 0;
00656 }
00657 #endif
00658
00659 delta = NULL;
00660 }
00661
00662 inline
00663 void IpoptData::set_delta(SmartPtr<const IteratesVector>& delta)
00664 {
00665 delta_ = delta;
00666 #if COIN_IPOPT_CHECKLEVEL > 0
00667
00668 if (IsValid(delta)) {
00669 debug_delta_tag_ = delta->GetTag();
00670 debug_delta_tag_sum_ = delta->GetTagSum();
00671 }
00672 else {
00673 debug_delta_tag_ = 0;
00674 debug_delta_tag_sum_ = 0;
00675 }
00676 #endif
00677
00678 delta = NULL;
00679 }
00680
00681 inline
00682 void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff)
00683 {
00684 delta_aff_ = ConstPtr(delta_aff);
00685 #if COIN_IPOPT_CHECKLEVEL > 0
00686
00687 if (IsValid(delta_aff)) {
00688 debug_delta_aff_tag_ = delta_aff->GetTag();
00689 debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
00690 }
00691 else {
00692 debug_delta_aff_tag_ = 0;
00693 debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
00694 }
00695 #endif
00696
00697 delta_aff = NULL;
00698 }
00699
00700 }
00701
00702 #endif