45 #ifndef ROL_PARAMETER_LIST_CONVERTERS_H
46 #define ROL_PARAMETER_LIST_CONVERTERS_H
50 #include "ROL_ParameterList.hpp"
55 namespace StringList {
58 inline std::vector<std::string>
join(
const std::string &s1,
59 const std::string &s2 ) {
60 std::vector<std::string> v;
68 inline std::vector<std::string>
join(
const std::string &s1,
69 const std::string &s2,
70 const std::string &s3 ) {
71 std::vector<std::string> v;
80 inline std::vector<std::string>
join(
const std::string &s1,
81 const std::string &s2,
82 const std::string &s3,
83 const std::string &s4 ) {
84 std::vector<std::string> v;
94 inline std::vector<std::string>
join(
const std::string &s1,
95 const std::string &s2,
96 const std::string &s3,
97 const std::string &s4,
98 const std::string &s5 ) {
99 std::vector<std::string> v;
111 template<
class ParameterType>
113 const std::vector<std::string> &location,
114 const std::vector<std::string>::iterator iter,
115 ParameterType
value ) {
117 if( iter == location.end()-1 ) {
118 parlist.set(*iter,value);
121 ROL::ParameterList &sublist = parlist.sublist(*iter);
132 const ROL::ParameterList &inList ) {
136 typedef std::string Str;
137 typedef std::vector<Str> Vec;
138 typedef std::map<Str,Vec> Map;
139 typedef ParameterList::ConstIterator IterPL;
140 typedef typename Vec::iterator IterVec;
141 typedef typename Map::iterator IterMap;
146 dict[
"Use Inexact Gradient"] =
join(
"General",
"Inexact Gradient");
147 dict[
"Use Inexact Objective Function"] =
join(
"General",
"Inexact Objective Function");
148 dict[
"Use Inexact Hessian-Times-A-Vector"] =
join(
"General",
"Inexact Hessian-Times-A-Vector");
149 dict[
"Use Projected Gradient Criticality Measure"] =
join(
"General",
"Projected Gradient Criticality Measure");
150 dict[
"Scale for Epsilon Active Sets"] =
join(
"General",
"Scale for Epsilon Active Sets");
152 dict[
"Absolute Krylov Tolerance"] =
join(
"General",
"Krylov",
"Absolute Tolerance");
153 dict[
"Relative Krylov Tolerance"] =
join(
"General",
"Krylov",
"Relative Tolerance");
154 dict[
"Maximum Number of Krylov Iterations"] =
join(
"General",
"Krylov",
"Iteration Limit");
155 dict[
"Krylov Type"] =
join(
"General",
"Krylov",
"Type");
157 dict[
"Barzilai-Borwein"] =
join(
"General",
"Secant",
"Barzilai-Borwein");
158 dict[
"Maximum Secant Storage"] =
join(
"General",
"Secant",
"Maximum Storage");
159 dict[
"Secant Type"] =
join(
"General",
"Secant",
"Type");
160 dict[
"Use Secant Hessian-Times-A-Vector"] =
join(
"General",
"Secant",
"Use as Hessian");
161 dict[
"Use Secant Preconditioning"] =
join(
"General",
"Secant",
"Use as Preconditioner");
163 dict[
"Gradient Tolerance"] =
join(
"Status Test",
"Gradient Tolerance");
164 dict[
"Maximum Number of Iterations"] =
join(
"Status Test",
"Iteration Limit");
165 dict[
"Step Tolerance"] =
join(
"Status Test",
"Step Tolerance");
167 dict[
"Accept Last Alpha"] =
join(
"Step",
"Line Search",
"Accept Last Alpha");
168 dict[
"Accept Linesearch Minimizer"] =
join(
"Step",
"Line Search",
"Accept Linesearch Minimizer");
169 dict[
"Maximum Number of Function Evaluations"] =
join(
"Step",
"Line Search",
"Function Evaluation Limit");
170 dict[
"Initial Linesearch Parameter"] =
join(
"Step",
"Line Search",
"Initial Step Size");
171 dict[
"Sufficient Decrease Parameter"] =
join(
"Step",
"Line Search",
"Sufficient Decrease Tolerance");
172 dict[
"User Defined Linesearch Parameter"] =
join(
"Step",
"Line Search",
"User Defined Initial Step Size");
174 dict[
"Curvature Conditions Parameter"] =
join(
"Step",
"Line Search",
"Curvature Condition",
"General Parameter");
175 dict[
"Curvature Conditions Parameter: Generalized Wolfe"] =
join(
"Step",
"Line Search",
"Curvature Condition",
"Generalized Wolfe Parameter");
176 dict[
"Linesearch Curvature Condition"] =
join(
"Step",
"Line Search",
"Curvature Condition",
"Type");
178 dict[
"Nonlinear CG Type"] =
join(
"Step",
"Line Search",
"Descent Method",
"Nonlinear CG Type");
179 dict[
"Descent Type"] =
join(
"Step",
"Line Search",
"Descent Method",
"Type");
181 dict[
"Backtracking Rate"] =
join(
"Step",
"Line Search",
"Line-Search Method",
"Backtracking Rate");
182 dict[
"Bracketing Tolerance"] =
join(
"Step",
"Line Search",
"Line-Search Method",
"Bracketing Tolerance");
183 dict[
"Linesearch Type"] =
join(
"Step",
"Line Search",
"Line-Search Method",
"Type");
185 dict[
"Initial Trust-Region Radius"] =
join(
"Step",
"Trust Region",
"Initial Radius");
186 dict[
"Maximum Trust-Region Radius"] =
join(
"Step",
"Trust Region",
"Maximum Radius");
187 dict[
"Radius Growing Threshold"] =
join(
"Step",
"Trust Region",
"Radius Growing Threshold");
188 dict[
"Radius Growing Rate"] =
join(
"Step",
"Trust Region",
"Radius Growing Rate");
189 dict[
"Radius Shrinking Threshold"] =
join(
"Step",
"Trust Region",
"Radius Shrinking Threshold");
190 dict[
"Trust-Region Safeguard"] =
join(
"Step",
"Trust Region",
"Safeguard Size");
191 dict[
"Trust-Region Subproblem Solver Type"] =
join(
"Step",
"Trust Region",
"Subproblem Solver");
192 dict[
"Step Acceptance Parameter"] =
join(
"Step",
"Trust Region",
"Step Acceptance Threshold");
194 dict[
"Gradient Update Relative Tolerance"] =
join(
"Step",
"Trust Region",
"Gradient",
"Relative Tolerance");
195 dict[
"Gradient Update Tolerance Scaling"] =
join(
"Step",
"Trust Region",
"Gradient",
"Tolerance Scaling");
196 dict[
"Value Update Exponent"] =
join(
"Step",
"Trust Region",
"Inexact",
"Value",
"Exponent");
197 dict[
"Value Update Forcing Sequence Initial Value"] =
join(
"Step",
"Trust Region",
"Inexact",
"Value",
"Forcing Sequence Initial Value");
198 dict[
"Value Update Forcing Sequence Reduction Factor"] =
join(
"Step",
"Trust Region",
"Inexact",
"Value",
"Forcing Sequence Reduction Factor");
199 dict[
"Value Update Forcing Sequence Update Frequency"] =
join(
"Step",
"Trust Region",
"Inexact",
"Value",
"Forcing Sequence Update Frequency");
200 dict[
"Value Update Tolerance Scaling"] =
join(
"Step",
"Trust Region",
"Inexact",
"Value",
"Tolerance Scaling");
204 for(IterMap itmap = dict.begin(); itmap != dict.end(); ++itmap) {
205 Str key = itmap->first;
206 Vec
value = itmap->second;
212 for(IterPL itpl = inList.begin(); itpl != inList.end(); ++itpl) {
215 Str key( inList.name(itpl) );
221 if(location.size() != 0) {
223 IterVec itvec = location.begin();
225 if( inList.isType<
bool>(key) ) {
226 bool value = inList.get<
bool>( key );
229 else if( inList.isType<
int>(key) ) {
230 int value = inList.get<
int>( key );
233 else if( inList.isType<
double>(key) ) {
234 double value = inList.get<
double>( key );
237 else if( inList.isType<std::string>(key) ) {
238 std::string
value = inList.get<std::string>( key );
242 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
243 ">>>Error: Unhandled parameter type." );
void setParameter(ROL::ParameterList &parlist, const std::vector< std::string > &location, const std::vector< std::string >::iterator iter, ParameterType value)
Contains definitions of custom data types in ROL.
std::string removeStringFormat(std::string s)
ROL::Objective_SimOpt value
std::vector< std::string > join(const std::string &s1, const std::string &s2)
Helper function for making vectors of strings.
void tierParameterList(ROL::ParameterList &outList, const ROL::ParameterList &inList)
Produce a heirarchical parameter list using the new names from a flat list of the old names...