<commit_before>#ifndef AMICI_SOLVER_H
#define AMICI_SOLVER_H

#include "amici/vector.h"
#include "amici/defines.h"
#include "amici/misc.h"
#include "amici/exception.h"
#include "amici/symbolic_functions.h"

#include <nvector/nvector_serial.h>   // DlsMat
#include <sundials/sundials_sparse.h> // SlsMat

namespace amici {

class ReturnData;
class ForwardProblem;
class BackwardProblem;
class Model;
class Solver;

extern msgIdAndTxtFp warnMsgIdAndTxt;
} // namespace amici


// for serialization friend in Solver
namespace boost { namespace serialization {
template <class Archive>
void serialize(Archive &ar, amici::Solver &u, const unsigned int version);
}}


namespace amici {

/** Solver class.
 * provides a generic interface to CVode and IDA solvers, individual realizations
 * are realized in the CVodeSolver and the IDASolver class.
 */
class Solver {
  public:
    Solver() = default;

    /**
     * @brief Solver copy constructor
     * @param other
     */
    Solver(const Solver &other) : Solver()
    {
        sensi = other.sensi;
        atol = other.atol;
        rtol = other.rtol;
        quad_atol = other.quad_atol;
        quad_rtol = other.quad_rtol;
        maxsteps = other.maxsteps;
        maxstepsB = other.maxstepsB;
        newton_maxsteps = other.newton_maxsteps;
        newton_maxlinsteps = other.newton_maxlinsteps;
        newton_preeq = other.newton_preeq;
        newton_precon = other.newton_precon;
        ism = other.ism;
        sensi_meth = other.sensi_meth;
        linsol = other.linsol;
        interpType = other.interpType;
        lmm = other.lmm;
        iter = other.iter;
        stldet = other.stldet;
        ordering = other.ordering;
        ism = other.ism;
    }

    virtual ~Solver() = default;

    /**
     * @brief Clone this instance
     * @return The clone
     */
    virtual Solver* clone() const = 0;


    void setupAMI(ForwardProblem *fwd, Model *model);

    void setupAMIB(BackwardProblem *bwd, Model *model);

    /**
     * AMIGetSens extracts diagnosis information from solver memory block and
     * writes them into the return data instance
     *
     * @param tret time at which the sensitivities should be computed
     * @param yySout vector with sensitivities
     */
    virtual void AMIGetSens(realtype *tret, AmiVectorArray *yySout) = 0;

    void getDiagnosis(const int it, ReturnData *rdata);

    void getDiagnosisB(const int it, ReturnData *rdata, const BackwardProblem *bwd);

    /**
     * AMIGetRootInfo extracts information which event occured
     *
     * @param rootsfound array with flags indicating whether the respective<commit_msg>Fix looser throw specifier for 'virtual amici::CVodeSolver::~CVodeSolver()'. Fixes #289<commit_after>#ifndef AMICI_SOLVER_H
#define AMICI_SOLVER_H

#include "amici/vector.h"
#include "amici/defines.h"
#include "amici/misc.h"
#include "amici/exception.h"
#include "amici/symbolic_functions.h"

#include <nvector/nvector_serial.h>   // DlsMat
#include <sundials/sundials_sparse.h> // SlsMat

namespace amici {

class ReturnData;
class ForwardProblem;
class BackwardProblem;
class Model;
class Solver;

extern msgIdAndTxtFp warnMsgIdAndTxt;
} // namespace amici


// for serialization friend in Solver
namespace boost { namespace serialization {
template <class Archive>
void serialize(Archive &ar, amici::Solver &u, const unsigned int version);
}}


namespace amici {

/** Solver class.
 * provides a generic interface to CVode and IDA solvers, individual realizations
 * are realized in the CVodeSolver and the IDASolver class.
 */
class Solver {
  public:
    Solver() = default;

    /**
     * @brief Solver copy constructor
     * @param other
     */
    Solver(const Solver &other) : Solver()
    {
        sensi = other.sensi;
        atol = other.atol;
        rtol = other.rtol;
        quad_atol = other.quad_atol;
        quad_rtol = other.quad_rtol;
        maxsteps = other.maxsteps;
        maxstepsB = other.maxstepsB;
        newton_maxsteps = other.newton_maxsteps;
        newton_maxlinsteps = other.newton_maxlinsteps;
        newton_preeq = other.newton_preeq;
        newton_precon = other.newton_precon;
        ism = other.ism;
        sensi_meth = other.sensi_meth;
        linsol = other.linsol;
        interpType = other.interpType;
        lmm = other.lmm;
        iter = other.iter;
        stldet = other.stldet;
        ordering = other.ordering;
        ism = other.ism;
    }

    virtual ~Solver() {}

    /**
     * @brief Clone this instance
     * @return The clone
     */
    virtual Solver* clone() const = 0;


    void setupAMI(ForwardProblem *fwd, Model *model);

    void setupAMIB(BackwardProblem *bwd, Model *model);

    /**
     * AMIGetSens extracts diagnosis information from solver memory block and
     * writes them into the return data instance
     *
     * @param tret time at which the sensitivities should be computed
     * @param yySout vector with sensitivities
     */
    virtual void AMIGetSens(realtype *tret, AmiVectorArray *yySout) = 0;

    void getDiagnosis(const int it, ReturnData *rdata);

    void getDiagnosisB(const int it, ReturnData *rdata, const BackwardProblem *bwd);

    /**
     * AMIGetRootInfo extracts information which event occured
     *
     * @param rootsfound array with flags indicating whether the respective
{'fraction_non_alphanumeric': 0.08980127484064492, 'fraction_numerical': 0.0013123359580052493, 'mean_word_length': 2.9843166542195667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3587952', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1687, 'n_words': 466}