Skip to content

Commit 2df15c6

Browse files
Solver Core - Give "epsilon" tolerance values better names.
These names are inline with the Ceres solver tolerance variable names. Also, this change actually fixes a bug where the function tolerence (epsilon1) was being incorrectly set as the grdient tolerance (epsilon3).
1 parent e0e92cf commit 2df15c6

16 files changed

+206
-179
lines changed

docs/source/commands_solve.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ The command can be run in both MEL and Python.
1414

1515
Here is a table of command flags, as currently specified in the command.
1616

17-
======================== ========================================== ======================================================================= ==============
18-
Flag Type Description Default Value
19-
======================== ========================================== ======================================================================= ==============
20-
-camera (-c) string, string Camera transform and shape nodes None
21-
-marker (-m) string, string, string Marker, Camera, Bundle None
22-
-attr (-a) string, string, string, string, string Node attribute, min value, max value, offset and scale None
23-
-frame (-f) long int Frame number to solve with 1
24-
-attrStiffness (-asf) string, string, string, string Node attribute, weight plug name, variance plug name, value plug name. None
25-
-attrSmoothness (-asm) string, string, string, string Node attribute, weight plug name, variance plug name, value plug name. None
26-
-solverType (-st) unsigned int Type of solver to use. <auto detected>
27-
-sceneGraphMode (-sgm) unsigned int The Scene Graph used; 0=Maya DAG, 1=MM Scene Graph 0 (Maya DAG)
28-
-timeEvalMode (-tem) unsigned int How to evalulate values at different times, 0=DG Context 1=Set TIme 0 (DG Context)
29-
-iterations (-it) unsigned int Maximum number of iterations 20
30-
-tauFactor (-t) double Initial Damping Factor 1E-03
31-
-epsilon1 (-e1) double Acceptable gradient change 1E-06
32-
-epsilon2 (-e2) double Acceptable parameter change 1E-06
33-
-epsilon3 (-e3) double Acceptable error 1E-06
34-
-delta (-dt) double Change to the guessed parameters each iteration 1E-04
35-
-autoDiffType (-adt) unsigned int Auto-differencing type 0=forward 1=central 0 (forward)
36-
-verbose (-v) bool Prints more information False
37-
======================== ========================================== ======================================================================= ==============
17+
======================== ===================== ========================================== ======================================================================= ==============
18+
Command Flag Command Flag (short) Type Description Default Value
19+
======================== ===================== ========================================== ======================================================================= ==============
20+
-camera -c string, string Camera transform and shape nodes. None
21+
-marker -m string, string, string Marker, Camera, Bundle. None
22+
-attr -a string, string, string, string, string Node attribute, min value, max value, offset and scale. None
23+
-frame -f long int Frame number to solve with. 1
24+
-attrStiffness -asf string, string, string, string Node attribute, weight plug name, variance plug name, value plug name. None
25+
-attrSmoothness -asm string, string, string, string Node attribute, weight plug name, variance plug name, value plug name. None
26+
-solverType -st unsigned int Type of solver to use. <auto detected>
27+
-sceneGraphMode -sgm unsigned int The Scene Graph used; 0=Maya DAG, 1=MM Scene Graph. 0 (Maya DAG)
28+
-timeEvalMode -tem unsigned int How to evalulate values at different times, 0=DG Context 1=Set Time. 0 (DG Context)
29+
-iterations -it unsigned int Maximum number of iterations. 20
30+
-tauFactor -t double Initial Damping Factor. 1E-03
31+
-functionTolerance -ftl double Acceptable function change. 1E-06
32+
-parameterTolerance -ptl double Acceptable parameter change. 1E-06
33+
-gradientTolerance -gtl double Acceptable gradient error. 1E-06
34+
-delta -dt double Change to the guessed parameters each iteration. 1E-04
35+
-autoDiffType -adt unsigned int Auto-differencing type 0=forward 1=central. 0 (forward)
36+
-verbose -v bool Prints more information. False
37+
======================== ===================== ========================================== ======================================================================= ==============
3838

3939
Return
4040
------
@@ -102,7 +102,7 @@ Python Example:
102102
solvers = maya.cmds.mmSolverType(query=True, list=True)
103103
default_solver = maya.cmds.mmSolverType(query=True, default=True)
104104
105-
105+
106106
``mmSolverAffects`` Command
107107
+++++++++++++++++++++++++++
108108

python/mmSolver/_api/solverstep.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,17 +680,17 @@ def compile(self, col, mkr_list, attr_list, withtest=False):
680680
if tau_factor is not None:
681681
kwargs['tauFactor'] = tau_factor
682682

