48 #include "MoochoPack_NLPAlgoConfigIP.hpp"
49 #include "NLPInterfacePack_NLPBarrier.hpp"
50 #include "MoochoPack_NLPAlgo.hpp"
51 #include "MoochoPack_IpState.hpp"
52 #include "MoochoPack_NLPAlgoContainer.hpp"
53 #include "AbstractLinAlgPack_MatrixSymPosDefCholFactor.hpp"
55 #include "ConstrainedOptPack_MatrixSymPosDefLBFGS.hpp"
57 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp"
59 #include "NLPInterfacePack_NLPDirect.hpp"
60 #include "NLPInterfacePack_NLPVarReductPerm.hpp"
61 #include "NLPInterfacePack_CalcFiniteDiffProd.hpp"
64 #include "ConstrainedOptPack_DirectLineSearchArmQuad_Strategy.hpp"
65 #include "ConstrainedOptPack_DirectLineSearchArmQuad_StrategySetOptions.hpp"
66 #include "ConstrainedOptPack_MeritFuncNLPL1.hpp"
67 #include "ConstrainedOptPack_MeritFuncNLPModL1.hpp"
70 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
71 #include "ConstrainedOptPack_DecompositionSystemVarReductPerm.hpp"
74 #include "MoochoPack_MoochoAlgorithmStepNames.hpp"
76 #include "MoochoPack_UpdateBarrierParameter_Step.hpp"
78 #include "MoochoPack_PreEvalNewPointBarrier_Step.hpp"
79 #include "MoochoPack_PostEvalNewPointBarrier_Step.hpp"
80 #include "MoochoPack_ReducedGradientStd_Step.hpp"
83 #include "MoochoPack_ReducedHessianSecantUpdateStd_Step.hpp"
84 #include "MoochoPack_ReducedHessianSecantUpdateBFGSFull_Strategy.hpp"
89 #include "MoochoPack_BFGSUpdate_Strategy.hpp"
90 #include "MoochoPack_BFGSUpdate_StrategySetOptions.hpp"
91 #include "MoochoPack_QuasiNormalStepStd_Step.hpp"
92 #include "MoochoPack_CheckDescentQuasiNormalStep_Step.hpp"
93 #include "MoochoPack_CheckDecompositionFromPy_Step.hpp"
94 #include "MoochoPack_CheckDecompositionFromRPy_Step.hpp"
95 #include "MoochoPack_TangentialStepIP_Step.hpp"
100 #include "MoochoPack_QPFailureReinitReducedHessian_Step.hpp"
101 #include "MoochoPack_CalcDFromYPYZPZ_Step.hpp"
102 #include "MoochoPack_CalcD_vStep_Step.hpp"
104 #include "MoochoPack_PreProcessBarrierLineSearch_Step.hpp"
105 #include "MoochoPack_PostProcessBarrierLineSearch_Step.hpp"
106 #include "MoochoPack_LineSearchFailureNewDecompositionSelection_Step.hpp"
107 #include "MoochoPack_LineSearchFilter_Step.hpp"
108 #include "MoochoPack_LineSearchFilter_StepSetOptions.hpp"
109 #include "MoochoPack_LineSearchFullStep_Step.hpp"
110 #include "MoochoPack_LineSearchDirect_Step.hpp"
121 #include "MoochoPack_CalcReducedGradLagrangianStd_AddedStep.hpp"
122 #include "MoochoPack_CheckConvergenceStd_AddedStep.hpp"
123 #include "MoochoPack_CheckConvergenceIP_Strategy.hpp"
124 #include "MoochoPack_CheckSkipBFGSUpdateStd_StepSetOptions.hpp"
125 #include "MoochoPack_MeritFunc_PenaltyParamUpdate_AddedStepSetOptions.hpp"
126 #include "MoochoPack_MeritFunc_PenaltyParamUpdateMultFree_AddedStep.hpp"
133 #include "MoochoPack_UpdateReducedSigma_Step.hpp"
135 #include "MoochoPack_quasi_newton_stats.hpp"
138 #include "Teuchos_AbstractFactoryStd.hpp"
139 #include "Teuchos_dyn_cast.hpp"
140 #include "ReleaseResource_ref_count_ptr.hpp"
141 #include "Teuchos_Assert.hpp"
144 #include "OptionsFromStreamPack_StringToIntMap.hpp"
145 #include "OptionsFromStreamPack_StringToBool.hpp"
153 const double INF_BASIS_COND_CHANGE_FRAC = 1e+20;
156 namespace MoochoPack {
162 NLPAlgoConfigIP::SOptionValues::SOptionValues()
163 :max_basis_cond_change_frac_(-1.0)
164 ,exact_reduced_hessian_(false)
165 ,quasi_newton_(QN_AUTO)
166 ,num_lbfgs_updates_stored_(-1)
167 ,lbfgs_auto_scaling_(true)
168 ,hessian_initialization_(INIT_HESS_AUTO)
169 ,qp_solver_type_(QP_AUTO)
170 ,reinit_hessian_on_qp_fail_(true)
171 ,line_search_method_(LINE_SEARCH_AUTO)
172 ,merit_function_type_(MERIT_FUNC_AUTO)
173 ,l1_penalty_param_update_(L1_PENALTY_PARAM_AUTO)
174 ,full_steps_after_k_(-1)
199 ,std::ostream *trase_out
210 <<
"*****************************************************************\n"
211 <<
"*** NLPAlgoConfigIP configuration ***\n"
213 <<
"*** Here, summary information about how the algorithm is ***\n"
214 <<
"*** configured is printed so that the user can see how the ***\n"
215 <<
"*** properties of the NLP and the set options influence ***\n"
216 <<
"*** how an algorithm is configured. ***\n"
217 <<
"*****************************************************************\n";
227 *trase_out <<
"\n*** Creating the NLPAlgo algo object ...\n";
232 algo_cntr->set_algo(algo);
233 algo->set_algo_cntr(algo_cntr);
242 *trase_out <<
"\n*** Setting the NLP and track objects to the algo object ...\n";
244 algo->set_nlp( algo_cntr->get_nlp().get() );
245 algo->set_track( algo_cntr->get_track() );
252 readin_options( *options_, &uov_, trase_out );
257 <<
"\n*** Warning, no OptionsFromStream object was set so a default set"
258 " of options will be used!\n";
262 NLP &nlp = algo->nlp();
263 nlp.initialize(algo->algo_cntr().check_results());
270 nb = nlp.num_bounded_x();
273 NLPFirstOrder *nlp_foi = NULL;
274 NLPSecondOrder *nlp_soi = NULL;
275 NLPDirect *nlp_fod = NULL;
276 bool tailored_approach =
false;
279 ,&nlp_foi, &nlp_soi, &nlp_fod, &tailored_approach
282 const int max_dof_quasi_newton_dense
287 m == 0, std::logic_error
288 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
289 "can not currently solve an unconstrained NLP!" );
291 n == m, std::logic_error
292 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
293 "can not currently solve a square system of equations!" );
300 <<
"\n*** Sorting out some of the options given input options ...\n";
302 if( tailored_approach ) {
306 <<
"\nThis is a tailored approach NLP (NLPDirect) which forces the following options:\n"
307 <<
"merit_function_type = L1;\n"
308 <<
"l1_penalty_parameter_update = MULT_FREE;\n"
309 <<
"null_space_matrix = EXPLICIT;\n"
312 cov_.merit_function_type_
314 cov_.l1_penalty_param_update_
315 = L1_PENALTY_PARAM_MULT_FREE;
317 = DecompositionSystemStateStepBuilderStd::NULL_SPACE_MATRIX_EXPLICIT;
320 if( !tailored_approach && uov_.merit_function_type_ != MERIT_FUNC_L1 ) {
323 <<
"\nThe only merit function currently supported is:\n"
324 <<
"merit_function_type = L1;\n"
327 cov_.merit_function_type_ = MERIT_FUNC_L1;
331 switch( uov_.quasi_newton_ ) {
335 <<
"\nquasi_newton == AUTO:"
336 <<
"\nnlp.num_bounded_x() == " << nlp.num_bounded_x() <<
":\n";
348 <<
"n-r = " << n-r <<
" <= max_dof_quasi_newton_dense = "
349 << max_dof_quasi_newton_dense <<
":\n"
350 <<
"setting quasi_newton == BFGS\n";
351 cov_.quasi_newton_ = QN_BFGS;
359 cov_.quasi_newton_ = uov_.quasi_newton_;
368 set_default_options(uov_,&cov_,trase_out);
371 if( cov_.line_search_method_ == LINE_SEARCH_2ND_ORDER_CORRECT ) {
374 "\nline_search_method == 2ND_ORDER_CORRECT:\n"
375 "Sorry, the second order corrrection linesearch is not updated yet!\n"
376 "setting line_search_method = DIRECT ...\n";
377 cov_.line_search_method_ = LINE_SEARCH_DIRECT;
379 if( cov_.line_search_method_ == LINE_SEARCH_WATCHDOG ) {
382 "\nline_search_method ==WATCHDOG:\n"
383 "Sorry, the watchdog linesearch is not updated yet!\n"
384 "setting line_search_method = DIRECT ...\n";
385 cov_.line_search_method_ = LINE_SEARCH_DIRECT;
392 decomp_sys_ptr_t decomp_sys;
394 trase_out, nlp, nlp_foi, nlp_soi, nlp_fod, tailored_approach
398 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
400 decomp_sys_perm = Teuchos::rcp_dynamic_cast<DecompositionSystemVarReductPerm>(decomp_sys);
408 <<
"\n*** Creating the state object and setting up iteration quantity objects ...\n";
423 ? ( nlp_fod->var_dep().size()
424 ? nlp.space_x()->sub_space(nlp_fod->var_dep())->clone()
426 : decomp_sys->space_range()
429 ?( nlp_fod->var_indep().size()
430 ? nlp.space_x()->sub_space(nlp_fod->var_indep())->clone()
432 : decomp_sys->space_null()
442 trase_out, nlp, nlp_foi, nlp_soi, nlp_fod, tailored_approach, decomp_sys
449 state->set_iter_quant(
452 new IterQuantityAccessContiguous<MatrixSymDiagStd>(
456 MatrixSymDiagStd::PostMod>( nlp.space_x() )
462 state->set_iter_quant(
465 new IterQuantityAccessContiguous<MatrixSymDiagStd>(
469 MatrixSymDiagStd::PostMod>( nlp.space_x() )
475 state->set_iter_quant(
478 new IterQuantityAccessContiguous<MatrixSymDiagStd>(
482 MatrixSymDiagStd::PostMod>( nlp.space_x() )
488 state->set_iter_quant(
491 new IterQuantityAccessContiguous<MatrixSymDiagStd>(
495 MatrixSymDiagStd::PostMod>( nlp.space_x() )
501 state->set_iter_quant(
504 new IterQuantityAccessContiguous<MatrixSymOp>(
509 MatrixSymPosDefCholFactor::PostMod(
520 state->set_iter_quant(
523 new IterQuantityAccessContiguous<MatrixSymOp>(
528 MatrixSymPosDefCholFactor::PostMod(
539 state->set_iter_quant(
542 new IterQuantityAccessContiguous<MatrixSymDiagStd>(
546 MatrixSymDiagStd::PostMod>( nlp.space_x() )
554 dyn_cast< IterQuantityAccessContiguous<value_type> >(state->barrier_obj()).resize(2);
555 dyn_cast< IterQuantityAccessContiguous<VectorMutable> >(state->grad_barrier_obj()).resize(2);
559 if( !cov_.exact_reduced_hessian_ ) {
563 MatrixSymPosDefCholFactor::PostMod(
570 state->set_iter_quant(
573 new IterQuantityAccessContiguous<MatrixSymOp>(
576 ,abstract_factory_rHL
589 if( cov_.line_search_method_ != LINE_SEARCH_NONE
590 && cov_.line_search_method_ != LINE_SEARCH_FILTER) {
592 merit_func_factory = Teuchos::null;
593 switch( cov_.merit_function_type_ ) {
598 case MERIT_FUNC_MOD_L1:
599 case MERIT_FUNC_MOD_L1_INCR:
606 state->set_iter_quant(
609 new IterQuantityAccessContiguous<MeritFuncNLP>(
618 if (cov_.line_search_method_ == LINE_SEARCH_FILTER)
621 state->set_iter_quant(
624 new IterQuantityAccessContiguous<Filter_T>(1,FILTER_IQ_STRING)
637 typedef IterQuantityAccessContiguous<value_type> IQ_scalar_cngs;
638 typedef IterQuantityAccessContiguous<VectorMutable> IQ_vector_cngs;
640 dyn_cast<IQ_vector_cngs>(state->x()).resize(2);
641 dyn_cast<IQ_scalar_cngs>(state->f()).resize(2);
642 if(m)
dyn_cast<IQ_vector_cngs>(state->c()).resize(2);
643 dyn_cast<IQ_vector_cngs>(state->Gf()).resize(2);
644 if(m && nlp_foi) state->Gc();
647 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
648 && decomp_sys_perm.
get() == NULL
651 if(m)
dyn_cast<IQ_vector_cngs>(state->Ypy()).resize(2);
653 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
654 && decomp_sys_perm.
get() == NULL
657 if(m)
dyn_cast<IQ_vector_cngs>(state->Zpz()).resize(2);
658 dyn_cast<IQ_vector_cngs>(state->d()).resize(2);
661 dyn_cast<IQ_vector_cngs>(state->rGf()).resize(2);
668 dyn_cast<IQ_scalar_cngs>(state->barrier_parameter()).resize(2);
670 dyn_cast<IQ_scalar_cngs>(state->alpha()).resize(2);
671 dyn_cast<IQ_scalar_cngs>(state->mu()).resize(2);
672 dyn_cast<IQ_scalar_cngs>(state->phi()).resize(2);
674 dyn_cast<IQ_scalar_cngs>(state->opt_kkt_err()).resize(2);
675 dyn_cast<IQ_scalar_cngs>(state->feas_kkt_err()).resize(2);
677 dyn_cast<IQ_vector_cngs>(state->rGL()).resize(2);
679 if(m)
dyn_cast<IQ_vector_cngs>(state->lambda()).resize(2);
680 dyn_cast<IQ_vector_cngs>(state->nu()).resize(2);
683 algo->set_state( state );
690 *trase_out <<
"\n*** Creating and setting the step objects ...\n";
702 algo_step_ptr_t eval_new_point_step = Teuchos::null;
707 trase_out, nlp, nlp_foi, nlp_soi, nlp_fod, tailored_approach, decomp_sys
708 ,&eval_new_point_step, &calc_fd_prod, &bounds_tester, &new_decomp_selection_strategy
716 UpdateBarrierParameter_StepSetOptions options_setter(updateBarrierParameter_step.
get());
717 options_setter.set_options(*options_);
725 PreEvalNewPointBarrier_StepSetOptions
726 options_setter(preEvalNewPointBarrier_step.
get());
727 options_setter.set_options(*options_);
734 algo_step_ptr_t reduced_gradient_step = Teuchos::null;
735 if( !tailored_approach ) {
740 algo_step_ptr_t quasi_normal_step_step = Teuchos::null;
741 if( !tailored_approach ) {
746 algo_step_ptr_t check_decomp_from_py_step = Teuchos::null;
747 algo_step_ptr_t check_decomp_from_Rpy_step = Teuchos::null;
748 if( new_decomp_selection_strategy.
get() && cov_.max_basis_cond_change_frac_ < INF_BASIS_COND_CHANGE_FRAC ) {
751 new_decomp_selection_strategy
752 ,cov_.max_basis_cond_change_frac_
756 new_decomp_selection_strategy
757 ,cov_.max_basis_cond_change_frac_
762 algo_step_ptr_t check_descent_quasi_normal_step_step = Teuchos::null;
763 if( algo->algo_cntr().check_results() ) {
774 algo_step_ptr_t check_skip_bfgs_update_step = Teuchos::null;
775 if(!cov_.exact_reduced_hessian_) {
780 opt_setter( step.
get() );
783 check_skip_bfgs_update_step = step;
787 algo_step_ptr_t reduced_hessian_step = Teuchos::null;
791 secant_update_strategy = Teuchos::null;
792 switch( cov_.quasi_newton_ )
805 opt_setter( bfgs_strategy.get() );
808 switch( cov_.quasi_newton_ ) {
819 true, std::logic_error
820 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
821 "The quansi_newton options of PBFGS and LPBFGS have not been updated yet!" );
835 algo->state().set_iter_quant(
836 quasi_newton_stats_name
837 ,
Teuchos::rcp(
new IterQuantityAccessContiguous<QuasiNewtonStats>(
839 ,quasi_newton_stats_name
853 UpdateReducedSigma_StepSetOptions
854 options_setter(updateReducedSigma_step.
get());
855 options_setter.set_options(*options_);
897 algo_step_ptr_t calc_d_from_Ypy_Zpy_step = Teuchos::null;
916 algo_step_ptr_t calc_reduced_grad_lagr_step = Teuchos::null;
923 algo_step_ptr_t check_convergence_step = Teuchos::null;
932 opt_setter( check_convergence_strategy.
get() );
939 check_convergence_step = _check_convergence_step;
943 algo_step_ptr_t merit_func_penalty_param_update_step = Teuchos::null;
944 if( cov_.line_search_method_ == LINE_SEARCH_FILTER ) {
947 else if( cov_.line_search_method_ != LINE_SEARCH_NONE ) {
949 param_update_step = Teuchos::null;
950 switch( cov_.merit_function_type_ ) {
951 case MERIT_FUNC_L1: {
952 switch(cov_.l1_penalty_param_update_) {
953 case L1_PENALTY_PARAM_WITH_MULT:
957 true, std::logic_error
958 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
959 "The l1_penalty_parameter_update option of MULT_FREE has not been updated yet!" );
961 case L1_PENALTY_PARAM_MULT_FREE:
970 case MERIT_FUNC_MOD_L1:
971 case MERIT_FUNC_MOD_L1_INCR:
975 true, std::logic_error
976 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
977 "The merit_function_type options of MODIFIED_L1 and MODIFIED_L1_INCR have not been updated yet!" );
984 ppu_options_setter( param_update_step.
get() );
987 merit_func_penalty_param_update_step = param_update_step;
991 algo_step_ptr_t line_search_full_step_step = Teuchos::null;
997 algo_step_ptr_t line_search_step = Teuchos::null;
998 if( cov_.line_search_method_ != LINE_SEARCH_NONE ) {
1000 direct_line_search =
Teuchos::rcp(
new DirectLineSearchArmQuad_Strategy());
1001 if(options_.
get()) {
1003 ls_options_setter( direct_line_search.
get(),
"DirectLineSearchArmQuadSQPStep" );
1006 switch( cov_.line_search_method_ ) {
1007 case LINE_SEARCH_DIRECT: {
1011 case LINE_SEARCH_2ND_ORDER_CORRECT: {
1013 true, std::logic_error
1014 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
1015 "The line_search_method option of 2ND_ORDER_CORRECT has not been updated yet!" );
1018 case LINE_SEARCH_WATCHDOG: {
1020 true, std::logic_error
1021 ,
"NLPAlgoConfigIP::config_algo_cntr(...) : Error, "
1022 "The line_search_method option of WATCHDOG has not been updated yet!" );
1025 case LINE_SEARCH_FILTER:
1032 LineSearchFilter_StepSetOptions options_setter(line_search_filter_step.
get());
1033 options_setter.set_options(*options_);
1036 line_search_step = line_search_filter_step;
1043 if( new_decomp_selection_strategy.
get() ) {
1047 ,new_decomp_selection_strategy
1063 <<
"\nConfiguring an algorithm for an unconstrained "
1064 <<
"NLP (m == 0, num_bounded_x == 0) ...\n";
1066 m == 0 && nb == 0, std::logic_error
1067 ,
"NLPAlgoConfigIP::config_alg_cntr(...) : Error, "
1068 "Unconstrained NLPs are not supported yet!" );
1076 <<
"\nConfiguring an algorithm for a simple bound constrained "
1077 <<
"NLP (m == 0, num_bounded_x > 0) ...\n";
1079 m == 0 && nb == 0, std::logic_error
1080 ,
"NLPAlgoConfigIP::config_alg_cntr(...) : Error, "
1081 "Bound constrained NLPs are not supported yet!" );
1090 <<
"\nConfiguring an algorithm for a system of nonlinear equations "
1091 <<
"NLP (n == m) ...\n";
1093 n == m, std::logic_error
1094 ,
"NLPAlgoConfigIP::config_alg_cntr(...) : Error, "
1095 "Nonlinear equation (NLE) problems are not supported yet!" );
1098 else if ( m > 0 || nb > 0 ) {
1108 <<
"\nConfiguring an algorithm for a nonlinear equality constrained "
1109 <<
"NLP ( m > 0 && num_bounded_x == 0) ...\n";
1117 <<
"\nConfiguring an algorithm for a nonlinear generally constrained "
1118 <<
"NLP ( num_bounded_x > 0 ) ...\n";
1128 int assoc_step_num = 0;
1134 algo->insert_step( ++step_num, EvalNewPoint_name, eval_new_point_step );
1138 algo->insert_assoc_step( step_num, IterationPack::PRE_STEP, 1,
"PreEvalNewPointBarrier", preEvalNewPointBarrier_step);
1141 if( check_descent_quasi_normal_step_step.get() && tailored_approach && algo->algo_cntr().check_results() )
1143 algo->insert_assoc_step(
1145 ,IterationPack::POST_STEP
1147 ,
"CheckDescentQuasiNormalStep"
1148 ,check_descent_quasi_normal_step_step
1153 algo->insert_assoc_step( step_num, IterationPack::POST_STEP, ++assoc_step_num,
"PostEvalNewPointBarrier", postEvalNewPointBarrier_step);
1157 if( !tailored_approach ) {
1158 algo->insert_step( ++step_num, ReducedGradient_name, reduced_gradient_step );
1162 algo->insert_step( ++step_num, CalcReducedGradLagrangian_name, calc_reduced_grad_lagr_step );
1166 if( !tailored_approach ) {
1171 algo->insert_step( ++step_num, CheckConvergence_name, check_convergence_step );
1176 algo->insert_step( ++step_num,
"UpdateBarrierParameter", updateBarrierParameter_step );
1179 if( !tailored_approach ) {
1180 algo->insert_step( ++step_num, QuasiNormalStep_name, quasi_normal_step_step );
1182 if( check_decomp_from_py_step.get() )
1183 algo->insert_assoc_step(
1185 ,IterationPack::POST_STEP
1187 ,
"CheckDecompositionFromPy"
1188 ,check_decomp_from_py_step
1190 if( check_decomp_from_Rpy_step.get() )
1191 algo->insert_assoc_step(
1193 ,IterationPack::POST_STEP
1195 ,
"CheckDecompositionFromRPy"
1196 ,check_decomp_from_Rpy_step
1198 if( check_descent_quasi_normal_step_step.get() )
1199 algo->insert_assoc_step(
1201 ,IterationPack::POST_STEP
1203 ,
"CheckDescentQuasiNormalStep"
1204 ,check_descent_quasi_normal_step_step
1209 algo->insert_step( ++step_num, ReducedHessian_name, reduced_hessian_step );
1212 algo->insert_step( ++step_num,
"UpdateReducedSigma", updateReducedSigma_step);
1215 algo->insert_step( ++step_num,
"TangentialStepIP", tangential_step);
1217 algo->insert_step( ++step_num, CalcDFromYPYZPZ_name, calc_d_from_Ypy_Zpy_step );
1220 algo->insert_step( ++step_num,
"CalcD_vStep_Step", calc_d_v_step_step );
1223 algo->insert_step( ++step_num,
"PreProcessBarrierLineSearch_Step", preprocess_barrier_linesearch_step );
1226 if( cov_.line_search_method_ == LINE_SEARCH_NONE ) {
1227 algo->insert_step( ++step_num, LineSearch_name, line_search_full_step_step );
1231 algo->insert_step( ++step_num, LineSearch_name, line_search_step );
1244 if(merit_func_penalty_param_update_step.get()) {
1245 algo->insert_assoc_step(
1247 ,IterationPack::PRE_STEP
1249 ,
"MeritFunc_PenaltyParamUpdate"
1250 ,merit_func_penalty_param_update_step
1256 algo->insert_step( ++step_num,
"PostProcessBarrierLineSearch_Step", postprocess_barrier_linesearch_step );
1274 _algo == NULL, std::invalid_argument
1275 ,
"NLPAlgoConfigIP::init_algo(_algo) : Error, "
1276 "_algo can not be NULL" );
1280 NLP &nlp = algo.nlp();
1290 << std::setprecision(algo.algo_cntr().journal_print_digits())
1301 void NLPAlgoConfigIP::readin_options(
1304 , std::ostream *trase_out
1307 namespace ofsp = OptionsFromStreamPack;
1308 using ofsp::OptionsFromStream;
1309 typedef OptionsFromStream::options_group_t options_group_t;
1310 using ofsp::StringToIntMap;
1311 using ofsp::StringToBool;
1316 const std::string opt_grp_name =
"NLPAlgoConfigIP";
1317 const OptionsFromStream::options_group_t optgrp = options.
options_group( opt_grp_name );
1318 if( OptionsFromStream::options_group_exists( optgrp ) ) {
1321 const int num_opts = 11;
1323 MAX_BASIS_COND_CHANGE_FRAC
1324 ,EXACT_REDUCED_HESSIAN
1326 ,NUM_LBFGS_UPDATES_STORED
1328 ,HESSIAN_INITIALIZATION
1330 ,REINIT_HESSIAN_ON_QP_FAIL
1332 ,MERIT_FUNCTION_TYPE
1333 ,L1_PENALTY_PARAM_UPDATE
1335 const char* SIpConfig[num_opts] = {
1336 "max_basis_cond_change_frac"
1337 ,
"exact_reduced_hessian"
1339 ,
"num_lbfgs_updates_stored"
1340 ,
"lbfgs_auto_scaling"
1341 ,
"hessian_initialization"
1343 ,
"reinit_hessian_on_qp_fail"
1344 ,
"line_search_method"
1345 ,
"merit_function_type"
1346 ,
"l1_penalty_parameter_update"
1348 StringToIntMap map( opt_grp_name, num_opts, SIpConfig );
1350 options_group_t::const_iterator itr = optgrp.begin();
1351 for( ; itr != optgrp.end(); ++itr ) {
1352 switch( (EIpConfig)map( ofsp::option_name(itr) ) ) {
1353 case MAX_BASIS_COND_CHANGE_FRAC:
1354 ov->max_basis_cond_change_frac_ = std::atof( ofsp::option_value(itr).c_str() );
1356 case EXACT_REDUCED_HESSIAN:
1357 ov->exact_reduced_hessian_ = StringToBool(
"exact_reduced_hessian", ofsp::option_value(itr).c_str() );
1361 const std::string &opt_val = ofsp::option_value(itr);
1362 if( opt_val ==
"AUTO" )
1363 ov->quasi_newton_ = QN_AUTO;
1364 else if( opt_val ==
"BFGS" )
1365 ov->quasi_newton_ = QN_BFGS;
1366 else if( opt_val ==
"PBFGS" )
1367 ov->quasi_newton_ = QN_PBFGS;
1368 else if( opt_val ==
"LBFGS" )
1369 ov->quasi_newton_ = QN_LBFGS;
1370 else if( opt_val ==
"LPBFGS" )
1371 ov->quasi_newton_ = QN_LPBFGS;
1374 true, std::invalid_argument
1375 ,
"NLPAlgoConfigIP::readin_options(...) : "
1376 "Error, incorrect value for \"quasi_newton\" "
1377 ", Only options of BFGS, PBFGS"
1378 ", LBFGS, LPBFGS and AUTO are avalible."
1382 case NUM_LBFGS_UPDATES_STORED:
1383 ov->num_lbfgs_updates_stored_ = std::atoi( ofsp::option_value(itr).c_str() );
1385 case LBFGS_AUTO_SCALING:
1386 ov->lbfgs_auto_scaling_
1387 = StringToBool(
"lbfgs_auto_scaling", ofsp::option_value(itr).c_str() );
1389 case HESSIAN_INITIALIZATION:
1391 const std::string &opt_val = ofsp::option_value(itr);
1392 if( opt_val ==
"IDENTITY" )
1393 ov->hessian_initialization_ = INIT_HESS_IDENTITY;
1394 else if( opt_val ==
"FINITE_DIFF_SCALE_IDENTITY" )
1395 ov->hessian_initialization_ = INIT_HESS_FIN_DIFF_SCALE_IDENTITY;
1396 else if( opt_val ==
"FINITE_DIFF_DIAGONAL" )
1397 ov->hessian_initialization_ = INIT_HESS_FIN_DIFF_SCALE_DIAGONAL;
1398 else if( opt_val ==
"FINITE_DIFF_DIAGONAL_ABS" )
1399 ov->hessian_initialization_ = INIT_HESS_FIN_DIFF_SCALE_DIAGONAL_ABS;
1400 else if( opt_val ==
"AUTO" )
1401 ov->hessian_initialization_ = INIT_HESS_AUTO;
1404 true, std::invalid_argument
1405 ,
"NLPAlgoConfigIP::readin_options(...) : "
1406 "Error, incorrect value for \"hessian_initialization\" "
1407 ", Only options of IDENTITY, FINITE_DIFF_SCALE_IDENTITY,"
1408 " FINITE_DIFF_DIAGONAL, FINITE_DIFF_DIAGONAL_ABS and AUTO"
1414 const std::string &qp_solver = ofsp::option_value(itr);
1415 if( qp_solver ==
"AUTO" ) {
1416 ov->qp_solver_type_ = QP_AUTO;
1417 }
else if( qp_solver ==
"QPSOL" ) {
1418 ov->qp_solver_type_ = QP_QPSOL;
1419 }
else if( qp_solver ==
"QPOPT" ) {
1420 #ifdef CONSTRAINED_OPTIMIZATION_PACK_USE_QPOPT
1421 ov->qp_solver_type_ = QP_QPOPT;
1424 true, std::invalid_argument
1425 ,
"NLPAlgoConfigIP::readin_options(...) : QPOPT is not supported,"
1426 " must define CONSTRAINED_OPTIMIZATION_PACK_USE_QPOPT!" );
1428 }
else if( qp_solver ==
"QPKWIK" ) {
1429 ov->qp_solver_type_ = QP_QPKWIK;
1430 }
else if( qp_solver ==
"QPSCHUR" ) {
1431 ov->qp_solver_type_ = QP_QPSCHUR;
1434 true, std::invalid_argument
1435 ,
"NLPAlgoConfigIP::readin_options(...) : "
1436 "Error, incorrect value for \"qp_solver\" "
1437 "Only qp solvers QPOPT, QPSOL, QPKWIK, QPSCHUR and AUTO are avalible." );
1441 case REINIT_HESSIAN_ON_QP_FAIL:
1442 ov->reinit_hessian_on_qp_fail_ = StringToBool(
"reinit_hessian_on_qp_fail", ofsp::option_value(itr).c_str() );
1444 case LINE_SEARCH_METHOD:
1446 const std::string &option = ofsp::option_value(itr);
1447 if( option ==
"NONE" ) {
1448 ov->line_search_method_ = LINE_SEARCH_NONE;
1449 }
else if( option ==
"DIRECT" ) {
1450 ov->line_search_method_ = LINE_SEARCH_DIRECT;
1451 }
else if( option ==
"2ND_ORDER_CORRECT" ) {
1452 ov->line_search_method_ = LINE_SEARCH_2ND_ORDER_CORRECT;
1453 }
else if( option ==
"WATCHDOG" ) {
1454 ov->line_search_method_ = LINE_SEARCH_WATCHDOG;
1455 }
else if( option ==
"AUTO" ) {
1456 ov->line_search_method_ = LINE_SEARCH_AUTO;
1457 }
else if( option ==
"FILTER" ) {
1458 ov->line_search_method_ = LINE_SEARCH_FILTER;
1461 true, std::invalid_argument
1462 ,
"NLPAlgoConfigIP::readin_options(...) : "
1463 "Error, incorrect value for \"line_search_method\".\n"
1464 "Only the options NONE, DIRECT, 2ND_ORDER_CORRECT, FILTER, WATCHDOG "
1465 "and AUTO are avalible." );
1469 case MERIT_FUNCTION_TYPE:
1471 const std::string &option = ofsp::option_value(itr);
1472 if( option ==
"L1" )
1473 ov->merit_function_type_ = MERIT_FUNC_L1;
1474 else if( option ==
"MODIFIED_L1" )
1475 ov->merit_function_type_ = MERIT_FUNC_MOD_L1;
1476 else if( option ==
"MODIFIED_L1_INCR" )
1477 ov->merit_function_type_ = MERIT_FUNC_MOD_L1_INCR;
1478 else if( option ==
"AUTO" )
1479 ov->merit_function_type_ = MERIT_FUNC_AUTO;
1482 true, std::invalid_argument
1483 ,
"NLPAlgoConfigIP::readin_options(...) : "
1484 "Error, incorrect value for \"merit_function_type\".\n"
1485 "Only the options L1, MODIFIED_L1, MODIFIED_L1_INCR "
1486 "and AUTO are avalible." );
1489 case L1_PENALTY_PARAM_UPDATE:
1491 const std::string &option = ofsp::option_value(itr);
1492 if( option ==
"WITH_MULT" )
1493 ov->l1_penalty_param_update_
1494 = L1_PENALTY_PARAM_WITH_MULT;
1495 else if( option ==
"MULT_FREE" )
1496 ov->l1_penalty_param_update_
1497 = L1_PENALTY_PARAM_MULT_FREE;
1498 else if( option ==
"AUTO" )
1499 ov->l1_penalty_param_update_
1500 = L1_PENALTY_PARAM_AUTO;
1503 true, std::invalid_argument
1504 ,
"NLPAlgoConfigIP::readin_options(...) : "
1505 "Error, incorrect value for \"l1_penalty_param_update\".\n"
1506 "Only the options WITH_MULT, MULT_FREE and AUTO"
1518 <<
"\n\n*** Warning! The options group \"NLPAlgoConfigIP\" was not found.\n"
1519 <<
"Using a default set of options instead ... \n";
1527 void NLPAlgoConfigIP::set_default_options(
1528 const SOptionValues &uov
1530 ,std::ostream *trase_out
1535 <<
"\n*** Setting option defaults for options not set by the user or determined some other way ...\n";
1537 if( cov->max_basis_cond_change_frac_ < 0.0 && uov.max_basis_cond_change_frac_ < 0.0 ) {
1540 <<
"\nmax_basis_cond_change_frac < 0 : setting max_basis_cond_change_frac = 1e+4 \n";
1541 cov->max_basis_cond_change_frac_ = 1e+4;
1544 cov->max_basis_cond_change_frac_ = uov.max_basis_cond_change_frac_;
1546 cov->exact_reduced_hessian_ = uov.exact_reduced_hessian_;
1547 if( cov->quasi_newton_ == QN_AUTO && uov.quasi_newton_ == QN_AUTO ) {
1550 <<
"\nquasi_newton == AUTO: setting quasi_newton = BFGS\n";
1551 cov->quasi_newton_ = QN_BFGS;
1553 else if(cov->quasi_newton_ == QN_AUTO) {
1554 cov->quasi_newton_ = uov.quasi_newton_;
1556 if( cov->num_lbfgs_updates_stored_ < 0 && uov.num_lbfgs_updates_stored_ < 0 ) {
1559 <<
"\nnum_lbfgs_updates_stored < 0 : setting num_lbfgs_updates_stored = 10\n";
1560 cov->num_lbfgs_updates_stored_ = 10;
1562 else if(cov->num_lbfgs_updates_stored_ < 0) {
1563 cov->num_lbfgs_updates_stored_ = uov.num_lbfgs_updates_stored_;
1565 cov->lbfgs_auto_scaling_ = uov.lbfgs_auto_scaling_;
1566 if( cov->hessian_initialization_ == INIT_HESS_AUTO && uov.hessian_initialization_ == INIT_HESS_AUTO ) {
1569 <<
"\nhessian_initialization == AUTO: setting hessian_initialization = FINITE_DIFF_DIAGONAL_ABS\n";
1570 cov->hessian_initialization_ = INIT_HESS_FIN_DIFF_SCALE_DIAGONAL_ABS;
1572 else if(cov->hessian_initialization_ == INIT_HESS_AUTO) {
1573 cov->hessian_initialization_ = uov.hessian_initialization_;
1575 if( cov->qp_solver_type_ == QP_AUTO && uov.qp_solver_type_ == QP_AUTO ) {
1578 <<
"\nqp_solver_type == AUTO: setting qp_solver_type = QPSCHUR\n";
1579 cov->qp_solver_type_ = QP_QPSCHUR;
1581 else if(cov->qp_solver_type_ == QP_AUTO) {
1582 cov->qp_solver_type_ = uov.qp_solver_type_;
1584 cov->reinit_hessian_on_qp_fail_ = uov.reinit_hessian_on_qp_fail_;
1585 if( cov->line_search_method_ == LINE_SEARCH_AUTO && uov.line_search_method_ == LINE_SEARCH_AUTO ) {
1588 <<
"\nline_search_method == AUTO: setting line_search_method = FILTER\n";
1589 cov->line_search_method_ = LINE_SEARCH_FILTER;
1591 else if(cov->line_search_method_ == LINE_SEARCH_AUTO) {
1592 cov->line_search_method_ = uov.line_search_method_;
1594 if( cov->merit_function_type_ == MERIT_FUNC_AUTO && uov.merit_function_type_ == MERIT_FUNC_AUTO ) {
1597 <<
"\nmerit_function_type == AUTO: setting merit_function_type = MODIFIED_L1_INCR\n";
1598 cov->merit_function_type_ = MERIT_FUNC_MOD_L1_INCR;
1600 else if(cov->merit_function_type_ == MERIT_FUNC_AUTO) {
1601 cov->merit_function_type_ = uov.merit_function_type_;
1603 if( cov->l1_penalty_param_update_ == L1_PENALTY_PARAM_AUTO && uov.l1_penalty_param_update_ == L1_PENALTY_PARAM_AUTO ) {
1606 <<
"\nl1_penalty_param_update == AUTO: setting l1_penalty_param_update = MULT_FREE\n";
1607 cov->l1_penalty_param_update_ = L1_PENALTY_PARAM_MULT_FREE;
1609 else if(cov->l1_penalty_param_update_ == L1_PENALTY_PARAM_AUTO) {
1610 cov->l1_penalty_param_update_ = uov.l1_penalty_param_update_;
1612 if( cov->full_steps_after_k_ < 0 && uov.full_steps_after_k_ < 0 ) {
1615 <<
"\nfull_steps_after_k < 0 : the line search will never be turned off after so many iterations\n";
1618 cov->full_steps_after_k_ = uov.full_steps_after_k_;
1622 <<
"\n*** End setting default options\n";
Checks for descent in the decomposed equality constraints with respect to the range space step Ypy us...
void config_algo_cntr(NLPAlgoContainer *algo_cntr, std::ostream *trase_out)
Set options for CheckSkipBFGSUpdateStd_Step from a OptionsFromStream object.
Fraction to boundary rule for calculating alpha max.
void process_nlp_and_options(std::ostream *trase_out, NLP &nlp, NLPFirstOrder **nlp_foi, NLPSecondOrder **nlp_soi, NLPDirect **nlp_fod, bool *tailored_approach)
Process the NLP and process the options passed in from set_options(). Postconditions: ...
Checks if a BFGS update should be preformed.
virtual void max_iter(size_t max_iter)
void create_eval_new_point(std::ostream *trase_out, NLP &nlp, NLPFirstOrder *nlp_foi, NLPSecondOrder *nlp_soi, NLPDirect *nlp_fod, bool tailored_approach, const Teuchos::RCP< DecompositionSystem > &decomp_sys, Teuchos::RCP< IterationPack::AlgorithmStep > *eval_new_point_step, Teuchos::RCP< CalcFiniteDiffProd > *calc_fd_prod, Teuchos::RCP< VariableBoundsTester > *bounds_tester, Teuchos::RCP< NewDecompositionSelection_Strategy > *new_decomp_selection_strategy)
Create the EvalNewPoint step object and allocated objects.
Set options for MeritFunc_PenaltyParamUpdate_AddedStep from a OptionsFromStream object.
Interface NLPAlgoContainer uses to access NLPAlgo.
Fraction to boundary rule for calculating alpha max.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void set_options(const OptionsFromStream &options)
T_To & dyn_cast(T_From &from)
Computes the reducecd gradient of the objective rGf_k = Z_k' * Gf_k
void InitializeFromNLP(Teuchos::RCP< NLP > original_nlp)
SOptionValues & current_option_values()
Return the current option values being used.
rSQP Algorithm control class.
void init_algo(NLPAlgoInterface *algo)
Standard class for updating the reduced sigma for interior point optimization.
Specializes the update of the penalty parameter for a merit function as: min_mu = |(Gf_k+nu_k)'* Ypy_...
Directs the selection of a new decomposition if the line search fails.
void add_iter_quantities(std::ostream *trase_out, NLP &nlp, NLPFirstOrder *nlp_foi, NLPSecondOrder *nlp_soi, NLPDirect *nlp_fod, bool tailored_approach, const Teuchos::RCP< DecompositionSystem > &decomp_sys, const Teuchos::RCP< NLPAlgoState > &state)
Add the common iteration quantities to the state object.
Set options for CheckConvergence_Strategy from an OptionsFromStream object.
Implementation for NLPAlgo solver.
Calculates dvl_k = mu*invXl_k*e - vl_k - invXl_k*Vl_k*d_k and dvu_k = mu*invXu_k*e - vu_k + invXu_k*V...
Barrier Parameter (mu) Update.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Takes the full step x_kp1 = x_k + d_k (d_k = Ypy_k + Zpz_k).
virtual std::ostream & journal_out() const
Reduced space SQP state encapsulation interface.
virtual void max_run_time(double max_iter)
AlgorithmTracker & track()
Updates rHL_k using a secant update.
Delegates the line search to a DirectLineSearch_Strategy object.
Implementation of CheckConvergence_Strategy interface.
Null Space Step for Interior Point algorithm.
Perform BFGS updates on full reduced Hessian.
Check if the decomposition is going singular and if it is select a new decomposition.
void create_decomp_sys(std::ostream *trase_out, NLP &nlp, NLPFirstOrder *nlp_foi, NLPSecondOrder *nlp_soi, NLPDirect *nlp_fod, bool tailored_approach, Teuchos::RCP< DecompositionSystem > *decomp_sys)
Create the decomposition system object.
Calculates the reduced gradient of the Lagrangian rGL = rGf + Z' * nu + GcUP' * lambda(equ_undecomp) ...
void set_options(const options_ptr_t &options)
Set the OptionsFromStream object that will be used for specifying the options.
options_group_t options_group(const std::string &options_group_name)
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
Calculates the range space step by, solving for py = -inv(R)*c(equ_decomp), then setting Ypy = Y * py...
Standard evaluation step class for extra parameters in primal/dual barrier method.
Strategy interface which contains the guts for a dampened BFGS update.
Set options for BFGSUpdate_Strategy from an OptionsFromStream object.
const options_ptr_t & get_options() const
void do_step_first(Algorithm::poss_type first_step_poss)
Check if the decomposition is going singular and if it is select a new decomposition.
Standard evaluation step class for extra parameters in primal/dual barrier method.
void set_options(const options_ptr_t &options)
Set the options that will be used to configure the algorithmic objects.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Filter line-search step class.