Class CeresNonlinearSolver#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Class Documentation#

class CeresNonlinearSolver : public Karana::Dynamics::NonlinearSolver#

CeresNonlinearSolver class manages a nonlinear problem and associated solver.

Public Types

enum SolverType#

Solver types used by the Ceres nonlinear solver.

Values:

enumerator LEVENBERG_MARQUARDT#

Levenberg-Marquardt Newton-style method.

enumerator DOGLEG#

Powell’s dogleg method.

enumerator BFGS#

BFGS with line search.

enumerator AUTO#

Automatically decide based on presence of joint stops.

enum LinearSolverType#

Solver types used by the Ceres nonlinear solver.

Values:

enumerator DENSE_QR#

Dense QR factorization: the most stable, but sometimes slower.

enumerator DENSE_SCHUR#

Dense Schur factorization: an alternative to QR.

enumerator DENSE_NORMAL_CHOLESKY#

Dense Cholesky factorization: up to 2x faster than QR less numerically stable.

Public Functions

CeresNonlinearSolver(std::string_view name, int input_dim, int value_dim, cost_fn f, jac_fn j, SolverType type = SolverType::DOGLEG)#

CeresNonlinearSolver constructor. This is a container that holds the information needed to solve a nonlinear problem.

Parameters:
  • name – The name of the nonlinear solver.

  • input_dim – The number of inputs.

  • value_dim – The number of values (outputs).

  • f – The cost function. This should take in a vector of inputs and output a vector of outputs.

  • j – The jacobian function. This should take in a vector of inputs and output a matrix of outputs.

  • type – The type of nonlinear solver to use.

SolverType getSolverType() const#

Get the non-linear solver type.

Returns:

The current non-linear solver type.

void setSolverType(const SolverType &type)#

Set the nonlinear solver type.

Parameters:

type – New solver type to use.

void setLinearSolverType(const LinearSolverType &type)#

Set the linear solver type to use within iterations.

Parameters:

type – New linear solver type to use.

ceres::Solver::Options &getMutableOptions()#

Get a reference to the internal ceres options object for more advanced tuning.

Returns:

ceres::Solver::Options& Reference to the options field; only use this for advanced tuning.

Public Static Functions

static kc::ks_ptr<CeresNonlinearSolver> create(std::string_view name, int input_dim, int value_dim, cost_fn f, jac_fn j, SolverType type = SolverType::AUTO)#

CeresNonlinearSolver constructor. This is a container that holds the information CeresNonlinearSolver needs to solve a nonlinear problem.

Parameters:
  • name – The name of the Nonlinear solver.

  • input_dim – The number of inputs.

  • value_dim – The number of values (outputs).

  • f – The cost function. This should take in a vector of inputs and output a vector of outputs.

  • j – The jacobian function. This should take in a vector of inputs and output a matrix of outputs.

  • type – The type of nonlinear solver to use.

Returns:

A ks_ptr to a new Nonlinear solver instance.

Protected Functions

virtual void _makeHealthy() final override#

Internal method to ensure the solver is ready.

void _rebuildProblemStructure()#

Build internal state for Ceres solver; this is done internally on _solve() calls.

void _updateBounds(const km::Vec &lower_bounds, const km::Vec &upper_bounds)#

Update upper and lower bounds on solution variables.

Parameters:
  • lower_bounds – New lower bound to use (or empty vec for no bounds)

  • upper_bounds – New upper bound to use (or empty vec for no bounds)