67 #include "json/json.h"
68 #include "Teuchos_ParameterList.hpp"
77 void addJSONBlockToPL(
const Json::Value& block,Teuchos::ParameterList& parlist);
78 void addJSONPairToPL(
const Json::Value& block,
const std::string &key,Teuchos::ParameterList& parlist);
89 const std::string &key,
90 Teuchos::ParameterList& parlist) {
92 Json::Value val = block[key];
95 parlist.set(key,val.asString());
96 }
else if(val.isBool()) {
97 parlist.set(key,val.asBool());
98 }
else if(val.isInt()) {
99 parlist.set(key,val.asInt());
100 }
else if(val.isUInt()) {
101 parlist.set(key,val.asUInt());
102 }
else if(val.isDouble()) {
103 parlist.set(key,val.asDouble());
104 }
else if(val.isObject()) {
108 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
">>> ERROR (addJSONPairToPL, "
109 "json value has unsupported type.");
120 Teuchos::ParameterList& parlist) {
122 for(Json::ValueIterator itr = block.begin(); itr != block.end(); ++itr) {
139 Teuchos::ParameterList& parlist) {
142 std::ifstream stream(jsonFileName, std::ifstream::binary);
145 if(json.isMember(
"ROL")) {
146 Json::Value rolBlock = json[
"ROL"];
152 if(rolBlock.isMember(
"Algorithm")) {
153 std::string rolAlgorithm = rolBlock[
"Algorithm"].asString();
155 if(rolAlgorithm.find(
"Trust-Region") != std::string::npos) {
157 parlist.set(
"Step Type",
"Trust-Region");
160 if(rolAlgorithm.find(
"Cauchy Point") != std::string::npos) {
161 parlist.set(
"Trust-Region Subproblem Solver Type",
"Cauchy Point");
163 else if(rolAlgorithm.find(
"Double Dogleg") != std::string::npos) {
164 parlist.set(
"Trust-Region Subproblem Solver Type",
"Double Dogleg");
166 else if(rolAlgorithm.find(
"Dogleg") != std::string::npos) {
167 parlist.set(
"Trust-Region Subproblem Solver Type",
"Dogleg");
169 else if(rolAlgorithm.find(
"Truncated CG") != std::string::npos) {
170 parlist.set(
"Trust-Region Subproblem Solver Type",
"Truncated CG");
175 parlist.set(
"Step Type",
"Linesearch");
178 if(rolAlgorithm.find(
"Steepest Descent") != std::string::npos) {
179 parlist.set(
"Descent Type",
"Steepest Descent");
181 else if(rolAlgorithm.find(
"Quasi-Newton") != std::string::npos) {
182 parlist.set(
"Descent Type",
"Quasi-Newton Method");
184 else if(rolAlgorithm.find(
"Newton-Krylov") != std::string::npos) {
185 parlist.set(
"Descent Type",
"Newton-Krylov");
187 else if(rolAlgorithm.find(
"Nonlinear CG") != std::string::npos) {
188 parlist.set(
"Descent Type",
"Nonlinear CG");
195 parlist.set(
"Step Type",
"Linesearch");
196 parlist.set(
"Descent Type",
"Nonlinear CG");
208 template <
class Real>
211 if(parlist.get(
"Step Type",
"Linesearch")==
"Trust-Region") {
void stepFactory(Teuchos::ParameterList &parlist, Teuchos::RCP< ROL::Step< Real > > &step)
A minimalist step factory which specializes the Step Type depending on whether a Trust-Region or Line...
Provides the interface to compute optimization steps.
Provides the interface to compute optimization steps with line search.
void addJSONBlockToPL(const Json::Value &block, Teuchos::ParameterList &parlist)
Iterate over a block and insert key-value pairs into the Teuchos::ParameterList.
void JSON_Parameters(const std::string &jsonFileName, Teuchos::ParameterList &parlist)
Read a JSON file and store all parameters in a Teuchos::ParameterList. Checks for a key called "Algor...
void addJSONPairToPL(const Json::Value &block, const std::string &key, Teuchos::ParameterList &parlist)
Given a JSON block and a key, get the value and insert the key-value pair into a Teuchos::ParameterLi...
Provides the interface to compute optimization steps with trust regions.