NonlinearOptimizerParams.cpp
Go to the documentation of this file.
1 
12 
13 namespace gtsam {
14 
15 /* ************************************************************************* */
17  const std::string &src) {
18  std::string s = src;
19  // Convert to upper case
20  std::transform(s.begin(), s.end(), s.begin(), ::toupper);
21  if (s == "SILENT")
23  if (s == "ERROR")
25  if (s == "VALUES")
27  if (s == "DELTA")
29  if (s == "LINEAR")
31  if (s == "TERMINATION")
33 
34  /* default is silent */
36 }
37 
38 /* ************************************************************************* */
40  Verbosity value) {
41  std::string s;
42  switch (value) {
44  s = "SILENT";
45  break;
47  s = "TERMINATION";
48  break;
50  s = "ERROR";
51  break;
53  s = "VALUES";
54  break;
56  s = "DELTA";
57  break;
59  s = "LINEAR";
60  break;
61  default:
62  s = "UNDEFINED";
63  break;
64  }
65  return s;
66 }
67 
68 /* ************************************************************************* */
70  const std::shared_ptr<IterativeOptimizationParameters> params) {
72 }
73 
74 /* ************************************************************************* */
75 void NonlinearOptimizerParams::print(const std::string& str) const {
76 
77  //NonlinearOptimizerParams::print(str);
78  std::cout << str << "\n";
79  std::cout << "relative decrease threshold: " << relativeErrorTol << "\n";
80  std::cout << "absolute decrease threshold: " << absoluteErrorTol << "\n";
81  std::cout << " total error threshold: " << errorTol << "\n";
82  std::cout << " maximum iterations: " << maxIterations << "\n";
83  std::cout << " verbosity: " << verbosityTranslator(verbosity)
84  << "\n";
85  std::cout.flush();
86 
87  switch (linearSolverType) {
89  std::cout << " linear solver type: MULTIFRONTAL CHOLESKY\n";
90  break;
91  case MULTIFRONTAL_QR:
92  std::cout << " linear solver type: MULTIFRONTAL QR\n";
93  break;
95  std::cout << " linear solver type: SEQUENTIAL CHOLESKY\n";
96  break;
97  case SEQUENTIAL_QR:
98  std::cout << " linear solver type: SEQUENTIAL QR\n";
99  break;
100  case CHOLMOD:
101  std::cout << " linear solver type: CHOLMOD\n";
102  break;
103  case Iterative:
104  std::cout << " linear solver type: ITERATIVE\n";
105  break;
106  default:
107  std::cout << " linear solver type: (invalid)\n";
108  break;
109  }
110 
111  switch (orderingType){
112  case Ordering::COLAMD:
113  std::cout << " ordering: COLAMD\n";
114  break;
115  case Ordering::METIS:
116  std::cout << " ordering: METIS\n";
117  break;
118  default:
119  std::cout << " ordering: custom\n";
120  break;
121  }
122 
123  std::cout.flush();
124 }
125 
126 /* ************************************************************************* */
129  switch (linearSolverType) {
131  return "MULTIFRONTAL_CHOLESKY";
132  case MULTIFRONTAL_QR:
133  return "MULTIFRONTAL_QR";
134  case SEQUENTIAL_CHOLESKY:
135  return "SEQUENTIAL_CHOLESKY";
136  case SEQUENTIAL_QR:
137  return "SEQUENTIAL_QR";
138  case Iterative:
139  return "ITERATIVE";
140  case CHOLMOD:
141  return "CHOLMOD";
142  default:
143  throw std::invalid_argument(
144  "Unknown linear solver type in SuccessiveLinearizationOptimizer");
145  }
146 }
147 
148 /* ************************************************************************* */
150  const std::string& linearSolverType) const {
151  if (linearSolverType == "MULTIFRONTAL_CHOLESKY")
152  return MULTIFRONTAL_CHOLESKY;
153  if (linearSolverType == "MULTIFRONTAL_QR")
154  return MULTIFRONTAL_QR;
155  if (linearSolverType == "SEQUENTIAL_CHOLESKY")
156  return SEQUENTIAL_CHOLESKY;
157  if (linearSolverType == "SEQUENTIAL_QR")
158  return SEQUENTIAL_QR;
159  if (linearSolverType == "ITERATIVE")
160  return Iterative;
161  if (linearSolverType == "CHOLMOD")
162  return CHOLMOD;
163  throw std::invalid_argument(
164  "Unknown linear solver type in SuccessiveLinearizationOptimizer");
165 }
166 
167 /* ************************************************************************* */
170  switch (type) {
171  case Ordering::METIS:
172  return "METIS";
173  case Ordering::COLAMD:
174  return "COLAMD";
175  default:
176  if (ordering)
177  return "CUSTOM";
178  else
179  throw std::invalid_argument(
180  "Invalid ordering type: You must provide an ordering for a custom ordering type. See setOrdering");
181  }
182 }
183 
184 /* ************************************************************************* */
186  const std::string& type) const {
187  if (type == "METIS")
188  return Ordering::METIS;
189  if (type == "COLAMD")
190  return Ordering::COLAMD;
191  throw std::invalid_argument(
192  "Invalid ordering type: You must provide an ordering for a custom ordering type. See setOrdering");
193 }
194 
195 
196 } // namespace
static Verbosity verbosityTranslator(const std::string &s)
Verbosity verbosity
The printing verbosity during optimization (default SILENT)
std::string orderingTypeTranslator(Ordering::OrderingType type) const
virtual void print(const std::string &str="") const
double absoluteErrorTol
The maximum absolute error decrease to stop iterating (default 1e-5)
static const SmartProjectionParams params
double relativeErrorTol
The maximum relative error decrease to stop iterating (default 1e-5)
double errorTol
The maximum total error to stop iterating (default 0.0)
Definition: pytypes.h:1403
RealScalar s
IterativeOptimizationParameters::shared_ptr iterativeParams
The container for iterativeOptimization parameters. used in CG Solvers.
OrderingType
Type of ordering to use.
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
Definition: geometry.cpp:25
void setIterativeParams(const std::shared_ptr< IterativeOptimizationParameters > params)
std::string linearSolverTranslator(LinearSolverType linearSolverType) const
traits
Definition: chartTesting.h:28
Parameters for nonlinear optimization.
Ordering::OrderingType orderingType
The method of ordering use during variable elimination (default COLAMD)
std::optional< Ordering > ordering
The optional variable elimination ordering, or empty to use COLAMD (default: empty) ...
LinearSolverType linearSolverType
The type of linear solver to use in the nonlinear optimizer.
size_t maxIterations
The maximum iterations to stop iterating (default 100)
Definition: pytypes.h:1370


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:57