17 #ifndef ACADOS_SOLVER_BASE__ACADOS_SOLVER_HPP_
18 #define ACADOS_SOLVER_BASE__ACADOS_SOLVER_HPP_
20 #include <Eigen/Dense>
31 #include "acados_c/ocp_nlp_interface.h"
503 unsigned int expected_total_indexes);
515 unsigned int expected_total_indexes);
547 unsigned int vector_size,
561 unsigned int vector_size);
591 unsigned int nx()
const;
600 unsigned int nz()
const;
609 unsigned int np()
const;
618 unsigned int nu()
const;
625 unsigned int N()
const;
880 bool _is_initialized =
false;
Container for the (fixed) dimensions of the imported Acados OCP.
Definition: acados_solver.hpp:48
unsigned int nbx
Number of state stage bounds.
Definition: acados_solver.hpp:67
unsigned int ns
Total number of slack variable.
Definition: acados_solver.hpp:105
unsigned int nsphi
Number of slack variables used by convex-over-nonlinear constraints.
Definition: acados_solver.hpp:133
unsigned int nu
Control vector size.
Definition: acados_solver.hpp:62
unsigned int nphi
Number of "convex-over-nonlinear" constraints (see Acados documentation)
Definition: acados_solver.hpp:97
unsigned int nsg
Number of slack variables used by polytopic constraints.
Definition: acados_solver.hpp:126
unsigned int nbx_0
Number of initial state stage bounds.
Definition: acados_solver.hpp:71
unsigned int ng
Number of polytopic constraints.
Definition: acados_solver.hpp:83
unsigned int nphi_N
Number of "convex-over-nonlinear" constraints at stage N.
Definition: acados_solver.hpp:100
unsigned int nsbx
Number of slack variables used by state bounds.
Definition: acados_solver.hpp:111
unsigned int np
Runtime parameters vector size.
Definition: acados_solver.hpp:59
unsigned int ny_0
Size of the reference vector at initial stage.
Definition: acados_solver.hpp:143
unsigned int ny
Size of the reference vector.
Definition: acados_solver.hpp:140
unsigned int nbx_N
Number of terminal state bounds.
Definition: acados_solver.hpp:74
unsigned int nsbu
Number of slack variables used by control bounds.
Definition: acados_solver.hpp:117
unsigned int nh_N
Number of non-linear constraints at stage N.
Definition: acados_solver.hpp:94
unsigned int nsbx_N
Number of slack variables used by terminal state bounds.
Definition: acados_solver.hpp:114
unsigned int ny_N
Size of the reference vector at terminal stage.
Definition: acados_solver.hpp:146
unsigned int nh
Number of non-linear constraints.
Definition: acados_solver.hpp:91
unsigned int nsg_N
Number of slack variables used by (terminal) polytopic constraints.
Definition: acados_solver.hpp:129
unsigned int ng_N
Number of polytopic constraints at stage N.
Definition: acados_solver.hpp:86
unsigned int nx
Differential state vector size.
Definition: acados_solver.hpp:53
unsigned int nr
Dimensions of the image of the inner nonlinear function in positive definite constr....
Definition: acados_solver.hpp:152
unsigned int ns_N
Total number of slack variable at stage N.
Definition: acados_solver.hpp:108
unsigned int nsphi_N
Number of slack variables used by (terminal) convex-over-nonlinear constraints.
Definition: acados_solver.hpp:136
unsigned int nz
Algebraic state vector size.
Definition: acados_solver.hpp:56
unsigned int nsh_N
Number of slack variables used by (terminal) non-linear constraints.
Definition: acados_solver.hpp:123
unsigned int nsh
Number of slack variables used by non-linear constraints.
Definition: acados_solver.hpp:120
unsigned int nbu
Number of control bounds.
Definition: acados_solver.hpp:78
Abstract C++ wrapper of generated Acados solver C-code.
Definition: acados_solver.hpp:42
int initialize_control_values(ValueMap const &u_i_map)
Initialize the control variable values for ALL stages at once from a key/values map.
virtual ocp_nlp_out * get_sens_out() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_out property of the solver.
ValueVector get_algebraic_state_values(unsigned int stage)
Retrieve the algebraic state variables at a given stage.
IndexMap _z_index_map
Unordered map used to set or retrieve the values of algebraic state variables by name.
Definition: acados_solver.hpp:652
int set_runtime_parameters(ValueVector &p_i)
Set the runtime parameters for all stages at once from ordered value vector.
int set_initial_state_values(ValueMap const &x_0_map)
Set the initial state values (i.e., add constraints on initial state) from a map of key/ValueVector p...
int set_control_bounds(IndexVector &idxbu, ValueVector &lbu, ValueVector &ubu)
Set control bounds for all stages.
ValueMap get_algebraic_state_values_as_map(unsigned int stage)
Retrieve the algebraic state variables at a given stage and package them as a ValueMap.
const IndexMap & u_index_map() const
Returns a constant reference to the Key/IndexVector map of control variables internally stored in Aca...
const IndexMap & z_index_map() const
Returns a constant reference to the Key/IndexVector map of algebraic state variables internally store...
ValueVector get_control_values(unsigned int stage)
Retrieve the control variables at a given stage.
int solve()
Solve the non-linear optimization problem given the provided initial state, constraints,...
int initialize_state_values(ValueMap const &x_i_map)
Initialize the (differential) state values for ALL stages at once from a key/values map.
int initialize_state_values(ValueVector &x_i)
Initialize the (differential) state values for ALL stages at once from an ordered value vector.
virtual ocp_nlp_plan_t * get_nlp_plan() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_plan property of the solver.
virtual void internal_print_stats() const =0
Print the solver stats (e.g., number of SQP iters, number of QP iters, etc.) to the console.
virtual int internal_update_params_sparse(unsigned int stage, int *idx, double *p, int n_update)=0
A sparse implementation of internal_update_params_sparse().
static bool is_values_map_complete(IndexMap const &index_map, ValueMap const &values_map)
Check if for each key-index pair contained in the index map there is a value provided by the value ma...
int set_state_bounds(unsigned int stage, IndexVector &idxbx, ValueVector &lbx, ValueVector &ubx)
Set (differential) state bounds at a given stage.
static ValueVector value_vector_from_map(IndexMap const &index_map, ValueMap const &values_map, unsigned int vector_size)
Returns a vector containing the values provided through the value map.
virtual ocp_nlp_out * get_nlp_out() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_out property of the solver.
int free_memory()
Free all the allocated memory.
const Dimensions & dims() const
Returns the (fixed) dimensions of the OCP problem stored in AcadosSolver::_dims.
IndexMap _p_index_map
Unordered map used to set the values of runtime parameters by name.
Definition: acados_solver.hpp:655
int initialize_control_values(unsigned int stage, ValueVector &u_i)
Initialize the control variable values for one stage from an ordered value vector.
int reset()
Resets the Acados solver, including the internal QP solver and the RTI phase cache.
virtual ocp_nlp_config * get_nlp_config() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_config property of the solver.
unsigned int np() const
Returns the number of runtime parameters.
virtual void * get_nlp_opts() const =0
Legacy C-function to retrieve the C-interface get_nlp_opts property of the solver.
int set_state_bounds(IndexVector &idxbx, ValueVector &lbx, ValueVector &ubx)
Set (differential) state bounds for all stages.
std::vector< double > sampling_intervals() const
Returns the vector of sampling interval (in seconds).
virtual int internal_update_params(unsigned int stage, double *value, int np)=0
Internal update of the solver runtime parameters.
ValueMap get_control_values_as_map(unsigned int stage)
Retrieve the control variables at a given stage and package them as a ValueMap.
int initialize_control_values(unsigned int stage, ValueMap const &u_i_map)
Initialize the control variable values for one stage from a key/values map.
double Ts() const
Returns the (constant) sampling interval Ts (in seconds).
virtual int internal_create_with_discretization(int n_time_steps, double *new_time_steps)=0
Initialize Acados solver and (optionally) redefine the shooting nodes.
virtual int internal_free_capsule()=0
Free the memory allocated for the capsule.
static bool is_map_size_consistent(IndexMap const &index_map, unsigned int expected_total_indexes)
Check if the total number of indexes contained in the provided index map is equal to an expected numb...
int set_runtime_parameters(ValueMap const &p_i_map)
Set the runtime parameters for all stages at once from a key/values map.
virtual ocp_nlp_dims * get_nlp_dims() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_dims property of the solver that contains the d...
static void fill_vector_from_map(IndexMap const &index_map, ValueMap const &values_map, unsigned int vector_size, ValueVector &values)
Fill (and resize if necessary) a vector with the values contained in the value map.
int initialize_state_values(unsigned int stage, ValueVector &x_i)
Initialize the (differential) state values for a stage from an ordered value vector.
virtual int internal_reset(int reset_qp_solver_mem=1)=0
Reset the solver memory and (opt.) the internal QP solver.
virtual ocp_nlp_in * get_nlp_in() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_in property of the solver.
int initialize_state_values(unsigned int stage, ValueMap const &x_i_map)
Initialize the (differential) state values for a stage from a key/values map.
virtual int internal_free()=0
Free the memory allocated for the solver.
unsigned int nz() const
Returns the dimensions of the algebraic state vector.
IndexMap _x_index_map
Unordered map used to set or retrieve the values of diff. state variables by name.
Definition: acados_solver.hpp:649
int init(unsigned int N, double Ts)
Initialize the solver and set the (constant) sampling intervals.
virtual int internal_update_qp_solver_cond_N(int qp_solver_cond_N)=0
Update the QP solver qp_solver_cond_N setting.
const IndexMap & x_index_map() const
Returns a constant reference to the Key/IndexVector map of differential state variables internally st...
static ValueMap create_map_from_values(IndexMap const &index_map, ValueVector const &values)
Returns a vector ValueMap object containing the values of the value vector.
Dimensions _dims
Fixed dimensions of the imported Acados OCP.
Definition: acados_solver.hpp:646
virtual int create_index_maps()=0
Reinitialize the maps used to set or retrieve value using string variable names.
int set_control_bounds(unsigned int stage, IndexVector &idxbu, ValueVector &lbu, ValueVector &ubu)
Set control bounds at a given stage.
int set_initial_state_values(ValueVector &x_0)
Set the initial state values (i.e., add constraints on initial state)
virtual ocp_nlp_solver * get_nlp_solver() const =0
Legacy C-function to retrieve the C-interface ocp_nlp_solver property of the solver.
IndexMap _u_index_map
Unordered map used to set or retrieve the values of control variables by name.
Definition: acados_solver.hpp:658
const IndexMap & p_index_map() const
Returns a constant reference to the Key/IndexVector map of runtime parameters internally stored in Ac...
unsigned int N() const
Returns the number of shooting nodes.
virtual int internal_solve()=0
Solve the non-linear optimization`.
int set_runtime_parameters(unsigned int stage, ValueVector &p_i)
Set the runtime parameters for one stage from ordered value vector.
AcadosSolver()
Constructor of the AcadosSolver object.
ValueVector get_state_values(unsigned int stage)
Retrieve the differential state variables at a given stage.
virtual ~AcadosSolver()
Destructor of the AcadosSolver object.
ValueMap get_state_values_as_map(unsigned int stage)
Retrieve the differential state variables at a given stage and package them as a ValueMap.
virtual int internal_create_capsule()=0
Create the Acados solver's capsule used by the Acados C-interface.
virtual unsigned int get_nlp_np() const =0
Legacy C-function to retrieve the number of runtime parameters from the Acados capsule.
static bool is_map_size_consistent(ValueMap const &values_map, unsigned int expected_total_indexes)
Check if the total number of values contained in the provided value map is equal to an expected numbe...
unsigned int nx() const
Returns the dimensions of the differential state vector.
int set_runtime_parameters(unsigned int stage, ValueMap const &p_i_map)
Set the runtime parameters for one stage from a key/values map.
int initialize_control_values(ValueVector &u_i)
Initialize the control variable values for ALL stages at once from an ordered value vector.
unsigned int nu() const
Returns the number of control variables.
Definition: acados_solver.hpp:35
std::unordered_map< std::string, IndexVector > IndexMap
Mapping between keys (std::string) and indexes (acados::IndexVector).
Definition: acados_types.hpp:36
std::vector< unsigned int > IndexVector
List of indexes.
Definition: acados_types.hpp:30
std::vector< double > ValueVector
List of values (double).
Definition: acados_types.hpp:33
std::unordered_map< std::string, ValueVector > ValueMap
Mapping between keys (std::string) and data (acados::ValueVector).
Definition: acados_types.hpp:39