1 /************************************************************************************************** 2 * * 3 * This file is part of HPIPM. * 4 * * 5 * HPIPM -- High-Performance Interior Point Method. * 6 * Copyright (C) 2017-2018 by Gianluca Frison. * 7 * Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * 8 * All rights reserved. * 9 * * 10 * This program is free software: you can redistribute it and/or modify * 11 * it under the terms of the GNU General Public License as published by * 12 * the Free Software Foundation, either version 3 of the License, or * 13 * (at your option) any later version *. 14 * * 15 * This program is distributed in the hope that it will be useful, * 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 * GNU General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU General Public License * 21 * along with this program. If not, see <https://www.gnu.org/licenses/>. * 22 * * 23 * The authors designate this particular file as subject to the "Classpath" exception * 24 * as provided by the authors in the LICENSE file that accompained this code. * 25 * * 26 * Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * 27 * * 28 **************************************************************************************************/ 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 struct d_erk_arg 35 { 36 struct d_rk_data *rk_data; // integrator data 37 double h; // step size 38 int steps; // number of steps 39 int for_sens; // compute adjoint sensitivities 40 int adj_sens; // compute adjoint sensitivities 41 int memsize; 42 }; 43 44 45 46 struct d_erk_workspace 47 { 48 void (*ode)(int t, double *x, double *p, void *ode_args, double *xdot); // function pointer to ode 49 void (*vde_for)(int t, double *x, double *p, void *ode_args, double *xdot); // function pointer to forward vde 50 void (*vde_adj)(int t, double *adj_in, void *ode_args, double *adj_out); // function pointer to adjoint vde 51 void *ode_args; // pointer to ode args 52 struct d_erk_arg *erk_arg; // erk arg 53 double *K; // internal variables 54 double *x_for; // states and forward sensitivities 55 double *x_traj; // states at all steps 56 double *l; // adjoint sensitivities 57 double *p; // parameter 58 double *x_tmp; // temporary states and forward sensitivities 59 double *adj_in; 60 double *adj_tmp; 61 int nx; // number of states 62 int np; // number of parameters 63 int nf; // number of forward sensitivities 64 int na; // number of adjoint sensitivities 65 int nf_max; // max number of forward sensitivities 66 int na_max; // max number of adjoint sensitivities 67 int memsize; 68 }; 69 70 71 72 // 73 int d_memsize_erk_int(struct d_erk_arg *erk_arg, int nx, int np, int nf_max, int na_max); 74 // 75 void d_create_erk_int(struct d_erk_arg *erk_arg, int nx, int np, int nf_max, int na_max, struct d_erk_workspace *workspace, void *memory); 76 // 77 void d_init_erk_int(int nf, int na, double *x0, double *p0, double *fs0, double *bs0, void (*vde_for)(int t, double *x, double *p, void *ode_args, double *xdot), void (*vde_adj)(int t, double *adj_in, void *ode_args, double *adj_out), void *ode_args, struct d_erk_workspace *ws); 78 // 79 //void d_update_p_erk_int(double *p0, struct d_erk_workspace *ws); 80 // 81 void d_erk_int(struct d_erk_workspace *workspace); 82 83 #ifdef __cplusplus 84 } /* extern "C" */ 85 #endif 86