56 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
99 const int DEFAULT_MAX_DOF_QUASI_NEWTON_DENSE = 200;
102 namespace MoochoPack {
109 :null_space_matrix_type_(NULL_SPACE_MATRIX_AUTO)
110 ,range_space_matrix_type_(RANGE_SPACE_MATRIX_AUTO)
111 ,max_dof_quasi_newton_dense_(-1)
129 std::ostream *trase_out
131 ,NLPFirstOrder **nlp_foi
132 ,NLPSecondOrder **nlp_soi
134 ,
bool *tailored_approach
150 *trase_out <<
"\n*** Probing the NLP object for supported interfaces ...\n";
153 *nlp_foi =
dynamic_cast<NLPFirstOrder*
>(&nlp);
154 *nlp_soi =
dynamic_cast<NLPSecondOrder*
>(&nlp);
155 *nlp_fod =
dynamic_cast<NLPDirect*
>(&nlp);
156 *tailored_approach =
false;
159 *trase_out <<
"\nDetected that NLP object supports the NLPFirstOrder interface!\n";
160 *tailored_approach =
false;
162 else if( *nlp_fod ) {
164 *trase_out <<
"\nDetected that NLP object supports the NLPDirect interface!\n";
165 *tailored_approach =
true;
169 true, std::logic_error
170 ,
"NLPAlgoConfigMamaJama::config_algo_cntr(...) : Error, "
171 "the NLP object of type \'" <<
typeName(nlp) <<
172 "\' does not support the NLPFirstOrder or NLPDirect "
177 *trase_out <<
"\nDetected that NLP object also supports the NLPSecondOrder interface!\n";
191 <<
"\n*** Warning, no OptionsFromStream object was set so a default set"
192 " of options will be used!\n";
207 <<
"\nrange_space_matrix == AUTO:"
208 <<
"\n(n-r)^2/r = (" << dof <<
")^2/r = " << (dof*dof/r)
209 << ( use_orth ?
" <= " :
" > " ) <<
"max_dof_quasi_newton_dense^2 = ("
213 ?
"\nsetting range_space_matrix = ORTHOGONAL\n"
214 :
"\nsetting range_space_matrix = COORDINATE\n" );
227 std::ostream *trase_out
229 ,NLPFirstOrder *nlp_foi
230 ,NLPSecondOrder *nlp_soi
232 ,
bool tailored_approach
236 namespace mmp = MemMngPack;
248 if(!tailored_approach) {
250 basis_sys = nlp_foi->basis_sys();
251 if( basis_sys.
get() == NULL ) {
253 true, std::logic_error
254 ,
"\nA basis system object was not specified by the NLPFirstOrder object of type \'"
255 <<
typeName(nlp) <<
"\' and we can not build a rSQP algorithm without one!" );
260 basis_sys_tester =
Teuchos::rcp(
new BasisSystemTester());
262 BasisSystemTesterSetOptions
263 opt_setter(basis_sys_tester.
get());
267 DecompositionSystemVarReduct::EExplicitImplicit
271 D_imp = DecompositionSystemVarReduct::MAT_IMP_AUTO;
274 D_imp = DecompositionSystemVarReduct::MAT_IMP_EXPLICIT;
277 D_imp = DecompositionSystemVarReduct::MAT_IMP_IMPLICIT;
282 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
284 basis_sys_perm_ = Teuchos::rcp_dynamic_cast<BasisSystemPerm>(basis_sys);
288 decomp_sys_imp_ptr_t decomp_sys_imp;
313 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
318 <<
"\nThe BasisSystem object with concreate type \'" <<
typeName(*basis_sys)
319 <<
"\' supports the BasisSystemPerm interface.\n"
320 <<
"Using DecompositionSystemVarReductPermStd to support basis permutations ...\n";
322 new DecompositionSystemVarReductPermStd(
333 <<
"\nThe BasisSystem object with concreate type \'" <<
typeName(*basis_sys)
334 <<
"\' does not support the BasisSystemPerm interface.\n"
335 <<
"Using " <<
typeName(*decomp_sys_imp) <<
" with a fixed basis ...\n";
336 decomp_sys_imp->initialize(
341 *decomp_sys = decomp_sys_imp;
343 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
349 std::ostream *trase_out
351 ,NLPFirstOrder *nlp_foi
352 ,NLPSecondOrder *nlp_soi
354 ,
bool tailored_approach
359 namespace mmp = MemMngPack;
366 if( tailored_approach ) {
374 state->set_iter_quant(
377 new IterQuantityAccessContiguous<MatrixOp>(
380 ,nlp_foi->factory_Gc()
385 state->set_iter_quant(
388 new IterQuantityAccessContiguous<MatrixSymOp>(
391 ,nlp_soi->factory_HL()
404 if(tailored_approach) {
406 state->set_iter_quant(
409 new IterQuantityAccessContiguous<MatrixOp>(
417 state->set_iter_quant(
420 new IterQuantityAccessContiguous<MatrixOp>(
433 state->set_iter_quant(
436 new IterQuantityAccessContiguous<MatrixOp>(
439 ,decomp_sys->factory_Z()
444 state->set_iter_quant(
447 new IterQuantityAccessContiguous<MatrixOp>(
450 ,decomp_sys->factory_Y()
455 state->set_iter_quant(
458 new IterQuantityAccessContiguous<MatrixOpNonsing>(
461 ,decomp_sys->factory_R()
466 state->set_iter_quant(
469 new IterQuantityAccessContiguous<MatrixOp>(
472 ,decomp_sys->factory_Uz()
477 state->set_iter_quant(
480 new IterQuantityAccessContiguous<MatrixOp>(
483 ,decomp_sys->factory_Uy()
490 state->set_iter_quant(
493 new IterQuantityAccessContiguous<MatrixOp>(
501 state->set_iter_quant(
504 new IterQuantityAccessContiguous<MatrixOpNonsing>(
507 ,dyn_cast<NLPFirstOrder>(nlp).basis_sys()->factory_C()
516 state->set_iter_quant(
519 new IterQuantityAccessContiguous<MatrixOp>(
531 std::ostream *trase_out
533 ,NLPFirstOrder *nlp_foi
534 ,NLPSecondOrder *nlp_soi
536 ,
bool tailored_approach
544 namespace mmp = MemMngPack;
549 nb = nlp.num_bounded_x();
553 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
555 decomp_sys_handler_select_new_ptr_t decomp_sys_handler_select_new =
Teuchos::null;
560 const value_type var_bounds_warning_tol = 1e-10;
563 new VariableBoundsTester(
564 var_bounds_warning_tol
565 ,var_bounds_error_tol
569 options_setter( bounds_tester->
get() );
577 ConstrainedOptPack::CalcFiniteDiffProdSetOptions
578 options_setter( calc_fd_prod->
get() );
579 options_setter.set_options(*
options_);
586 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
588 decomp_sys_handler = decomp_sys_handler_select_new
595 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
597 if( decomp_sys_handler_select_new.get() ) {
617 if( tailored_approach ) {
624 ,NLPDirectTester::FD_DIRECTIONAL
625 ,NLPDirectTester::FD_DIRECTIONAL
629 options_setter(deriv_tester.get());
634 _eval_new_point_step_ptr_t
650 options_setter(_eval_new_point_step.get());
653 *eval_new_point_step = _eval_new_point_step;
660 new NLPFirstDerivTester(
662 ,NLPFirstDerivTester::FD_DIRECTIONAL
666 options_setter(deriv_tester.get());
671 decomp_sys_tester_ptr_t
672 decomp_sys_tester =
Teuchos::rcp(
new DecompositionSystemTester() );
674 DecompositionSystemTesterSetOptions
675 options_setter(decomp_sys_tester.get());
676 options_setter.set_options(*
options_);
687 EvalNewPointStd_StepSetOptions
688 options_setter(_eval_new_point_step.
get());
689 options_setter.set_options(*
options_);
691 *eval_new_point_step = _eval_new_point_step;
702 namespace ofsp = OptionsFromStreamPack;
703 using ofsp::OptionsFromStream;
704 typedef OptionsFromStream::options_group_t options_group_t;
705 using ofsp::StringToIntMap;
710 const std::string opt_grp_name =
"DecompositionSystemStateStepBuilderStd";
711 const OptionsFromStream::options_group_t optgrp = options.
options_group( opt_grp_name );
712 if( OptionsFromStream::options_group_exists( optgrp ) ) {
714 const int num_opts = 3;
718 ,MAX_DOF_QUASI_NEWTON_DENSE
720 const char* SBuilder[num_opts] = {
722 ,
"range_space_matrix"
723 ,
"max_dof_quasi_newton_dense"
725 StringToIntMap map( opt_grp_name, num_opts, SBuilder );
727 options_group_t::const_iterator itr = optgrp.begin();
728 for( ; itr != optgrp.end(); ++itr ) {
730 case NULL_SPACE_MATRIX:
733 if( opt_val ==
"EXPLICIT" ) {
735 }
else if( opt_val ==
"IMPLICIT" ) {
737 }
else if( opt_val ==
"AUTO" ) {
741 true, std::invalid_argument
742 ,
"NLPAlgoConfigMamaJama::readin_options(...) : "
743 "Error, incorrect value for \"null_space_matrix\" "
744 ", Only the options for Z of EXPLICIT, IMPLICIT"
745 ", and AUTO are avalible." );
749 case RANGE_SPACE_MATRIX:
752 if( opt_val ==
"COORDINATE" )
754 else if( opt_val ==
"ORTHOGONAL" )
756 else if( opt_val ==
"AUTO" )
760 true, std::invalid_argument
761 ,
"NLPAlgoConfigMamaJama::readin_options(...) : "
762 "Error, incorrect value for \"range_space_matrix\" "
763 ", Only the options for Z of COORDINATE,"
764 ", ORTHOGONAL and AUTO are avalible." );
767 case MAX_DOF_QUASI_NEWTON_DENSE:
778 <<
"\n\n*** Warning! The options group \"DecompositionSystemStateStepBuilderStd\" was not found.\n"
779 <<
"Using a default set of options instead ... \n";
786 ,std::ostream* trase_out
794 <<
"\n*** Setting option defaults for options not set by the user or determined some other way ...\n";
799 <<
"\nnull_space_matrix_type == AUTO: Let the algorithm deside as it goes along\n";
807 <<
"\nrange_space_matrix_type == AUTO: Let the algorithm deside as it goes along\n";
815 <<
"\nmax_dof_quasi_newton_dense < 0 : setting max_dof_quasi_newton_dense = "<<DEFAULT_MAX_DOF_QUASI_NEWTON_DENSE<<
"\n";
823 <<
"\n*** End setting default options\n";
Extracts options from a text stream and then allows convenient access to them.
AbstractLinAlgPack::size_type size_type
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: ...
int max_dof_quasi_newton_dense_
std::string typeName(const T &t)
options_ptr_t options_
Smart pointer to options.
bool StringToBool(const char *opt_name, const char *str)
Convert a string "true" or "false" into bool #true# or #false#.
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.
SOptionValues uov_
Options structs.
Teuchos::RCP< BasisSystemPerm > basis_sys_perm_
Set options for NLPDirectTester from an OptionsFromStream object.
Subclass for selecting and updating the range/null space decomposition using the DecompositionSystemV...
static void readin_options(const OptionsFromStreamPack::OptionsFromStream &options, SOptionValues *option_values, std::ostream *trase_out)
Read in the options from a stream.
static void set_default_options(const SOptionValues &user_option_values, SOptionValues *current_option_values, std::ostream *trase_out)
Set the defaults for options not set by the user.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const std::string & option_name(OptionsGroup::const_iterator &itr)
void set_options(const OptionsFromStream &options)
Overridden from SetOptionsFromStream and calls setOption(...).
Subclass for updating the range/null space decomposition using the base DecompositionSystem interface...
const std::string Gc_name
Implements "orthogonal" decompostion for "Tailored Appraoch".
Set options for VariableBoundsTester from an OptionsFromStream object.
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.
const options_ptr_t & get_options() const
DecompositionSystemStateStepBuilderStd()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Set options for EvalNewPointTailoredApproach_Step from an OptionsFromStream object.
T_To & dyn_cast(T_From &from)
Set options for NLPFirstDerivTester from an OptionsFromStream object.
ENullSpaceMatrixType null_space_matrix_type_
Just force the decomposition system object to select a new decomposition and let everyone else fend f...
const std::string HL_name
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.
Implements "coordinate" decompostion for "Tailored Appraoch".
const std::string Uy_name
ERangeSpaceMatrixType range_space_matrix_type_
Standard new point evaluation step class.
AbstractLinAlgPack::value_type value_type
options_group_t options_group(const std::string &options_group_name)
const std::string Uz_name
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)
const std::string & option_value(OptionsGroup::const_iterator &itr)