Files
BQP/srcs/RobotNet10/RobotApp/Communication/CartographerSharp/Models/Common/CeresSolverOptions.cs
2026-07-13 09:25:40 +07:00

76 lines
2.8 KiB
C#

/*
* 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;
/// <summary>
/// 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/
/// </summary>
public struct CeresSolverOptions(
bool useNonmonotonicSteps,
int maxNumIterations,
int numThreads,
double? functionTolerance = null,
double? gradientTolerance = null,
double? parameterTolerance = null)
{
/// <summary>
/// Use non-monotonic steps in the solver.
/// </summary>
[JsonPropertyName("use_nonmonotonic_steps")]
public bool UseNonmonotonicSteps { get; set; } = useNonmonotonicSteps;
/// <summary>
/// Maximum number of iterations for the solver.
/// </summary>
[JsonPropertyName("max_num_iterations")]
public int MaxNumIterations { get; set; } = maxNumIterations;
/// <summary>
/// Number of threads to use in the solver.
/// </summary>
[JsonPropertyName("num_threads")]
public int NumThreads { get; set; } = numThreads;
/// <summary>
/// Function tolerance for convergence check.
/// Minimizer terminates when (new_cost - old_cost) < function_tolerance * old_cost
/// </summary>
[JsonPropertyName("function_tolerance")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? FunctionTolerance { get; set; } = functionTolerance;
/// <summary>
/// Gradient tolerance for convergence check.
/// Minimizer terminates when max_i |x - Project(Plus(x, -g(x))| < gradient_tolerance
/// </summary>
[JsonPropertyName("gradient_tolerance")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? GradientTolerance { get; set; } = gradientTolerance;
/// <summary>
/// Parameter tolerance for convergence check.
/// Minimizer terminates when |step|_2 <= parameter_tolerance * (|x|_2 + parameter_tolerance)
/// </summary>
[JsonPropertyName("parameter_tolerance")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? ParameterTolerance { get; set; } = parameterTolerance;
}