/* * Copyright 2016 The Cartographer Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System.Text.Json.Serialization; namespace CartographerSharp.Models.Common; /// /// Protocol buffer representation of Ceres Solver options. /// Configure the Ceres solver. See the Ceres documentation for more /// information: https://code.google.com/p/ceres-solver/ /// public struct CeresSolverOptions( bool useNonmonotonicSteps, int maxNumIterations, int numThreads, double? functionTolerance = null, double? gradientTolerance = null, double? parameterTolerance = null) { /// /// Use non-monotonic steps in the solver. /// [JsonPropertyName("use_nonmonotonic_steps")] public bool UseNonmonotonicSteps { get; set; } = useNonmonotonicSteps; /// /// Maximum number of iterations for the solver. /// [JsonPropertyName("max_num_iterations")] public int MaxNumIterations { get; set; } = maxNumIterations; /// /// Number of threads to use in the solver. /// [JsonPropertyName("num_threads")] public int NumThreads { get; set; } = numThreads; /// /// Function tolerance for convergence check. /// Minimizer terminates when (new_cost - old_cost) < function_tolerance * old_cost /// [JsonPropertyName("function_tolerance")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public double? FunctionTolerance { get; set; } = functionTolerance; /// /// Gradient tolerance for convergence check. /// Minimizer terminates when max_i |x - Project(Plus(x, -g(x))| < gradient_tolerance /// [JsonPropertyName("gradient_tolerance")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public double? GradientTolerance { get; set; } = gradientTolerance; /// /// Parameter tolerance for convergence check. /// Minimizer terminates when |step|_2 <= parameter_tolerance * (|x|_2 + parameter_tolerance) /// [JsonPropertyName("parameter_tolerance")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public double? ParameterTolerance { get; set; } = parameterTolerance; }