Program Listing for File abstract_model.h

Return to documentation for file (include/amici/abstract_model.h)

#ifndef AMICI_ABSTRACT_MODEL_H
#define AMICI_ABSTRACT_MODEL_H

#include "amici/defines.h"
#include "amici/sundials_matrix_wrapper.h"
#include "amici/vector.h"

#include <sunmatrix/sunmatrix_band.h>
#include <sunmatrix/sunmatrix_dense.h>
#include <sunmatrix/sunmatrix_sparse.h>

#include <memory>

namespace amici {

class Solver;

class AbstractModel {
  public:
    virtual ~AbstractModel() = default;

    virtual std::unique_ptr<Solver> getSolver() = 0;

    virtual void froot(const realtype t, const AmiVector &x,
                       const AmiVector &dx, gsl::span<realtype> root) = 0;

    virtual void fxdot(const realtype t, const AmiVector &x,
                       const AmiVector &dx, AmiVector &xdot) = 0;

    virtual void fsxdot(const realtype t, const AmiVector &x,
                        const AmiVector &dx, int ip, const AmiVector &sx,
                        const AmiVector &sdx, AmiVector &sxdot) = 0;

    virtual void fxBdot_ss(const realtype t, const AmiVector &xB,
                           const AmiVector &dxB, AmiVector &xBdot) = 0;

    virtual void fJSparseB_ss(SUNMatrix JB) = 0;

    virtual void writeSteadystateJB(const realtype t, realtype cj,
                                    const AmiVector &x, const AmiVector &dx,
                                    const AmiVector &xB, const AmiVector &dxB,
                                    const AmiVector &xBdot) = 0;

    virtual void fJ(const realtype t, realtype cj, const AmiVector &x,
                    const AmiVector &dx, const AmiVector &xdot,
                    SUNMatrix J) = 0;

    virtual void fJB(const realtype t, realtype cj, const AmiVector &x,
                     const AmiVector &dx, const AmiVector &xB,
                     const AmiVector &dxB, const AmiVector &xBdot,
                     SUNMatrix JB) = 0;

    virtual void fJSparse(const realtype t, realtype cj, const AmiVector &x,
                          const AmiVector &dx, const AmiVector &xdot,
                          SUNMatrix J) = 0;

    virtual void fJSparseB(const realtype t, realtype cj, const AmiVector &x,
                           const AmiVector &dx, const AmiVector &xB,
                           const AmiVector &dxB, const AmiVector &xBdot,
                           SUNMatrix JB) = 0;

    virtual void fJDiag(const realtype t, AmiVector &Jdiag, realtype cj,
                        const AmiVector &x, const AmiVector &dx) = 0;

    virtual void fdxdotdp(const realtype t, const AmiVector &x,
                          const AmiVector &dx) = 0;

    virtual void fJv(const realtype t, const AmiVector &x, const AmiVector &dx,
                     const AmiVector &xdot, const AmiVector &v, AmiVector &nJv,
                     realtype cj) = 0;

    virtual std::string getAmiciVersion() const;

    virtual std::string getAmiciCommit() const;

    virtual void fx0(realtype *x0, const realtype t, const realtype *p,
                     const realtype *k);

    virtual bool isFixedParameterStateReinitializationAllowed() const;

    virtual void fx0_fixedParameters(realtype *x0, const realtype t,
                                     const realtype *p, const realtype *k,
                                     gsl::span<const int> reinitialization_state_idxs);

    virtual void fsx0_fixedParameters(realtype *sx0, const realtype t,
                                      const realtype *x0, const realtype *p,
                                      const realtype *k, int ip,
                                      gsl::span<const int> reinitialization_state_idxs);

    virtual void fsx0(realtype *sx0, const realtype t, const realtype *x0,
                      const realtype *p, const realtype *k, int ip);

    virtual void fdx0(AmiVector &x0, AmiVector &dx0);

    virtual void fstau(realtype *stau, const realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       const realtype *sx, int ip, int ie);

    virtual void fy(realtype *y, const realtype t, const realtype *x,
                    const realtype *p, const realtype *k, const realtype *h,
                    const realtype *w);

    virtual void fdydp(realtype *dydp, const realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       int ip, const realtype *w, const realtype *dwdp);

    virtual void fdydx(realtype *dydx, const realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       const realtype *w, const realtype *dwdx);

    virtual void fz(realtype *z, int ie, const realtype t, const realtype *x,
                    const realtype *p, const realtype *k, const realtype *h);

    virtual void fsz(realtype *sz, int ie, const realtype t, const realtype *x,
                     const realtype *p, const realtype *k, const realtype *h,
                     const realtype *sx, int ip);

    virtual void frz(realtype *rz, int ie, const realtype t, const realtype *x,
                     const realtype *p, const realtype *k, const realtype *h);

    virtual void fsrz(realtype *srz, int ie, const realtype t,
                      const realtype *x, const realtype *p, const realtype *k,
                      const realtype *h, const realtype *sx, int ip);

    virtual void fdzdp(realtype *dzdp, int ie, const realtype t,
                       const realtype *x, const realtype *p, const realtype *k,
                       const realtype *h, int ip);