683-
gradient_error_factor = self.get_gradient_error_factor()
684-
if gradient_error_factor is not None:
685-
kwargs['epsilon1'] = gradient_error_factor
683+
function_error_factor = self.get_error_factor()
684+
if function_error_factor is not None:
685+
kwargs['function_tolerance'] = function_error_factor
686686

687687
parameter_error_factor = self.get_parameter_error_factor()
688688
if parameter_error_factor is not None:
689-
kwargs['epsilon2'] = parameter_error_factor
689+
kwargs['parameter_tolerance'] = parameter_error_factor
690690

691-
error_factor = self.get_error_factor()
692-
if error_factor is not None:
693-
kwargs['epsilon3'] = error_factor
691+
gradient_error_factor = self.get_gradient_error_factor()
692+
if gradient_error_factor is not None:
693+
kwargs['gradient_tolerance'] = gradient_error_factor
694694

695695
robust_loss_type = self.get_robust_loss_type()
696696
if robust_loss_type is not None:

share/design/api/api_classes_detail.graphml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ get_max_iterations()
321321
set_max_iterations(value)
322322

323323
get_tau_factor()
324-
get_epsilon1()
325-
get_epsilon2()
326-
get_epsilon3()
324+
get_function_tolerance()
325+
get_parameter_tolerance()
326+
get_gradient_tolerance()
327327
get_delta()
328328
set_tau_factor(value)
329-
set_epsilon1(value)
330-
set_epsilon2(value)
331-
set_epsilon3(value)
329+
set_function_tolerance(value)
330+
set_parameter_tolerance(value)
331+
set_gradient_tolerance(value)
332332
set_delta(value)
333333

334334
get_frame_list()

