Class NonlinearSolver#
Defined in File NonlinearSolver.h
Inheritance Relationships#
Base Type#
public Karana::Core::LockingBase(Class LockingBase)
Class Documentation#
-
class NonlinearSolver : public Karana::Core::LockingBase#
NonlinearSolver class manages a nonlinear problem and associated solver.
Public Functions
-
NonlinearSolver(const std::string &name, int input_dim, int value_dim, cost_fn f, jac_fn j = nullptr)#
NonlinearSolver constructor. This is a container that holds the information needed to solve a nonlinear problem. However, the solver itself is not added during construction. You must either pass in a solver with setSolver or create one with createSolver.
- 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 is optional, if not specified, the jacobian will be computed by forward numerical differentiation.
-
void setF(cost_fn f)#
Set the cost function. After setting the function, you will need to re-create the solver if one has already been set. Otherwise, the solver will still retain the old cost function.
- Parameters:
f – The cost function.
-
void setJac(jac_fn jac)#
Set the jacobian function. After setting the jacobian.function, you will need to re-create the solver if one has already been set. Otherwise, the solver will still retain the old cost function.
- Parameters:
jac – The jacobian function.
-
kc::ks_ptr<solver_type> getSolver()#
Get the non-linear solver.
- Returns:
The current non-linear solver.
-
void setSolver(const kc::ks_ptr<solver_type> &solver)#
Set the solver.
- Parameters:
solver – The solver.
-
kc::ks_ptr<solver_type> createSolver(const solver_enum &solver)#
Create a solver of the given type. This will return a copy of the shared pointer to the solver as well as set the solver for this NonlinearSolver.
- Parameters:
solver – The solver type to create.
- Returns:
The solver that was created.
Public Members
-
std::variant<Eigen::LevenbergMarquardtSpace::Status, Eigen::HybridNonLinearSolverSpace::Status> status#
The status of the nonlinear solver.
Public Static Functions
-
static kc::ks_ptr<NonlinearSolver> create(const std::string &name, int input_dim, int value_dim, cost_fn f, jac_fn j = nullptr)#
NonlinearSolver constructor. This is a container that holds the information needed to solve a nonlinear problem. However, the solver itself is not added during construction. You must either pass in a solver with setSolver or create one with createSolver.
- 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 is optional, if not specified, the jacobian will be computed by forward numerical differentiation.
- Returns:
A ks_ptr to a new Nonlinear solver instance.
Protected Functions
-
virtual void _makeCurrent() final#
Internal method to ensure the solver is ready.
-
NonlinearSolver(const std::string &name, int input_dim, int value_dim, cost_fn f, jac_fn j = nullptr)#