- Main Page
- Classes
- Files

- File List
- File Members

# src/Algorithm/IpIpoptCalculatedQuantities.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2011 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Eclipse Public License.
    00004 //
    00005 // $Id: IpIpoptCalculatedQuantities.hpp 2020 2011-06-16 20:46:16Z andreasw $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    00008
    00009 #ifndef __IPIPOPTCALCULATEDQUANTITIES_HPP__
    00010 #define __IPIPOPTCALCULATEDQUANTITIES_HPP__
    00011
    00012 #include "IpSmartPtr.hpp"
    00013 #include "IpCachedResults.hpp"
    00014
    00015 #include <string>
    00016
    00017 namespace Ipopt
    00018 {
    00019   class IpoptNLP;
    00020   class IpoptData;
    00021   class Vector;
    00022   class Matrix;
    00023   class SymMatrix;
    00024   class Journalist;
    00025   class OptionsList;
    00026   class RegisteredOptions;
    00027
    00029   enum ENormType {
    00030     NORM_1=0,
    00031     NORM_2,
    00032     NORM_MAX
    00033   };
    00034
    00040   class IpoptAdditionalCq : public ReferencedObject
    00041   {
    00042   public:
    00046     IpoptAdditionalCq()
    00047     {}
    00048
    00050     virtual ~IpoptAdditionalCq()
    00051     {}
    00053
    00057     virtual bool Initialize(const Journalist& jnlst,
    00058                             const OptionsList& options,
    00059                             const std::string& prefix) = 0;
    00060
    00061   private:
    00071     IpoptAdditionalCq(const IpoptAdditionalCq&);
    00072
    00074     void operator=(const IpoptAdditionalCq&);
    00076   };
    00077
    00081   class IpoptCalculatedQuantities : public ReferencedObject
    00082   {
    00083   public:
    00084
    00088     IpoptCalculatedQuantities(const SmartPtr<IpoptNLP>& ip_nlp,
    00089                               const SmartPtr<IpoptData>& ip_data);
    00091     virtual ~IpoptCalculatedQuantities();
    00093
    00096     void SetAddCq(SmartPtr<IpoptAdditionalCq> add_cq)
    00097     {
    00098       DBG_ASSERT(!HaveAddCq());
    00099       add_cq_ = add_cq;
    00100     }
    00101
    00104     bool HaveAddCq()
    00105     {
    00106       return IsValid(add_cq_);
    00107     }
    00108
    00112     bool Initialize(const Journalist& jnlst,
    00113                     const OptionsList& options,
    00114                     const std::string& prefix);
    00115
    00119     SmartPtr<const Vector> curr_slack_x_L();
    00121     SmartPtr<const Vector> curr_slack_x_U();
    00123     SmartPtr<const Vector> curr_slack_s_L();
    00125     SmartPtr<const Vector> curr_slack_s_U();
    00127     SmartPtr<const Vector> trial_slack_x_L();
    00129     SmartPtr<const Vector> trial_slack_x_U();
    00131     SmartPtr<const Vector> trial_slack_s_L();
    00133     SmartPtr<const Vector> trial_slack_s_U();
    00135     Index AdjustedTrialSlacks();
    00137     void ResetAdjustedTrialSlacks();
    00139
    00143     virtual Number curr_f();
    00145     virtual Number unscaled_curr_f();
    00147     virtual Number trial_f();
    00149     virtual Number unscaled_trial_f();
    00151     SmartPtr<const Vector> curr_grad_f();
    00153     SmartPtr<const Vector> trial_grad_f();
    00155
    00161     virtual Number curr_barrier_obj();
    00165     virtual Number trial_barrier_obj();
    00166
    00169     SmartPtr<const Vector> curr_grad_barrier_obj_x();
    00172     SmartPtr<const Vector> curr_grad_barrier_obj_s();
    00173
    00176     SmartPtr<const Vector> grad_kappa_times_damping_x();
    00179     SmartPtr<const Vector> grad_kappa_times_damping_s();
    00181
    00185     SmartPtr<const Vector> curr_c();
    00187     SmartPtr<const Vector> unscaled_curr_c();
    00189     SmartPtr<const Vector> trial_c();
    00191     SmartPtr<const Vector> unscaled_trial_c();
    00193     SmartPtr<const Vector> curr_d();
    00195     SmartPtr<const Vector> unscaled_curr_d();
    00197     SmartPtr<const Vector> trial_d();
    00199     SmartPtr<const Vector> curr_d_minus_s();
    00201     SmartPtr<const Vector> trial_d_minus_s();
    00203     SmartPtr<const Matrix> curr_jac_c();
    00205     SmartPtr<const Matrix> trial_jac_c();
    00207     SmartPtr<const Matrix> curr_jac_d();
    00209     SmartPtr<const Matrix> trial_jac_d();
    00212     SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec);
    00215     SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec);
    00218     SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec);
    00221     SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec);
    00224     SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
    00227     SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
    00230     SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
    00233     SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
    00236     SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec);
    00239     SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec);
    00243     virtual Number curr_constraint_violation();
    00247     virtual Number trial_constraint_violation();
    00251     virtual Number curr_nlp_constraint_violation(ENormType NormType);
    00255     virtual Number unscaled_curr_nlp_constraint_violation(ENormType NormType);
    00259     virtual Number unscaled_trial_nlp_constraint_violation(ENormType NormType);
    00261
    00265     SmartPtr<const SymMatrix> curr_exact_hessian();
    00267
    00271     SmartPtr<const Vector> curr_grad_lag_x();
    00273     SmartPtr<const Vector> trial_grad_lag_x();
    00275     SmartPtr<const Vector> curr_grad_lag_s();
    00277     SmartPtr<const Vector> trial_grad_lag_s();
    00280     SmartPtr<const Vector> curr_grad_lag_with_damping_x();
    00283     SmartPtr<const Vector> curr_grad_lag_with_damping_s();
    00285     SmartPtr<const Vector> curr_compl_x_L();
    00287     SmartPtr<const Vector> curr_compl_x_U();
    00289     SmartPtr<const Vector> curr_compl_s_L();
    00291     SmartPtr<const Vector> curr_compl_s_U();
    00293     SmartPtr<const Vector> trial_compl_x_L();
    00295     SmartPtr<const Vector> trial_compl_x_U();
    00297     SmartPtr<const Vector> trial_compl_s_L();
    00299     SmartPtr<const Vector> trial_compl_s_U();
    00301     SmartPtr<const Vector> curr_relaxed_compl_x_L();
    00303     SmartPtr<const Vector> curr_relaxed_compl_x_U();
    00305     SmartPtr<const Vector> curr_relaxed_compl_s_L();
    00307     SmartPtr<const Vector> curr_relaxed_compl_s_U();
    00308
    00310     virtual Number curr_primal_infeasibility(ENormType NormType);
    00312     virtual Number trial_primal_infeasibility(ENormType NormType);
    00313
    00315     virtual Number curr_dual_infeasibility(ENormType NormType);
    00317     virtual Number trial_dual_infeasibility(ENormType NormType);
    00319     virtual Number unscaled_curr_dual_infeasibility(ENormType NormType);
    00320
    00323     virtual Number curr_complementarity(Number mu, ENormType NormType);
    00326     virtual Number trial_complementarity(Number mu, ENormType NormType);
    00329     virtual Number unscaled_curr_complementarity(Number mu, ENormType NormType);
    00330
    00332     Number CalcCentralityMeasure(const Vector& compl_x_L,
    00333                                  const Vector& compl_x_U,
    00334                                  const Vector& compl_s_L,
    00335                                  const Vector& compl_s_U);
    00337     virtual Number curr_centrality_measure();
    00338
    00343     virtual Number curr_nlp_error();
    00348     virtual Number unscaled_curr_nlp_error();
    00349
    00352     virtual Number curr_barrier_error();
    00353
    00360     virtual Number curr_primal_dual_system_error(Number mu);
    00367     virtual Number trial_primal_dual_system_error(Number mu);
    00369
    00374     Number primal_frac_to_the_bound(Number tau,
    00375                                     const Vector& delta_x,
    00376                                     const Vector& delta_s);
    00379     Number curr_primal_frac_to_the_bound(Number tau);
    00382     Number dual_frac_to_the_bound(Number tau,
    00383                                   const Vector& delta_z_L,
    00384                                   const Vector& delta_z_U,
    00385                                   const Vector& delta_v_L,
    00386                                   const Vector& delta_v_U);
    00389     Number uncached_dual_frac_to_the_bound(Number tau,
    00390                                            const Vector& delta_z_L,
    00391                                            const Vector& delta_z_U,
    00392                                            const Vector& delta_v_L,
    00393                                            const Vector& delta_v_U);
    00396     Number curr_dual_frac_to_the_bound(Number tau);
    00404     Number uncached_slack_frac_to_the_bound(Number tau,
    00405                                             const Vector& delta_x_L,
    00406                                             const Vector& delta_x_U,
    00407                                             const Vector& delta_s_L,
    00408                                             const Vector& delta_s_U);
    00410
    00413     SmartPtr<const Vector> curr_sigma_x();
    00414     SmartPtr<const Vector> curr_sigma_s();
    00416
    00418     Number curr_avrg_compl();
    00420     Number trial_avrg_compl();
    00421
    00424     Number curr_gradBarrTDelta();
    00425
    00427     Number
    00428     CalcNormOfType(ENormType NormType,
    00429                    std::vector<SmartPtr<const Vector> > vecs);
    00430
    00432     Number
    00433     CalcNormOfType(ENormType NormType,
    00434                    const Vector& vec1, const Vector& vec2);
    00435
    00437     ENormType constr_viol_normtype() const
    00438     {
    00439       return constr_viol_normtype_;
    00440     }
    00441
    00443     bool IsSquareProblem() const;
    00444
    00447     SmartPtr<IpoptNLP>& GetIpoptNLP()
    00448     {
    00449       return ip_nlp_;
    00450     }
    00451
    00452     IpoptAdditionalCq& AdditionalCq()
    00453     {
    00454       DBG_ASSERT(IsValid(add_cq_));
    00455       return *add_cq_;
    00456     }
    00457
    00461     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
    00463
    00464   private:
    00474     IpoptCalculatedQuantities();
    00475
    00477     IpoptCalculatedQuantities(const IpoptCalculatedQuantities&);
    00478
    00480     void operator=(const IpoptCalculatedQuantities&);
    00482
    00486     SmartPtr<IpoptNLP> ip_nlp_;
    00488     SmartPtr<IpoptData> ip_data_;
    00490     SmartPtr<IpoptAdditionalCq> add_cq_;
    00492
    00499     Number s_max_;
    00502     Number kappa_d_;
    00504     Number slack_move_;
    00506     ENormType constr_viol_normtype_;
    00509     bool warm_start_same_structure_;
    00511     Number mu_target_;
    00513
    00516     CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_;
    00517     CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_;
    00518     CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_;
    00519     CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_;
    00520     CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_;
    00521     CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_;
    00522     CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_;
    00523     CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_;
    00524     Index num_adjusted_slack_x_L_;
    00525     Index num_adjusted_slack_x_U_;
    00526     Index num_adjusted_slack_s_L_;
    00527     Index num_adjusted_slack_s_U_;
    00529
    00532     CachedResults<Number> curr_f_cache_;
    00533     CachedResults<Number> trial_f_cache_;
    00534     CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_;
    00535     CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_;
    00537
    00540     CachedResults<Number> curr_barrier_obj_cache_;
    00541     CachedResults<Number> trial_barrier_obj_cache_;
    00542     CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_;
    00543     CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_;
    00544     CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_;
    00545     CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_;
    00547
    00550     CachedResults< SmartPtr<const Vector> > curr_c_cache_;
    00551     CachedResults< SmartPtr<const Vector> > trial_c_cache_;
    00552     CachedResults< SmartPtr<const Vector> > curr_d_cache_;
    00553     CachedResults< SmartPtr<const Vector> > trial_d_cache_;
    00554     CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_;
    00555     CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_;
    00556     CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_;
    00557     CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_;
    00558     CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_;
    00559     CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_;
    00560     CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_;
    00561     CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_;
    00562     CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_;
    00563     CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_;
    00564     CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_;
    00565     CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_;
    00566     CachedResults<Number> curr_constraint_violation_cache_;
    00567     CachedResults<Number> trial_constraint_violation_cache_;
    00568     CachedResults<Number> curr_nlp_constraint_violation_cache_;
    00569     CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_;
    00570     CachedResults<Number> unscaled_trial_nlp_constraint_violation_cache_;
    00572
    00574     CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_;
    00575
    00578     CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_;
    00579     CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_;
    00580     CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_;
    00581     CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_;
    00582     CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_;
    00583     CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_;
    00584     CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_;
    00585     CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_;
    00586     CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_;
    00587     CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_;
    00588     CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_;
    00589     CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_;
    00590     CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_;
    00591     CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_;
    00592     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_;
    00593     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_;
    00594     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_;
    00595     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_;
    00596     CachedResults<Number> curr_primal_infeasibility_cache_;
    00597     CachedResults<Number> trial_primal_infeasibility_cache_;
    00598     CachedResults<Number> curr_dual_infeasibility_cache_;
    00599     CachedResults<Number> trial_dual_infeasibility_cache_;
    00600     CachedResults<Number> unscaled_curr_dual_infeasibility_cache_;
    00601     CachedResults<Number> curr_complementarity_cache_;
    00602     CachedResults<Number> trial_complementarity_cache_;
    00603     CachedResults<Number> curr_centrality_measure_cache_;
    00604     CachedResults<Number> curr_nlp_error_cache_;
    00605     CachedResults<Number> unscaled_curr_nlp_error_cache_;
    00606     CachedResults<Number> curr_barrier_error_cache_;
    00607     CachedResults<Number> curr_primal_dual_system_error_cache_;
    00608     CachedResults<Number> trial_primal_dual_system_error_cache_;
    00610
    00613     CachedResults<Number> primal_frac_to_the_bound_cache_;
    00614     CachedResults<Number> dual_frac_to_the_bound_cache_;
    00616
    00619     CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_;
    00620     CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_;
    00622
    00624     CachedResults<Number> curr_avrg_compl_cache_;
    00626     CachedResults<Number> trial_avrg_compl_cache_;
    00627
    00629     CachedResults<Number> curr_gradBarrTDelta_cache_;
    00630
    00636     SmartPtr<Vector> dampind_x_L_;
    00639     SmartPtr<Vector> dampind_x_U_;
    00642     SmartPtr<Vector> dampind_s_L_;
    00645     SmartPtr<Vector> dampind_s_U_;
    00647
    00652     SmartPtr<Vector> tmp_x_;
    00653     SmartPtr<Vector> tmp_s_;
    00654     SmartPtr<Vector> tmp_c_;
    00655     SmartPtr<Vector> tmp_d_;
    00656     SmartPtr<Vector> tmp_x_L_;
    00657     SmartPtr<Vector> tmp_x_U_;
    00658     SmartPtr<Vector> tmp_s_L_;
    00659     SmartPtr<Vector> tmp_s_U_;
    00660
    00662     Vector& Tmp_x();
    00663     Vector& Tmp_s();
    00664     Vector& Tmp_c();
    00665     Vector& Tmp_d();
    00666     Vector& Tmp_x_L();
    00667     Vector& Tmp_x_U();
    00668     Vector& Tmp_s_L();
    00669     Vector& Tmp_s_U();
    00671
    00674     bool initialize_called_;
    00675
    00681     SmartPtr<Vector> CalcSlack_L(const Matrix& P,
    00682                                  const Vector& x,
    00683                                  const Vector& x_bound);
    00687     SmartPtr<Vector> CalcSlack_U(const Matrix& P,
    00688                                  const Vector& x,
    00689                                  const Vector& x_bound);
    00693     Number CalcBarrierTerm(Number mu,
    00694                            const Vector& slack_x_L,
    00695                            const Vector& slack_x_U,
    00696                            const Vector& slack_s_L,
    00697                            const Vector& slack_s_U);
    00698
    00700     SmartPtr<const Vector> CalcCompl(const Vector& slack,
    00701                                      const Vector& mult);
    00702
    00704     Number CalcFracToBound(const Vector& slack_L,
    00705                            Vector& tmp_L,
    00706                            const Matrix& P_L,
    00707                            const Vector& slack_U,
    00708                            Vector& tmp_U,
    00709                            const Matrix& P_U,
    00710                            const Vector& delta,
    00711                            Number tau);
    00712
    00714     void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d,
    00715                                        const Vector& z_L, const Vector& z_U,
    00716                                        const Vector& v_L, const Vector& v_U,
    00717                                        Number s_max,
    00718                                        Number& s_d, Number& s_c);
    00719
    00723     Index CalculateSafeSlack(SmartPtr<Vector>& slack,
    00724                              const SmartPtr<const Vector>& bound,
    00725                              const SmartPtr<const Vector>& curr_point,
    00726                              const SmartPtr<const Vector>& multiplier);
    00727
    00733     void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L,
    00734                                   SmartPtr<const Vector>& dampind_x_U,
    00735                                   SmartPtr<const Vector>& dampind_s_L,
    00736                                   SmartPtr<const Vector>& dampind_s_U);
    00737
    00744     bool in_restoration_phase();
    00745
    00747   };
    00748
    00749 } // namespace Ipopt
    00750
    00751 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines