Ipopt Documentation  
 
Loading...
Searching...
No Matches
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// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6
7#ifndef __IPIPOPTDATA_HPP__
8#define __IPIPOPTDATA_HPP__
9
10#include "IpSymMatrix.hpp"
11#include "IpOptionsList.hpp"
12#include "IpIteratesVector.hpp"
13#include "IpRegOptions.hpp"
15
16namespace Ipopt
17{
18
19/* Forward declaration */
20class IpoptNLP;
21
30{
31public:
34
36 { }
37
40 { }
42
48 virtual bool Initialize(
49 const Journalist& jnlst,
50 const OptionsList& options,
51 const std::string& prefix
52 ) = 0;
53
55 virtual bool InitializeDataStructures() = 0;
56
62 virtual void AcceptTrialPoint() = 0;
63
64private:
75
78 );
79
83 );
85};
86
98{
99public:
102
104 SmartPtr<IpoptAdditionalData> add_data = NULL
105 );
106
108 virtual ~IpoptData();
110
113 IpoptNLP& ip_nlp,
114 bool want_x,
115 bool want_y_c,
116 bool want_y_d,
117 bool want_z_L,
118 bool want_z_U
119 );
120
127 const Journalist& jnlst,
128 const OptionsList& options,
129 const std::string& prefix
130 );
131
134
135 inline SmartPtr<const IteratesVector> curr() const;
136
142 // SmartPtr<IteratesVector> curr_container() const;
144 inline SmartPtr<const IteratesVector> trial() const;
145
151 //SmartPtr<IteratesVector> trial_container() const;
158 inline
159 void set_trial(
161 );
162 /* ToDo: I may need to add versions of set_trial like the
163 * following, but I am not sure
164 */
165 // void set_trial(const SmartPtr<IteratesVector>& trial_iterates);
166 // void set_trial(SmartPtr<const IteratesVector>& trial_iterates);
167
172 Number alpha,
173 const Vector& delta_x,
174 const Vector& delta_s
175 );
181 Number alpha,
182 const Vector& delta_y_c,
183 const Vector& delta_y_d
184 );
190 Number alpha,
191 const Vector& delta_z_L,
192 const Vector& delta_z_U,
193 const Vector& delta_v_L,
194 const Vector& delta_v_U
195 );
196
198 inline SmartPtr<const IteratesVector> delta() const;
199
206 inline
207 void set_delta(
209 );
210
219 inline
220 void set_delta(
222 );
223
225 inline SmartPtr<const IteratesVector> delta_aff() const;
226
233 inline
234 void set_delta_aff(
235 SmartPtr<IteratesVector>& delta_aff
236 );
237
240 {
241 return W_;
242 }
243
245 void Set_W(
247 )
248 {
249 W_ = W;
250 }
251
261
271 bool HaveDeltas() const
272 {
273 return have_deltas_;
274 }
275
285 bool have_deltas
286 )
287 {
288 have_deltas_ = have_deltas;
289 }
291
301
311 bool HaveAffineDeltas() const
312 {
313 return have_affine_deltas_;
314 }
315
325 bool have_affine_deltas
326 )
327 {
328 have_affine_deltas_ = have_affine_deltas;
329 }
331
334
335 inline
336 void CopyTrialToCurrent();
337
341
345 {
346 return iter_count_;
347 }
349 Index iter_count
350 )
351 {
352 iter_count_ = iter_count;
353 }
354
356 {
357 DBG_ASSERT(mu_initialized_);
358 return curr_mu_;
359 }
360 void Set_mu(
361 Number mu
362 )
363 {
364 curr_mu_ = mu;
365 mu_initialized_ = true;
366 }
367 bool MuInitialized() const
368 {
369 return mu_initialized_;
370 }
371
373 {
374 DBG_ASSERT(tau_initialized_);
375 return curr_tau_;
376 }
378 Number tau
379 )
380 {
381 curr_tau_ = tau;
382 tau_initialized_ = true;
383 }
384 bool TauInitialized() const
385 {
386 return tau_initialized_;
387 }
388
390 bool free_mu_mode
391 )
392 {
393 free_mu_mode_ = free_mu_mode;
394 }
395 bool FreeMuMode() const
396 {
397 return free_mu_mode_;
398 }
399
404 bool flag
405 )
406 {
407 tiny_step_flag_ = flag;
408 }
410 {
411 return tiny_step_flag_;
412 }
414
423
424 Number tol() const
425 {
426 DBG_ASSERT(initialize_called_);
427 return tol_;
428 }
440 Number tol
441 )
442 {
443 tol_ = tol;
444 }
446
456 {
457 return timing_statistics_.OverallAlgorithm().StartCpuTime();
458 }
459
463 {
464 return info_regu_x_;
465 }
467 Number regu_x
468 )
469 {
470 info_regu_x_ = regu_x;
471 }
473 {
474 return info_alpha_primal_;
475 }
477 Number alpha_primal
478 )
479 {
480 info_alpha_primal_ = alpha_primal;
481 }
483 {
484 return info_alpha_primal_char_;
485 }
487 char info_alpha_primal_char
488 )
489 {
490 info_alpha_primal_char_ = info_alpha_primal_char;
491 }
493 {
494 return info_alpha_dual_;
495 }
497 Number alpha_dual
498 )
499 {
500 info_alpha_dual_ = alpha_dual;
501 }
503 {
504 return info_ls_count_;
505 }
507 Index ls_count
508 )
509 {
510 info_ls_count_ = ls_count;
511 }
512 bool info_skip_output() const
513 {
514 return info_skip_output_;
515 }
517 const std::string& add_str
518 )
519 {
520 info_string_ += add_str;
521 }
522 const std::string& info_string() const
523 {
524 return info_string_;
525 }
530 bool info_skip_output
531 )
532 {
533 info_skip_output_ = info_skip_output;
534 }
535
538 {
539 return info_last_output_;
540 }
543 Number info_last_output
544 )
545 {
546 info_last_output_ = info_last_output;
547 }
548
553 {
554 return info_iters_since_header_;
555 }
560 {
561 info_iters_since_header_++;
562 }
567 int info_iters_since_header
568 )
569 {
570 info_iters_since_header_ = info_iters_since_header;
571 }
572
575 {
576 info_regu_x_ = 0;
577 info_alpha_primal_ = 0;
578 info_alpha_dual_ = 0.;
579 info_alpha_primal_char_ = ' ';
580 info_skip_output_ = false;
581 info_string_.erase();
582 }
584
587 {
588 return timing_statistics_;
589 }
590
593 {
594 return IsValid(add_data_);
595 }
596
599 {
600 return *add_data_;
601 }
602
606 )
607 {
608 // cppcheck-suppress assertWithSideEffect
609 DBG_ASSERT(!HaveAddData());
610 add_data_ = add_data;
611 }
612
615 Number pd_pert_x,
616 Number pd_pert_s,
617 Number pd_pert_c,
618 Number pd_pert_d
619 )
620 {
621 pd_pert_x_ = pd_pert_x;
622 pd_pert_s_ = pd_pert_s;
623 pd_pert_c_ = pd_pert_c;
624 pd_pert_d_ = pd_pert_d;
625 }
626
629 Number& pd_pert_x,
630 Number& pd_pert_s,
631 Number& pd_pert_c,
632 Number& pd_pert_d
633 )
634 {
635 pd_pert_x = pd_pert_x_;
636 pd_pert_s = pd_pert_s_;
637 pd_pert_c = pd_pert_c_;
638 pd_pert_d = pd_pert_d_;
639 }
640
641 static void RegisterOptions(
642 const SmartPtr<RegisteredOptions>& roptions
643 );
644
645private:
648
650
653
656
667 // ToDo we could cue off of a null delta_
670
686 // ToDo we could cue off of a null delta_aff_
689
692
696
700
703
708
717
720
723
728
731
746 std::string info_string_;
754
757
760
765
773
784
786 const IpoptData&
787 );
788
791 const IpoptData&
792 );
794
795#if IPOPT_CHECKLEVEL > 0
800 TaggedObject::Tag debug_curr_tag_;
801 TaggedObject::Tag debug_trial_tag_;
802 TaggedObject::Tag debug_delta_tag_;
803 TaggedObject::Tag debug_delta_aff_tag_;
804 TaggedObject::Tag debug_curr_tag_sum_;
805 TaggedObject::Tag debug_trial_tag_sum_;
806 TaggedObject::Tag debug_delta_tag_sum_;
807 TaggedObject::Tag debug_delta_aff_tag_sum_;
809#endif
810
811};
812
814{
815 DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
816
817 return curr_;
818}
819
821{
822 DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
823
824 return trial_;
825}
826
828{
829 DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
830
831 return delta_;
832}
833
835{
836 DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
837
838 return delta_aff_;
839}
840
841inline
843{
844 curr_ = trial_;
845#if IPOPT_CHECKLEVEL > 0
846
847 if (IsValid(curr_))
848 {
849 debug_curr_tag_ = curr_->GetTag();
850 debug_curr_tag_sum_ = curr_->GetTagSum();
851 }
852 else
853 {
854 debug_curr_tag_ = 0;
855 debug_curr_tag_sum_ = 0;
856 }
857#endif
858
859}
860
861inline
864)
865{
867
868#if IPOPT_CHECKLEVEL > 0
869 // verify the correct space
870 DBG_ASSERT(trial_->OwnerSpace() == static_cast<VectorSpace*>(GetRawPtr(iterates_space_)));
871 if (IsValid(trial))
872 {
873 debug_trial_tag_ = trial->GetTag();
874 debug_trial_tag_sum_ = trial->GetTagSum();
875 }
876 else
877 {
878 debug_trial_tag_ = 0;
879 debug_trial_tag_sum_ = 0;
880 }
881#endif
882
883 trial = NULL;
884}
885
886inline
889)
890{
892#if IPOPT_CHECKLEVEL > 0
893
894 if (IsValid(delta))
895 {
896 debug_delta_tag_ = delta->GetTag();
897 debug_delta_tag_sum_ = delta->GetTagSum();
898 }
899 else
900 {
901 debug_delta_tag_ = 0;
902 debug_delta_tag_sum_ = 0;
903 }
904#endif
905
906 delta = NULL;
907}
908
909inline
912)
913{
914 delta_ = delta;
915#if IPOPT_CHECKLEVEL > 0
916
917 if (IsValid(delta))
918 {
919 debug_delta_tag_ = delta->GetTag();
920 debug_delta_tag_sum_ = delta->GetTagSum();
921 }
922 else
923 {
924 debug_delta_tag_ = 0;
925 debug_delta_tag_sum_ = 0;
926 }
927#endif
928
929 delta = NULL;
930}
931
932inline
934 SmartPtr<IteratesVector>& delta_aff
935)
936{
938#if IPOPT_CHECKLEVEL > 0
939
940 if (IsValid(delta_aff))
941 {
942 debug_delta_aff_tag_ = delta_aff->GetTag();
943 debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
944 }
945 else
946 {
947 debug_delta_aff_tag_ = 0;
948 debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
949 }
950#endif
951
952 delta_aff = NULL;
953}
954
955} // namespace Ipopt
956
957#endif
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
#define IPOPT_DEPRECATED
macro to declare symbols as deprecated
Definition: IpTypes.h:25
Base class for additional data that is special to a particular type of algorithm, such as the CG pena...
Definition: IpIpoptData.hpp:30
IpoptAdditionalData()
Default Constructor.
Definition: IpIpoptData.hpp:35
IpoptAdditionalData(const IpoptAdditionalData &)
Copy Constructor.
void operator=(const IpoptAdditionalData &)
Default Assignment 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()
Destructor.
Definition: IpIpoptData.hpp:39
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:98
TimingStatistics timing_statistics_
TimingStatistics object collecting all Ipopt timing statistics.
Number info_alpha_primal() const
Index info_ls_count_
Number of backtracking trial steps.
void operator=(const IpoptData &)
Default Assignment 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.
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
get the current delta
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...
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.
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)
IPOPT_DEPRECATED Number cpu_time_start() const
Cpu time counter at the beginning of the optimization.
virtual ~IpoptData()
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.
Number curr_mu() const
SmartPtr< const SymMatrix > W_
Hessian (approximation) - might be changed elsewhere!
IpoptData(SmartPtr< IpoptAdditionalData > add_data=NULL)
Constructor.
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:36
Class responsible for all message output.
This class stores a list of user set options.
Storing the reference count of all the smart pointers that currently reference it.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:165
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:473
Vector Base Class.
Definition: IpVector.hpp:48
#define IPOPTLIB_EXPORT
Definition: config.h:94
This file contains a base class for all exceptions and a set of macros to help with exceptions.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:663
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:672
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:649
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
bool IsNull(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:680