ROL
ROL_Types.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) 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 lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 #ifndef ROL_TYPES_HPP
50 #define ROL_TYPES_HPP
51 
52 #ifdef HAVE_ROL_DEBUG
53 #define ROL_VALIDATE( A ) A
54 #else
55 #define ROL_VALIDATE( A ) /* empty */
56 #endif
57 
58 #include <algorithm>
59 #include <string>
60 #include <limits>
61 #include <Teuchos_getConst.hpp>
62 #include <Teuchos_RCP.hpp>
63 #include <Teuchos_ScalarTraits.hpp>
64 #include <Teuchos_TestForException.hpp>
65 #include <ROL_Vector.hpp>
66 
70 #define ROL_NUM_CHECKDERIV_STEPS 13
71 
72 namespace ROL {
73 
76  template<class Real>
77  struct AlgorithmState {
78  int iter;
79  int minIter;
80  int nfval;
81  int ncval;
82  int ngrad;
83  Real value;
84  Real minValue;
85  Real gnorm;
86  Real cnorm;
87  Real snorm;
90  bool flag;
91  Teuchos::RCP<Vector<Real> > iterateVec;
92  Teuchos::RCP<Vector<Real> > lagmultVec;
93  Teuchos::RCP<Vector<Real> > minIterVec;
94  AlgorithmState(void) : iter(0), minIter(0), nfval(0), ngrad(0), value(0), minValue(0),
95  gnorm(std::numeric_limits<Real>::max()),
96  cnorm(std::numeric_limits<Real>::max()),
97  snorm(std::numeric_limits<Real>::max()),
98  aggregateGradientNorm(std::numeric_limits<Real>::max()),
99  aggregateModelError(std::numeric_limits<Real>::max()),
100  flag(false),
101  iterateVec(Teuchos::null), lagmultVec(Teuchos::null), minIterVec(Teuchos::null) {}
102  };
103 
106  template<class Real>
107  struct StepState {
108  Teuchos::RCP<Vector<Real> > gradientVec;
109  Teuchos::RCP<Vector<Real> > descentVec;
110  Teuchos::RCP<Vector<Real> > constraintVec;
111  Real searchSize; // line search parameter (alpha) or trust-region radius (delta)
112  StepState(void) : gradientVec(Teuchos::null), descentVec(Teuchos::null), constraintVec(Teuchos::null),
113  searchSize(0) {}
114  };
115 
118  static const double ROL_EPSILON = std::abs(Teuchos::ScalarTraits<double>::eps());
119 
122  static const double ROL_THRESHOLD = 10.0 * ROL_EPSILON;
123 
126  static const double ROL_OVERFLOW = std::abs(Teuchos::ScalarTraits<double>::rmax());
127 
128  static const double ROL_INF = 0.1*ROL_OVERFLOW;
129  static const double ROL_NINF = -ROL_INF;
130 
133  static const double ROL_UNDERFLOW = std::abs(Teuchos::ScalarTraits<double>::rmin());
134 
136  bool operator()(char c) {
137  return (c ==' ' || c =='-' || c == '(' || c == ')' || c=='\'' || c=='\r' || c=='\n' || c=='\t');
138  }
139  };
140 
141  inline std::string removeStringFormat( std::string s ) {
142  std::string output = s;
143  output.erase( std::remove_if( output.begin(), output.end(), removeSpecialCharacters()), output.end() );
144  std::transform( output.begin(), output.end(), output.begin(), ::tolower );
145  return output;
146  }
147 
159  enum EStep{
169  };
170 
171  inline std::string EStepToString(EStep tr) {
172  std::string retString;
173  switch(tr) {
174  case STEP_AUGMENTEDLAGRANGIAN: retString = "Augmented Lagrangian"; break;
175  case STEP_BUNDLE: retString = "Bundle"; break;
176  case STEP_COMPOSITESTEP: retString = "Composite Step"; break;
177  case STEP_LINESEARCH: retString = "Line Search"; break;
178  case STEP_MOREAUYOSIDAPENALTY: retString = "Moreau-Yosida Penalty"; break;
179  case STEP_PRIMALDUALACTIVESET: retString = "Primal Dual Active Set"; break;
180  case STEP_TRUSTREGION: retString = "Trust Region"; break;
181  case STEP_INTERIORPOINT: retString = "Interior Point"; break;
182  case STEP_LAST: retString = "Last Type (Dummy)"; break;
183  default: retString = "INVALID EStep";
184  }
185  return retString;
186  }
187 
193  inline int isValidStep(EStep ls) {
194  return( (ls == STEP_AUGMENTEDLAGRANGIAN) ||
195  (ls == STEP_BUNDLE) ||
196  (ls == STEP_COMPOSITESTEP) ||
197  (ls == STEP_LINESEARCH) ||
198  (ls == STEP_MOREAUYOSIDAPENALTY) ||
199  (ls == STEP_PRIMALDUALACTIVESET) ||
200  (ls == STEP_TRUSTREGION) ||
201  (ls == STEP_INTERIORPOINT) ) ;
202  }
203 
204  inline EStep & operator++(EStep &type) {
205  return type = static_cast<EStep>(type+1);
206  }
207 
208  inline EStep operator++(EStep &type, int) {
209  EStep oldval = type;
210  ++type;
211  return oldval;
212  }
213 
214  inline EStep & operator--(EStep &type) {
215  return type = static_cast<EStep>(type-1);
216  }
217 
218  inline EStep operator--(EStep &type, int) {
219  EStep oldval = type;
220  --type;
221  return oldval;
222  }
223 
224  inline EStep StringToEStep(std::string s) {
225  s = removeStringFormat(s);
226  for ( EStep tr = STEP_AUGMENTEDLAGRANGIAN; tr < STEP_LAST; tr++ ) {
227  if ( !s.compare(removeStringFormat(EStepToString(tr))) ) {
228  return tr;
229  }
230  }
231  return STEP_TRUSTREGION;
232  }
233 
246  };
247 
248  inline std::string EBoundAlgorithmToString(EBoundAlgorithm tr) {
249  std::string retString;
250  switch(tr) {
251  case BOUNDALGORITHM_PROJECTED: retString = "Projected"; break;
252  case BOUNDALGORITHM_PRIMALDUALACTIVESET: retString = "Primal Dual Active Set"; break;
253  case BOUNDALGORITHM_INTERIORPOINTS: retString = "Interior Points"; break;
254  case BOUNDALGORITHM_LAST: retString = "Last Type (Dummy)"; break;
255  default: retString = "INVALID EBoundAlgorithm";
256  }
257  return retString;
258  }
259 
266  return( (d == BOUNDALGORITHM_PROJECTED) ||
269  );
270  }
271 
273  return type = static_cast<EBoundAlgorithm>(type+1);
274  }
275 
277  EBoundAlgorithm oldval = type;
278  ++type;
279  return oldval;
280  }
281 
283  return type = static_cast<EBoundAlgorithm>(type-1);
284  }
285 
287  EBoundAlgorithm oldval = type;
288  --type;
289  return oldval;
290  }
291 
292  inline EBoundAlgorithm StringToEBoundAlgorithm(std::string s) {
293  s = removeStringFormat(s);
294  for ( EBoundAlgorithm des = BOUNDALGORITHM_PROJECTED; des < BOUNDALGORITHM_LAST; des++ ) {
295  if ( !s.compare(removeStringFormat(EBoundAlgorithmToString(des))) ) {
296  return des;
297  }
298  }
300  }
301 
312  enum EDescent{
319  };
320 
321  inline std::string EDescentToString(EDescent tr) {
322  std::string retString;
323  switch(tr) {
324  case DESCENT_STEEPEST: retString = "Steepest Descent"; break;
325  case DESCENT_NONLINEARCG: retString = "Nonlinear CG"; break;
326  case DESCENT_SECANT: retString = "Quasi-Newton Method"; break;
327  case DESCENT_NEWTON: retString = "Newton's Method"; break;
328  case DESCENT_NEWTONKRYLOV: retString = "Newton-Krylov"; break;
329  case DESCENT_LAST: retString = "Last Type (Dummy)"; break;
330  default: retString = "INVALID ESecant";
331  }
332  return retString;
333  }
334 
340  inline int isValidDescent(EDescent d){
341  return( (d == DESCENT_STEEPEST) ||
342  (d == DESCENT_NONLINEARCG) ||
343  (d == DESCENT_SECANT) ||
344  (d == DESCENT_NEWTON) ||
345  (d == DESCENT_NEWTONKRYLOV)
346  );
347  }
348 
349  inline EDescent & operator++(EDescent &type) {
350  return type = static_cast<EDescent>(type+1);
351  }
352 
353  inline EDescent operator++(EDescent &type, int) {
354  EDescent oldval = type;
355  ++type;
356  return oldval;
357  }
358 
359  inline EDescent & operator--(EDescent &type) {
360  return type = static_cast<EDescent>(type-1);
361  }
362 
363  inline EDescent operator--(EDescent &type, int) {
364  EDescent oldval = type;
365  --type;
366  return oldval;
367  }
368 
369  inline EDescent StringToEDescent(std::string s) {
370  s = removeStringFormat(s);
371  for ( EDescent des = DESCENT_STEEPEST; des < DESCENT_LAST; des++ ) {
372  if ( !s.compare(removeStringFormat(EDescentToString(des))) ) {
373  return des;
374  }
375  }
376  return DESCENT_SECANT;
377  }
378 
387  enum ESecant{
394  };
395 
396  inline std::string ESecantToString(ESecant tr) {
397  std::string retString;
398  switch(tr) {
399  case SECANT_LBFGS: retString = "Limited-Memory BFGS"; break;
400  case SECANT_LDFP: retString = "Limited-Memory DFP"; break;
401  case SECANT_LSR1: retString = "Limited-Memory SR1"; break;
402  case SECANT_BARZILAIBORWEIN: retString = "Barzilai-Borwein"; break;
403  case SECANT_USERDEFINED: retString = "User-Defined"; break;
404  case SECANT_LAST: retString = "Last Type (Dummy)"; break;
405  default: retString = "INVALID ESecant";
406  }
407  return retString;
408  }
409 
415  inline int isValidSecant(ESecant s) {
416  return( (s == SECANT_LBFGS) ||
417  (s == SECANT_LDFP) ||
418  (s == SECANT_LSR1) ||
419  (s == SECANT_BARZILAIBORWEIN) ||
420  (s == SECANT_USERDEFINED)
421  );
422  }
423 
424  inline ESecant & operator++(ESecant &type) {
425  return type = static_cast<ESecant>(type+1);
426  }
427 
428  inline ESecant operator++(ESecant &type, int) {
429  ESecant oldval = type;
430  ++type;
431  return oldval;
432  }
433 
434  inline ESecant & operator--(ESecant &type) {
435  return type = static_cast<ESecant>(type-1);
436  }
437 
438  inline ESecant operator--(ESecant &type, int) {
439  ESecant oldval = type;
440  --type;
441  return oldval;
442  }
443 
444  inline ESecant StringToESecant(std::string s) {
445  s = removeStringFormat(s);
446  for ( ESecant sec = SECANT_LBFGS; sec < SECANT_LAST; sec++ ) {
447  if ( !s.compare(removeStringFormat(ESecantToString(sec))) ) {
448  return sec;
449  }
450  }
451  return SECANT_LBFGS;
452  }
453 
460  enum EKrylov{
466  };
467 
468  inline std::string EKrylovToString(EKrylov tr) {
469  std::string retString;
470  switch(tr) {
471  case KRYLOV_CG: retString = "Conjugate Gradients"; break;
472  case KRYLOV_CR: retString = "Conjugate Residuals"; break;
473  case KRYLOV_GMRES: retString = "GMRES"; break;
474  case KRYLOV_USERDEFINED: retString = "User Defined"; break;
475  case KRYLOV_LAST: retString = "Last Type (Dummy)"; break;
476  default: retString = "INVALID EKrylov";
477  }
478  return retString;
479  }
480 
486  inline int isValidKrylov(EKrylov d){
487  return( (d == KRYLOV_CG) ||
488  (d == KRYLOV_CR) ||
489  (d == KRYLOV_GMRES) ||
490  (d == KRYLOV_USERDEFINED) );
491  }
492 
493  inline EKrylov & operator++(EKrylov &type) {
494  return type = static_cast<EKrylov>(type+1);
495  }
496 
497  inline EKrylov operator++(EKrylov &type, int) {
498  EKrylov oldval = type;
499  ++type;
500  return oldval;
501  }
502 
503  inline EKrylov & operator--(EKrylov &type) {
504  return type = static_cast<EKrylov>(type-1);
505  }
506 
507  inline EKrylov operator--(EKrylov &type, int) {
508  EKrylov oldval = type;
509  --type;
510  return oldval;
511  }
512 
513  inline EKrylov StringToEKrylov(std::string s) {
514  s = removeStringFormat(s);
515  for ( EKrylov des = KRYLOV_CG; des < KRYLOV_LAST; des++ ) {
516  if ( !s.compare(removeStringFormat(EKrylovToString(des))) ) {
517  return des;
518  }
519  }
520  return KRYLOV_CG;
521  }
522 
547  };
548 
549  inline std::string ENonlinearCGToString(ENonlinearCG tr) {
550  std::string retString;
551  switch(tr) {
552  case NONLINEARCG_HESTENES_STIEFEL: retString = "Hestenes-Stiefel"; break;
553  case NONLINEARCG_FLETCHER_REEVES: retString = "Fletcher-Reeves"; break;
554  case NONLINEARCG_DANIEL: retString = "Daniel (uses Hessian)"; break;
555  case NONLINEARCG_POLAK_RIBIERE: retString = "Polak-Ribiere"; break;
556  case NONLINEARCG_FLETCHER_CONJDESC: retString = "Fletcher Conjugate Descent"; break;
557  case NONLINEARCG_LIU_STOREY: retString = "Liu-Storey"; break;
558  case NONLINEARCG_DAI_YUAN: retString = "Dai-Yuan"; break;
559  case NONLINEARCG_HAGER_ZHANG: retString = "Hager-Zhang"; break;
560  case NONLINEARCG_OREN_LUENBERGER: retString = "Oren-Luenberger"; break;
561  case NONLINEARCG_LAST: retString = "Last Type (Dummy)"; break;
562  default: retString = "INVALID ENonlinearCG";
563  }
564  return retString;
565  }
566 
573  return( (s == NONLINEARCG_HESTENES_STIEFEL) ||
575  (s == NONLINEARCG_DANIEL) ||
576  (s == NONLINEARCG_POLAK_RIBIERE) ||
578  (s == NONLINEARCG_LIU_STOREY) ||
579  (s == NONLINEARCG_DAI_YUAN) ||
580  (s == NONLINEARCG_HAGER_ZHANG) ||
582  );
583  }
584 
586  return type = static_cast<ENonlinearCG>(type+1);
587  }
588 
589  inline ENonlinearCG operator++(ENonlinearCG &type, int) {
590  ENonlinearCG oldval = type;
591  ++type;
592  return oldval;
593  }
594 
596  return type = static_cast<ENonlinearCG>(type-1);
597  }
598 
599  inline ENonlinearCG operator--(ENonlinearCG &type, int) {
600  ENonlinearCG oldval = type;
601  --type;
602  return oldval;
603  }
604 
605  inline ENonlinearCG StringToENonlinearCG(std::string s) {
606  s = removeStringFormat(s);
607  for ( ENonlinearCG nlcg = NONLINEARCG_HESTENES_STIEFEL; nlcg < NONLINEARCG_LAST; nlcg++ ) {
608  if ( !s.compare(removeStringFormat(ENonlinearCGToString(nlcg))) ) {
609  return nlcg;
610  }
611  }
613  }
614 
635  };
636 
637  inline std::string ELineSearchToString(ELineSearch ls) {
638  std::string retString;
639  switch(ls) {
640  case LINESEARCH_ITERATIONSCALING: retString = "Iteration Scaling"; break;
641  case LINESEARCH_PATHBASEDTARGETLEVEL: retString = "Path-Based Target Level"; break;
642  case LINESEARCH_BACKTRACKING: retString = "Backtracking"; break;
643  case LINESEARCH_BISECTION: retString = "Bisection"; break;
644  case LINESEARCH_GOLDENSECTION: retString = "Golden Section"; break;
645  case LINESEARCH_CUBICINTERP: retString = "Cubic Interpolation"; break;
646  case LINESEARCH_BRENTS: retString = "Brents"; break;
647  case LINESEARCH_USERDEFINED: retString = "User Defined"; break;
648  case LINESEARCH_LAST: retString = "Last Type (Dummy)"; break;
649  default: retString = "INVALID ELineSearch";
650  }
651  return retString;
652  }
653 
660  return( (ls == LINESEARCH_BACKTRACKING) ||
661  (ls == LINESEARCH_ITERATIONSCALING) ||
663  (ls == LINESEARCH_BISECTION) ||
664  (ls == LINESEARCH_GOLDENSECTION) ||
665  (ls == LINESEARCH_CUBICINTERP) ||
666  (ls == LINESEARCH_BRENTS) ||
667  (ls == LINESEARCH_USERDEFINED)
668  );
669  }
670 
672  return type = static_cast<ELineSearch>(type+1);
673  }
674 
675  inline ELineSearch operator++(ELineSearch &type, int) {
676  ELineSearch oldval = type;
677  ++type;
678  return oldval;
679  }
680 
682  return type = static_cast<ELineSearch>(type-1);
683  }
684 
685  inline ELineSearch operator--(ELineSearch &type, int) {
686  ELineSearch oldval = type;
687  --type;
688  return oldval;
689  }
690 
691  inline ELineSearch StringToELineSearch(std::string s) {
692  s = removeStringFormat(s);
693  for ( ELineSearch ls = LINESEARCH_ITERATIONSCALING; ls < LINESEARCH_LAST; ls++ ) {
694  if ( !s.compare(removeStringFormat(ELineSearchToString(ls))) ) {
695  return ls;
696  }
697  }
699  }
700 
716  };
717 
719  std::string retString;
720  switch(ls) {
721  case CURVATURECONDITION_WOLFE: retString = "Wolfe Conditions"; break;
722  case CURVATURECONDITION_STRONGWOLFE: retString = "Strong Wolfe Conditions"; break;
723  case CURVATURECONDITION_GENERALIZEDWOLFE: retString = "Generalized Wolfe Conditions"; break;
724  case CURVATURECONDITION_APPROXIMATEWOLFE: retString = "Approximate Wolfe Conditions"; break;
725  case CURVATURECONDITION_GOLDSTEIN: retString = "Goldstein Conditions"; break;
726  case CURVATURECONDITION_NULL: retString = "Null Curvature Condition"; break;
727  case CURVATURECONDITION_LAST: retString = "Last Type (Dummy)"; break;
728  default: retString = "INVALID ECurvatureCondition";
729  }
730  return retString;
731  }
732 
739  return( (ls == CURVATURECONDITION_WOLFE) ||
745  );
746  }
747 
749  return type = static_cast<ECurvatureCondition>(type+1);
750  }
751 
753  ECurvatureCondition oldval = type;
754  ++type;
755  return oldval;
756  }
757 
759  return type = static_cast<ECurvatureCondition>(type-1);
760  }
761 
763  ECurvatureCondition oldval = type;
764  --type;
765  return oldval;
766  }
767 
769  s = removeStringFormat(s);
771  if ( !s.compare(removeStringFormat(ECurvatureConditionToString(cc))) ) {
772  return cc;
773  }
774  }
776  }
777 
792  };
793 
794  inline std::string ETrustRegionToString(ETrustRegion tr) {
795  std::string retString;
796  switch(tr) {
797  case TRUSTREGION_CAUCHYPOINT: retString = "Cauchy Point"; break;
798  case TRUSTREGION_TRUNCATEDCG: retString = "Truncated CG"; break;
799  case TRUSTREGION_DOGLEG: retString = "Dogleg"; break;
800  case TRUSTREGION_DOUBLEDOGLEG: retString = "Double Dogleg"; break;
801  case TRUSTREGION_LAST: retString = "Last Type (Dummy)"; break;
802  default: retString = "INVALID ETrustRegion";
803  }
804  return retString;
805  }
806 
813  return( (ls == TRUSTREGION_CAUCHYPOINT) ||
814  (ls == TRUSTREGION_TRUNCATEDCG) ||
815  (ls == TRUSTREGION_DOGLEG) ||
817  );
818  }
819 
821  return type = static_cast<ETrustRegion>(type+1);
822  }
823 
824  inline ETrustRegion operator++(ETrustRegion &type, int) {
825  ETrustRegion oldval = type;
826  ++type;
827  return oldval;
828  }
829 
831  return type = static_cast<ETrustRegion>(type-1);
832  }
833 
834  inline ETrustRegion operator--(ETrustRegion &type, int) {
835  ETrustRegion oldval = type;
836  --type;
837  return oldval;
838  }
839 
840  inline ETrustRegion StringToETrustRegion(std::string s) {
841  s = removeStringFormat(s);
842  for ( ETrustRegion tr = TRUSTREGION_CAUCHYPOINT; tr < TRUSTREGION_LAST; tr++ ) {
843  if ( !s.compare(removeStringFormat(ETrustRegionToString(tr))) ) {
844  return tr;
845  }
846  }
848  }
849 
870  };
871 
872  inline std::string ETestObjectivesToString(ETestObjectives to) {
873  std::string retString;
874  switch(to) {
875  case TESTOBJECTIVES_ROSENBROCK: retString = "Rosenbrock's Function"; break;
876  case TESTOBJECTIVES_FREUDENSTEINANDROTH: retString = "Freudenstein and Roth's Function"; break;
877  case TESTOBJECTIVES_BEALE: retString = "Beale's Function"; break;
878  case TESTOBJECTIVES_POWELL: retString = "Powell's Badly Scaled Function"; break;
879  case TESTOBJECTIVES_SUMOFSQUARES: retString = "Sum of Squares Function"; break;
880  case TESTOBJECTIVES_LEASTSQUARES: retString = "Least Squares Function"; break;
881  case TESTOBJECTIVES_POISSONCONTROL: retString = "Poisson Optimal Control"; break;
882  case TESTOBJECTIVES_POISSONINVERSION: retString = "Poisson Inversion Problem"; break;
883  case TESTOBJECTIVES_ZAKHAROV: retString = "Zakharov's Function"; break;
884  case TESTOBJECTIVES_LAST: retString = "Last Type (Dummy)"; break;
885  default: retString = "INVALID ETestObjectives";
886  }
887  return retString;
888  }
889 
896  return( (to == TESTOBJECTIVES_ROSENBROCK) ||
898  (to == TESTOBJECTIVES_BEALE) ||
899  (to == TESTOBJECTIVES_POWELL) ||
900  (to == TESTOBJECTIVES_SUMOFSQUARES) ||
901  (to == TESTOBJECTIVES_LEASTSQUARES) ||
905  );
906  }
907 
909  return type = static_cast<ETestObjectives>(type+1);
910  }
911 
913  ETestObjectives oldval = type;
914  ++type;
915  return oldval;
916  }
917 
919  return type = static_cast<ETestObjectives>(type-1);
920  }
921 
923  ETestObjectives oldval = type;
924  --type;
925  return oldval;
926  }
927 
928  inline ETestObjectives StringToETestObjectives(std::string s) {
929  s = removeStringFormat(s);
931  if ( !s.compare(removeStringFormat(ETestObjectivesToString(to))) ) {
932  return to;
933  }
934  }
936  }
937 
959  };
960 
961  inline std::string ETestOptProblemToString(ETestOptProblem to) {
962  std::string retString;
963  switch(to) {
964  case TESTOPTPROBLEM_HS1: retString = "Hock and Schittkowski Test Problem #1"; break;
965  case TESTOPTPROBLEM_HS2: retString = "Hock and Schittkowski Test Problem #2"; break;
966  case TESTOPTPROBLEM_HS3: retString = "Hock and Schittkowski Test Problem #3"; break;
967  case TESTOPTPROBLEM_HS4: retString = "Hock and Schittkowski Test Problem #4"; break;
968  case TESTOPTPROBLEM_HS5: retString = "Hock and Schittkowski Test Problem #5"; break;
969  case TESTOPTPROBLEM_HS25: retString = "Hock and Schittkowski Test Problem #25"; break;
970  case TESTOPTPROBLEM_HS38: retString = "Hock and Schittkowski Test Problem #38"; break;
971  case TESTOPTPROBLEM_HS45: retString = "Hock and Schittkowski Test Problem #45"; break;
972  case TESTOPTPROBLEM_BVP: retString = "Boundary Value Problem"; break;
973  case TESTOPTPROBLEM_LAST: retString = "Last Type (Dummy)"; break;
974  default: retString = "INVALID ETestOptProblem";
975  }
976  return retString;
977  }
978 
985  return( (to == TESTOPTPROBLEM_HS1) ||
986  (to == TESTOPTPROBLEM_HS2) ||
987  (to == TESTOPTPROBLEM_HS3) ||
988  (to == TESTOPTPROBLEM_HS4) ||
989  (to == TESTOPTPROBLEM_HS5) ||
990  (to == TESTOPTPROBLEM_HS25) ||
991  (to == TESTOPTPROBLEM_HS38) ||
992  (to == TESTOPTPROBLEM_HS45) ||
993  (to == TESTOPTPROBLEM_BVP) );
994  }
995 
997  return type = static_cast<ETestOptProblem>(type+1);
998  }
999 
1001  ETestOptProblem oldval = type;
1002  ++type;
1003  return oldval;
1004  }
1005 
1007  return type = static_cast<ETestOptProblem>(type-1);
1008  }
1009 
1011  ETestOptProblem oldval = type;
1012  --type;
1013  return oldval;
1014  }
1015 
1017  s = removeStringFormat(s);
1018  for ( ETestOptProblem to = TESTOPTPROBLEM_HS1; to < TESTOPTPROBLEM_LAST; to++ ) {
1019  if ( !s.compare(removeStringFormat(ETestOptProblemToString(to))) ) {
1020  return to;
1021  }
1022  }
1023  return TESTOPTPROBLEM_HS1;
1024  }
1025 
1026 
1037  };
1038 
1039  inline std::string EConstraintToString(EConstraint c) {
1040  std::string retString;
1041  switch(c) {
1042  case CONSTRAINT_EQUALITY: retString = "Equality"; break;
1043  case CONSTRAINT_INEQUALITY: retString = "Inequality"; break;
1044  case CONSTRAINT_LAST: retString = "Last Type (Dummy)"; break;
1045  default: retString = "INVALID EConstraint";
1046  }
1047  return retString;
1048  }
1049 
1056  return( (c == CONSTRAINT_EQUALITY) ||
1057  (c == CONSTRAINT_INEQUALITY) );
1058  }
1059 
1061  return type = static_cast<EConstraint>(type+1);
1062  }
1063 
1064  inline EConstraint operator++(EConstraint &type, int) {
1065  EConstraint oldval = type;
1066  ++type;
1067  return oldval;
1068  }
1069 
1071  return type = static_cast<EConstraint>(type-1);
1072  }
1073 
1074  inline EConstraint operator--(EConstraint &type, int) {
1075  EConstraint oldval = type;
1076  --type;
1077  return oldval;
1078  }
1079 
1080  inline EConstraint StringToEConstraint(std::string s) {
1081  s = removeStringFormat(s);
1082  for ( EConstraint ctype = CONSTRAINT_EQUALITY; ctype < CONSTRAINT_LAST; ctype++ ) {
1083  if ( !s.compare(removeStringFormat(EConstraintToString(ctype))) ) {
1084  return ctype;
1085  }
1086  }
1087  return CONSTRAINT_EQUALITY;
1088  }
1089 
1090  // For use in gradient and Hessian checks
1091  namespace Finite_Difference_Arrays {
1092 
1093  // Finite difference steps in axpy form
1094  const int shifts[4][4] = { { 1, 0, 0, 0 }, // First order
1095  { -1, 2, 0, 0 }, // Second order
1096  { -1, 2, 1, 0 }, // Third order
1097  { -1, -1, 3, 1 } // Fourth order
1098  };
1099 
1100  // Finite difference weights
1101  const double weights[4][5] = { { -1.0, 1.0, 0.0, 0.0, 0.0 }, // First order
1102  { 0.0, -1.0/2.0, 1.0/2.0, 0.0, 0.0 }, // Second order
1103  { -1.0/2.0, -1.0/3.0, 1.0, -1.0/6.0, 0.0 }, // Third order
1104  { 0.0, -2.0/3.0, 1.0/12.0, 2.0/3.0, -1.0/12.0 } // Fourth order
1105  };
1106 
1107  }
1108 
1109 
1110 
1111 } // namespace ROL
1112 
1113 
1322 #endif
ETestOptProblem
Enumeration of test optimization problems.
Definition: ROL_Types.hpp:948
int isValidKrylov(EKrylov d)
Verifies validity of a Secant enum.
Definition: ROL_Types.hpp:486
EStep StringToEStep(std::string s)
Definition: ROL_Types.hpp:224
int isValidConstraint(EConstraint c)
Verifies validity of a Secant enum.
Definition: ROL_Types.hpp:1055
int isValidSecant(ESecant s)
Verifies validity of a Secant enum.
Definition: ROL_Types.hpp:415
EDistribution & operator--(EDistribution &type)
const double weights[4][5]
Definition: ROL_Types.hpp:1101
ELineSearch StringToELineSearch(std::string s)
Definition: ROL_Types.hpp:691
EBoundAlgorithm StringToEBoundAlgorithm(std::string s)
Definition: ROL_Types.hpp:292
EBoundAlgorithm
Enumeration of algorithms to handle bound constraints.
Definition: ROL_Types.hpp:241
int isValidBoundAlgorithm(EBoundAlgorithm d)
Verifies validity of a Bound Algorithm enum.
Definition: ROL_Types.hpp:265
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:141
ELineSearch
Enumeration of line-search types.
Definition: ROL_Types.hpp:625
static const double ROL_THRESHOLD
Tolerance for various equality tests.
Definition: ROL_Types.hpp:122
EConstraint StringToEConstraint(std::string s)
Definition: ROL_Types.hpp:1080
ESecant StringToESecant(std::string s)
Definition: ROL_Types.hpp:444
std::string EDescentToString(EDescent tr)
Definition: ROL_Types.hpp:321
int isValidTestOptProblem(ETestOptProblem to)
Verifies validity of a TestOptProblem enum.
Definition: ROL_Types.hpp:984
Teuchos::RCP< Vector< Real > > descentVec
Definition: ROL_Types.hpp:109
EKrylov
Enumeration of Krylov methods.
Definition: ROL_Types.hpp:460
int isValidTestObjectives(ETestObjectives to)
Verifies validity of a TestObjectives enum.
Definition: ROL_Types.hpp:895
int isValidTrustRegion(ETrustRegion ls)
Verifies validity of a TrustRegion enum.
Definition: ROL_Types.hpp:812
EKrylov StringToEKrylov(std::string s)
Definition: ROL_Types.hpp:513
EDescent StringToEDescent(std::string s)
Definition: ROL_Types.hpp:369
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:77
ENonlinearCG
Enumeration of nonlinear CG algorithms.
Definition: ROL_Types.hpp:536
ETestObjectives StringToETestObjectives(std::string s)
Definition: ROL_Types.hpp:928
std::string ECurvatureConditionToString(ECurvatureCondition ls)
Definition: ROL_Types.hpp:718
std::string EConstraintToString(EConstraint c)
Definition: ROL_Types.hpp:1039
ESecant
Enumeration of secant update algorithms.
Definition: ROL_Types.hpp:387
std::string ETestOptProblemToString(ETestOptProblem to)
Definition: ROL_Types.hpp:961
EDistribution & operator++(EDistribution &type)
std::string ENonlinearCGToString(ENonlinearCG tr)
Definition: ROL_Types.hpp:549
ENonlinearCG StringToENonlinearCG(std::string s)
Definition: ROL_Types.hpp:605
int isValidDescent(EDescent d)
Verifies validity of a Secant enum.
Definition: ROL_Types.hpp:340
std::string ELineSearchToString(ELineSearch ls)
Definition: ROL_Types.hpp:637
int isValidLineSearch(ELineSearch ls)
Verifies validity of a LineSearch enum.
Definition: ROL_Types.hpp:659
State for step class. Will be used for restarts.
Definition: ROL_Types.hpp:107
int isValidStep(EStep ls)
Verifies validity of a TrustRegion enum.
Definition: ROL_Types.hpp:193
ETestObjectives
Enumeration of test objective functions.
Definition: ROL_Types.hpp:859
static const double ROL_INF
Definition: ROL_Types.hpp:128
Teuchos::RCP< Vector< Real > > minIterVec
Definition: ROL_Types.hpp:93
std::string EKrylovToString(EKrylov tr)
Definition: ROL_Types.hpp:468
Teuchos::RCP< Vector< Real > > constraintVec
Definition: ROL_Types.hpp:110
int isValidCurvatureCondition(ECurvatureCondition ls)
Verifies validity of a CurvatureCondition enum.
Definition: ROL_Types.hpp:738
ETrustRegion StringToETrustRegion(std::string s)
Definition: ROL_Types.hpp:840
ECurvatureCondition
Enumeration of line-search curvature conditions.
Definition: ROL_Types.hpp:708
std::string ETestObjectivesToString(ETestObjectives to)
Definition: ROL_Types.hpp:872
Teuchos::RCP< Vector< Real > > lagmultVec
Definition: ROL_Types.hpp:92
Teuchos::RCP< Vector< Real > > iterateVec
Definition: ROL_Types.hpp:91
ECurvatureCondition StringToECurvatureCondition(std::string s)
Definition: ROL_Types.hpp:768
ETrustRegion
Enumeration of trust-region solver types.
Definition: ROL_Types.hpp:786
static const double ROL_NINF
Definition: ROL_Types.hpp:129
std::string ETrustRegionToString(ETrustRegion tr)
Definition: ROL_Types.hpp:794
std::string ESecantToString(ESecant tr)
Definition: ROL_Types.hpp:396
std::string EStepToString(EStep tr)
Definition: ROL_Types.hpp:171
EStep
Enumeration of step types.
Definition: ROL_Types.hpp:159
static const double ROL_OVERFLOW
Platform-dependent maximum double.
Definition: ROL_Types.hpp:126
EConstraint
Enumeration of constraint types.
Definition: ROL_Types.hpp:1033
ETestOptProblem StringToETestOptProblem(std::string s)
Definition: ROL_Types.hpp:1016
int isValidNonlinearCG(ENonlinearCG s)
Verifies validity of a NonlinearCG enum.
Definition: ROL_Types.hpp:572
std::string EBoundAlgorithmToString(EBoundAlgorithm tr)
Definition: ROL_Types.hpp:248
EDescent
Enumeration of descent direction types.
Definition: ROL_Types.hpp:312
Teuchos::RCP< Vector< Real > > gradientVec
Definition: ROL_Types.hpp:108
static const double ROL_UNDERFLOW
Platform-dependent minimum double.
Definition: ROL_Types.hpp:133
static const double ROL_EPSILON
Platform-dependent machine epsilon.
Definition: ROL_Types.hpp:118