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 #include "ROL_Types.hpp"
53 
54 namespace ROL {
55 
71  };
72 
73  inline std::string ETrustRegionToString(ETrustRegion tr) {
74  std::string retString;
75  switch(tr) {
76  case TRUSTREGION_CAUCHYPOINT: retString = "Cauchy Point"; break;
77  case TRUSTREGION_TRUNCATEDCG: retString = "Truncated CG"; break;
78  case TRUSTREGION_DOGLEG: retString = "Dogleg"; break;
79  case TRUSTREGION_DOUBLEDOGLEG: retString = "Double Dogleg"; break;
80  case TRUSTREGION_LINMORE: retString = "Lin-More"; break;
81  case TRUSTREGION_LAST: retString = "Last Type (Dummy)"; break;
82  default: retString = "INVALID ETrustRegion";
83  }
84  return retString;
85  }
86 
93  return( (ls == TRUSTREGION_CAUCHYPOINT) ||
94  (ls == TRUSTREGION_TRUNCATEDCG) ||
95  (ls == TRUSTREGION_DOGLEG) ||
96  (ls == TRUSTREGION_DOUBLEDOGLEG) ||
97  (ls == TRUSTREGION_LINMORE)
98  );
99  }
100 
102  return type = static_cast<ETrustRegion>(type+1);
103  }
104 
105  inline ETrustRegion operator++(ETrustRegion &type, int) {
106  ETrustRegion oldval = type;
107  ++type;
108  return oldval;
109  }
110 
112  return type = static_cast<ETrustRegion>(type-1);
113  }
114 
115  inline ETrustRegion operator--(ETrustRegion &type, int) {
116  ETrustRegion oldval = type;
117  --type;
118  return oldval;
119  }
120 
121  inline ETrustRegion StringToETrustRegion(std::string s) {
122  s = removeStringFormat(s);
123  for ( ETrustRegion tr = TRUSTREGION_CAUCHYPOINT; tr < TRUSTREGION_LAST; tr++ ) {
124  if ( !s.compare(removeStringFormat(ETrustRegionToString(tr))) ) {
125  return tr;
126  }
127  }
129  }
130 
142  };
143 
145  std::string retString;
146  switch(tr) {
147  case TRUSTREGION_MODEL_COLEMANLI: retString = "Coleman-Li"; break;
148  case TRUSTREGION_MODEL_KELLEYSACHS: retString = "Kelley-Sachs"; break;
149  case TRUSTREGION_MODEL_LINMORE: retString = "Lin-More"; break;
150  case TRUSTREGION_MODEL_LAST: retString = "Last Type (Dummy)"; break;
151  default: retString = "INVALID ETrustRegionModel";
152  }
153  return retString;
154  }
155 
162  return( (ls == TRUSTREGION_MODEL_COLEMANLI) ||
165  );
166  }
167 
169  return type = static_cast<ETrustRegionModel>(type+1);
170  }
171 
173  ETrustRegionModel oldval = type;
174  ++type;
175  return oldval;
176  }
177 
179  return type = static_cast<ETrustRegionModel>(type-1);
180  }
181 
183  ETrustRegionModel oldval = type;
184  --type;
185  return oldval;
186  }
187 
189  s = removeStringFormat(s);
191  if ( !s.compare(removeStringFormat(ETrustRegionModelToString(tr))) ) {
192  return tr;
193  }
194  }
196  }
197 
198  inline bool isValidTrustRegionSubproblem(ETrustRegion etr, ETrustRegionModel etrm, bool isBnd) {
199  if (etrm != TRUSTREGION_MODEL_LINMORE || !isBnd) {
200  switch(etr) {
201  case TRUSTREGION_CAUCHYPOINT: return true;
202  case TRUSTREGION_DOGLEG: return true;
203  case TRUSTREGION_DOUBLEDOGLEG: return true;
204  case TRUSTREGION_TRUNCATEDCG: return true;
205  case TRUSTREGION_LINMORE: return false;
206  default: return false;
207  }
208  }
209  else {
210  switch(etr) {
211  case TRUSTREGION_CAUCHYPOINT: return false;
212  case TRUSTREGION_DOGLEG: return false;
213  case TRUSTREGION_DOUBLEDOGLEG: return false;
214  case TRUSTREGION_TRUNCATEDCG: return false;
215  case TRUSTREGION_LINMORE: return true;
216  default: return false;
217  }
218  }
219  }
220 
240  };
241 
242 
243  inline std::string ETrustRegionFlagToString(ETrustRegionFlag trf) {
244  std::string retString;
245  switch(trf) {
247  retString = "Both actual and predicted reductions are positive (success)";
248  break;
250  retString = "Actual reduction is positive and predicted reduction is negative (impossible)";
251  break;
253  retString = "Actual reduction is nonpositive and predicted reduction is positive";
254  break;
256  retString = "Actual reduction is nonpositive and predicted reduction is negative (impossible)";
257  break;
259  retString = "Sufficient decrease of the quadratic model not met (bound constraints only)";
260  break;
262  retString = "Actual and/or predicted reduction is a NaN";
263  break;
264  default:
265  retString = "INVALID ETrustRegionFlag";
266  }
267  return retString;
268  }
269 
270 
271 
272 
273 
274 }
275 
276 #endif
std::string ETrustRegionModelToString(ETrustRegionModel tr)
EPolyProjAlgo & operator++(EPolyProjAlgo &type)
Contains definitions of custom data types in ROL.
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:249
bool isValidTrustRegionSubproblem(ETrustRegion etr, ETrustRegionModel etrm, bool isBnd)
int isValidTrustRegion(ETrustRegion ls)
Verifies validity of a TrustRegion enum.
EPolyProjAlgo & operator--(EPolyProjAlgo &type)
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)
ETrustRegionFlag
Enumation of flags used by trust-region solvers.
std::string ETrustRegionToString(ETrustRegion tr)
int isValidTrustRegionModel(ETrustRegionModel ls)
Verifies validity of a TrustRegionModel enum.