Ipopt 3.11.9
IpIpoptData.hpp
Go to the documentation of this file.
1// Copyright (C) 2004, 2009 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// $Id: IpIpoptData.hpp 2476 2014-04-08 09:41:07Z stefan $
6//
7// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9#ifndef __IPIPOPTDATA_HPP__
10#define __IPIPOPTDATA_HPP__
11
12#include "IpSymMatrix.hpp"
13#include "IpOptionsList.hpp"
14#include "IpIteratesVector.hpp"
15#include "IpRegOptions.hpp"
17
18namespace Ipopt
19{
20
21 /* Forward declaration */
22 class IpoptNLP;
23
29 {
30 public:
35 {}
36
39 {}
41
45 virtual bool Initialize(const Journalist& jnlst,
46 const OptionsList& options,
47 const std::string& prefix) = 0;
48
50 virtual bool InitializeDataStructures() = 0;
51
55 virtual void AcceptTrialPoint() = 0;
56
57 private:
68
72 };
73
84 {
85 public:
91
93 virtual ~IpoptData();
95
98 bool want_x,
99 bool want_y_c,
100 bool want_y_d,
101 bool want_z_L,
102 bool want_z_U);
103
107 bool Initialize(const Journalist& jnlst,
108 const OptionsList& options,
109 const std::string& prefix);
110
114 inline
116
121 // SmartPtr<IteratesVector> curr_container() const;
122
124 inline
126
131 //SmartPtr<IteratesVector> trial_container() const;
132
137 inline
139
144 const Vector& delta_x,
145 const Vector& delta_s);
151 const Vector& delta_y_c,
152 const Vector& delta_y_d);
158 const Vector& delta_z_L,
159 const Vector& delta_z_U,
160 const Vector& delta_v_L,
161 const Vector& delta_v_U);
162
166 // void set_trial(const SmartPtr<IteratesVector>& trial_iterates);
167 // void set_trial(SmartPtr<const IteratesVector>& trial_iterates);
168
170 inline
172
177 inline
179
186 inline
188
190 inline
192
197 inline
199
202 {
204 return W_;
205 }
206
209 {
210 W_ = W;
211 }
212
219
227 bool HaveDeltas() const
228 {
229 return have_deltas_;
230 }
231
237 void SetHaveDeltas(bool have_deltas)
238 {
239 have_deltas_ = have_deltas;
240 }
242
249
257 bool HaveAffineDeltas() const
258 {
259 return have_affine_deltas_;
260 }
261
267 void SetHaveAffineDeltas(bool have_affine_deltas)
268 {
269 have_affine_deltas_ = have_affine_deltas;
270 }
272
276 inline
277 void CopyTrialToCurrent();
278
283
287 {
288 return iter_count_;
289 }
291 {
293 }
294
296 {
298 return curr_mu_;
299 }
300 void Set_mu(Number mu)
301 {
302 curr_mu_ = mu;
303 mu_initialized_ = true;
304 }
305 bool MuInitialized() const
306 {
307 return mu_initialized_;
308 }
309
311 {
313 return curr_tau_;
314 }
315 void Set_tau(Number tau)
316 {
317 curr_tau_ = tau;
318 tau_initialized_ = true;
319 }
320 bool TauInitialized() const
321 {
322 return tau_initialized_;
323 }
324
325 void SetFreeMuMode(bool free_mu_mode)
326 {
327 free_mu_mode_ = free_mu_mode;
328 }
329 bool FreeMuMode() const
330 {
331 return free_mu_mode_;
332 }
333
336 void Set_tiny_step_flag(bool flag)
337 {
338 tiny_step_flag_ = flag;
339 }
341 {
342 return tiny_step_flag_;
343 }
345
352 Number tol() const
353 {
355 return tol_;
356 }
365 {
366 tol_ = tol;
367 }
369
374 {
375 return cpu_time_start_;
376 }
377
381 {
382 return info_regu_x_;
383 }
385 {
386 info_regu_x_ = regu_x;
387 }
389 {
390 return info_alpha_primal_;
391 }
392 void Set_info_alpha_primal(Number alpha_primal)
393 {
394 info_alpha_primal_ = alpha_primal;
395 }
397 {
399 }
401 {
403 }
405 {
406 return info_alpha_dual_;
407 }
409 {
410 info_alpha_dual_ = alpha_dual;
411 }
413 {
414 return info_ls_count_;
415 }
417 {
418 info_ls_count_ = ls_count;
419 }
420 bool info_skip_output() const
421 {
422 return info_skip_output_;
423 }
424 void Append_info_string(const std::string& add_str)
425 {
426 info_string_ += add_str;
427 }
428 const std::string& info_string() const
429 {
430 return info_string_;
431 }
435 {
437 }
438
441 {
442 return info_last_output_;
443 }
446 {
448 }
449
453 {
455 }
459 {
461 }
465 {
467 }
468
471 {
472 info_regu_x_ = 0;
474 info_alpha_dual_ = 0.;
476 info_skip_output_ = false;
477 info_string_.erase();
478 }
480
483 {
484 return timing_statistics_;
485 }
486
489 {
490 return IsValid(add_data_);
491 }
492
495 {
496 return *add_data_;
497 }
498
501 {
503 add_data_ = add_data;
504 }
505
507 void setPDPert(Number pd_pert_x, Number pd_pert_s,
508 Number pd_pert_c, Number pd_pert_d)
509 {
510 pd_pert_x_ = pd_pert_x;
511 pd_pert_s_ = pd_pert_s;
512 pd_pert_c_ = pd_pert_c;
513 pd_pert_d_ = pd_pert_d;
514 }
515
517 void getPDPert(Number& pd_pert_x, Number& pd_pert_s,
518 Number& pd_pert_c, Number& pd_pert_d)
519 {
520 pd_pert_x = pd_pert_x_;
521 pd_pert_s = pd_pert_s_;
522 pd_pert_c = pd_pert_c_;
523 pd_pert_d = pd_pert_d_;
524 }
525
528 static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions);
530
531 private:
537
541
544
557
572
575
579
583
587
591
600
608
625 std::string info_string_;
632
635
639
642
646
655
666
668 void operator=(const IpoptData&);
670
671#if COIN_IPOPT_CHECKLEVEL > 0
676 TaggedObject::Tag debug_curr_tag_;
677 TaggedObject::Tag debug_trial_tag_;
678 TaggedObject::Tag debug_delta_tag_;
679 TaggedObject::Tag debug_delta_aff_tag_;
680 TaggedObject::Tag debug_curr_tag_sum_;
681 TaggedObject::Tag debug_trial_tag_sum_;
682 TaggedObject::Tag debug_delta_tag_sum_;
683 TaggedObject::Tag debug_delta_aff_tag_sum_;
685#endif
686
687 };
688
689 inline
691 {
692 DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
693
694 return curr_;
695 }
696
697 inline
699 {
700 DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
701
702 return trial_;
703 }
704
705 inline
707 {
708 DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
709
710 return delta_;
711 }
712
713 inline
715 {
716 DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
717
718 return delta_aff_;
719 }
720
721 inline
723 {
724 curr_ = trial_;
725#if COIN_IPOPT_CHECKLEVEL > 0
726
727 if (IsValid(curr_)) {
728 debug_curr_tag_ = curr_->GetTag();
729 debug_curr_tag_sum_ = curr_->GetTagSum();
730 }
731 else {
732 debug_curr_tag_ = 0;
733 debug_curr_tag_sum_ = 0;
734 }
735#endif
736
737 }
738
739 inline
741 {
743
744#if COIN_IPOPT_CHECKLEVEL > 0
745 // verify the correct space
747 if (IsValid(trial)) {
748 debug_trial_tag_ = trial->GetTag();
749 debug_trial_tag_sum_ = trial->GetTagSum();
750 }
751 else {
752 debug_trial_tag_ = 0;
753 debug_trial_tag_sum_ = 0;
754 }
755#endif
756
757 trial = NULL;
758 }
759
760 inline
762 {
764#if COIN_IPOPT_CHECKLEVEL > 0
765
766 if (IsValid(delta)) {
767 debug_delta_tag_ = delta->GetTag();
768 debug_delta_tag_sum_ = delta->GetTagSum();
769 }
770 else {
771 debug_delta_tag_ = 0;
772 debug_delta_tag_sum_ = 0;
773 }
774#endif
775
776 delta = NULL;
777 }
778
779 inline
781 {
782 delta_ = delta;
783#if COIN_IPOPT_CHECKLEVEL > 0
784
785 if (IsValid(delta)) {
786 debug_delta_tag_ = delta->GetTag();
787 debug_delta_tag_sum_ = delta->GetTagSum();
788 }
789 else {
790 debug_delta_tag_ = 0;
791 debug_delta_tag_sum_ = 0;
792 }
793#endif
794
795 delta = NULL;
796 }
797
798 inline
800 {
802#if COIN_IPOPT_CHECKLEVEL > 0
803
804 if (IsValid(delta_aff)) {
805 debug_delta_aff_tag_ = delta_aff->GetTag();
806 debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
807 }
808 else {
809 debug_delta_aff_tag_ = 0;
810 debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
811 }
812#endif
813
814 delta_aff = NULL;
815 }
816
817} // namespace Ipopt
818
819#endif
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Base class for additional data that is special to a particular type of algorithm, such as the CG pena...
Definition: IpIpoptData.hpp:29
IpoptAdditionalData()
Default Constructor.
Definition: IpIpoptData.hpp:34
IpoptAdditionalData(const IpoptAdditionalData &)
Copy Constructor.
void operator=(const IpoptAdditionalData &)
Overloaded Equals Operator.
virtual bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)=0
This method is called to initialize the global algorithmic parameters.
virtual bool InitializeDataStructures()=0
Initialize Data Structures at the beginning.
virtual ~IpoptAdditionalData()
Default destructor.
Definition: IpIpoptData.hpp:38
virtual void AcceptTrialPoint()=0
Do whatever is necessary to accept a trial point as current iterate.
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:84
TimingStatistics timing_statistics_
TimingStatistics object collecting all Ipopt timing statistics.
Number cpu_time_start() const
Cpu time counter at the beginning of the optimization.
Number info_alpha_primal() const
Index info_ls_count_
Number of backtracking trial steps.
void operator=(const IpoptData &)
Overloaded Equals Operator.
bool HaveAddData()
Check if additional data has been set.
Number info_regu_x() const
std::string info_string_
any string of characters for the end of the output line
const std::string & info_string() const
void set_delta_aff(SmartPtr< IteratesVector > &delta_aff)
Set the affine delta - like the trial point, this method copies the pointer for efficiency (no copy a...
void Append_info_string(const std::string &add_str)
void setPDPert(Number pd_pert_x, Number pd_pert_s, Number pd_pert_c, Number pd_pert_d)
Set the perturbation of the primal-dual system.
bool free_mu_mode_
flag indicating whether the algorithm is in the free mu mode
void Set_info_last_output(Number info_last_output)
sets time when the last summary output line was printed
SmartPtr< const SymMatrix > W()
Hessian or Hessian approximation (do not hold on to it, it might be changed)
void Set_info_regu_x(Number regu_x)
void Set_W(SmartPtr< const SymMatrix > W)
Set Hessian approximation.
SmartPtr< const IteratesVector > trial_
Main iteration variables (trial calculations)
SmartPtr< const IteratesVector > delta_aff_
void Inc_info_iters_since_header()
increases number of iteration summaries actually printed since last summary header was printed
bool have_deltas_
The following flag is set to true, if some other part of the algorithm (like the method for computing...
bool initialize_called_
flag indicating if Initialize method has been called (for debugging)
Index info_ls_count() const
void SetTrialEqMultipliersFromStep(Number alpha, const Vector &delta_y_c, const Vector &delta_y_d)
Set the values of the trial values for the equality constraint multipliers (y_c and y_d) from provide...
void SetHaveDeltas(bool have_deltas)
Method for setting the HaveDeltas flag.
Number curr_tau() const
int info_iters_since_header_
number of iteration summaries actually printed since last summary header was printed
TimingStatistics & TimingStats()
Return Timing Statistics Object.
bool HaveDeltas() const
Returns true, if the primal-dual step have been already computed for the current iteration.
Number info_alpha_dual_
Dual step size.
SmartPtr< const IteratesVector > delta() const
ToDo: I may need to add versions of set_trial like the following, but I am not sure.
void Set_info_ls_count(Index ls_count)
SmartPtr< IpoptAdditionalData > add_data_
Object for the data specific for the Chen-Goldfarb penalty method algorithm.
bool have_affine_deltas_
The following flag is set to true, if some other part of the algorithm (like the method for computing...
Number cpu_time_start_
CPU time counter at initialization.
SmartPtr< const IteratesVector > curr_
Main iteration variables (current iteration)
IpoptAdditionalData & AdditionalData()
Get access to additional data object.
void SetTrialPrimalVariablesFromStep(Number alpha, const Vector &delta_x, const Vector &delta_s)
Set the values of the primal trial variables (x and s) from provided Step with step length alpha.
IpoptData(SmartPtr< IpoptAdditionalData > add_data=NULL, Number cpu_time_start=-1.)
Constructor.
void AcceptTrialPoint()
Set the current iterate values from the trial values.
Number info_alpha_primal_
Primal step size.
void CopyTrialToCurrent()
Copy the trial values to the current values.
void Set_info_alpha_primal_char(char info_alpha_primal_char)
Number info_alpha_dual() const
IpoptData(const IpoptData &)
Copy Constructor.
void Set_tiny_step_flag(bool flag)
Setting the flag that indicates if a tiny step (below machine precision) has been detected.
Index iter_count() const
SmartPtr< const IteratesVector > curr() const
Current point.
void Set_info_alpha_dual(Number alpha_dual)
void ResetInfo()
Reset all info fields.
void SetTrialBoundMultipliersFromStep(Number alpha, const Vector &delta_z_L, const Vector &delta_z_U, const Vector &delta_v_L, const Vector &delta_v_U)
Set the value of the trial values for the bound multipliers (z_L, z_U, v_L, v_U) from provided step w...
void Set_iter_count(Index iter_count)
Number curr_tau_
current fraction to the boundary parameter
SmartPtr< const IteratesVector > trial() const
Get the current point in a copied container that is non-const.
bool HaveAffineDeltas() const
Returns true, if the affine-scaling step have been already computed for the current iteration.
int info_iters_since_header()
gives number of iteration summaries actually printed since last summary header was printed
bool tiny_step_flag_
flag indicating if a tiny step has been detected
void Set_info_iters_since_header(int info_iters_since_header)
sets number of iteration summaries actually printed since last summary header was printed
SmartPtr< IteratesVectorSpace > iterates_space_
VectorSpace for all the iterates.
void Set_tau(Number tau)
bool info_skip_output() const
Number tol_
Overall convergence tolerance.
Number curr_mu_
current barrier parameter
void Set_info_skip_output(bool info_skip_output)
Set this to true, if the next time when output is written, the summary line should not be printed.
Number tol() const
Overall convergence tolerance.
bool FreeMuMode() const
char info_alpha_primal_char_
Info character for primal step size.
bool have_prototypes_
flag for debugging whether we have already curr_ values available (from which new Vectors can be gene...
void Set_tol(Number tol)
Set a new value for the tolerance.
bool info_skip_output_
true, if next summary output line should not be printed (eg after restoration phase.
void SetFreeMuMode(bool free_mu_mode)
static void RegisterOptions(const SmartPtr< RegisteredOptions > &roptions)
Methods for IpoptType.
virtual ~IpoptData()
Default destructor.
bool InitializeDataStructures(IpoptNLP &ip_nlp, bool want_x, bool want_y_c, bool want_y_d, bool want_z_L, bool want_z_U)
Initialize Data Structures.
char info_alpha_primal_char() const
SmartPtr< const IteratesVector > delta_
bool Initialize(const Journalist &jnlst, const OptionsList &options, const std::string &prefix)
This method must be called to initialize the global algorithmic parameters.
Number info_last_output_
time when the last summary output line was printed
Index iter_count_
iteration count
Number info_last_output()
gives time when the last summary output line was printed
void set_delta(SmartPtr< IteratesVector > &delta)
Set the current delta - like the trial point, this method copies the pointer for efficiency (no copy ...
Number curr_mu() const
SmartPtr< const SymMatrix > W_
Hessian (approximation) - might be changed elsewhere!
void Set_mu(Number mu)
bool MuInitialized() const
void SetHaveAffineDeltas(bool have_affine_deltas)
Method for setting the HaveDeltas flag.
void Set_info_alpha_primal(Number alpha_primal)
void set_trial(SmartPtr< IteratesVector > &trial)
Get Trial point in a copied container that is non-const.
void getPDPert(Number &pd_pert_x, Number &pd_pert_s, Number &pd_pert_c, Number &pd_pert_d)
Get the current perturbation of the primal-dual system.
bool TauInitialized() const
SmartPtr< const IteratesVector > delta_aff() const
Affine Delta.
Number info_regu_x_
Size of regularization for the Hessian.
void SetAddData(SmartPtr< IpoptAdditionalData > add_data)
Set a new pointer for additional Ipopt data.
This is the abstract base class for classes that map the traditional NLP into something that is more ...
Definition: IpIpoptNLP.hpp:29
Class responsible for all message output.
This class stores a list of user set options.
ReferencedObject class.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:183
unsigned int Tag
Type for the Tag values.
This class collects all timing statistics for Ipopt.
VectorSpace base class, corresponding to the Vector base class.
Definition: IpVector.hpp:391
Vector Base Class.
Definition: IpVector.hpp:48
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:582
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:589
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:570
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
bool IsNull(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:595
double Number
Type of all numbers.
Definition: IpTypes.hpp:17