Ipopt Documentation  
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 #include "IpIpoptData.hpp"
13 #include "IpSymMatrix.hpp"
14 #include "IpRegOptions.hpp"
15 
16 #include <string>
17 
18 namespace Ipopt
19 {
20 class IpoptNLP;
21 class Journalist;
22 class OptionsList;
23 
26 {
27  NORM_1 = 0,
30 };
31 
40 {
41 public:
43 
46  { }
47 
50  { }
52 
58  virtual bool Initialize(
59  const Journalist& jnlst,
60  const OptionsList& options,
61  const std::string& prefix
62  ) = 0;
63 
64 private:
74 
77  const IpoptAdditionalCq&);
78 
80  void operator=(
81  const IpoptAdditionalCq&);
83 };
84 
87 {
88 public:
89 
91 
94  const SmartPtr<IpoptNLP>& ip_nlp,
95  const SmartPtr<IpoptData>& ip_data
96  );
98  virtual ~IpoptCalculatedQuantities();
100 
106  void SetAddCq(
108  )
109  {
110  // cppcheck-suppress assertWithSideEffect
111  DBG_ASSERT(!HaveAddCq());
112  add_cq_ = add_cq;
113  }
114 
118  bool HaveAddCq()
119  {
120  return IsValid(add_cq_);
121  }
122 
128  bool Initialize(
129  const Journalist& jnlst,
130  const OptionsList& options,
131  const std::string& prefix
132  );
133 
135 
137  SmartPtr<const Vector> curr_slack_x_L();
139  SmartPtr<const Vector> curr_slack_x_U();
141  SmartPtr<const Vector> curr_slack_s_L();
143  SmartPtr<const Vector> curr_slack_s_U();
145  SmartPtr<const Vector> trial_slack_x_L();
147  SmartPtr<const Vector> trial_slack_x_U();
149  SmartPtr<const Vector> trial_slack_s_L();
151  SmartPtr<const Vector> trial_slack_s_U();
153  Index AdjustedTrialSlacks();
155  void ResetAdjustedTrialSlacks();
157 
159 
161  virtual Number curr_f();
163  virtual Number unscaled_curr_f();
165  virtual Number trial_f();
167  virtual Number unscaled_trial_f();
169  SmartPtr<const Vector> curr_grad_f();
171  SmartPtr<const Vector> trial_grad_f();
173 
175 
179  virtual Number curr_barrier_obj();
183  virtual Number trial_barrier_obj();
184 
188  SmartPtr<const Vector> curr_grad_barrier_obj_x();
192  SmartPtr<const Vector> curr_grad_barrier_obj_s();
193 
195  SmartPtr<const Vector> grad_kappa_times_damping_x();
197  SmartPtr<const Vector> grad_kappa_times_damping_s();
199 
201 
203  SmartPtr<const Vector> curr_c();
205  SmartPtr<const Vector> unscaled_curr_c();
207  SmartPtr<const Vector> trial_c();
209  SmartPtr<const Vector> unscaled_trial_c();
211  SmartPtr<const Vector> curr_d();
213  SmartPtr<const Vector> unscaled_curr_d();
215  SmartPtr<const Vector> trial_d();
217  SmartPtr<const Vector> curr_d_minus_s();
219  SmartPtr<const Vector> trial_d_minus_s();
221  SmartPtr<const Matrix> curr_jac_c();
223  SmartPtr<const Matrix> trial_jac_c();
225  SmartPtr<const Matrix> curr_jac_d();
227  SmartPtr<const Matrix> trial_jac_d();
231  SmartPtr<const Vector> curr_jac_cT_times_vec(
232  const Vector& vec
233  );
237  SmartPtr<const Vector> trial_jac_cT_times_vec(
238  const Vector& vec
239  );
243  SmartPtr<const Vector> curr_jac_dT_times_vec(
244  const Vector& vec
245  );
249  SmartPtr<const Vector> trial_jac_dT_times_vec(
250  const Vector& vec
251  );
255  SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
259  SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
263  SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
267  SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
271  SmartPtr<const Vector> curr_jac_c_times_vec(
272  const Vector& vec
273  );
277  SmartPtr<const Vector> curr_jac_d_times_vec(
278  const Vector& vec
279  );
288  virtual Number curr_constraint_violation();
297  virtual Number trial_constraint_violation();
303  virtual Number curr_nlp_constraint_violation(
304  ENormType NormType
305  );
311  virtual Number unscaled_curr_nlp_constraint_violation(
312  ENormType NormType
313  );
319  virtual Number unscaled_trial_nlp_constraint_violation(
320  ENormType NormType
321  );
323 
327 
334  SmartPtr<Vector> unscaled_orig_x_L_violation(
335  const Vector& x
336  );
343  SmartPtr<Vector> unscaled_orig_x_U_violation(
344  const Vector& x
345  );
352  SmartPtr<const Vector> unscaled_curr_orig_x_L_violation();
359  SmartPtr<const Vector> unscaled_curr_orig_x_U_violation();
365  virtual Number unscaled_curr_orig_bounds_violation(
366  ENormType NormType
367  );
368 
375  SmartPtr<Vector> orig_x_L_violation(
376  const Vector& x
377  );
384  SmartPtr<Vector> orig_x_U_violation(
385  const Vector& x
386  );
393  SmartPtr<const Vector> curr_orig_x_L_violation();
400  SmartPtr<const Vector> curr_orig_x_U_violation();
406  virtual Number curr_orig_bounds_violation(
407  ENormType NormType
408  );
410 
412 
414  SmartPtr<const SymMatrix> curr_exact_hessian();
416 
418 
420  SmartPtr<const Vector> curr_grad_lag_x();
422  SmartPtr<const Vector> trial_grad_lag_x();
424  SmartPtr<const Vector> curr_grad_lag_s();
426  SmartPtr<const Vector> trial_grad_lag_s();
430  SmartPtr<const Vector> curr_grad_lag_with_damping_x();
434  SmartPtr<const Vector> curr_grad_lag_with_damping_s();
436  SmartPtr<const Vector> curr_compl_x_L();
438  SmartPtr<const Vector> curr_compl_x_U();
440  SmartPtr<const Vector> curr_compl_s_L();
442  SmartPtr<const Vector> curr_compl_s_U();
444  SmartPtr<const Vector> trial_compl_x_L();
446  SmartPtr<const Vector> trial_compl_x_U();
448  SmartPtr<const Vector> trial_compl_s_L();
450  SmartPtr<const Vector> trial_compl_s_U();
452  SmartPtr<const Vector> curr_relaxed_compl_x_L();
454  SmartPtr<const Vector> curr_relaxed_compl_x_U();
456  SmartPtr<const Vector> curr_relaxed_compl_s_L();
458  SmartPtr<const Vector> curr_relaxed_compl_s_U();
459 
461  virtual Number curr_primal_infeasibility(
462  ENormType NormType
463  );
465  virtual Number trial_primal_infeasibility(
466  ENormType NormType
467  );
468 
470  virtual Number curr_dual_infeasibility(
471  ENormType NormType
472  );
474  virtual Number trial_dual_infeasibility(
475  ENormType NormType
476  );
478  virtual Number unscaled_curr_dual_infeasibility(
479  ENormType NormType
480  );
481 
485  virtual Number curr_complementarity(
486  Number mu,
487  ENormType NormType
488  );
492  virtual Number trial_complementarity(
493  Number mu,
494  ENormType NormType
495  );
499  virtual Number unscaled_curr_complementarity(
500  Number mu,
501  ENormType NormType
502  );
503 
505  Number CalcCentralityMeasure(
506  const Vector& compl_x_L,
507  const Vector& compl_x_U,
508  const Vector& compl_s_L,
509  const Vector& compl_s_U
510  );
512  virtual Number curr_centrality_measure();
513 
520  virtual Number curr_nlp_error();
528  virtual Number unscaled_curr_nlp_error();
529 
533  virtual Number curr_barrier_error();
534 
542  virtual Number curr_primal_dual_system_error(
543  Number mu
544  );
552  virtual Number trial_primal_dual_system_error(
553  Number mu
554  );
556 
558 
562  Number primal_frac_to_the_bound(
563  Number tau,
564  const Vector& delta_x,
565  const Vector& delta_s
566  );
570  Number curr_primal_frac_to_the_bound(
571  Number tau
572  );
576  Number dual_frac_to_the_bound(
577  Number tau,
578  const Vector& delta_z_L,
579  const Vector& delta_z_U,
580  const Vector& delta_v_L,
581  const Vector& delta_v_U
582  );
586  Number uncached_dual_frac_to_the_bound(
587  Number tau,
588  const Vector& delta_z_L,
589  const Vector& delta_z_U,
590  const Vector& delta_v_L,
591  const Vector& delta_v_U
592  );
596  Number curr_dual_frac_to_the_bound(
597  Number tau
598  );
609  Number uncached_slack_frac_to_the_bound(
610  Number tau,
611  const Vector& delta_x_L,
612  const Vector& delta_x_U,
613  const Vector& delta_s_L,
614  const Vector& delta_s_U
615  );
617 
619  SmartPtr<const Vector> curr_sigma_x();
621  SmartPtr<const Vector> curr_sigma_s();
623 
625  Number curr_avrg_compl();
627  Number trial_avrg_compl();
628 
632  Number curr_gradBarrTDelta();
633 
635  Number
636  CalcNormOfType(
637  ENormType NormType,
638  std::vector<SmartPtr<const Vector> > vecs
639  );
640 
642  Number
643  CalcNormOfType(
644  ENormType NormType,
645  const Vector& vec1,
646  const Vector& vec2
647  );
648 
651  {
652  return constr_viol_normtype_;
653  }
654 
656  bool IsSquareProblem() const;
657 
663  {
664  return ip_nlp_;
665  }
666 
668  {
669  DBG_ASSERT(IsValid(add_cq_));
670  return *add_cq_;
671  }
672 
674  static void RegisterOptions(
676  );
677 
678 private:
688 
691 
695  );
696 
698  void operator=(
700  );
702 
704 
712 
718 
738 
740  CachedResults<SmartPtr<Vector> > curr_slack_x_L_cache_;
754 
756  CachedResults<Number> curr_f_cache_;
762 
764  CachedResults<Number> curr_barrier_obj_cache_;
772 
774  CachedResults<SmartPtr<const Vector> > curr_c_cache_;
797 
800 
802  CachedResults<SmartPtr<const Vector> > curr_grad_lag_x_cache_;
835 
837  CachedResults<std::pair<SmartPtr<Vector>, SmartPtr<Vector> > > unscaled_curr_orig_x_LU_viol_cache_;
844 
846  CachedResults<Number> primal_frac_to_the_bound_cache_;
850 
852  CachedResults<SmartPtr<const Vector> > curr_sigma_x_cache_;
856 
861 
864 
867 
885 
891  SmartPtr<Vector> tmp_x_;
900 
902  Vector& Tmp_x();
903  Vector& Tmp_s();
904  Vector& Tmp_c();
905  Vector& Tmp_d();
906  Vector& Tmp_x_L();
907  Vector& Tmp_x_U();
908  Vector& Tmp_s_L();
909  Vector& Tmp_s_U();
911 
916 
918 
922  SmartPtr<Vector> CalcSlack_L(
923  const Matrix& P,
924  const Vector& x,
925  const Vector& x_bound
926  );
930  SmartPtr<Vector> CalcSlack_U(
931  const Matrix& P,
932  const Vector& x,
933  const Vector& x_bound
934  );
938  Number CalcBarrierTerm(
939  Number mu,
940  const Vector& slack_x_L,
941  const Vector& slack_x_U,
942  const Vector& slack_s_L,
943  const Vector& slack_s_U
944  );
945 
947  SmartPtr<const Vector> CalcCompl(
948  const Vector& slack,
949  const Vector& mult
950  );
951 
953  Number CalcFracToBound(
954  const Vector& slack_L,
955  Vector& tmp_L,
956  const Matrix& P_L,
957  const Vector& slack_U,
958  Vector& tmp_U,
959  const Matrix& P_U,
960  const Vector& delta,
961  Number tau
962  );
963 
965  void ComputeOptimalityErrorScaling(
966  const Vector& y_c,
967  const Vector& y_d,
968  const Vector& z_L,
969  const Vector& z_U,
970  const Vector& v_L,
971  const Vector& v_U,
972  Number s_max,
973  Number& s_d,
974  Number& s_c
975  );
976 
983  Index CalculateSafeSlack(
984  SmartPtr<Vector>& slack,
985  const SmartPtr<const Vector>& bound,
986  const SmartPtr<const Vector>& curr_point,
987  const SmartPtr<const Vector>& multiplier
988  );
989 
997  void ComputeDampingIndicators(
998  SmartPtr<const Vector>& dampind_x_L,
999  SmartPtr<const Vector>& dampind_x_U,
1000  SmartPtr<const Vector>& dampind_s_L,
1001  SmartPtr<const Vector>& dampind_s_U
1002  );
1003 
1005 };
1006 
1007 } // namespace Ipopt
1008 
1009 #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:672
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_
#define IPOPTLIB_EXPORT
Definition: config.h:94
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_
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_
ENormType constr_viol_normtype() const
Norm type used for calculating constraint violation.
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_
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
This file contains a base class for all exceptions and a set of macros to help with exceptions...
CachedResults< Number > curr_gradBarrTDelta_cache_
Cache for grad barrier obj.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:164
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_
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
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_
CachedResults< SmartPtr< Vector > > curr_orig_x_L_viol_cache_
#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_
CachedResults< SmartPtr< const Vector > > curr_grad_barrier_obj_s_cache_
void SetAddCq(SmartPtr< IpoptAdditionalCq > add_cq)
Method for setting pointer for additional calculated quantities.
CachedResults< SmartPtr< Vector > > curr_orig_x_U_viol_cache_
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_
SmartPtr< IpoptData > ip_data_
Ipopt Data object.
CachedResults< Number > unscaled_curr_orig_bounds_viol_cache_
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_