Permalink
Browse files

cleaning of nlp_config

  • Loading branch information...
giaf committed Jun 7, 2018
1 parent eebd95b commit 56316ae633525a2c5875327dcd637cdc6bcbef37
Showing with 104 additions and 104 deletions.
  1. +62 −72 acados/ocp_nlp/ocp_nlp_common.h
  2. +34 −24 acados/ocp_nlp/ocp_nlp_sqp.c
  3. +8 −8 acados/ocp_nlp/ocp_nlp_sqp.h
@@ -32,6 +32,41 @@ extern "C" {
#include "acados/utils/external_function_generic.h"
#include "acados/utils/types.h"
/************************************************
* config
************************************************/
typedef struct
{
int N; // number of stages
// all the others
int (*opts_calculate_size)(void *config, void *dims);
void *(*opts_assign)(void *config, void *dims, void *raw_memory);
void (*opts_initialize_default)(void *config, void *dims, void *opts_);
void (*opts_update)(void *config, void *dims, void *opts_);
int (*memory_calculate_size)(void *config, void *dims, void *opts_);
void *(*memory_assign)(void *config, void *dims, void *opts_, void *raw_memory);
int (*workspace_calculate_size)(void *config, void *dims, void *opts_);
int (*evaluate)(void *config, void *dims, void *qp_in, void *qp_out,
void *opts_, void *mem, void *work);
void (*config_initialize_default)(void *config);
ocp_qp_xcond_solver_config *qp_solver;
// sim_solver_config **sim_solvers;
ocp_nlp_dynamics_config **dynamics;
ocp_nlp_cost_config **cost;
ocp_nlp_constraints_config **constraints;
} ocp_nlp_solver_config;
//
int ocp_nlp_solver_config_calculate_size(int N);
//
ocp_nlp_solver_config *ocp_nlp_solver_config_assign(int N, void *raw_memory);
/************************************************
* dims
************************************************/
@@ -61,6 +96,8 @@ ocp_nlp_dims *ocp_nlp_dims_assign(void *config, void *raw_memory);
void ocp_nlp_dims_initialize(void *config, int *nx, int *nu, int *ny, int *nbx, int *nbu, int *ng,
int *nh, int *nq, int *ns, ocp_nlp_dims *dims);
/************************************************
* in
************************************************/
@@ -74,6 +111,13 @@ typedef struct
void **constraints;
} ocp_nlp_in;
//
int ocp_nlp_in_calculate_size(ocp_nlp_solver_config *config, ocp_nlp_dims *dims);
//
ocp_nlp_in *ocp_nlp_in_assign(ocp_nlp_solver_config *config, ocp_nlp_dims *dims, void *raw_memory);
/************************************************
* out
************************************************/
@@ -89,6 +133,14 @@ typedef struct
double inf_norm_res;
} ocp_nlp_out;
//
int ocp_nlp_out_calculate_size(ocp_nlp_solver_config *config, ocp_nlp_dims *dims);
//
ocp_nlp_out *ocp_nlp_out_assign(ocp_nlp_solver_config *config, ocp_nlp_dims *dims,
void *raw_memory);
/************************************************
* memory TODO move to sqp ???
************************************************/
@@ -102,6 +154,14 @@ typedef struct
struct blasfeo_dvec *dyn_adj;
} ocp_nlp_memory;
//
int ocp_nlp_memory_calculate_size(ocp_nlp_solver_config *config, ocp_nlp_dims *dims);
//
ocp_nlp_memory *ocp_nlp_memory_assign(ocp_nlp_solver_config *config, ocp_nlp_dims *dims,
void *raw_memory);
/************************************************
* residuals
************************************************/
@@ -119,78 +179,6 @@ typedef struct
int memsize;
} ocp_nlp_res;
/************************************************
* config
************************************************/
typedef struct
{
int N; // number of stages
// all the others
int (*opts_calculate_size)(void *config, ocp_nlp_dims *dims);
void *(*opts_assign)(void *config, ocp_nlp_dims *dims, void *raw_memory);
void (*opts_initialize_default)(void *config, ocp_nlp_dims *dims, void *opts_);
void (*opts_update)(void *config, ocp_nlp_dims *dims, void *opts_);
int (*memory_calculate_size)(void *config, ocp_nlp_dims *dims, void *opts_);
void *(*memory_assign)(void *config, ocp_nlp_dims *dims, void *opts_, void *raw_memory);
int (*workspace_calculate_size)(void *config, ocp_nlp_dims *dims, void *opts_);
int (*evaluate)(void *config, ocp_nlp_dims *dims, ocp_nlp_in *qp_in, ocp_nlp_out *qp_out,
void *opts_, void *mem, void *work);
void (*config_initialize_default)(void *config);
ocp_qp_xcond_solver_config *qp_solver;
// sim_solver_config **sim_solvers;
ocp_nlp_dynamics_config **dynamics;
ocp_nlp_cost_config **cost;
ocp_nlp_constraints_config **constraints;
} ocp_nlp_solver_config;
/************************************************
* headers
************************************************/
/************************************************
* config
************************************************/
//
int ocp_nlp_solver_config_calculate_size(int N);
//
ocp_nlp_solver_config *ocp_nlp_solver_config_assign(int N, void *raw_memory);
/************************************************
* in
************************************************/
//
int ocp_nlp_in_calculate_size(ocp_nlp_solver_config *config, ocp_nlp_dims *dims);
//
ocp_nlp_in *ocp_nlp_in_assign(ocp_nlp_solver_config *config, ocp_nlp_dims *dims, void *raw_memory);
/************************************************
* out
************************************************/
//
int ocp_nlp_out_calculate_size(ocp_nlp_solver_config *config, ocp_nlp_dims *dims);
//
ocp_nlp_out *ocp_nlp_out_assign(ocp_nlp_solver_config *config, ocp_nlp_dims *dims,
void *raw_memory);
/************************************************
* memory
************************************************/
//
int ocp_nlp_memory_calculate_size(ocp_nlp_solver_config *config, ocp_nlp_dims *dims);
//
ocp_nlp_memory *ocp_nlp_memory_assign(ocp_nlp_solver_config *config, ocp_nlp_dims *dims,
void *raw_memory);
/************************************************
* residuals
************************************************/
//
int ocp_nlp_res_calculate_size(ocp_nlp_dims *dims);
//
@@ -199,6 +187,8 @@ ocp_nlp_res *ocp_nlp_res_assign(ocp_nlp_dims *dims, void *raw_memory);
void ocp_nlp_res_compute(ocp_nlp_dims *dims, ocp_nlp_in *in, ocp_nlp_out *out, ocp_nlp_res *res,
ocp_nlp_memory *mem);
#ifdef __cplusplus
} /* extern "C" */
#endif
@@ -70,9 +70,10 @@
* options
************************************************/
int ocp_nlp_sqp_opts_calculate_size(void *config_, ocp_nlp_dims *dims)
int ocp_nlp_sqp_opts_calculate_size(void *config_, void *dims_)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -113,9 +114,10 @@ int ocp_nlp_sqp_opts_calculate_size(void *config_, ocp_nlp_dims *dims)
void *ocp_nlp_sqp_opts_assign(void *config_, ocp_nlp_dims *dims, void *raw_memory)
void *ocp_nlp_sqp_opts_assign(void *config_, void *dims_, void *raw_memory)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -167,10 +169,11 @@ void *ocp_nlp_sqp_opts_assign(void *config_, ocp_nlp_dims *dims, void *raw_memor
void ocp_nlp_sqp_opts_initialize_default(void *config_, ocp_nlp_dims *dims, void *opts_)
void ocp_nlp_sqp_opts_initialize_default(void *config_, void *dims_, void *opts_)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_sqp_opts *opts = (ocp_nlp_sqp_opts *) opts_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_nlp_sqp_opts *opts = opts_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -213,10 +216,11 @@ void ocp_nlp_sqp_opts_initialize_default(void *config_, ocp_nlp_dims *dims, void
void ocp_nlp_sqp_opts_update(void *config_, ocp_nlp_dims *dims, void *opts_)
void ocp_nlp_sqp_opts_update(void *config_, void *dims_, void *opts_)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_sqp_opts *opts = (ocp_nlp_sqp_opts *) opts_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_nlp_sqp_opts *opts = opts_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -256,10 +260,11 @@ void ocp_nlp_sqp_opts_update(void *config_, ocp_nlp_dims *dims, void *opts_)
* memory
************************************************/
int ocp_nlp_sqp_memory_calculate_size(void *config_, ocp_nlp_dims *dims, void *opts_)
int ocp_nlp_sqp_memory_calculate_size(void *config_, void *dims_, void *opts_)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_sqp_opts *opts = (ocp_nlp_sqp_opts *) opts_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_nlp_sqp_opts *opts = opts_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -315,10 +320,11 @@ int ocp_nlp_sqp_memory_calculate_size(void *config_, ocp_nlp_dims *dims, void *o
void *ocp_nlp_sqp_memory_assign(void *config_, ocp_nlp_dims *dims, void *opts_, void *raw_memory)
void *ocp_nlp_sqp_memory_assign(void *config_, void *dims_, void *opts_, void *raw_memory)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_sqp_opts *opts = (ocp_nlp_sqp_opts *) opts_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_nlp_sqp_opts *opts = opts_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -393,10 +399,11 @@ void *ocp_nlp_sqp_memory_assign(void *config_, ocp_nlp_dims *dims, void *opts_,
* workspace
************************************************/
int ocp_nlp_sqp_workspace_calculate_size(void *config_, ocp_nlp_dims *dims, void *opts_)
int ocp_nlp_sqp_workspace_calculate_size(void *config_, void *dims_, void *opts_)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_sqp_opts *opts = (ocp_nlp_sqp_opts *) opts_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_nlp_sqp_opts *opts = opts_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_dynamics_config **dynamics = config->dynamics;
@@ -769,15 +776,18 @@ static void sqp_update_variables(ocp_nlp_dims *dims, ocp_nlp_out *nlp_out, ocp_n
// Simple fixed-step Gauss-Newton based SQP routine
int ocp_nlp_sqp(void *config_, ocp_nlp_dims *dims, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out,
int ocp_nlp_sqp(void *config_, void *dims_, void *nlp_in_, void *nlp_out_,
void *opts_, void *mem_, void *work_)
{
ocp_nlp_solver_config *config = (ocp_nlp_solver_config *) config_;
ocp_nlp_sqp_opts *opts = (ocp_nlp_sqp_opts *) opts_;
ocp_nlp_sqp_memory *mem = (ocp_nlp_sqp_memory *) mem_;
ocp_nlp_dims *dims = dims_;
ocp_nlp_solver_config *config = config_;
ocp_nlp_sqp_opts *opts = opts_;
ocp_nlp_sqp_memory *mem = mem_;
ocp_nlp_in *nlp_in = nlp_in_;
ocp_nlp_out *nlp_out = nlp_out_;
ocp_qp_xcond_solver_config *qp_solver = config->qp_solver;
ocp_nlp_sqp_work *work = (ocp_nlp_sqp_work *) work_;
ocp_nlp_sqp_work *work = work_;
ocp_nlp_sqp_cast_workspace(config, dims, work, mem, opts);
@@ -49,13 +49,13 @@ typedef struct
} ocp_nlp_sqp_opts;
//
int ocp_nlp_sqp_opts_calculate_size(void *config, ocp_nlp_dims *dims);
int ocp_nlp_sqp_opts_calculate_size(void *config, void *dims);
//
void *ocp_nlp_sqp_opts_assign(void *config, ocp_nlp_dims *dims, void *raw_memory);
void *ocp_nlp_sqp_opts_assign(void *config, void *dims, void *raw_memory);
//
void ocp_nlp_sqp_opts_initialize_default(void *config, ocp_nlp_dims *dims, void *opts);
void ocp_nlp_sqp_opts_initialize_default(void *config, void *dims, void *opts);
//
void ocp_nlp_sqp_opts_update(void *config, ocp_nlp_dims *dims, void *opts);
void ocp_nlp_sqp_opts_update(void *config, void *dims, void *opts);
/************************************************
* memory
@@ -81,9 +81,9 @@ typedef struct
} ocp_nlp_sqp_memory;
//
int ocp_nlp_sqp_memory_calculate_size(void *config, ocp_nlp_dims *dims, void *opts_);
int ocp_nlp_sqp_memory_calculate_size(void *config, void *dims, void *opts_);
//
void *ocp_nlp_sqp_memory_assign(void *config, ocp_nlp_dims *dims, void *opts_, void *raw_memory);
void *ocp_nlp_sqp_memory_assign(void *config, void *dims, void *opts_, void *raw_memory);
/************************************************
* workspace
@@ -103,14 +103,14 @@ typedef struct
} ocp_nlp_sqp_work;
//
int ocp_nlp_sqp_workspace_calculate_size(void *config, ocp_nlp_dims *dims, void *opts_);
int ocp_nlp_sqp_workspace_calculate_size(void *config, void *dims, void *opts_);
/************************************************
* functions
************************************************/
//
int ocp_nlp_sqp(void *config, ocp_nlp_dims *dims, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out,
int ocp_nlp_sqp(void *config, void *dims, void *nlp_in, void *nlp_out,
void *args, void *mem, void *work_);
//
void ocp_nlp_sqp_config_initialize_default(void *config_);

0 comments on commit 56316ae

Please sign in to comment.