1
1
/* * This file provides a convenient functional interface to the SESync
2
- * algorithm.
3
- *
4
- * Copyright (C) 2016 - 2018 by David M. Rosen
5
- */
2
+ * algorithm.
3
+ *
4
+ * Copyright (C) 2016 - 2018 by David M. Rosen
5
+ */
6
6
7
7
#pragma once
8
8
@@ -22,25 +22,25 @@ struct SESyncOpts {
22
22
// / OPTIMIZATION STOPPING CRITERIA
23
23
24
24
/* * Stopping tolerance for the norm of the Riemannian gradient */
25
- double grad_norm_tol = 1e-2 ;
25
+ Scalar grad_norm_tol = 1e-2 ;
26
26
27
27
/* * Stopping tolerance for the norm of the preconditioned Riemannian gradient
28
28
*/
29
- double preconditioned_grad_norm_tol = 1e-4 ;
29
+ Scalar preconditioned_grad_norm_tol = 1e-4 ;
30
30
31
31
/* * Stopping criterion based upon the relative decrease in function value */
32
- double rel_func_decrease_tol = 1e-7 ;
32
+ Scalar rel_func_decrease_tol = 1e-7 ;
33
33
34
34
/* * Stopping criterion based upon the norm of an accepted update step */
35
- double stepsize_tol = 1e-3 ;
35
+ Scalar stepsize_tol = 1e-3 ;
36
36
37
37
/* * Maximum permitted number of (outer) iterations of the Riemannian
38
38
* trust-region method when solving each instance of Problem 9 */
39
- unsigned int max_iterations = 1000 ;
39
+ size_t max_iterations = 1000 ;
40
40
41
41
/* * Maximum number of inner (truncated conjugate-gradient) iterations to
42
42
* perform per out iteration */
43
- unsigned int max_tCG_iterations = 10000 ;
43
+ size_t max_tCG_iterations = 10000 ;
44
44
45
45
// / These next two parameters define the stopping criteria for the truncated
46
46
// / preconditioned conjugate-gradient solver running in the inner loop --
@@ -53,14 +53,14 @@ struct SESyncOpts {
53
53
/* * Gradient tolerance for the truncated preconditioned conjugate
54
54
gradient solver: stop if ||g|| < kappa * ||g_0||. This parameter should be in
55
55
the range (0,1). */
56
- double STPCG_kappa = .1 ;
56
+ Scalar STPCG_kappa = .1 ;
57
57
58
58
/* * Gradient tolerance based upon a fractional-power reduction in the norm of
59
59
* the gradient: stop if ||g|| < ||kappa||^{1+ theta}. This value should be
60
60
* positive, and controls the asymptotic convergence rate of the
61
61
* truncated-Newton trust-region solver: specifically, for theta > 0, the TNT
62
62
* algorithm converges q-superlinearly with order (1+theta). */
63
- double STPCG_theta = .5 ;
63
+ Scalar STPCG_theta = .5 ;
64
64
65
65
/* * Maximum elapsed computation time (in seconds) */
66
66
double max_computation_time = std::numeric_limits<double >::max();
@@ -76,24 +76,24 @@ struct SESyncOpts {
76
76
Formulation formulation = Formulation::Simplified;
77
77
78
78
/* * The initial level of the Riemannian Staircase */
79
- unsigned int r0 = 5 ;
79
+ size_t r0 = 5 ;
80
80
81
81
/* * The maximum level of the Riemannian Staircase to explore */
82
- unsigned int rmax = 10 ;
82
+ size_t rmax = 10 ;
83
83
84
84
/* * The maximum number of Lanczos iterations to admit for eigenvalue
85
85
* computations */
86
- unsigned int max_eig_iterations = 10000 ;
86
+ size_t max_eig_iterations = 10000 ;
87
87
88
88
/* * A numerical tolerance for acceptance of the minimum eigenvalue of Q -
89
89
* Lambda(Y*) as numerically nonnegative; this should be a small positive
90
90
* value e.g. 10^-4 */
91
- double min_eig_num_tol = 1e-5 ;
91
+ Scalar min_eig_num_tol = 1e-5 ;
92
92
93
93
/* * The number of working vectors to use in the minimum eigenvalue computation
94
94
(using the implicitly-restarted Arnoldi algorithm); must be in the range [1,
95
95
(#poses) * (#problem dimension) - 1] */
96
- unsigned int num_Lanczos_vectors = 20 ;
96
+ size_t num_Lanczos_vectors = 20 ;
97
97
98
98
/* * Whether to use the Cholesky or QR factorization when computing the
99
99
* orthogonal projection */
@@ -106,11 +106,11 @@ struct SESyncOpts {
106
106
107
107
/* * Maximum admissible condition number for the regularized Cholesky
108
108
* preconditioner */
109
- double reg_Cholesky_precon_max_condition_number = 1e6 ;
109
+ Scalar reg_Cholesky_precon_max_condition_number = 1e6 ;
110
110
111
111
/* * If no initial iterate Y0 is supplied, this boolean determines the
112
- * initialization strategy employed by SE-Sync: 'true' -> chordal, 'false' ->
113
- * random sampling */
112
+ * initialization strategy employed by SE-Sync: 'true' -> chordal, 'false' ->
113
+ * random sampling */
114
114
Initialization initialization = Initialization::Chordal;
115
115
116
116
/* * Whether to print output as the algorithm runs */
@@ -122,7 +122,7 @@ struct SESyncOpts {
122
122
123
123
/* * The number of threads to use for parallelization (assuming that SE-Sync is
124
124
* built using a compiler that supports OpenMP */
125
- unsigned int num_threads = 1 ;
125
+ size_t num_threads = 1 ;
126
126
};
127
127
128
128
/* * These enumerations describe the termination status of the SE-Sync algorithm
@@ -158,10 +158,10 @@ struct SESyncResult {
158
158
Matrix Yopt;
159
159
160
160
/* * The value of the objective F(Y^T Y) = F(Z) attained by the Yopt */
161
- double SDPval;
161
+ Scalar SDPval;
162
162
163
163
/* * The norm of the Riemannian gradient at Yopt */
164
- double gradnorm;
164
+ Scalar gradnorm;
165
165
166
166
/* * The Lagrange multiplier matrix Lambda corresponding to Yopt, computed
167
167
* according to eq. (119) in the SE-Sync tech report. If Z = Y^T Y is an
@@ -171,31 +171,31 @@ struct SESyncResult {
171
171
172
172
/* * The trace of Lambda; this is the value of Lambda under the objective of
173
173
* the (primal) semidefinite relaxation Problem 6. */
174
- double trace_Lambda;
174
+ Scalar trace_Lambda;
175
175
176
176
/* * The duality gap between the estimates for the primal and dual solutions
177
177
* Lambda and Z = Y^T Y of Problems 7 and 6, respectively; it is given by:
178
178
*
179
179
* SDP_duality_gap := F(Y^T Y) - tr(Lambda)
180
180
*
181
181
*/
182
- double SDP_duality_gap;
182
+ Scalar SDP_duality_gap;
183
183
184
184
/* * The minimum eigenvalue of the matrix S - Lambda */
185
- double lambda_min;
185
+ Scalar lambda_min;
186
186
187
187
/* * The corresponding eigenvector of the minimum eigenvalue */
188
188
Vector v_min;
189
189
190
190
/* * The value of the rounded solution xhat in SE(d)^n */
191
- double Fxhat;
191
+ Scalar Fxhat;
192
192
193
193
/* * The rounded solution xhat = [t | R] in SE(d)^n */
194
194
Matrix xhat;
195
195
196
196
/* * Upper bound on the global suboptimality of the recovered pose estimates
197
197
* xhat; this is equal to F(xhat) - tr(Lambda) */
198
- double suboptimality_upper_bound;
198
+ Scalar suboptimality_upper_bound;
199
199
200
200
/* * The total elapsed computation time for the SE-Sync algorithm */
201
201
double total_computation_time;
@@ -206,12 +206,12 @@ struct SESyncResult {
206
206
207
207
/* * A vector containing the sequence of function values obtained during the
208
208
* optimization at each level of the Riemannian Staircase */
209
- std::vector<std::vector<double >> function_values;
209
+ std::vector<std::vector<Scalar >> function_values;
210
210
211
211
/* * A vector containing the sequence of norms of the Riemannian gradients
212
212
* obtained during the optimization at each level of the Riemannian Staircase
213
213
*/
214
- std::vector<std::vector<double >> gradient_norms;
214
+ std::vector<std::vector<Scalar >> gradient_norms;
215
215
216
216
/* * A vector containing the sequence of (# Hessian-vector product operations)
217
217
* carried out during the optimization at each level of the Riemannian
@@ -226,12 +226,12 @@ struct SESyncResult {
226
226
/* * A vector containing the sequence of minimum eigenvalues of the certificate
227
227
* matrix constructed from the critical point recovered from the
228
228
* optimization at each level of the Riemannian Staircase */
229
- std::vector<double > minimum_eigenvalues;
229
+ std::vector<Scalar > minimum_eigenvalues;
230
230
231
231
/* * A vector containing the number of matrix-vector multiplication operations
232
232
* performed for the minimum-eigenvalue computation at each level of the
233
233
* Riemannian Staircase */
234
- std::vector<unsigned int > minimum_eigenvalue_matrix_ops;
234
+ std::vector<size_t > minimum_eigenvalue_matrix_ops;
235
235
236
236
/* * A vector containing the elapsed time of the minimum eigenvalue computation
237
237
* at each level of the Riemannian Staircase */
@@ -292,8 +292,8 @@ SESyncResult SESync(const measurements_t &measurements,
292
292
* of the Riemannian Staircase
293
293
*/
294
294
bool escape_saddle (const SESyncProblem &problem, const Matrix &Y,
295
- double lambda_min, const Vector &v_min,
296
- double gradient_tolerance,
297
- double preconditioned_gradient_tolerance, Matrix &Yplus);
295
+ Scalar lambda_min, const Vector &v_min,
296
+ Scalar gradient_tolerance,
297
+ Scalar preconditioned_gradient_tolerance, Matrix &Yplus);
298
298
299
299
} // namespace SESync
0 commit comments