    virtual void fdzdx(realtype *dzdx, int ie, const realtype t,
                       const realtype *x, const realtype *p, const realtype *k,
                       const realtype *h);

    virtual void fdrzdp(realtype *drzdp, int ie, const realtype t,
                        const realtype *x, const realtype *p, const realtype *k,
                        const realtype *h, int ip);

    virtual void fdrzdx(realtype *drzdx, int ie, const realtype t,
                        const realtype *x, const realtype *p, const realtype *k,
                        const realtype *h);

    virtual void fdeltax(realtype *deltax, const realtype t, const realtype *x,
                         const realtype *p, const realtype *k,
                         const realtype *h, int ie, const realtype *xdot,
                         const realtype *xdot_old);

    virtual void fdeltasx(realtype *deltasx, const realtype t,
                          const realtype *x, const realtype *p,
                          const realtype *k, const realtype *h,
                          const realtype *w, int ip, int ie,
                          const realtype *xdot, const realtype *xdot_old,
                          const realtype *sx, const realtype *stau);

    virtual void fdeltaxB(realtype *deltaxB, const realtype t,
                          const realtype *x, const realtype *p,
                          const realtype *k, const realtype *h, int ie,
                          const realtype *xdot, const realtype *xdot_old,
                          const realtype *xB);

    virtual void fdeltaqB(realtype *deltaqB, const realtype t,
                          const realtype *x, const realtype *p,
                          const realtype *k, const realtype *h, int ip, int ie,
                          const realtype *xdot, const realtype *xdot_old,
                          const realtype *xB);

    virtual void fsigmay(realtype *sigmay, const realtype t, const realtype *p,
                         const realtype *k);

    virtual void fdsigmaydp(realtype *dsigmaydp, const realtype t,
                            const realtype *p, const realtype *k, int ip);

    virtual void fsigmaz(realtype *sigmaz, const realtype t, const realtype *p,
                         const realtype *k);

    virtual void fdsigmazdp(realtype *dsigmazdp, const realtype t,
                            const realtype *p, const realtype *k, int ip);

    virtual void fJy(realtype *nllh, int iy, const realtype *p,
                     const realtype *k, const realtype *y,
                     const realtype *sigmay, const realtype *my);

    virtual void fJz(realtype *nllh, int iz, const realtype *p,
                     const realtype *k, const realtype *z,
                     const realtype *sigmaz, const realtype *mz);

    virtual void fJrz(realtype *nllh, int iz, const realtype *p,
                      const realtype *k, const realtype *z,
                      const realtype *sigmaz);

    virtual void fdJydy(realtype *dJydy, int iy, const realtype *p,
                        const realtype *k, const realtype *y,
                        const realtype *sigmay, const realtype *my);

    virtual void fdJydy_colptrs(SUNMatrixWrapper &dJydy, int index);

    virtual void fdJydy_rowvals(SUNMatrixWrapper &dJydy, int index);

    virtual void fdJydsigma(realtype *dJydsigma, int iy, const realtype *p,
                            const realtype *k, const realtype *y,
                            const realtype *sigmay, const realtype *my);

    virtual void fdJzdz(realtype *dJzdz, int iz, const realtype *p,
                        const realtype *k, const realtype *z,
                        const realtype *sigmaz, const realtype *mz);

    virtual void fdJzdsigma(realtype *dJzdsigma, int iz, const realtype *p,
                            const realtype *k, const realtype *z,
                            const realtype *sigmaz, const realtype *mz);

    virtual void fdJrzdz(realtype *dJrzdz, int iz, const realtype *p,
                         const realtype *k, const realtype *rz,
                         const realtype *sigmaz);

    virtual void fdJrzdsigma(realtype *dJrzdsigma, int iz, const realtype *p,
                             const realtype *k, const realtype *rz,
                             const realtype *sigmaz);

    virtual void fw(realtype *w, const realtype t, const realtype *x,
                    const realtype *p, const realtype *k, const realtype *h,
                    const realtype *tcl);

    virtual void fdwdp(realtype *dwdp, const realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       const realtype *w, const realtype *tcl,
                       const realtype *stcl);

    virtual void fdwdp_colptrs(SUNMatrixWrapper &dwdp);

    virtual void fdwdp_rowvals(SUNMatrixWrapper &dwdp);

    virtual void fdwdp(realtype *dwdp, const realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       const realtype *w, const realtype *tcl,
                       const realtype *stcl, int ip);

    virtual void fdwdx(realtype *dwdx, const realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       const realtype *w, const realtype *tcl);

    virtual void fdwdx_colptrs(SUNMatrixWrapper &dwdx);

    virtual void fdwdx_rowvals(SUNMatrixWrapper &dwdx);

    virtual void fdwdw(realtype *dwdw, realtype t, const realtype *x,
                       const realtype *p, const realtype *k, const realtype *h,
                       const realtype *w, const realtype *tcl);

    virtual void fdwdw_colptrs(SUNMatrixWrapper &dwdw);

    virtual void fdwdw_rowvals(SUNMatrixWrapper &dwdw);
};

} // namespace amici

#endif // AMICI_ABSTRACT_MODEL_H