This file contains the description of all external functions interfaced to acados.

!!! Please keep it updated when developing new features !!!



/************************************************
* ocp_nlp_cost_external
************************************************/

// complete gradient and hessian of cost, computed externally

external function: ext_cost_jac_hes

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC_ARGS
1) [u]    size: nu    type: BLASFEO_DVEC_ARGS
outputs:
0) [grad_u; grad_x]    size: nu+nx    type: BLASFEO_DVEC
1) [hess_uu, hess_ux; hess_xu; hess_xx]    size: (nu+nx)*(nu+nx)    type: BLASFEO_DMAT



/************************************************
* ocp_nlp_cost_nls
************************************************/

// function and jacobian_transposed of residuals of nonlinear least-squares

external function: nls_res_jac

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC_ARGS
1) [u]    size: nu    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]    size: ny    type: BLASFEO_DVEC
1) [jac_u'; jac_x']    size: (nu+nx)*(ny)    type: BLASFEO_DMAT



// exact hessian of nonlinear least-squares, computed using the numerical values in fun for the residuals

external function: nls_hess

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC_ARGS
1) [u]    size: nu    type: BLASFEO_DVEC_ARGS
2) [fun]  size: ny    type: BLASFEO_DVEC

outputs:
0) [hess_uu, hess_ux; hess_xu; hess_xx]    size: (nu+nx)*(nu+nx)    type: BLASFEO_DMAT



/************************************************
* ocp_nlp_constraints
************************************************/

// function and jacobian_transposed of nonlinear constraints

external function: nl_constr_h_fun_jac

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC_ARGS
1) [u]    size: nu    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]               size: nh            type: BLASFEO_DVEC_ARGS
1) [jac_u'; jac_x']    size: (nu+nx)*nh    type: BLASFEO_DMAT_ARGS



// function and jacobian_transposed and hessian*multipliers of nonlinear constraints

external function: nl_constr_h_fun_jac

inputs:
0) [x]      size: nx    type: BLASFEO_DVEC_ARGS
1) [u]      size: nu    type: BLASFEO_DVEC_ARGS
2) [lam]    size: nh    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]               size: nh                 type: BLASFEO_DVEC_ARGS
1) [jac_u'; jac_x']    size: (nu+nx)*nh         type: BLASFEO_DMAT_ARGS
2) [hess*lam]          size: (nu+nx)*(nu+nx)    type: BLASFEO_DMAT_ARGS



// TODO(whoever): add documentation; split input into x, u;
external function: p

/************************************************
* dynamics discrete
************************************************/

// function and jacobian of discrete dynamics

external function: disc_dyn_fun_jac

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC_ARGS
1) [u]    size: nu    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]               size: nx1            type: BLASFEO_DVEC_ARGS
1) [jac_u'; jac_x']    size: (nu+nx)*nx1    type: BLASFEO_DMAT_ARGS



// function and jacobian and hessian of discrete dynamics

external function: disc_dyn_fun_jac_hess

inputs:
0) [x]      size: nx     type: BLASFEO_DVEC_ARGS
1) [u]      size: nu     type: BLASFEO_DVEC_ARGS
2) [lam]    size: nx1    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]               size: nx1                type: BLASFEO_DVEC_ARGS
1) [jac_u'; jac_x']    size: (nu+nx)*nx1        type: BLASFEO_DMAT_ARGS
2) [hess*lam]          size: (nu+nx)*(nu+nx)    type: BLASFEO_DMAT_ARGS



/************************************************
* sim_erk_integrator
************************************************/

// function of explicit ode model
        - needed if opts->sens_forw == false

external function: expl_ode_fun

inputs:
0) [x]    size: nx    type: COLMAJ
1) [u]    size: nu    type: COLMAJ

outputs:
0) [fun]    size: nx    type: COLMAJ



// function and jacobian-times-seeds (forward sensitivities) of explicit ode model, computed using vde model
        - needed if opts->sens_forw == true

external function: expl_vde_for

inputs:
0) [x]    size: nx       type: COLMAJ
1) [Sx]   size: nx*nx    type: COLMAJ
2) [Su]   size: nx*nu    type: COLMAJ
3) [u]    size: nu       type: COLMAJ

outputs:
0) [fun]               size: nx       type: COLMAJ
1) [jac_x*Sx]          size: nx*nx    type: COLMAJ
2) [jac_x*Su+jac_u]    size: nx*nu    type: COLMAJ



// jacobian_transposed-times-vector (adjoint sensitivities) of explicit ode model
        - needed if opts->sens_adj == true

external function: expl_ode_adj

0) [x]      size: nx    type: COLMAJ
1) [lam]    size: nx    type: COLMAJ
2) [u]      size: nu    type: COLMAJ

outputs:
0) [jac_x'*lam; jac_u'*lam]    size: nx+nu    type: COLMAJ



// hessian of explicit ode model, computed using vde model
    - needed if opts->sens_hess == true

external function: expl_vde_hess

0) [x]    size: nx    type: COLMAJ
1) [Sx]    size: nx*nx    type: COLMAJ
2) [Su]    size: nx*nu    type: COLMAJ
3) [lam]    size: nx    type: COLMAJ
4) [u]    size: nu    type: COLMAJ

outputs:
0) [jac_x'*lam; jac_u'*lam]    size: nx+nu    type: COLMAJ
1) [hess_xx, hess_xu; hess_ux, hess_uu]    size: (nx+nu)*(nx+nu)    type: COLMAJ



/************************************************
* sim_irk_integrator
************************************************/

// function of implicit ode model

external function: impl_ode_fun
        -- only needed if opts->jac_reuse == true

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC
1) [K]    size: nx    type: BLASFEO_DVEC_ARGS
2) [u]    size: nu    type: COLMAJ
3) [z]    size: nz    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]    size: nx    type: BLASFEO_DVEC_ARGS



