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 #include "IpCGPenaltyCq.hpp"
00015
00016 namespace Ipopt
00017 {
00018
00020 enum ENormType {
00021 NORM_1=0,
00022 NORM_2,
00023 NORM_MAX
00024 };
00025
00026
00027 class CGPenaltyCq;
00028
00032 class IpoptCalculatedQuantities : public ReferencedObject
00033 {
00034 public:
00035
00039 IpoptCalculatedQuantities(const SmartPtr<IpoptNLP>& ip_nlp,
00040 const SmartPtr<IpoptData>& ip_data);
00042 virtual ~IpoptCalculatedQuantities();
00044
00048 bool Initialize(const Journalist& jnlst,
00049 const OptionsList& options,
00050 const std::string& prefix);
00051
00055 SmartPtr<const Vector> curr_slack_x_L();
00057 SmartPtr<const Vector> curr_slack_x_U();
00059 SmartPtr<const Vector> curr_slack_s_L();
00061 SmartPtr<const Vector> curr_slack_s_U();
00063 SmartPtr<const Vector> trial_slack_x_L();
00065 SmartPtr<const Vector> trial_slack_x_U();
00067 SmartPtr<const Vector> trial_slack_s_L();
00069 SmartPtr<const Vector> trial_slack_s_U();
00071 Index AdjustedTrialSlacks();
00073 void ResetAdjustedTrialSlacks();
00075
00079 Number curr_f();
00081 Number unscaled_curr_f();
00083 Number trial_f();
00085 Number unscaled_trial_f();
00087 SmartPtr<const Vector> curr_grad_f();
00089 SmartPtr<const Vector> trial_grad_f();
00091
00097 Number curr_barrier_obj();
00101 Number trial_barrier_obj();
00102
00105 SmartPtr<const Vector> curr_grad_barrier_obj_x();
00108 SmartPtr<const Vector> curr_grad_barrier_obj_s();
00109
00112 SmartPtr<const Vector> grad_kappa_times_damping_x();
00115 SmartPtr<const Vector> grad_kappa_times_damping_s();
00117
00121 SmartPtr<const Vector> curr_c();
00123 SmartPtr<const Vector> unscaled_curr_c();
00125 SmartPtr<const Vector> trial_c();
00127 SmartPtr<const Vector> curr_d();
00129 SmartPtr<const Vector> unscaled_curr_d();
00131 SmartPtr<const Vector> trial_d();
00133 SmartPtr<const Vector> curr_d_minus_s();
00135 SmartPtr<const Vector> trial_d_minus_s();
00137 SmartPtr<const Matrix> curr_jac_c();
00139 SmartPtr<const Matrix> trial_jac_c();
00141 SmartPtr<const Matrix> curr_jac_d();
00143 SmartPtr<const Matrix> trial_jac_d();
00146 SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec);
00149 SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec);
00152 SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec);
00155 SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec);
00158 SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
00161 SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
00164 SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
00167 SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
00170 SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec);
00173 SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec);
00177 Number curr_constraint_violation();
00181 Number trial_constraint_violation();
00185 Number curr_nlp_constraint_violation(ENormType NormType);
00189 Number unscaled_curr_nlp_constraint_violation(ENormType NormType);
00191
00195 SmartPtr<const SymMatrix> curr_exact_hessian();
00197
00201 SmartPtr<const Vector> curr_grad_lag_x();
00203 SmartPtr<const Vector> trial_grad_lag_x();
00205 SmartPtr<const Vector> curr_grad_lag_s();
00207 SmartPtr<const Vector> trial_grad_lag_s();
00210 SmartPtr<const Vector> curr_grad_lag_with_damping_x();
00213 SmartPtr<const Vector> curr_grad_lag_with_damping_s();
00215 SmartPtr<const Vector> curr_compl_x_L();
00217 SmartPtr<const Vector> curr_compl_x_U();
00219 SmartPtr<const Vector> curr_compl_s_L();
00221 SmartPtr<const Vector> curr_compl_s_U();
00223 SmartPtr<const Vector> trial_compl_x_L();
00225 SmartPtr<const Vector> trial_compl_x_U();
00227 SmartPtr<const Vector> trial_compl_s_L();
00229 SmartPtr<const Vector> trial_compl_s_U();
00231 SmartPtr<const Vector> curr_relaxed_compl_x_L();
00233 SmartPtr<const Vector> curr_relaxed_compl_x_U();
00235 SmartPtr<const Vector> curr_relaxed_compl_s_L();
00237 SmartPtr<const Vector> curr_relaxed_compl_s_U();
00238
00240 Number curr_primal_infeasibility(ENormType NormType);
00242 Number trial_primal_infeasibility(ENormType NormType);
00243
00245 Number curr_dual_infeasibility(ENormType NormType);
00247 Number trial_dual_infeasibility(ENormType NormType);
00249 Number unscaled_curr_dual_infeasibility(ENormType NormType);
00250
00253 Number curr_complementarity(Number mu, ENormType NormType);
00256 Number trial_complementarity(Number mu, ENormType NormType);
00259 Number unscaled_curr_complementarity(Number mu, ENormType NormType);
00260
00262 Number CalcCentralityMeasure(const Vector& compl_x_L,
00263 const Vector& compl_x_U,
00264 const Vector& compl_s_L,
00265 const Vector& compl_s_U);
00267 Number curr_centrality_measure();
00268
00273 Number curr_nlp_error();
00278 Number unscaled_curr_nlp_error();
00279
00282 Number curr_barrier_error();
00283
00290 Number curr_primal_dual_system_error(Number mu);
00297 Number trial_primal_dual_system_error(Number mu);
00299
00304 Number primal_frac_to_the_bound(Number tau,
00305 const Vector& delta_x,
00306 const Vector& delta_s);
00309 Number curr_primal_frac_to_the_bound(Number tau);
00312 Number dual_frac_to_the_bound(Number tau,
00313 const Vector& delta_z_L,
00314 const Vector& delta_z_U,
00315 const Vector& delta_v_L,
00316 const Vector& delta_v_U);
00319 Number uncached_dual_frac_to_the_bound(Number tau,
00320 const Vector& delta_z_L,
00321 const Vector& delta_z_U,
00322 const Vector& delta_v_L,
00323 const Vector& delta_v_U);
00326 Number curr_dual_frac_to_the_bound(Number tau);
00334 Number uncached_slack_frac_to_the_bound(Number tau,
00335 const Vector& delta_x_L,
00336 const Vector& delta_x_U,
00337 const Vector& delta_s_L,
00338 const Vector& delta_s_U);
00340
00343 SmartPtr<const Vector> curr_sigma_x();
00344 SmartPtr<const Vector> curr_sigma_s();
00346
00348 Number curr_avrg_compl();
00350 Number trial_avrg_compl();
00351
00354 Number curr_gradBarrTDelta();
00355
00357 Number
00358 CalcNormOfType(ENormType NormType,
00359 std::vector<SmartPtr<const Vector> > vecs);
00360
00362 Number
00363 CalcNormOfType(ENormType NormType,
00364 const Vector& vec1, const Vector& vec2);
00365
00367 ENormType constr_viol_normtype() const
00368 {
00369 return constr_viol_normtype_;
00370 }
00371
00373 bool IsSquareProblem() const;
00374
00377 SmartPtr<IpoptNLP>& GetIpoptNLP()
00378 {
00379 return ip_nlp_;
00380 }
00381
00382 CGPenaltyCq& CGPenCq()
00383 {
00384 return *cgpen_cq_;
00385 }
00386
00390 static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
00392
00393 private:
00403 IpoptCalculatedQuantities();
00404
00406 IpoptCalculatedQuantities(const IpoptCalculatedQuantities&);
00407
00409 void operator=(const IpoptCalculatedQuantities&);
00411
00415 SmartPtr<IpoptNLP> ip_nlp_;
00417 SmartPtr<IpoptData> ip_data_;
00419 CGPenaltyCq* cgpen_cq_;
00421
00428 Number s_max_;
00431 Number kappa_d_;
00433 Number slack_move_;
00435 ENormType constr_viol_normtype_;
00438 bool warm_start_same_structure_;
00440
00443 CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_;
00444 CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_;
00445 CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_;
00446 CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_;
00447 CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_;
00448 CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_;
00449 CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_;
00450 CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_;
00451 Index num_adjusted_slack_x_L_;
00452 Index num_adjusted_slack_x_U_;
00453 Index num_adjusted_slack_s_L_;
00454 Index num_adjusted_slack_s_U_;
00456
00459 CachedResults<Number> curr_f_cache_;
00460 CachedResults<Number> trial_f_cache_;
00461 CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_;
00462 CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_;
00464
00467 CachedResults<Number> curr_barrier_obj_cache_;
00468 CachedResults<Number> trial_barrier_obj_cache_;
00469 CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_;
00470 CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_;
00471 CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_;
00472 CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_;
00474
00477 CachedResults< SmartPtr<const Vector> > curr_c_cache_;
00478 CachedResults< SmartPtr<const Vector> > trial_c_cache_;
00479 CachedResults< SmartPtr<const Vector> > curr_d_cache_;
00480 CachedResults< SmartPtr<const Vector> > trial_d_cache_;
00481 CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_;
00482 CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_;
00483 CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_;
00484 CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_;
00485 CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_;
00486 CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_;
00487 CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_;
00488 CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_;
00489 CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_;
00490 CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_;
00491 CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_;
00492 CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_;
00493 CachedResults<Number> curr_constraint_violation_cache_;
00494 CachedResults<Number> trial_constraint_violation_cache_;
00495 CachedResults<Number> curr_nlp_constraint_violation_cache_;
00496 CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_;
00498
00500 CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_;
00501
00504 CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_;
00505 CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_;
00506 CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_;
00507 CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_;
00508 CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_;
00509 CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_;
00510 CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_;
00511 CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_;
00512 CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_;
00513 CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_;
00514 CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_;
00515 CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_;
00516 CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_;
00517 CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_;
00518 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_;
00519 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_;
00520 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_;
00521 CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_;
00522 CachedResults<Number> curr_primal_infeasibility_cache_;
00523 CachedResults<Number> trial_primal_infeasibility_cache_;
00524 CachedResults<Number> curr_dual_infeasibility_cache_;
00525 CachedResults<Number> trial_dual_infeasibility_cache_;
00526 CachedResults<Number> unscaled_curr_dual_infeasibility_cache_;
00527 CachedResults<Number> curr_complementarity_cache_;
00528 CachedResults<Number> trial_complementarity_cache_;
00529 CachedResults<Number> curr_centrality_measure_cache_;
00530 CachedResults<Number> curr_nlp_error_cache_;
00531 CachedResults<Number> unscaled_curr_nlp_error_cache_;
00532 CachedResults<Number> curr_barrier_error_cache_;
00533 CachedResults<Number> curr_primal_dual_system_error_cache_;
00534 CachedResults<Number> trial_primal_dual_system_error_cache_;
00536
00539 CachedResults<Number> primal_frac_to_the_bound_cache_;
00540 CachedResults<Number> dual_frac_to_the_bound_cache_;
00542
00545 CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_;
00546 CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_;
00548
00550 CachedResults<Number> curr_avrg_compl_cache_;
00552 CachedResults<Number> trial_avrg_compl_cache_;
00553
00555 CachedResults<Number> curr_gradBarrTDelta_cache_;
00556
00562 SmartPtr<Vector> dampind_x_L_;
00565 SmartPtr<Vector> dampind_x_U_;
00568 SmartPtr<Vector> dampind_s_L_;
00571 SmartPtr<Vector> dampind_s_U_;
00573
00578 SmartPtr<Vector> tmp_x_;
00579 SmartPtr<Vector> tmp_s_;
00580 SmartPtr<Vector> tmp_c_;
00581 SmartPtr<Vector> tmp_d_;
00582 SmartPtr<Vector> tmp_x_L_;
00583 SmartPtr<Vector> tmp_x_U_;
00584 SmartPtr<Vector> tmp_s_L_;
00585 SmartPtr<Vector> tmp_s_U_;
00586
00588 Vector& Tmp_x();
00589 Vector& Tmp_s();
00590 Vector& Tmp_c();
00591 Vector& Tmp_d();
00592 Vector& Tmp_x_L();
00593 Vector& Tmp_x_U();
00594 Vector& Tmp_s_L();
00595 Vector& Tmp_s_U();
00597
00600 bool initialize_called_;
00601
00607 SmartPtr<Vector> CalcSlack_L(const Matrix& P,
00608 const Vector& x,
00609 const Vector& x_bound);
00613 SmartPtr<Vector> CalcSlack_U(const Matrix& P,
00614 const Vector& x,
00615 const Vector& x_bound);
00619 Number CalcBarrierTerm(Number mu,
00620 const Vector& slack_x_L,
00621 const Vector& slack_x_U,
00622 const Vector& slack_s_L,
00623 const Vector& slack_s_U);
00624
00626 SmartPtr<const Vector> CalcCompl(const Vector& slack,
00627 const Vector& mult);
00628
00630 Number CalcFracToBound(const Vector& slack_L,
00631 Vector& tmp_L,
00632 const Matrix& P_L,
00633 const Vector& slack_U,
00634 Vector& tmp_U,
00635 const Matrix& P_U,
00636 const Vector& delta,
00637 Number tau);
00638
00640 void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d,
00641 const Vector& z_L, const Vector& z_U,
00642 const Vector& v_L, const Vector& v_U,
00643 Number s_max,
00644 Number& s_d, Number& s_c);
00645
00649 Index CalculateSafeSlack(SmartPtr<Vector>& slack,
00650 const SmartPtr<const Vector>& bound,
00651 const SmartPtr<const Vector>& curr_point,
00652 const SmartPtr<const Vector>& multiplier);
00653
00659 void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L,
00660 SmartPtr<const Vector>& dampind_x_U,
00661 SmartPtr<const Vector>& dampind_s_L,
00662 SmartPtr<const Vector>& dampind_s_U);
00663
00670 bool in_restoration_phase();
00671
00673 };
00674
00675 }
00676
00677 #endif