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 
69  };
70 
71  inline std::string ETrustRegionToString(ETrustRegion tr) {
72  std::string retString;
73  switch(tr) {
74  case TRUSTREGION_CAUCHYPOINT: retString = "Cauchy Point"; break;
75  case TRUSTREGION_TRUNCATEDCG: retString = "Truncated CG"; break;
76  case TRUSTREGION_DOGLEG: retString = "Dogleg"; break;
77  case TRUSTREGION_DOUBLEDOGLEG: retString = "Double Dogleg"; break;
78  case TRUSTREGION_LINMORE: retString = "Lin-More"; break;
79  case TRUSTREGION_LAST: retString = "Last Type (Dummy)"; break;
80  default: retString = "INVALID ETrustRegion";
81  }
82  return retString;
83  }
84 
91  return( (ls == TRUSTREGION_CAUCHYPOINT) ||
92  (ls == TRUSTREGION_TRUNCATEDCG) ||
93  (ls == TRUSTREGION_DOGLEG) ||
94  (ls == TRUSTREGION_DOUBLEDOGLEG) ||
95  (ls == TRUSTREGION_LINMORE)
96  );
97  }
98 
100  return type = static_cast<ETrustRegion>(type+1);
101  }
102 
103  inline ETrustRegion operator++(ETrustRegion &type, int) {
104  ETrustRegion oldval = type;
105  ++type;
106  return oldval;
107  }
108 
110  return type = static_cast<ETrustRegion>(type-1);
111  }
112 
113  inline ETrustRegion operator--(ETrustRegion &type, int) {
114  ETrustRegion oldval = type;
115  --type;
116  return oldval;
117  }
118 
119  inline ETrustRegion StringToETrustRegion(std::string s) {
120  s = removeStringFormat(s);
121  for ( ETrustRegion tr = TRUSTREGION_CAUCHYPOINT; tr < TRUSTREGION_LAST; tr++ ) {
122  if ( !s.compare(removeStringFormat(ETrustRegionToString(tr))) ) {
123  return tr;
124  }
125  }
127  }
128 
140  };
141 
143  std::string retString;
144  switch(tr) {
145  case TRUSTREGION_MODEL_COLEMANLI: retString = "Coleman-Li"; break;
146  case TRUSTREGION_MODEL_KELLEYSACHS: retString = "Kelley-Sachs"; break;
147  case TRUSTREGION_MODEL_LINMORE: retString = "Lin-More"; break;
148  case TRUSTREGION_MODEL_LAST: retString = "Last Type (Dummy)"; break;
149  default: retString = "INVALID ETrustRegionModel";
150  }
151  return retString;
152  }
153 
160  return( (ls == TRUSTREGION_MODEL_COLEMANLI) ||
163  );
164  }
165 
167  return type = static_cast<ETrustRegionModel>(type+1);
168  }
169 
171  ETrustRegionModel oldval = type;
172  ++type;
173  return oldval;
174  }
175 
177  return type = static_cast<ETrustRegionModel>(type-1);
178  }
179 
181  ETrustRegionModel oldval = type;
182  --type;
183  return oldval;
184  }
185 
187  s = removeStringFormat(s);
189  if ( !s.compare(removeStringFormat(ETrustRegionModelToString(tr))) ) {
190  return tr;
191  }
192  }
194  }
195 
196  inline bool isValidTrustRegionSubproblem(ETrustRegion etr, ETrustRegionModel etrm, bool isBnd) {
197  if (etrm != TRUSTREGION_MODEL_LINMORE || !isBnd) {
198  switch(etr) {
199  case TRUSTREGION_CAUCHYPOINT: return true;
200  case TRUSTREGION_DOGLEG: return true;
201  case TRUSTREGION_DOUBLEDOGLEG: return true;
202  case TRUSTREGION_TRUNCATEDCG: return true;
203  case TRUSTREGION_LINMORE: return false;
204  default: return false;
205  }
206  }
207  else {
208  switch(etr) {
209  case TRUSTREGION_CAUCHYPOINT: return false;
210  case TRUSTREGION_DOGLEG: return false;
211  case TRUSTREGION_DOUBLEDOGLEG: return false;
212  case TRUSTREGION_TRUNCATEDCG: return false;
213  case TRUSTREGION_LINMORE: return true;
214  default: return false;
215  }
216  }
217  }
218 
238  };
239 
240 
241  inline std::string ETrustRegionFlagToString(ETrustRegionFlag trf) {
242  std::string retString;
243  switch(trf) {
245  retString = "Both actual and predicted reductions are positive (success)";
246  break;
248  retString = "Actual reduction is positive and predicted reduction is negative (impossible)";
249  break;
251  retString = "Actual reduction is nonpositive and predicted reduction is positive";
252  break;
254  retString = "Actual reduction is nonpositive and predicted reduction is negative (impossible)";
255  break;
257  retString = "Sufficient decrease of the quadratic model not met (bound constraints only)";
258  break;
260  retString = "Actual and/or predicted reduction is a NaN";
261  break;
262  default:
263  retString = "INVALID ETrustRegionFlag";
264  }
265  return retString;
266  }
267 
268 
269 
270 
271 
272 }
273 
274 #endif
std::string ETrustRegionModelToString(ETrustRegionModel tr)
EKrylov & operator++(EKrylov &type)
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:247
bool isValidTrustRegionSubproblem(ETrustRegion etr, ETrustRegionModel etrm, bool isBnd)
int isValidTrustRegion(ETrustRegion ls)
Verifies validity of a TrustRegion enum.
ETrustRegionModel StringToETrustRegionModel(std::string s)
ETrustRegionModel
Enumeration of trust-region model types.
ETrustRegion StringToETrustRegion(std::string s)
ETrustRegion
Enumeration of trust-region solver types.
std::string ETrustRegionFlagToString(ETrustRegionFlag trf)
EKrylov & operator--(EKrylov &type)
ETrustRegionFlag
Enumation of flags used by trust-region solvers.
std::string ETrustRegionToString(ETrustRegion tr)
int isValidTrustRegionModel(ETrustRegionModel ls)
Verifies validity of a TrustRegionModel enum.