// function and jacobians of implicit ode model

external function: impl_ode_fun_jac_x_xdot_z
        -- ALWAYS NEEDED!
inputs:
0) [x]    size: nx    type: BLASFEO_DVEC
1) [K]    size: nx    type: BLASFEO_DVEC_ARGS
2) [u]    size: nu    type: COLMAJ
3) [z]    size: nz    type: BLASFEO_DVEC_ARGS

outputs:
0) [fun]        size: nx       type: BLASFEO_DVEC_ARGS
1) [jac_x]      size: nx*nx    type: BLASFEO_DMAT
2) [jac_xdot]   size: nx*nx    type: BLASFEO_DMAT
3) [jac_z]      size: nx*nz    type: BLASFEO_DMAT



// jacobians of implicit ode model

external function: impl_ode_jac_x_xdot_u_z
        - needed if ( opts->sens_forw || opts->sens_hess || opts->sens_algebraic || opts->sens_adj )
inputs:
0) [x]    size: nx    type: BLASFEO_DVEC
1) [K]    size: nx    type: BLASFEO_DVEC_ARGS
2) [u]    size: nu    type: COLMAJ
3) [z]    size: nz    type: BLASFEO_DVEC_ARGS


outputs:
0) [jac_x]      size: nx*nx    type: BLASFEO_DMAT
1) [jac_xdot]   size: nx*nx    type: BLASFEO_DMAT
2) [jac_u]      size: nx*nu    type: BLASFEO_DMAT
3) [jac_z]      size: nx*nz    type: BLASFEO_DMAT


// // hessian function of implicit ode model (multiplications with seeds done in CasADi)
//         - only needed if opts->sens_hess
// external function: impl_ode_hess
// 
// inputs:
// 0) [x]          size: nx                    type: BLASFEO_DVEC
// 1) [K]          size: nx                    type: BLASFEO_DVEC_ARGS
// 2) [u]          size: nu                    type: COLMAJ
// 3) [z]          size: nz                    type: BLASFEO_DVEC_ARGS
// 4) [lam]        size: nx+nz                 type: BLASFEO_DVEC_ARGS
// 5) [dxkzu_w0]   size: (2*nx+nz+nu, nx+nu)   type: BLASFEO_DMAT_ARGS
// 
// outputs:
// 0) [f_hess]     size: (nx+nu, nx+nu)        type: BLASFEO_DMAT

// hessian function of implicit ode model (multiplications with seeds done in BLASFEO)
        - only needed if opts->sens_hess
external function: impl_ode_hess

inputs:
0) [x]      size: nx       type: BLASFEO_DVEC
1) [K]      size: nx       type: BLASFEO_DVEC_ARGS
2) [u]      size: nu       type: COLMAJ
3) [z]      size: nz       type: BLASFEO_DVEC_ARGS
4) [lam]    size: nx+nz    type: BLASFEO_DVEC_ARGS

outputs:
0) [f_hess]     size: (2*nx+nz+nu, 2*nx+nz+nu)    type: BLASFEO_DMAT

/************************************************
* sim_lifted_irk_integrator
************************************************/

// function of implicit ode model

external function: impl_ode_fun
        - needed   if (!update_sens)
inputs:
0) [x]    size: nx    type: BLASFEO_DVEC
1) [K]    size: nx    type: BLASFEO_DVEC_ARGS
2) [u]    size: nu    type: COLMAJ

outputs:
0) [fun]    size: nx    type: BLASFEO_DVEC_ARGS



// function of implicit ode model + jacobians of implicit ode model

external function: impl_ode_fun_jac_x_xdot_u
        - needed   if (update_sens)

inputs:
0) [x]    size: nx    type: BLASFEO_DVEC
1) [K]    size: nx    type: BLASFEO_DVEC_ARGS
2) [u]    size: nu    type: COLMAJ

outputs:
0) [fun]        size: nx        type: BLASFEO_DVEC_ARGS
1) [jac_x]      size: nx*nx     type: BLASFEO_DMAT
2) [jac_xdot]   size: nx*nx     type: BLASFEO_DMAT
3) [jac_u]      size: nx*nu     type: BLASFEO_DMAT

/************************************************
* sim_gnsf
************************************************/

/* nonlinearity function phi */

external functions: phi_fun, phi_fun_jac_y, phi_jac_y_uhat

inputs:
0) [y]    size: ny    type: BLASFEO_DVEC_ARGS
1) [uhat] size: nuhat type: BLASFEO_DVEC

// phi_fun
outputs:
0) [fun]    size: n_out    type: BLASFEO_DVEC_ARGS

// phi_fun_jac_y
outputs:
0) [fun]    size: n_out    type: BLASFEO_DVEC_ARGS
1) [jac_y]  size: n_out*ny type: BLASFEO_DMAT_ARGS

// phi_jac_y_uhat
outputs:
0) [jac_y]  size: n_out*ny type: BLASFEO_DMAT_ARGS
1) [jac_uhat]  size: n_out*nuhat type: BLASFEO_DMAT_ARGS



/* linear output function f_lo */

external function: f_lo_fun_jac_x1_x1dot_u_z

inputs:
0) [x1]    size: nx1   type: BLASFEO_DVEC_ARGS
1) [x1dot] size: nx1   type: BLASFEO_DVEC_ARGS
2) [z]     size: nz    type: BLASFEO_DVEC_ARGS
3) [u]     size: nu    type: BLASFEO_DVEC

outputs:
0) [fun]              size: nx2                 type: BLASFEO_DVEC_ARGS
1) [jac_x1_x1dot_u_z] size: nx2*(2*nx1+nu+nz)   type: BLASFEO_DMAT_ARGS
