00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __IPIPOPTCALCULATEDQUANTITIES_HPP__
00010 #define __IPIPOPTCALCULATEDQUANTITIES_HPP__
00011
00012 #include "IpIpoptNLP.hpp"
00013 #include "IpIpoptData.hpp"
00014
00015 namespace Ipopt
00016 {
00017
00019 enum ENormType {
00020 NORM_1=0,
00021 NORM_2,
00022 NORM_MAX
00023 };
00024
00028 class IpoptCalculatedQuantities : public ReferencedObject
00029 {
00030 public:
00031
00035 IpoptCalculatedQuantities(const SmartPtr<IpoptNLP>& ip_nlp,
00036 const SmartPtr<IpoptData>& ip_data);
00038 virtual ~IpoptCalculatedQuantities();
00040
00044 bool Initialize(const Journalist& jnlst,
00045 const OptionsList& options,
00046 const std::string& prefix);
00047
00051 SmartPtr<const Vector> curr_slack_x_L();
00053 SmartPtr<const Vector> curr_slack_x_U();
00055 SmartPtr<const Vector> curr_slack_s_L();
00057 SmartPtr<const Vector> curr_slack_s_U();
00059 SmartPtr<const Vector> trial_slack_x_L();
00061 SmartPtr<const Vector> trial_slack_x_U();
00063 SmartPtr<const Vector> trial_slack_s_L();
00065 SmartPtr<const Vector> trial_slack_s_U();
00067 Index AdjustedTrialSlacks();
00069 void ResetAdjustedTrialSlacks();
00071
00075 Number curr_f();
00077 Number unscaled_curr_f();
00079 Number trial_f();
00081 Number unscaled_trial_f();
00083 SmartPtr<const Vector> curr_grad_f();
00085 SmartPtr<const Vector> trial_grad_f();
00087
00093 Number curr_barrier_obj();
00097 Number trial_barrier_obj();
00098
00101 SmartPtr<const Vector> curr_grad_barrier_obj_x();
00104 SmartPtr<const Vector> curr_grad_barrier_obj_s();
00105
00108 SmartPtr<const Vector> grad_kappa_times_damping_x();
00111 SmartPtr<const Vector> grad_kappa_times_damping_s();
00113
00117 SmartPtr<const Vector> curr_c();
00119 SmartPtr<const Vector> unscaled_curr_c();
00121 SmartPtr<const Vector> trial_c();
00123 SmartPtr<const Vector> curr_d();
00125 SmartPtr<const Vector> unscaled_curr_d();
00127 SmartPtr<const Vector> trial_d();
00129 SmartPtr<const Vector> curr_d_minus_s();
00131 SmartPtr<const Vector> trial_d_minus_s();
00133 SmartPtr<const Matrix> curr_jac_c();
00135 SmartPtr<const Matrix> trial_jac_c();
00137 SmartPtr<const Matrix> curr_jac_d();
00139 SmartPtr<const Matrix> trial_jac_d();
00142 SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec);
00145 SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec);
00148 SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec);
00151 SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec);
00154 SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
00157 SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
00160 SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
00163 SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
00166 SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec);
00169 SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec);
00173 Number curr_constraint_violation();
00177 Number trial_constraint_violation();
00181 Number curr_nlp_constraint_violation(ENormType NormType);
00185 Number unscaled_curr_nlp_constraint_violation(ENormType NormType);
00187
00191 SmartPtr<const SymMatrix> curr_exact_hessian();
00193
00197 SmartPtr<const Vector> curr_grad_lag_x();
00199 SmartPtr<const Vector> trial_grad_lag_x();
00201 SmartPtr<const Vector> curr_grad_lag_s();
00203 SmartPtr<const Vector> trial_grad_lag_s();
00206 SmartPtr<const Vector> curr_grad_lag_with_damping_x();
00209 SmartPtr<const Vector> curr_grad_lag_with_damping_s();
00211 SmartPtr<const Vector> curr_compl_x_L();
00213 SmartPtr<const Vector> curr_compl_x_U();
00215 SmartPtr<const Vector> curr_compl_s_L();
00217 SmartPtr<const Vector> curr_compl_s_U();
00219 SmartPtr<const Vector> trial_compl_x_L();
00221 SmartPtr<const Vector> trial_compl_x_U();
00223 SmartPtr<const Vector> trial_compl_s_L();
00225 SmartPtr<const Vector> trial_compl_s_U();
00227 SmartPtr<const Vector> curr_relaxed_compl_x_L();
00229 SmartPtr<const Vector> curr_relaxed_compl_x_U();
00231 SmartPtr<const Vector> curr_relaxed_compl_s_L();
00233 SmartPtr<const Vector> curr_relaxed_compl_s_U();
00234
00236 Number curr_primal_infeasibility(ENormType NormType);
00238 Number trial_primal_infeasibility(ENormType NormType);
00239
00241 Number curr_dual_infeasibility(ENormType NormType);
00243 Number trial_dual_infeasibility(ENormType NormType);
00245 Number unscaled_curr_dual_infeasibility(ENormType NormType);
00246
00249 Number curr_complementarity(Number mu, ENormType NormType);
00252 Number trial_complementarity(Number mu, ENormType NormType);
00255 Number unscaled_curr_complementarity(Number mu, ENormType NormType);
00256
00258 Number CalcCentralityMeasure(const Vector& compl_x_L,
00259 const Vector& compl_x_U,
00260 const Vector& compl_s_L,
00261 const Vector& compl_s_U);
00263 Number curr_centrality_measure();
00264
00269 Number curr_nlp_error();
00274 Number unscaled_curr_nlp_error();
00275
00278 Number curr_barrier_error();
00279
00286 Number curr_primal_dual_system_error(Number mu);
00293 Number trial_primal_dual_system_error(Number mu);
00295
00300 Number primal_frac_to_the_bound(Number tau,
00301 const Vector& delta_x,
00302 const Vector& delta_s);
00305 Number curr_primal_frac_to_the_bound(Number tau);
00308 Number dual_frac_to_the_bound(Number tau,
00309 const Vector& delta_z_L,
00310 const Vector& delta_z_U,
00311 const Vector& delta_v_L,
00312 const Vector& delta_v_U);
00315 Number uncached_dual_frac_to_the_bound(Number tau,
00316 const Vector& delta_z_L,
00317 const Vector& delta_z_U,
00318 const Vector& delta_v_L,
00319 const Vector& delta_v_U);
00322 Number curr_dual_frac_to_the_bound(Number tau);
00330 Number uncached_slack_frac_to_the_bound(Number tau,
00331 const Vector& delta_x_L,
00332 const Vector& delta_x_U,
00333 const Vector& delta_s_L,
00334 const Vector& delta_s_U);
00336
00339 SmartPtr<const Vector> curr_sigma_x();
00340 SmartPtr<const Vector> curr_sigma_s();
00342
00344 Number curr_avrg_compl();
00346 Number trial_avrg_compl();
00347
00350 Number curr_gradBarrTDelta();
00351
00353 Number
00354 CalcNormOfType(ENormType NormType,
00355 std::vector<SmartPtr<const Vector> > vecs);
00356
00358 Number
00359 CalcNormOfType(ENormType NormType,
00360 const Vector& vec1, const Vector& vec2);
00361
00363 ENormType constr_viol_normtype() const
00364 {
00365 return constr_viol_normtype_;
00366 }
00367
00369 bool IsSquareProblem() const;
00370
00374 static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
00376
00377 private:
00387 IpoptCalculatedQuantities();
00388
00390 IpoptCalculatedQuantities(const IpoptCalculatedQuantities&);
00391
00393 void operator=(const IpoptCalculatedQuantities&);
00395
00399 SmartPtr<IpoptNLP> ip_nlp_;
00401 SmartPtr<IpoptData> ip_data_;
00403
00410 Number s_max_;
00413 Number kappa_d_;
00415 Number slack_move_;
00417 ENormType constr_viol_normtype_;
00420 bool warm_start_same_structure_;
00422
00425 CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_;
00426 CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_;
00427 CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_;
00428 CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_;
00429 CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_;
00430 CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_;
00431 CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_;
00432 CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_;
00433 Index num_adjusted_slack_x_L_;
00434 Index num_adjusted_slack_x_U_;
00435 Index num_adjusted_slack_s_L_;
00436 Index num_adjusted_slack_s_U_;
00438
00441 CachedResults<Number> curr_f_cache_;
00442 CachedResults<Number> trial_f_cache_;
00443 CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_;
00444 CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_;
00446
00449 CachedResults<Number> curr_barrier_obj_cache_;
00450 CachedResults<Number> trial_barrier_obj_cache_;
00451 CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_;
00452 CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_;
00453 CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_;
00454 CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_;
00456
00459 CachedResults< SmartPtr<const Vector> > curr_c_cache_;
00460 CachedResults< SmartPtr<const Vector> > trial_c_cache_;
00461 CachedResults< SmartPtr<const Vector> > curr_d_cache_;
00462 CachedResults< SmartPtr<const Vector> > trial_d_cache_;
00463 CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_;
00464 CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_;
00465 CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_;
00466 CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_;
00467 CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_;
00468 CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_;
00469 CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_;
00470 CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_;
00471 CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_;
00472 CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_;
00473 CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_;
00474 CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_;
00475 CachedResults<Number> curr_constraint_violation_cache_;
00476 CachedResults<Number> trial_constraint_violation_cache_;
00477 CachedResults<Number> curr_nlp_constraint_violation_cache_;
00478 CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_;
00480
00482 CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_;
00483
00486 CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_;
00487 CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_;
00488 CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_;
00489 CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_;
00490 CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_;
00491 CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_;
00492 CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_;
00493 CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_;
00494 CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_;
00495 CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_;
00496 CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_;
00497 CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_;
00498 CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_;
00499 CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_;
00500 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_;
00501 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_;
00502 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_;
00503 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_;
00504 CachedResults<Number> curr_primal_infeasibility_cache_;
00505 CachedResults<Number> trial_primal_infeasibility_cache_;
00506 CachedResults<Number> curr_dual_infeasibility_cache_;
00507 CachedResults<Number> trial_dual_infeasibility_cache_;
00508 CachedResults<Number> unscaled_curr_dual_infeasibility_cache_;
00509 CachedResults<Number> curr_complementarity_cache_;
00510 CachedResults<Number> trial_complementarity_cache_;
00511 CachedResults<Number> curr_centrality_measure_cache_;
00512 CachedResults<Number> curr_nlp_error_cache_;
00513 CachedResults<Number> unscaled_curr_nlp_error_cache_;
00514 CachedResults<Number> curr_barrier_error_cache_;
00515 CachedResults<Number> curr_primal_dual_system_error_cache_;
00516 CachedResults<Number> trial_primal_dual_system_error_cache_;
00518
00521 CachedResults<Number> primal_frac_to_the_bound_cache_;
00522 CachedResults<Number> dual_frac_to_the_bound_cache_;
00524
00527 CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_;
00528 CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_;
00530
00532 CachedResults<Number> curr_avrg_compl_cache_;
00534 CachedResults<Number> trial_avrg_compl_cache_;
00535
00537 CachedResults<Number> curr_gradBarrTDelta_cache_;
00538
00544 SmartPtr<Vector> dampind_x_L_;
00547 SmartPtr<Vector> dampind_x_U_;
00550 SmartPtr<Vector> dampind_s_L_;
00553 SmartPtr<Vector> dampind_s_U_;
00555
00560 SmartPtr<Vector> tmp_x_;
00561 SmartPtr<Vector> tmp_s_;
00562 SmartPtr<Vector> tmp_c_;
00563 SmartPtr<Vector> tmp_d_;
00564 SmartPtr<Vector> tmp_x_L_;
00565 SmartPtr<Vector> tmp_x_U_;
00566 SmartPtr<Vector> tmp_s_L_;
00567 SmartPtr<Vector> tmp_s_U_;
00568
00570 Vector& Tmp_x();
00571 Vector& Tmp_s();
00572 Vector& Tmp_c();
00573 Vector& Tmp_d();
00574 Vector& Tmp_x_L();
00575 Vector& Tmp_x_U();
00576 Vector& Tmp_s_L();
00577 Vector& Tmp_s_U();
00579
00582 bool initialize_called_;
00583
00589 SmartPtr<Vector> CalcSlack_L(const Matrix& P,
00590 const Vector& x,
00591 const Vector& x_bound);
00595 SmartPtr<Vector> CalcSlack_U(const Matrix& P,
00596 const Vector& x,
00597 const Vector& x_bound);
00601 Number CalcBarrierTerm(Number mu,
00602 const Vector& slack_x_L,
00603 const Vector& slack_x_U,
00604 const Vector& slack_s_L,
00605 const Vector& slack_s_U);
00606
00608 SmartPtr<const Vector> CalcCompl(const Vector& slack,
00609 const Vector& mult);
00610
00612 Number CalcFracToBound(const Vector& slack_L,
00613 Vector& tmp_L,
00614 const Matrix& P_L,
00615 const Vector& slack_U,
00616 Vector& tmp_U,
00617 const Matrix& P_U,
00618 const Vector& delta,
00619 Number tau);
00620
00622 void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d,
00623 const Vector& z_L, const Vector& z_U,
00624 const Vector& v_L, const Vector& v_U,
00625 Number s_max,
00626 Number& s_d, Number& s_c);
00627
00631 Index CalculateSafeSlack(SmartPtr<Vector>& slack,
00632 const SmartPtr<const Vector>& bound,
00633 const SmartPtr<const Vector>& curr_point,
00634 const SmartPtr<const Vector>& multiplier);
00635
00641 void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L,
00642 SmartPtr<const Vector>& dampind_x_U,
00643 SmartPtr<const Vector>& dampind_s_L,
00644 SmartPtr<const Vector>& dampind_s_U);
00645
00652 bool in_restoration_phase();
00653
00655 };
00656
00657 }
00658
00659 #endif