- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.7.1/Ipopt/src/Algorithm/IpIpoptCalculatedQuantities.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2008 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpIpoptCalculatedQuantities.hpp 1521 2009-07-15 22:26:15Z 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     Number curr_f();
    00145     Number unscaled_curr_f();
    00147     Number trial_f();
    00149     Number unscaled_trial_f();
    00151     SmartPtr<const Vector> curr_grad_f();
    00153     SmartPtr<const Vector> trial_grad_f();
    00155
    00161     Number curr_barrier_obj();
    00165     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> curr_d();
    00193     SmartPtr<const Vector> unscaled_curr_d();
    00195     SmartPtr<const Vector> trial_d();
    00197     SmartPtr<const Vector> curr_d_minus_s();
    00199     SmartPtr<const Vector> trial_d_minus_s();
    00201     SmartPtr<const Matrix> curr_jac_c();
    00203     SmartPtr<const Matrix> trial_jac_c();
    00205     SmartPtr<const Matrix> curr_jac_d();
    00207     SmartPtr<const Matrix> trial_jac_d();
    00210     SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec);
    00213     SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec);
    00216     SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec);
    00219     SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec);
    00222     SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
    00225     SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
    00228     SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
    00231     SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
    00234     SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec);
    00237     SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec);
    00241     Number curr_constraint_violation();
    00245     Number trial_constraint_violation();
    00249     Number curr_nlp_constraint_violation(ENormType NormType);
    00253     Number unscaled_curr_nlp_constraint_violation(ENormType NormType);
    00255
    00259     SmartPtr<const SymMatrix> curr_exact_hessian();
    00261
    00265     SmartPtr<const Vector> curr_grad_lag_x();
    00267     SmartPtr<const Vector> trial_grad_lag_x();
    00269     SmartPtr<const Vector> curr_grad_lag_s();
    00271     SmartPtr<const Vector> trial_grad_lag_s();
    00274     SmartPtr<const Vector> curr_grad_lag_with_damping_x();
    00277     SmartPtr<const Vector> curr_grad_lag_with_damping_s();
    00279     SmartPtr<const Vector> curr_compl_x_L();
    00281     SmartPtr<const Vector> curr_compl_x_U();
    00283     SmartPtr<const Vector> curr_compl_s_L();
    00285     SmartPtr<const Vector> curr_compl_s_U();
    00287     SmartPtr<const Vector> trial_compl_x_L();
    00289     SmartPtr<const Vector> trial_compl_x_U();
    00291     SmartPtr<const Vector> trial_compl_s_L();
    00293     SmartPtr<const Vector> trial_compl_s_U();
    00295     SmartPtr<const Vector> curr_relaxed_compl_x_L();
    00297     SmartPtr<const Vector> curr_relaxed_compl_x_U();
    00299     SmartPtr<const Vector> curr_relaxed_compl_s_L();
    00301     SmartPtr<const Vector> curr_relaxed_compl_s_U();
    00302
    00304     Number curr_primal_infeasibility(ENormType NormType);
    00306     Number trial_primal_infeasibility(ENormType NormType);
    00307
    00309     Number curr_dual_infeasibility(ENormType NormType);
    00311     Number trial_dual_infeasibility(ENormType NormType);
    00313     Number unscaled_curr_dual_infeasibility(ENormType NormType);
    00314
    00317     Number curr_complementarity(Number mu, ENormType NormType);
    00320     Number trial_complementarity(Number mu, ENormType NormType);
    00323     Number unscaled_curr_complementarity(Number mu, ENormType NormType);
    00324
    00326     Number CalcCentralityMeasure(const Vector& compl_x_L,
    00327                                  const Vector& compl_x_U,
    00328                                  const Vector& compl_s_L,
    00329                                  const Vector& compl_s_U);
    00331     Number curr_centrality_measure();
    00332
    00337     Number curr_nlp_error();
    00342     Number unscaled_curr_nlp_error();
    00343
    00346     Number curr_barrier_error();
    00347
    00354     Number curr_primal_dual_system_error(Number mu);
    00361     Number trial_primal_dual_system_error(Number mu);
    00363
    00368     Number primal_frac_to_the_bound(Number tau,
    00369                                     const Vector& delta_x,
    00370                                     const Vector& delta_s);
    00373     Number curr_primal_frac_to_the_bound(Number tau);
    00376     Number dual_frac_to_the_bound(Number tau,
    00377                                   const Vector& delta_z_L,
    00378                                   const Vector& delta_z_U,
    00379                                   const Vector& delta_v_L,
    00380                                   const Vector& delta_v_U);
    00383     Number uncached_dual_frac_to_the_bound(Number tau,
    00384                                            const Vector& delta_z_L,
    00385                                            const Vector& delta_z_U,
    00386                                            const Vector& delta_v_L,
    00387                                            const Vector& delta_v_U);
    00390     Number curr_dual_frac_to_the_bound(Number tau);
    00398     Number uncached_slack_frac_to_the_bound(Number tau,
    00399                                             const Vector& delta_x_L,
    00400                                             const Vector& delta_x_U,
    00401                                             const Vector& delta_s_L,
    00402                                             const Vector& delta_s_U);
    00404
    00407     SmartPtr<const Vector> curr_sigma_x();
    00408     SmartPtr<const Vector> curr_sigma_s();
    00410
    00412     Number curr_avrg_compl();
    00414     Number trial_avrg_compl();
    00415
    00418     Number curr_gradBarrTDelta();
    00419
    00421     Number
    00422     CalcNormOfType(ENormType NormType,
    00423                    std::vector<SmartPtr<const Vector> > vecs);
    00424
    00426     Number
    00427     CalcNormOfType(ENormType NormType,
    00428                    const Vector& vec1, const Vector& vec2);
    00429
    00431     ENormType constr_viol_normtype() const
    00432     {
    00433       return constr_viol_normtype_;
    00434     }
    00435
    00437     bool IsSquareProblem() const;
    00438
    00441     SmartPtr<IpoptNLP>& GetIpoptNLP()
    00442     {
    00443       return ip_nlp_;
    00444     }
    00445
    00446     IpoptAdditionalCq& AdditionalCq()
    00447     {
    00448       DBG_ASSERT(IsValid(add_cq_));
    00449       return *add_cq_;
    00450     }
    00451
    00455     static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
    00457
    00458   private:
    00468     IpoptCalculatedQuantities();
    00469
    00471     IpoptCalculatedQuantities(const IpoptCalculatedQuantities&);
    00472
    00474     void operator=(const IpoptCalculatedQuantities&);
    00476
    00480     SmartPtr<IpoptNLP> ip_nlp_;
    00482     SmartPtr<IpoptData> ip_data_;
    00484     SmartPtr<IpoptAdditionalCq> add_cq_;
    00486
    00493     Number s_max_;
    00496     Number kappa_d_;
    00498     Number slack_move_;
    00500     ENormType constr_viol_normtype_;
    00503     bool warm_start_same_structure_;
    00505
    00508     CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_;
    00509     CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_;
    00510     CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_;
    00511     CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_;
    00512     CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_;
    00513     CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_;
    00514     CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_;
    00515     CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_;
    00516     Index num_adjusted_slack_x_L_;
    00517     Index num_adjusted_slack_x_U_;
    00518     Index num_adjusted_slack_s_L_;
    00519     Index num_adjusted_slack_s_U_;
    00521
    00524     CachedResults<Number> curr_f_cache_;
    00525     CachedResults<Number> trial_f_cache_;
    00526     CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_;
    00527     CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_;
    00529
    00532     CachedResults<Number> curr_barrier_obj_cache_;
    00533     CachedResults<Number> trial_barrier_obj_cache_;
    00534     CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_;
    00535     CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_;
    00536     CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_;
    00537     CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_;
    00539
    00542     CachedResults< SmartPtr<const Vector> > curr_c_cache_;
    00543     CachedResults< SmartPtr<const Vector> > trial_c_cache_;
    00544     CachedResults< SmartPtr<const Vector> > curr_d_cache_;
    00545     CachedResults< SmartPtr<const Vector> > trial_d_cache_;
    00546     CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_;
    00547     CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_;
    00548     CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_;
    00549     CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_;
    00550     CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_;
    00551     CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_;
    00552     CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_;
    00553     CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_;
    00554     CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_;
    00555     CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_;
    00556     CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_;
    00557     CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_;
    00558     CachedResults<Number> curr_constraint_violation_cache_;
    00559     CachedResults<Number> trial_constraint_violation_cache_;
    00560     CachedResults<Number> curr_nlp_constraint_violation_cache_;
    00561     CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_;
    00563
    00565     CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_;
    00566
    00569     CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_;
    00570     CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_;
    00571     CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_;
    00572     CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_;
    00573     CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_;
    00574     CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_;
    00575     CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_;
    00576     CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_;
    00577     CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_;
    00578     CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_;
    00579     CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_;
    00580     CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_;
    00581     CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_;
    00582     CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_;
    00583     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_;
    00584     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_;
    00585     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_;
    00586     CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_;
    00587     CachedResults<Number> curr_primal_infeasibility_cache_;
    00588     CachedResults<Number> trial_primal_infeasibility_cache_;
    00589     CachedResults<Number> curr_dual_infeasibility_cache_;
    00590     CachedResults<Number> trial_dual_infeasibility_cache_;
    00591     CachedResults<Number> unscaled_curr_dual_infeasibility_cache_;
    00592     CachedResults<Number> curr_complementarity_cache_;
    00593     CachedResults<Number> trial_complementarity_cache_;
    00594     CachedResults<Number> curr_centrality_measure_cache_;
    00595     CachedResults<Number> curr_nlp_error_cache_;
    00596     CachedResults<Number> unscaled_curr_nlp_error_cache_;
    00597     CachedResults<Number> curr_barrier_error_cache_;
    00598     CachedResults<Number> curr_primal_dual_system_error_cache_;
    00599     CachedResults<Number> trial_primal_dual_system_error_cache_;
    00601
    00604     CachedResults<Number> primal_frac_to_the_bound_cache_;
    00605     CachedResults<Number> dual_frac_to_the_bound_cache_;
    00607
    00610     CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_;
    00611     CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_;
    00613
    00615     CachedResults<Number> curr_avrg_compl_cache_;
    00617     CachedResults<Number> trial_avrg_compl_cache_;
    00618
    00620     CachedResults<Number> curr_gradBarrTDelta_cache_;
    00621
    00627     SmartPtr<Vector> dampind_x_L_;
    00630     SmartPtr<Vector> dampind_x_U_;
    00633     SmartPtr<Vector> dampind_s_L_;
    00636     SmartPtr<Vector> dampind_s_U_;
    00638
    00643     SmartPtr<Vector> tmp_x_;
    00644     SmartPtr<Vector> tmp_s_;
    00645     SmartPtr<Vector> tmp_c_;
    00646     SmartPtr<Vector> tmp_d_;
    00647     SmartPtr<Vector> tmp_x_L_;
    00648     SmartPtr<Vector> tmp_x_U_;
    00649     SmartPtr<Vector> tmp_s_L_;
    00650     SmartPtr<Vector> tmp_s_U_;
    00651
    00653     Vector& Tmp_x();
    00654     Vector& Tmp_s();
    00655     Vector& Tmp_c();
    00656     Vector& Tmp_d();
    00657     Vector& Tmp_x_L();
    00658     Vector& Tmp_x_U();
    00659     Vector& Tmp_s_L();
    00660     Vector& Tmp_s_U();
    00662
    00665     bool initialize_called_;
    00666
    00672     SmartPtr<Vector> CalcSlack_L(const Matrix& P,
    00673                                  const Vector& x,
    00674                                  const Vector& x_bound);
    00678     SmartPtr<Vector> CalcSlack_U(const Matrix& P,
    00679                                  const Vector& x,
    00680                                  const Vector& x_bound);
    00684     Number CalcBarrierTerm(Number mu,
    00685                            const Vector& slack_x_L,
    00686                            const Vector& slack_x_U,
    00687                            const Vector& slack_s_L,
    00688                            const Vector& slack_s_U);
    00689
    00691     SmartPtr<const Vector> CalcCompl(const Vector& slack,
    00692                                      const Vector& mult);
    00693
    00695     Number CalcFracToBound(const Vector& slack_L,
    00696                            Vector& tmp_L,
    00697                            const Matrix& P_L,
    00698                            const Vector& slack_U,
    00699                            Vector& tmp_U,
    00700                            const Matrix& P_U,
    00701                            const Vector& delta,
    00702                            Number tau);
    00703
    00705     void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d,
    00706                                        const Vector& z_L, const Vector& z_U,
    00707                                        const Vector& v_L, const Vector& v_U,
    00708                                        Number s_max,
    00709                                        Number& s_d, Number& s_c);
    00710
    00714     Index CalculateSafeSlack(SmartPtr<Vector>& slack,
    00715                              const SmartPtr<const Vector>& bound,
    00716                              const SmartPtr<const Vector>& curr_point,
    00717                              const SmartPtr<const Vector>& multiplier);
    00718
    00724     void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L,
    00725                                   SmartPtr<const Vector>& dampind_x_U,
    00726                                   SmartPtr<const Vector>& dampind_s_L,
    00727                                   SmartPtr<const Vector>& dampind_s_U);
    00728
    00735     bool in_restoration_phase();
    00736
    00738   };
    00739
    00740 } // namespace Ipopt
    00741
    00742 #endif