ROL
ROL_TrustRegionTypes.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_TRUSTREGIONTYPES_HPP
50 #define ROL_TRUSTREGIONTYPES_HPP
51 
52 namespace ROL {
53 
68  };
69 
70  inline std::string ETrustRegionToString(ETrustRegion tr) {
71  std::string retString;
72  switch(tr) {
73  case TRUSTREGION_CAUCHYPOINT: retString = "Cauchy Point"; break;
74  case TRUSTREGION_TRUNCATEDCG: retString = "Truncated CG"; break;
75  case TRUSTREGION_DOGLEG: retString = "Dogleg"; break;
76  case TRUSTREGION_DOUBLEDOGLEG: retString = "Double Dogleg"; break;
77  case TRUSTREGION_LAST: retString = "Last Type (Dummy)"; break;
78  default: retString = "INVALID ETrustRegion";
79  }
80  return retString;
81  }
82 
89  return( (ls == TRUSTREGION_CAUCHYPOINT) ||
90  (ls == TRUSTREGION_TRUNCATEDCG) ||
91  (ls == TRUSTREGION_DOGLEG) ||
93  );
94  }
95 
97  return type = static_cast<ETrustRegion>(type+1);
98  }
99 
100  inline ETrustRegion operator++(ETrustRegion &type, int) {
101  ETrustRegion oldval = type;
102  ++type;
103  return oldval;
104  }
105 
107  return type = static_cast<ETrustRegion>(type-1);
108  }
109 
110  inline ETrustRegion operator--(ETrustRegion &type, int) {
111  ETrustRegion oldval = type;
112  --type;
113  return oldval;
114  }
115 
116  inline ETrustRegion StringToETrustRegion(std::string s) {
117  s = removeStringFormat(s);
118  for ( ETrustRegion tr = TRUSTREGION_CAUCHYPOINT; tr < TRUSTREGION_LAST; tr++ ) {
119  if ( !s.compare(removeStringFormat(ETrustRegionToString(tr))) ) {
120  return tr;
121  }
122  }
124  }
125 
136  };
137 
139  std::string retString;
140  switch(tr) {
141  case TRUSTREGION_MODEL_COLEMANLI: retString = "Coleman-Li"; break;
142  case TRUSTREGION_MODEL_KELLEYSACHS: retString = "Kelley-Sachs"; break;
143  case TRUSTREGION_MODEL_LAST: retString = "Last Type (Dummy)"; break;
144  default: retString = "INVALID ETrustRegionModel";
145  }
146  return retString;
147  }
148 
155  return( (ls == TRUSTREGION_MODEL_COLEMANLI) ||
157  );
158  }
159 
161  return type = static_cast<ETrustRegionModel>(type+1);
162  }
163 
165  ETrustRegionModel oldval = type;
166  ++type;
167  return oldval;
168  }
169 
171  return type = static_cast<ETrustRegionModel>(type-1);
172  }
173 
175  ETrustRegionModel oldval = type;
176  --type;
177  return oldval;
178  }
179 
181  s = removeStringFormat(s);
183  if ( !s.compare(removeStringFormat(ETrustRegionModelToString(tr))) ) {
184  return tr;
185  }
186  }
188  }
189 
209  };
210 
211 
212  inline std::string ETrustRegionFlagToString(ETrustRegionFlag trf) {
213  std::string retString;
214  switch(trf) {
216  retString = "Both actual and predicted reductions are positive (success)";
217  break;
219  retString = "Actual reduction is positive and predicted reduction is negative (impossible)";
220  break;
222  retString = "Actual reduction is nonpositive and predicted reduction is positive";
223  break;
225  retString = "Actual reduction is nonpositive and predicted reduction is negative (impossible)";
226  break;
228  retString = "Sufficient decrease of the quadratic model not met (bound constraints only)";
229  break;
231  retString = "Actual and/or predicted reduction is a NaN";
232  break;
233  default:
234  retString = "INVALID ETrustRegionFlag";
235  }
236  return retString;
237  }
238 
239 
240 
241 
242 
243 }
244 
245 #endif
std::string ETrustRegionModelToString(ETrustRegionModel tr)
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:174
int isValidTrustRegion(ETrustRegion ls)
Verifies validity of a TrustRegion enum.
ETrustRegionModel StringToETrustRegionModel(std::string s)
ETrustRegion & operator--(ETrustRegion &type)
ETrustRegionModel
Enumeration of trust-region model types.
ETrustRegion StringToETrustRegion(std::string s)
ETrustRegion
Enumeration of trust-region solver types.
std::string ETrustRegionFlagToString(ETrustRegionFlag trf)
ETrustRegionFlag
Enumation of flags used by trust-region solvers.
std::string ETrustRegionToString(ETrustRegion tr)
ETrustRegion & operator++(ETrustRegion &type)
int isValidTrustRegionModel(ETrustRegionModel ls)
Verifies validity of a TrustRegionModel enum.