src/mmSolver/adjust/adjust_base.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,12 @@ MStatus solveFrames(
910910
MMSOLVER_MAYA_INFO("Solver Type=" << solverOptions.solverType);
911911
MMSOLVER_MAYA_INFO("Maximum Iterations=" << solverOptions.iterMax);
912912
MMSOLVER_MAYA_INFO("Tau=" << solverOptions.tau);
913-
MMSOLVER_MAYA_INFO("Epsilon1=" << solverOptions.eps1);
914-
MMSOLVER_MAYA_INFO("Epsilon2=" << solverOptions.eps2);
915-
MMSOLVER_MAYA_INFO("Epsilon3=" << solverOptions.eps3);
913+
MMSOLVER_MAYA_INFO(
914+
"Function Tolerance=" << solverOptions.function_tolerance);
915+
MMSOLVER_MAYA_INFO(
916+
"Parameter Tolerance=" << solverOptions.parameter_tolerance);
917+
MMSOLVER_MAYA_INFO(
918+
"Gradient Tolerance=" << solverOptions.gradient_tolerance);
916919
MMSOLVER_MAYA_INFO("Delta=" << fabs(solverOptions.delta));
917920
MMSOLVER_MAYA_INFO(
918921
"Auto Differencing Type=" << solverOptions.autoDiffType);

src/mmSolver/adjust/adjust_ceres_lmder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ bool solve_3d_ceres_lmder(SolverOptions& solverOptions,
213213
options.max_num_consecutive_invalid_steps = 5; // Allow some invalid steps.
214214

215215
options.max_num_iterations = solverOptions.iterMax;
216-
options.function_tolerance = solverOptions.eps1;
217-
options.parameter_tolerance = solverOptions.eps2;
218-
options.gradient_tolerance = solverOptions.eps3;
216+
options.function_tolerance = solverOptions.function_tolerance;
217+
options.parameter_tolerance = solverOptions.parameter_tolerance;
218+
options.gradient_tolerance = solverOptions.gradient_tolerance;
219219
options.initial_trust_region_radius = solverOptions.tau;
220220
options.jacobi_scaling = true;
221221
options.num_threads = 1;

src/mmSolver/adjust/adjust_ceres_lmdif.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ bool solve_3d_ceres_lmdif(SolverOptions& solverOptions,
131131
options.max_num_consecutive_invalid_steps = 5; // Allow some invalid steps.
132132

133133
options.max_num_iterations = solverOptions.iterMax;
134-
options.function_tolerance = solverOptions.eps1;
135-
options.parameter_tolerance = solverOptions.eps2;
136-
options.gradient_tolerance = solverOptions.eps3;
134+
options.function_tolerance = solverOptions.function_tolerance;
135+
options.parameter_tolerance = solverOptions.parameter_tolerance;
136+
options.gradient_tolerance = solverOptions.gradient_tolerance;
137137
options.initial_trust_region_radius = solverOptions.tau;
138138
options.jacobi_scaling = true;
139139
options.num_threads = 1;

src/mmSolver/adjust/adjust_cminpack_lmder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ bool solve_3d_cminpack_lmder(SolverOptions &solverOptions,
9999
ldfjac = numberOfParameters;
100100
}
101101

102-
double ftol = solverOptions.eps1;
103-
double xtol = solverOptions.eps2;
104-
double gtol = solverOptions.eps3;
102+
double ftol = solverOptions.function_tolerance;
103+
double xtol = solverOptions.parameter_tolerance;
104+
double gtol = solverOptions.gradient_tolerance;
105105

106106
int mode = 2; // Off
107107
if (solverOptions.autoParamScale == 1) {

src/mmSolver/adjust/adjust_cminpack_lmdif.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ bool solve_3d_cminpack_lmdif(SolverOptions &solverOptions,
9898
ldfjac = numberOfParameters;
9999
}
100100

101-
double ftol = solverOptions.eps1;
102-
double xtol = solverOptions.eps2;
103-
double gtol = solverOptions.eps3;
101+
double ftol = solverOptions.function_tolerance;
102+
double xtol = solverOptions.parameter_tolerance;
103+
double gtol = solverOptions.gradient_tolerance;
104104

105105
// Change the sign of the delta
106106
// Note: lmdif only supports auto-diff 'forward' mode.

src/mmSolver/adjust/adjust_data.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ struct PrintStatOptions {
134134
struct SolverOptions {
135135
int iterMax;
136136
double tau;
137-
double eps1;
138-
double eps2;
139-
double eps3;
137+
double function_tolerance;
138+
double parameter_tolerance;
139+
double gradient_tolerance;
140140
double delta;
141141
int autoDiffType;
142142
int autoParamScale;
@@ -163,9 +163,9 @@ struct SolverOptions {
163163
SolverOptions()
164164
: iterMax(0)
165165
, tau(0.0)
166-
, eps1(0.0)
167-
, eps2(0.0)
168-
, eps3(0.0)
166+
, function_tolerance(0.0)
167+
, parameter_tolerance(0.0)
168+
, gradient_tolerance(0.0)
169169
, delta(0.0)
170170
, autoDiffType(AUTO_DIFF_TYPE_FORWARD)
171171
, autoParamScale(0)

src/mmSolver/adjust/adjust_defines.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@
113113
//
114114
#define CMINPACK_LMDIF_ITERATIONS_DEFAULT_VALUE (100)
115115
#define CMINPACK_LMDIF_TAU_DEFAULT_VALUE (1.0)
116-
#define CMINPACK_LMDIF_EPSILON1_DEFAULT_VALUE (1E-6) // ftol
117-
#define CMINPACK_LMDIF_EPSILON2_DEFAULT_VALUE (1E-6) // xtol
118-
#define CMINPACK_LMDIF_EPSILON3_DEFAULT_VALUE (1E-6) // gtol
116+
#define CMINPACK_LMDIF_FUNCTION_TOLERANCE_DEFAULT_VALUE (1E-6) // ftol
117+
#define CMINPACK_LMDIF_PARAMETER_TOLERANCE_DEFAULT_VALUE (1E-6) // xtol
118+
#define CMINPACK_LMDIF_GRADIENT_TOLERANCE_DEFAULT_VALUE (1E-6) // gtol
119119
#define CMINPACK_LMDIF_DELTA_DEFAULT_VALUE (1E-04)
120120
// cminpack lmdif only supports forward '0=forward' differentiation.
121121
#define CMINPACK_LMDIF_AUTO_DIFF_TYPE_DEFAULT_VALUE (AUTO_DIFF_TYPE_FORWARD)
@@ -134,9 +134,9 @@
134134
//
135135
#define CMINPACK_LMDER_ITERATIONS_DEFAULT_VALUE (100)
136136
#define CMINPACK_LMDER_TAU_DEFAULT_VALUE (1.0)
137-
#define CMINPACK_LMDER_EPSILON1_DEFAULT_VALUE (1E-6) // ftol
138-
#define CMINPACK_LMDER_EPSILON2_DEFAULT_VALUE (1E-6) // xtol
139-
#define CMINPACK_LMDER_EPSILON3_DEFAULT_VALUE (1E-6) // gtol
137+
#define CMINPACK_LMDER_FUNCTION_TOLERANCE_DEFAULT_VALUE (1E-6) // ftol
138+
#define CMINPACK_LMDER_PARAMETER_TOLERANCE_DEFAULT_VALUE (1E-6) // xtol
139+
#define CMINPACK_LMDER_GRADIENT_TOLERANCE_DEFAULT_VALUE (1E-6) // gtol
140140
#define CMINPACK_LMDER_DELTA_DEFAULT_VALUE (1E-04)
141141
// cminpack lmder supports both forward '0=forward' and 'central' auto-diff'ing.
142142
#define CMINPACK_LMDER_AUTO_DIFF_TYPE_DEFAULT_VALUE (AUTO_DIFF_TYPE_FORWARD)
@@ -156,9 +156,9 @@
156156
//
157157
#define CERES_LMDIF_ITERATIONS_DEFAULT_VALUE (100)
158158
#define CERES_LMDIF_TAU_DEFAULT_VALUE (1E4)
159-
#define CERES_LMDIF_EPSILON1_DEFAULT_VALUE (1E-6) // function_tolerance
160-
#define CERES_LMDIF_EPSILON2_DEFAULT_VALUE (1E-10) // parameter_tolerance
161-
#define CERES_LMDIF_EPSILON3_DEFAULT_VALUE (1E-8) // gradient_tolerance
159+
#define CERES_LMDIF_FUNCTION_TOLERANCE_DEFAULT_VALUE (1E-6)
160+
#define CERES_LMDIF_PARAMETER_TOLERANCE_DEFAULT_VALUE (1E-10)
161+
#define CERES_LMDIF_GRADIENT_TOLERANCE_DEFAULT_VALUE (1E-8)
162162
#define CERES_LMDIF_DELTA_DEFAULT_VALUE (1E-04)
163163
// ceres lmder supports both forward '0=forward' and 'central' auto-diff'ing.
164164
#define CERES_LMDIF_AUTO_DIFF_TYPE_DEFAULT_VALUE (AUTO_DIFF_TYPE_FORWARD)
@@ -178,9 +178,9 @@
178178
//
179179
#define CERES_LMDER_ITERATIONS_DEFAULT_VALUE (100)
180180
#define CERES_LMDER_TAU_DEFAULT_VALUE (1E4)
181-
#define CERES_LMDER_EPSILON1_DEFAULT_VALUE (1E-6) // function_tolerance
182-
#define CERES_LMDER_EPSILON2_DEFAULT_VALUE (1E-10) // parameter_tolerance
183-
#define CERES_LMDER_EPSILON3_DEFAULT_VALUE (1E-8) // gradient_tolerance
181+
#define CERES_LMDER_FUNCTION_TOLERANCE_DEFAULT_VALUE (1E-6)
182+
#define CERES_LMDER_PARAMETER_TOLERANCE_DEFAULT_VALUE (1E-10)
183+
#define CERES_LMDER_GRADIENT_TOLERANCE_DEFAULT_VALUE (1E-8)
184184
#define CERES_LMDER_DELTA_DEFAULT_VALUE (1E-04)
185185
// ceres lmder supports both forward '0=forward' and 'central' auto-diff'ing.
186186
#define CERES_LMDER_AUTO_DIFF_TYPE_DEFAULT_VALUE (AUTO_DIFF_TYPE_FORWARD)
@@ -197,9 +197,9 @@
197197
//
198198
#define LEVMAR_ITERATIONS_DEFAULT_VALUE (100)
199199
#define LEVMAR_TAU_DEFAULT_VALUE (1.0)
200-
#define LEVMAR_EPSILON1_DEFAULT_VALUE (1E-6)
201-
#define LEVMAR_EPSILON2_DEFAULT_VALUE (1E-6)
202-
#define LEVMAR_EPSILON3_DEFAULT_VALUE (1E-6)
200+
#define LEVMAR_FUNCTION_TOLERANCE_DEFAULT_VALUE (1E-6)
201+
#define LEVMAR_PARAMETER_TOLERANCE_DEFAULT_VALUE (1E-6)
202+
#define LEVMAR_GRADIENT_TOLERANCE_DEFAULT_VALUE (1E-6)
203203
#define LEVMAR_DELTA_DEFAULT_VALUE (1E-04)
204204
#define LEVMAR_AUTO_DIFF_TYPE_DEFAULT_VALUE (AUTO_DIFF_TYPE_FORWARD)
205205
// LevMar does not have auto-parameter scaling.

0 commit comments

Comments
 (0)