Ipopt Documentation  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IpIpoptCalculatedQuantities.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2011 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 __IPIPOPTCALCULATEDQUANTITIES_HPP__
8 #define __IPIPOPTCALCULATEDQUANTITIES_HPP__
9 
10 #include "IpSmartPtr.hpp"
11 #include "IpCachedResults.hpp"
12 
13 #include <string>
14 
15 namespace Ipopt
16 {
17 class IpoptNLP;
18 class IpoptData;
19 class Vector;
20 class Matrix;
21 class SymMatrix;
22 class Journalist;
23 class OptionsList;
24 class RegisteredOptions;
25 
28 {
29  NORM_1 = 0,
32 };
33 
42 {
43 public:
45 
48  { }
49 
52  { }
54 
60  virtual bool Initialize(
61  const Journalist& jnlst,
62  const OptionsList& options,
63  const std::string& prefix
64  ) = 0;
65 
66 private:
76 
79  const IpoptAdditionalCq&);
80 
82  void operator=(
83  const IpoptAdditionalCq&);
85 };
86 
89 {
90 public:
91 
93 
96  const SmartPtr<IpoptNLP>& ip_nlp,
97  const SmartPtr<IpoptData>& ip_data
98  );
100  virtual ~IpoptCalculatedQuantities();
102 
108  void SetAddCq(
110  )
111  {
112  DBG_ASSERT(!HaveAddCq());
113  add_cq_ = add_cq;
114  }
115 
119  bool HaveAddCq()
120  {
121  return IsValid(add_cq_);
122  }
123 
129  bool Initialize(
130  const Journalist& jnlst,
131  const OptionsList& options,
132  const std::string& prefix
133  );
134 
136 
138  SmartPtr<const Vector> curr_slack_x_L();
140  SmartPtr<const Vector> curr_slack_x_U();
142  SmartPtr<const Vector> curr_slack_s_L();
144  SmartPtr<const Vector> curr_slack_s_U();
146  SmartPtr<const Vector> trial_slack_x_L();
148  SmartPtr<const Vector> trial_slack_x_U();
150  SmartPtr<const Vector> trial_slack_s_L();
152  SmartPtr<const Vector> trial_slack_s_U();
154  Index AdjustedTrialSlacks();
156  void ResetAdjustedTrialSlacks();
158 
160 
162  virtual Number curr_f();
164  virtual Number unscaled_curr_f();
166  virtual Number trial_f();
168  virtual Number unscaled_trial_f();
170  SmartPtr<const Vector> curr_grad_f();
172  SmartPtr<const Vector> trial_grad_f();
174 
176 
180  virtual Number curr_barrier_obj();
184  virtual Number trial_barrier_obj();
185 
189  SmartPtr<const Vector> curr_grad_barrier_obj_x();
193  SmartPtr<const Vector> curr_grad_barrier_obj_s();
194 
196  SmartPtr<const Vector> grad_kappa_times_damping_x();
198  SmartPtr<const Vector> grad_kappa_times_damping_s();
200 
202 
204  SmartPtr<const Vector> curr_c();
206  SmartPtr<const Vector> unscaled_curr_c();
208  SmartPtr<const Vector> trial_c();
210  SmartPtr<const Vector> unscaled_trial_c();
212  SmartPtr<const Vector> curr_d();
214  SmartPtr<const Vector> unscaled_curr_d();
216  SmartPtr<const Vector> trial_d();
218  SmartPtr<const Vector> curr_d_minus_s();
220  SmartPtr<const Vector> trial_d_minus_s();
222  SmartPtr<const Matrix> curr_jac_c();
224  SmartPtr<const Matrix> trial_jac_c();
226  SmartPtr<const Matrix> curr_jac_d();
228  SmartPtr<const Matrix> trial_jac_d();
232  SmartPtr<const Vector> curr_jac_cT_times_vec(
233  const Vector& vec
234  );
238  SmartPtr<const Vector> trial_jac_cT_times_vec(
239  const Vector& vec
240  );
244  SmartPtr<const Vector> curr_jac_dT_times_vec(
245  const Vector& vec
246  );
250  SmartPtr<const Vector> trial_jac_dT_times_vec(
251  const Vector& vec
252  );
256  SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
260  SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
264  SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
268  SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
272  SmartPtr<const Vector> curr_jac_c_times_vec(
273  const Vector& vec
274  );
278  SmartPtr<const Vector> curr_jac_d_times_vec(
279  const Vector& vec
280  );
287  virtual Number curr_constraint_violation();
294  virtual Number trial_constraint_violation();
299  virtual Number curr_nlp_constraint_violation(
300  ENormType NormType
301  );
306  virtual Number unscaled_curr_nlp_constraint_violation(
307  ENormType NormType
308  );
313  virtual Number unscaled_trial_nlp_constraint_violation(
314  ENormType NormType
315  );
317 
319 
321  SmartPtr<const SymMatrix> curr_exact_hessian();
323 
325 
327  SmartPtr<const Vector> curr_grad_lag_x();
329  SmartPtr<const Vector> trial_grad_lag_x();
331  SmartPtr<const Vector> curr_grad_lag_s();
333  SmartPtr<const Vector> trial_grad_lag_s();
337  SmartPtr<const Vector> curr_grad_lag_with_damping_x();
341  SmartPtr<const Vector> curr_grad_lag_with_damping_s();
343  SmartPtr<const Vector> curr_compl_x_L();
345  SmartPtr<const Vector> curr_compl_x_U();
347  SmartPtr<const Vector> curr_compl_s_L();
349  SmartPtr<const Vector> curr_compl_s_U();
351  SmartPtr<const Vector> trial_compl_x_L();
353  SmartPtr<const Vector> trial_compl_x_U();
355  SmartPtr<const Vector> trial_compl_s_L();
357  SmartPtr<const Vector> trial_compl_s_U();
359  SmartPtr<const Vector> curr_relaxed_compl_x_L();
361  SmartPtr<const Vector> curr_relaxed_compl_x_U();
363  SmartPtr<const Vector> curr_relaxed_compl_s_L();
365  SmartPtr<const Vector> curr_relaxed_compl_s_U();
366 
368  virtual Number curr_primal_infeasibility(
369  ENormType NormType
370  );
372  virtual Number trial_primal_infeasibility(
373  ENormType NormType
374  );
375 
377  virtual Number curr_dual_infeasibility(
378  ENormType NormType
379  );
381  virtual Number trial_dual_infeasibility(
382  ENormType NormType
383  );
385  virtual Number unscaled_curr_dual_infeasibility(
386  ENormType NormType
387  );
388 
392  virtual Number curr_complementarity(
393  Number mu,
394  ENormType NormType
395  );
399  virtual Number trial_complementarity(
400  Number mu,
401  ENormType NormType
402  );
406  virtual Number unscaled_curr_complementarity(
407  Number mu,
408  ENormType NormType
409  );
410 
412  Number CalcCentralityMeasure(
413  const Vector& compl_x_L,
414  const Vector& compl_x_U,
415  const Vector& compl_s_L,
416  const Vector& compl_s_U
417  );
419  virtual Number curr_centrality_measure();
420 
427  virtual Number curr_nlp_error();
435  virtual Number unscaled_curr_nlp_error();
436 
440  virtual Number curr_barrier_error();
441 
449  virtual Number curr_primal_dual_system_error(
450  Number mu
451  );
459  virtual Number trial_primal_dual_system_error(
460  Number mu
461  );
463 
465 
469  Number primal_frac_to_the_bound(
470  Number tau,
471  const Vector& delta_x,
472  const Vector& delta_s
473  );
477  Number curr_primal_frac_to_the_bound(
478  Number tau
479  );
483  Number dual_frac_to_the_bound(
484  Number tau,
485  const Vector& delta_z_L,
486  const Vector& delta_z_U,
487  const Vector& delta_v_L,
488  const Vector& delta_v_U
489  );
493  Number uncached_dual_frac_to_the_bound(
494  Number tau,
495  const Vector& delta_z_L,
496  const Vector& delta_z_U,
497  const Vector& delta_v_L,
498  const Vector& delta_v_U
499  );
503  Number curr_dual_frac_to_the_bound(
504  Number tau
505  );
516  Number uncached_slack_frac_to_the_bound(
517  Number tau,
518  const Vector& delta_x_L,
519  const Vector& delta_x_U,
520  const Vector& delta_s_L,
521  const Vector& delta_s_U
522  );
524 
526  SmartPtr<const Vector> curr_sigma_x();
528  SmartPtr<const Vector> curr_sigma_s();
530 
532  Number curr_avrg_compl();
534  Number trial_avrg_compl();
535 
539  Number curr_gradBarrTDelta();
540 
542  Number
543  CalcNormOfType(
544  ENormType NormType,
545  std::vector<SmartPtr<const Vector> > vecs
546  );
547 
549  Number
550  CalcNormOfType(
551  ENormType NormType,
552  const Vector& vec1,
553  const Vector& vec2
554  );
555 
558  {
559  return constr_viol_normtype_;
560  }
561 
563  bool IsSquareProblem() const;
564 
570  {
571  return ip_nlp_;
572  }
573 
575  {
576  DBG_ASSERT(IsValid(add_cq_));
577  return *add_cq_;
578  }
579 
581  static void RegisterOptions(
583  );
584 
585 private:
595 
598 
602  );
603 
605  void operator=(
607  );
609 
611 
619 
625 
645 
647  CachedResults<SmartPtr<Vector> > curr_slack_x_L_cache_;
661 
663  CachedResults<Number> curr_f_cache_;
669 
671  CachedResults<Number> curr_barrier_obj_cache_;
679 
681  CachedResults<SmartPtr<const Vector> > curr_c_cache_;
704 
707 
709  CachedResults<SmartPtr<const Vector> > curr_grad_lag_x_cache_;
742 
744  CachedResults<Number> primal_frac_to_the_bound_cache_;
748 
750  CachedResults<SmartPtr<const Vector> > curr_sigma_x_cache_;
754 
759 
762 
765 
783 
789  SmartPtr<Vector> tmp_x_;
798 
800  Vector& Tmp_x();
801  Vector& Tmp_s();
802  Vector& Tmp_c();
803  Vector& Tmp_d();
804  Vector& Tmp_x_L();
805  Vector& Tmp_x_U();
806  Vector& Tmp_s_L();
807  Vector& Tmp_s_U();
809 
814 
816 
820  SmartPtr<Vector> CalcSlack_L(
821  const Matrix& P,
822  const Vector& x,
823  const Vector& x_bound
824  );
828  SmartPtr<Vector> CalcSlack_U(
829  const Matrix& P,
830  const Vector& x,
831  const Vector& x_bound
832  );
836  Number CalcBarrierTerm(
837  Number mu,
838  const Vector& slack_x_L,
839  const Vector& slack_x_U,
840  const Vector& slack_s_L,
841  const Vector& slack_s_U
842  );
843 
845  SmartPtr<const Vector> CalcCompl(
846  const Vector& slack,
847  const Vector& mult
848  );
849 
851  Number CalcFracToBound(
852  const Vector& slack_L,
853  Vector& tmp_L,
854  const Matrix& P_L,
855  const Vector& slack_U,
856  Vector& tmp_U,
857  const Matrix& P_U,
858  const Vector& delta,
859  Number tau
860  );
861 
863  void ComputeOptimalityErrorScaling(
864  const Vector& y_c,
865  const Vector& y_d,
866  const Vector& z_L,
867  const Vector& z_U,
868  const Vector& v_L,
869  const Vector& v_U,
870  Number s_max,
871  Number& s_d,
872  Number& s_c
873  );
874 
881  Index CalculateSafeSlack(
882  SmartPtr<Vector>& slack,
883  const SmartPtr<const Vector>& bound,
884  const SmartPtr<const Vector>& curr_point,
885  const SmartPtr<const Vector>& multiplier
886  );
887 
895  void ComputeDampingIndicators(
896  SmartPtr<const Vector>& dampind_x_L,
897  SmartPtr<const Vector>& dampind_x_U,
898  SmartPtr<const Vector>& dampind_s_L,
899  SmartPtr<const Vector>& dampind_s_U
900  );
901 
912  bool in_restoration_phase();
913 
915 };
916 
917 } // namespace Ipopt
918 
919 #endif
CachedResults< SmartPtr< const Vector > > curr_compl_s_L_cache_
SmartPtr< Vector > dampind_s_U_
Indicator vector for selecting the elements in s that have only upper bounds.
SmartPtr< Vector > dampind_s_L_
Indicator vector for selecting the elements in s that have only lower bounds.
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:674
CachedResults< Number > trial_avrg_compl_cache_
Cache for average of trial complementarity.
CachedResults< Number > curr_constraint_violation_cache_
SmartPtr< Vector > dampind_x_U_
Indicator vector for selecting the elements in x that have only upper bounds.
CachedResults< SmartPtr< const Matrix > > trial_jac_c_cache_
CachedResults< SmartPtr< const Vector > > trial_compl_s_U_cache_
Class for all IPOPT specific calculated quantities.
CachedResults< Number > trial_constraint_violation_cache_
virtual ~IpoptAdditionalCq()
Destructor.
CachedResults< SmartPtr< const Matrix > > trial_jac_d_cache_
CachedResults< SmartPtr< Vector > > trial_slack_x_U_cache_
CachedResults< Number > curr_centrality_measure_cache_
CachedResults< SmartPtr< const Vector > > curr_grad_lag_with_damping_x_cache_
CachedResults< SmartPtr< Vector > > curr_slack_s_L_cache_
CachedResults< SmartPtr< const Vector > > curr_sigma_s_cache_
CachedResults< SmartPtr< const Vector > > trial_d_cache_
CachedResults< SmartPtr< const Vector > > curr_grad_lag_with_damping_s_cache_
CachedResults< SmartPtr< const Vector > > curr_jac_c_times_vec_cache_
CachedResults< SmartPtr< const Vector > > trial_compl_x_U_cache_
SmartPtr< IpoptNLP > ip_nlp_
Ipopt NLP object.
CachedResults< SmartPtr< const Vector > > trial_grad_lag_x_cache_
CachedResults< SmartPtr< const Vector > > trial_c_cache_
CachedResults< Number > unscaled_curr_nlp_error_cache_
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
SmartPtr< Vector > dampind_x_L_
Indicator vector for selecting the elements in x that have only lower bounds.
Vector Base Class.
Definition: IpVector.hpp:47
CachedResults< Number > trial_primal_infeasibility_cache_
CachedResults< SmartPtr< const Vector > > trial_d_minus_s_cache_
Number s_max_
Parameter in formula for computing overall primal-dual optimality error.
CachedResults< Number > curr_primal_dual_system_error_cache_
CachedResults< SmartPtr< const Vector > > trial_jac_cT_times_vec_cache_
CachedResults< SmartPtr< const Vector > > curr_jac_dT_times_vec_cache_
Number mu_target_
Desired value of the barrier parameter.
CachedResults< SmartPtr< const Vector > > curr_d_minus_s_cache_
CachedResults< Number > unscaled_trial_nlp_constraint_violation_cache_
CachedResults< SmartPtr< Vector > > trial_slack_x_L_cache_
CachedResults< SmartPtr< const Vector > > curr_relaxed_compl_s_L_cache_
CachedResults< SmartPtr< const Vector > > curr_jac_cT_times_vec_cache_
CachedResults< Number > curr_gradBarrTDelta_cache_
Cache for grad barrier obj.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:171
Storing the reference count of all the smart pointers that currently reference it.
This class stores a list of user set options.
SmartPtr< IpoptAdditionalCq > add_cq_
Chen-Goldfarb specific calculated quantities.
CachedResults< SmartPtr< const Vector > > curr_relaxed_compl_s_U_cache_
CachedResults< SmartPtr< const Vector > > curr_relaxed_compl_x_U_cache_
IpoptAdditionalCq()
Default Constructor.
Number kappa_d_
Weighting factor for the linear damping term added to the barrier objective function.
CachedResults< SmartPtr< const Vector > > curr_d_cache_
SmartPtr< IpoptNLP > & GetIpoptNLP()
Method returning the IpoptNLP object.
Number slack_move_
fractional movement allowed in bounds
CachedResults< Number > unscaled_curr_dual_infeasibility_cache_
Matrix Base Class.
Definition: IpMatrix.hpp:27
Cache Priority Enum.
CachedResults< SmartPtr< const SymMatrix > > curr_exact_hessian_cache_
Cache for the exact Hessian.
CachedResults< SmartPtr< const Matrix > > curr_jac_c_cache_
CachedResults< SmartPtr< Vector > > trial_slack_s_L_cache_
CachedResults< Number > curr_dual_infeasibility_cache_
CachedResults< SmartPtr< const Vector > > curr_grad_f_cache_
CachedResults< SmartPtr< const Vector > > curr_compl_s_U_cache_
CachedResults< SmartPtr< Vector > > curr_slack_x_U_cache_
CachedResults< SmartPtr< const Vector > > curr_grad_barrier_obj_x_cache_
CachedResults< SmartPtr< Vector > > curr_slack_s_U_cache_
CachedResults< Number > trial_primal_dual_system_error_cache_
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
CachedResults< SmartPtr< const Vector > > curr_relaxed_compl_x_L_cache_
CachedResults< SmartPtr< const Matrix > > curr_jac_d_cache_
CachedResults< SmartPtr< const Vector > > curr_jac_d_times_vec_cache_
CachedResults< Number > curr_primal_infeasibility_cache_
#define IPOPTLIB_EXPORT
CachedResults< SmartPtr< const Vector > > curr_grad_barrier_obj_s_cache_
void SetAddCq(SmartPtr< IpoptAdditionalCq > add_cq)
Method for setting pointer for additional calculated quantities.
bool initialize_called_
flag indicating if Initialize method has been called (for debugging)
CachedResults< Number > trial_dual_infeasibility_cache_
Class responsible for all message output.
CachedResults< SmartPtr< const Vector > > grad_kappa_times_damping_s_cache_
CachedResults< Number > curr_avrg_compl_cache_
Cache for average of current complementarity.
CachedResults< Number > curr_nlp_constraint_violation_cache_
CachedResults< SmartPtr< const Vector > > curr_grad_lag_s_cache_
CachedResults< SmartPtr< const Vector > > curr_compl_x_L_cache_
bool warm_start_same_structure_
Flag indicating whether the TNLP with identical structure has already been solved before...
CachedResults< SmartPtr< Vector > > trial_slack_s_U_cache_
CachedResults< SmartPtr< const Vector > > trial_compl_s_L_cache_
ENormType constr_viol_normtype() const
Norm type used for calculating constraint violation.
SmartPtr< IpoptData > ip_data_
Ipopt Data object.
CachedResults< SmartPtr< const Vector > > trial_grad_f_cache_
Base class for additional calculated quantities that is special to a particular type of algorithm...
CachedResults< SmartPtr< const Vector > > curr_compl_x_U_cache_
CachedResults< SmartPtr< const Vector > > trial_grad_lag_s_cache_
ENormType constr_viol_normtype_
Norm type to be used when calculating the constraint violation.
CachedResults< SmartPtr< const Vector > > trial_compl_x_L_cache_
CachedResults< Number > unscaled_curr_nlp_constraint_violation_cache_
bool HaveAddCq()
Method detecting if additional object for calculated quantities has already been set.
CachedResults< SmartPtr< const Vector > > trial_jac_dT_times_vec_cache_
CachedResults< SmartPtr< const Vector > > grad_kappa_times_damping_x_cache_