MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MoochoPack_DecompositionSystemStateStepBuilderStd.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
43 
44 // NLP Stuff
45 
51 
52 // Basis system and direct sparse solvers
53 
56 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
58 #endif
59 
60 // Range/null decomposition
61 
69 
70 // Iteration quantities
71 
74 
75 // Eval new point
76 
81 
82 // Other classes
83 
90 
91 // Common utilities
95 #include "Teuchos_Assert.hpp"
96 #include "Teuchos_dyn_cast.hpp"
97 
98 namespace {
99  const int DEFAULT_MAX_DOF_QUASI_NEWTON_DENSE = 200;
100 } // end namespace
101 
102 namespace MoochoPack {
103 
104 //
105 // Here is where we define the default values for the algorithm. These
106 // should agree with what are in the Moocho.opt.NLPAlgoConfigMamaJama file.
107 //
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)
112 {}
113 
115 {}
116 
118 {
119  options_ = options;
120 }
121 
124 {
125  return options_;
126 }
127 
129  std::ostream *trase_out
130  ,NLP &nlp
131  ,NLPFirstOrder **nlp_foi
132  ,NLPSecondOrder **nlp_soi
133  ,NLPDirect **nlp_fod
134  ,bool *tailored_approach
135  )
136 {
137 
138  //
139  // Probe the NLP interfaces
140  //
141 
142  // Get the dimensions of the NLP
143  const size_type
144  n = nlp.n(),
145  m = nlp.m(),
146  r = m, // ToDo: Compute this for real!
147  dof = n - r;
148 
149  if(trase_out)
150  *trase_out << "\n*** Probing the NLP object for supported interfaces ...\n";
151 
152  // Determine which NLP interface is supported
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;
157  if( *nlp_foi ) {
158  if(trase_out)
159  *trase_out << "\nDetected that NLP object supports the NLPFirstOrder interface!\n";
160  *tailored_approach = false;
161  }
162  else if( *nlp_fod ) {
163  if(trase_out)
164  *trase_out << "\nDetected that NLP object supports the NLPDirect interface!\n";
165  *tailored_approach = true;
166  }
167  else {
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 "
173  "interfaces!" );
174  }
175  if( *nlp_soi ) {
176  if(trase_out)
177  *trase_out << "\nDetected that NLP object also supports the NLPSecondOrder interface!\n";
178  }
179 
180  //
181  // Process the options
182  //
183 
184  // Readin the options
185  if(options_.get()) {
186  readin_options( *options_, &uov_, trase_out );
187  }
188  else {
189  if(trase_out) {
190  *trase_out
191  << "\n*** Warning, no OptionsFromStream object was set so a default set"
192  " of options will be used!\n";
193  }
194  }
195 
196  // Set default
198  cov_.max_dof_quasi_newton_dense_ = DEFAULT_MAX_DOF_QUASI_NEWTON_DENSE;
199  else
201 
202  // Decide what type of range-space matrix to use
204  const bool use_orth = (dof*dof/r) <= cov_.max_dof_quasi_newton_dense_*cov_.max_dof_quasi_newton_dense_;
205  if(trase_out)
206  *trase_out
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 = ("
210  << cov_.max_dof_quasi_newton_dense_ << ")^2 = "
212  << ( use_orth
213  ? "\nsetting range_space_matrix = ORTHOGONAL\n"
214  : "\nsetting range_space_matrix = COORDINATE\n" );
216  ( use_orth
219  }
220 
221  // Set the default options that where not already set yet
222  set_default_options(uov_,&cov_,trase_out);
223 
224 }
225 
227  std::ostream *trase_out
228  ,NLP &nlp
229  ,NLPFirstOrder *nlp_foi
230  ,NLPSecondOrder *nlp_soi
231  ,NLPDirect *nlp_fod
232  ,bool tailored_approach
234  )
235 {
236  namespace mmp = MemMngPack;
237  using Teuchos::RCP;
238 
239  const size_type
240  m = nlp.m();
241 
242  if( m == 0 ) {
243  *decomp_sys = Teuchos::null;
244  return;
245  }
246 
247  RCP<BasisSystem> basis_sys = Teuchos::null;
248  if(!tailored_approach) {
249  // Set the default basis system if one is not set
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!" );
256 
257  }
258  // Create the testing object for the basis system and set it up.
260  basis_sys_tester = Teuchos::rcp(new BasisSystemTester());
261  if(options_.get()) {
262  BasisSystemTesterSetOptions
263  opt_setter(basis_sys_tester.get());
264  opt_setter.set_options(*options_);
265  }
266  // Determine what type of null space matrix to use
267  DecompositionSystemVarReduct::EExplicitImplicit
268  D_imp;
269  switch( cov_.null_space_matrix_type_ ) {
271  D_imp = DecompositionSystemVarReduct::MAT_IMP_AUTO;
272  break;
274  D_imp = DecompositionSystemVarReduct::MAT_IMP_EXPLICIT;
275  break;
277  D_imp = DecompositionSystemVarReduct::MAT_IMP_IMPLICIT;
278  break;
279  default:
281  }
282 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
283  // See if the basis system object supports basis permutations
284  basis_sys_perm_ = Teuchos::rcp_dynamic_cast<BasisSystemPerm>(basis_sys);
285 #endif
286  // Create the DecompositionSystem implementation object
287  typedef RCP<DecompositionSystemVarReductImp> decomp_sys_imp_ptr_t;
288  decomp_sys_imp_ptr_t decomp_sys_imp;
289  switch( cov_.range_space_matrix_type_ ) {
291  decomp_sys_imp
292  = Teuchos::rcp(new DecompositionSystemCoordinate(
293  nlp.space_x()
294  ,nlp.space_c()
295  ,basis_sys // Will have basis_sys_->var_dep().size() == 0 if permutation
296  ,basis_sys_tester
297  ,D_imp
298  ) );
299  break;
301  decomp_sys_imp
302  = Teuchos::rcp(new DecompositionSystemOrthogonal(
303  nlp.space_x()
304  ,nlp.space_c()
305  ,basis_sys // Will have basis_sys_->var_dep().size() == 0 if permutation
306  ,basis_sys_tester
307  ) );
308  break;
309  }
310  default:
311  TEUCHOS_TEST_FOR_EXCEPT(true); // only a local error
312  }
313 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
314  // Create the actual DecompositionSystem object being used
315  if( basis_sys_perm_.get() != NULL ) {
316  if(trase_out)
317  *trase_out
318  << "\nThe BasisSystem object with concreate type \'" << typeName(*basis_sys)
319  << "\' supports the BasisSystemPerm interface.\n"
320  << "Using DecompositionSystemVarReductPermStd to support basis permutations ...\n";
321  *decomp_sys = Teuchos::rcp(
322  new DecompositionSystemVarReductPermStd(
323  decomp_sys_imp
325  ,false // basis_selected
326  ,D_imp
327  ) );
328  }
329  else {
330 #endif
331  if(trase_out)
332  *trase_out
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(
337  nlp.space_x()
338  ,nlp.space_c()
339  ,basis_sys // Must already be ready to go with a basis selection!
340  );
341  *decomp_sys = decomp_sys_imp;
342  }
343 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
344  }
345 #endif
346 }
347 
349  std::ostream *trase_out
350  ,NLP &nlp
351  ,NLPFirstOrder *nlp_foi
352  ,NLPSecondOrder *nlp_soi
353  ,NLPDirect *nlp_fod
354  ,bool tailored_approach
355  ,const Teuchos::RCP<DecompositionSystem> &decomp_sys
356  ,const Teuchos::RCP<NLPAlgoState> &state
357  )
358 {
359  namespace mmp = MemMngPack;
360  using Teuchos::dyn_cast;
361 
362  const size_type
363  n = nlp.n(),
364  m = nlp.m();
365 
366  if( tailored_approach ) {
367  // NLPDirect
368  TEUCHOS_TEST_FOR_EXCEPT( !( nlp_fod->con_undecomp().size() == 0 ) );
369  // ToDo: Add the necessary iteration quantities when con_undecomp().size() > 0 is supported!
370  }
371  else {
372  // NLPFirstOrder
373  if(m)
374  state->set_iter_quant(
375  Gc_name
376  ,Teuchos::rcp(
377  new IterQuantityAccessContiguous<MatrixOp>(
378  1
379  ,Gc_name
380  ,nlp_foi->factory_Gc()
381  )
382  )
383  );
384  if(nlp_soi)
385  state->set_iter_quant(
386  HL_name
387  ,Teuchos::rcp(
388  new IterQuantityAccessContiguous<MatrixSymOp>(
389  1
390  ,HL_name
391  ,nlp_soi->factory_HL()
392  )
393  )
394  );
395  }
396 
397  //
398  // Set the algorithm specific matrix objects
399  //
400 
401  // Add range/null decomposition matrices
402 
403  if( m ) {
404  if(tailored_approach) {
405  // Z
406  state->set_iter_quant(
407  Z_name
408  ,Teuchos::rcp(
409  new IterQuantityAccessContiguous<MatrixOp>(
410  1
411  ,Z_name
413  )
414  )
415  );
416  // Y
417  state->set_iter_quant(
418  Y_name
419  ,Teuchos::rcp(
420  new IterQuantityAccessContiguous<MatrixOp>(
421  1
422  ,Y_name
424  )
425  )
426  );
427  // ToDo: Add matrix iq object for Uz
428  // ToDo: Add matrix iq object for Uy
429  }
430  else {
431  if( n > m ) {
432  // Z
433  state->set_iter_quant(
434  Z_name
435  ,Teuchos::rcp(
436  new IterQuantityAccessContiguous<MatrixOp>(
437  1
438  ,Z_name
439  ,decomp_sys->factory_Z()
440  )
441  )
442  );
443  // Y
444  state->set_iter_quant(
445  Y_name
446  ,Teuchos::rcp(
447  new IterQuantityAccessContiguous<MatrixOp>(
448  1
449  ,Y_name
450  ,decomp_sys->factory_Y()
451  )
452  )
453  );
454  // R
455  state->set_iter_quant(
456  R_name
457  ,Teuchos::rcp(
458  new IterQuantityAccessContiguous<MatrixOpNonsing>(
459  1
460  ,R_name
461  ,decomp_sys->factory_R()
462  )
463  )
464  );
465  // Uz
466  state->set_iter_quant(
467  Uz_name
468  ,Teuchos::rcp(
469  new IterQuantityAccessContiguous<MatrixOp>(
470  1
471  ,Uz_name
472  ,decomp_sys->factory_Uz()
473  )
474  )
475  );
476  // Uy
477  state->set_iter_quant(
478  Uy_name
479  ,Teuchos::rcp(
480  new IterQuantityAccessContiguous<MatrixOp>(
481  1
482  ,Uy_name
483  ,decomp_sys->factory_Uy()
484  )
485  )
486  );
487  }
488  else {
489  // Y
490  state->set_iter_quant(
491  Y_name
492  ,Teuchos::rcp(
493  new IterQuantityAccessContiguous<MatrixOp>(
494  1
495  ,Y_name
497  )
498  )
499  );
500  // R
501  state->set_iter_quant(
502  R_name
503  ,Teuchos::rcp(
504  new IterQuantityAccessContiguous<MatrixOpNonsing>(
505  1
506  ,R_name
507  ,dyn_cast<NLPFirstOrder>(nlp).basis_sys()->factory_C()
508  )
509  )
510  );
511  }
512  }
513  }
514  else {
515  // Z
516  state->set_iter_quant(
517  Z_name
518  ,Teuchos::rcp(
519  new IterQuantityAccessContiguous<MatrixOp>(
520  1
521  ,Z_name
523  )
524  )
525  );
526  }
527 
528 }
529 
531  std::ostream *trase_out
532  ,NLP &nlp
533  ,NLPFirstOrder *nlp_foi
534  ,NLPSecondOrder *nlp_soi
535  ,NLPDirect *nlp_fod
536  ,bool tailored_approach
537  ,const Teuchos::RCP<DecompositionSystem> &decomp_sys
538  ,Teuchos::RCP<IterationPack::AlgorithmStep> *eval_new_point_step
539  ,Teuchos::RCP<CalcFiniteDiffProd> *calc_fd_prod
540  ,Teuchos::RCP<VariableBoundsTester> *bounds_tester
541  ,Teuchos::RCP<NewDecompositionSelection_Strategy> *new_decomp_selection_strategy
542  )
543 {
544  namespace mmp = MemMngPack;
545  using Teuchos::RCP;
546 
547  const size_type
548  m = nlp.m(),
549  nb = nlp.num_bounded_x();
550 
551  typedef RCP<DecompositionSystemHandler_Strategy> decomp_sys_handler_ptr_t;
552  decomp_sys_handler_ptr_t decomp_sys_handler = Teuchos::null;
553 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
554  typedef RCP<DecompositionSystemHandlerSelectNew_Strategy> decomp_sys_handler_select_new_ptr_t;
555  decomp_sys_handler_select_new_ptr_t decomp_sys_handler_select_new = Teuchos::null;
556 #endif
557 
558  // Create the variable bounds testing object.
559  if(nb) { // has variable bounds?
560  const value_type var_bounds_warning_tol = 1e-10;
561  const value_type var_bounds_error_tol = 1e-5;
562  *bounds_tester = Teuchos::rcp(
563  new VariableBoundsTester(
564  var_bounds_warning_tol // default warning tolerance
565  ,var_bounds_error_tol // default error tolerance
566  ) );
567  if(options_.get()) {
569  options_setter( bounds_tester->get() );
570  options_setter.set_options(*options_);
571  }
572  }
573 
574  // Create the finite difference class
575  *calc_fd_prod = Teuchos::rcp(new CalcFiniteDiffProd());
576  if(options_.get()) {
577  ConstrainedOptPack::CalcFiniteDiffProdSetOptions
578  options_setter( calc_fd_prod->get() );
579  options_setter.set_options(*options_);
580  }
581 
582  if( m ) {
583 
584  // Decomposition system handler
585  if( nlp_foi ) {
586 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
587  if( basis_sys_perm_.get() )
588  decomp_sys_handler = decomp_sys_handler_select_new
590  else
591 #endif
592  decomp_sys_handler = Teuchos::rcp( new DecompositionSystemHandlerStd_Strategy );
593  }
594 
595 #ifndef MOOCHO_NO_BASIS_PERM_DIRECT_SOLVERS
596  // NewDecompositionSelectionStd_Strategy
597  if( decomp_sys_handler_select_new.get() ) {
598  *new_decomp_selection_strategy = Teuchos::rcp(
599  new NewDecompositionSelectionStd_Strategy(decomp_sys_handler_select_new)
600  );
601  }
602 #else
603  *new_decomp_selection_strategy = Teuchos::null;
604 #endif
605 
606  }
607  else {
608  decomp_sys_handler = Teuchos::null;
609  *new_decomp_selection_strategy = Teuchos::null;
610  }
611 
612  //
613  // EvalNewPoint_Step
614  //
615 
616  // Create the step object
617  if( tailored_approach ) {
618  // create and setup the derivative tester
619  typedef Teuchos::RCP<NLPDirectTester> deriv_tester_ptr_t;
620  deriv_tester_ptr_t
621  deriv_tester = Teuchos::rcp(
622  new NLPDirectTester(
623  *calc_fd_prod
624  ,NLPDirectTester::FD_DIRECTIONAL // Gf testing
625  ,NLPDirectTester::FD_DIRECTIONAL // -Inv(C)*N testing
626  ) );
627  if(options_.get()) {
629  options_setter(deriv_tester.get());
630  options_setter.set_options(*options_);
631  }
632  // create the step
633  typedef Teuchos::RCP<EvalNewPointTailoredApproach_Step> _eval_new_point_step_ptr_t;
634  _eval_new_point_step_ptr_t
635  _eval_new_point_step = Teuchos::null;
636  switch( cov_.range_space_matrix_type_ ) {
638  _eval_new_point_step
639  = Teuchos::rcp(new EvalNewPointTailoredApproachCoordinate_Step(deriv_tester,*bounds_tester));
640  break;
642  _eval_new_point_step
643  = Teuchos::rcp(new EvalNewPointTailoredApproachOrthogonal_Step(deriv_tester,*bounds_tester) );
644  break;
645  default:
646  TEUCHOS_TEST_FOR_EXCEPT(true); // only a local error
647  }
648  if(options_.get()) {
650  options_setter(_eval_new_point_step.get());
651  options_setter.set_options(*options_);
652  }
653  *eval_new_point_step = _eval_new_point_step;
654  }
655  else {
656  // create and setup the derivative tester
657  typedef Teuchos::RCP<NLPFirstDerivTester> deriv_tester_ptr_t;
658  deriv_tester_ptr_t
659  deriv_tester = Teuchos::rcp(
660  new NLPFirstDerivTester(
661  *calc_fd_prod
662  ,NLPFirstDerivTester::FD_DIRECTIONAL
663  ) );
664  if(options_.get()) {
666  options_setter(deriv_tester.get());
667  options_setter.set_options(*options_);
668  }
669  // create and setup the decomposition system tester
670  typedef Teuchos::RCP<DecompositionSystemTester> decomp_sys_tester_ptr_t;
671  decomp_sys_tester_ptr_t
672  decomp_sys_tester = Teuchos::rcp( new DecompositionSystemTester() );
673  if(options_.get()) {
674  DecompositionSystemTesterSetOptions
675  options_setter(decomp_sys_tester.get());
676  options_setter.set_options(*options_);
677  }
679  _eval_new_point_step = Teuchos::rcp(
681  decomp_sys_handler
682  ,deriv_tester
683  ,*bounds_tester
684  ,decomp_sys_tester
685  ) );
686  if(options_.get()) {
687  EvalNewPointStd_StepSetOptions
688  options_setter(_eval_new_point_step.get());
689  options_setter.set_options(*options_);
690  }
691  *eval_new_point_step = _eval_new_point_step;
692  }
693 }
694 
695 // static
696 
699  ,SOptionValues *ov, std::ostream* trase_out
700  )
701 {
702  namespace ofsp = OptionsFromStreamPack;
703  using ofsp::OptionsFromStream;
704  typedef OptionsFromStream::options_group_t options_group_t;
705  using ofsp::StringToIntMap;
706  using ofsp::StringToBool;
707 
708  TEUCHOS_TEST_FOR_EXCEPT( !( ov ) ); // only a local class error
709 
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 ) ) {
713 
714  const int num_opts = 3;
715  enum EBuilder {
716  NULL_SPACE_MATRIX
717  ,RANGE_SPACE_MATRIX
718  ,MAX_DOF_QUASI_NEWTON_DENSE
719  };
720  const char* SBuilder[num_opts] = {
721  "null_space_matrix"
722  ,"range_space_matrix"
723  ,"max_dof_quasi_newton_dense"
724  };
725  StringToIntMap map( opt_grp_name, num_opts, SBuilder );
726 
727  options_group_t::const_iterator itr = optgrp.begin();
728  for( ; itr != optgrp.end(); ++itr ) {
729  switch( (EBuilder)map( ofsp::option_name(itr) ) ) {
730  case NULL_SPACE_MATRIX:
731  {
732  const std::string &opt_val = ofsp::option_value(itr);
733  if( opt_val == "EXPLICIT" ) {
735  } else if( opt_val == "IMPLICIT" ) {
737  } else if( opt_val == "AUTO" ) {
739  } else {
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." );
746  }
747  break;
748  }
749  case RANGE_SPACE_MATRIX:
750  {
751  const std::string &opt_val = ofsp::option_value(itr);
752  if( opt_val == "COORDINATE" )
754  else if( opt_val == "ORTHOGONAL" )
756  else if( opt_val == "AUTO" )
758  else
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." );
765  break;
766  }
767  case MAX_DOF_QUASI_NEWTON_DENSE:
768  ov->max_dof_quasi_newton_dense_ = std::atoi( ofsp::option_value(itr).c_str() );
769  break;
770  default:
771  TEUCHOS_TEST_FOR_EXCEPT(true); // this would be a local programming error only.
772  }
773  }
774  }
775  else {
776  if(trase_out)
777  *trase_out
778  << "\n\n*** Warning! The options group \"DecompositionSystemStateStepBuilderStd\" was not found.\n"
779  << "Using a default set of options instead ... \n";
780  }
781 }
782 
784  const SOptionValues& uov
785  ,SOptionValues *cov
786  ,std::ostream* trase_out
787  )
788 {
789 
790  TEUCHOS_TEST_FOR_EXCEPT( !( cov ) );
791 
792  if(trase_out)
793  *trase_out
794  << "\n*** Setting option defaults for options not set by the user or determined some other way ...\n";
795 
797  if(trase_out)
798  *trase_out
799  << "\nnull_space_matrix_type == AUTO: Let the algorithm deside as it goes along\n";
800  }
803  }
805  if(trase_out)
806  *trase_out
807  << "\nrange_space_matrix_type == AUTO: Let the algorithm deside as it goes along\n";
808  }
811  }
812  if( cov->max_dof_quasi_newton_dense_ < 0 && uov.max_dof_quasi_newton_dense_ < 0 ) {
813  if(trase_out)
814  *trase_out
815  << "\nmax_dof_quasi_newton_dense < 0 : setting max_dof_quasi_newton_dense = "<<DEFAULT_MAX_DOF_QUASI_NEWTON_DENSE<<"\n";
816  cov->max_dof_quasi_newton_dense_ = DEFAULT_MAX_DOF_QUASI_NEWTON_DENSE;
817  }
818  else if(cov->max_dof_quasi_newton_dense_ < 0) {
820  }
821  if(trase_out)
822  *trase_out
823  << "\n*** End setting default options\n";
824 }
825 
826 } // end class MoochoPack
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: ...
std::string typeName(const T &t)
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.
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
T * get() const
Set options for VariableBoundsTester from an OptionsFromStream object.
const std::string Y_name
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.
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.
const std::string Z_name
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.
const std::string Uy_name
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
const std::string R_name
int n
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)