From 68a6625eadf54a214bb0eda333139e84a3b7a46a Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 5 Jan 2024 09:32:50 +0100 Subject: [PATCH 1/2] Doc: Update edata.h (#2254) --- include/amici/edata.h | 61 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/include/amici/edata.h b/include/amici/edata.h index f8639ca2eb..78bcba0fc7 100644 --- a/include/amici/edata.h +++ b/include/amici/edata.h @@ -14,24 +14,24 @@ class ReturnData; /** * @brief ExpData carries all information about experimental or - * condition-specific data + * condition-specific data. */ class ExpData : public SimulationParameters { public: /** - * @brief default constructor + * @brief Default constructor. */ ExpData() = default; /** - * @brief Copy constructor, needs to be declared to be generated in - * swig + * @brief Copy constructor. */ + // needs to be declared to be wrapped by SWIG ExpData(ExpData const&) = default; /** - * @brief constructor that only initializes dimensions + * @brief Constructor that only initializes dimensions. * * @param nytrue Number of observables * @param nztrue Number of event outputs @@ -154,6 +154,16 @@ class ExpData : public SimulationParameters { /** * @brief Set output timepoints. * + * If the number of timepoint increases, this will grow the + * observation/sigma matrices and fill new entries with NaN. + * If the number of timepoints decreases, this will shrink the + * observation/sigma matrices. + * + * Note that the mapping from timepoints to measurements will not be + * preserved. E.g., say there are measurements at t = 2, and this + * function is called with [1, 2], then the old measurements will belong to + * t = 1. + * * @param ts timepoints */ void setTimepoints(std::vector const& ts); @@ -225,7 +235,7 @@ class ExpData : public SimulationParameters { void setObservedDataStdDev(std::vector const& observedDataStdDev); /** - * @brief Set indentical standard deviation for all measurements. + * @brief Set identical standard deviation for all measurements. * * @param stdDev standard deviation (dimension: scalar) */ @@ -278,8 +288,7 @@ class ExpData : public SimulationParameters { realtype const* getObservedDataStdDevPtr(int it) const; /** - * @brief set function that copies observed event data from input to - * ExpData::observedEvents + * @brief Set observed event data. * * @param observedEvents observed data (dimension: nmaxevent x nztrue, * row-major) @@ -287,8 +296,7 @@ class ExpData : public SimulationParameters { void setObservedEvents(std::vector const& observedEvents); /** - * @brief set function that copies observed event data for specific event - * observable + * @brief Set observed event data for specific event observable. * * @param observedEvents observed data (dimension: nmaxevent) * @param iz observed event data index @@ -296,8 +304,7 @@ class ExpData : public SimulationParameters { void setObservedEvents(std::vector const& observedEvents, int iz); /** - * @brief get function that checks whether event data at specified indices - * has been set + * @brief Check whether event data at specified indices has been set. * * @param ie event index * @param iz event observable index @@ -306,25 +313,23 @@ class ExpData : public SimulationParameters { bool isSetObservedEvents(int ie, int iz) const; /** - * @brief get function that copies data from ExpData::mz to output + * @brief Get observed event data. * * @return observed event data */ std::vector const& getObservedEvents() const; /** - * @brief get function that returns a pointer to observed data at ieth - * occurrence + * @brief Get pointer to observed data at ie-th occurrence. * * @param ie event occurrence * - * @return pointer to observed event data at ieth occurrence + * @return pointer to observed event data at ie-th occurrence */ realtype const* getObservedEventsPtr(int ie) const; /** - * @brief set function that copies data from input to - * ExpData::observedEventsStdDev + * @brief Set standard deviation of observed event data. * * @param observedEventsStdDev standard deviation of observed event data */ @@ -332,16 +337,14 @@ class ExpData : public SimulationParameters { setObservedEventsStdDev(std::vector const& observedEventsStdDev); /** - * @brief set function that sets all ExpData::observedDataStdDev to the - * input value + * @brief Set standard deviation of observed event data. * * @param stdDev standard deviation (dimension: scalar) */ void setObservedEventsStdDev(realtype stdDev); /** - * @brief set function that copies standard deviation of observed data for - * specific observable + * @brief Set standard deviation of observed data for a specific observable. * * @param observedEventsStdDev standard deviation of observed data * (dimension: nmaxevent) @@ -352,8 +355,7 @@ class ExpData : public SimulationParameters { ); /** - * @brief set function that sets all standard deviation of a specific - * observable to the input value + * @brief Set all standard deviations of a specific event-observable. * * @param stdDev standard deviation (dimension: scalar) * @param iz observed data index @@ -361,8 +363,8 @@ class ExpData : public SimulationParameters { void setObservedEventsStdDev(realtype stdDev, int iz); /** - * @brief get function that checks whether standard deviation of even data - * at specified indices has been set + * @brief Check whether standard deviation of event data + * at specified indices has been set. * * @param ie event index * @param iz event observable index @@ -371,16 +373,15 @@ class ExpData : public SimulationParameters { bool isSetObservedEventsStdDev(int ie, int iz) const; /** - * @brief get function that copies data from ExpData::observedEventsStdDev - * to output + * @brief Get standard deviation of observed event data. * * @return standard deviation of observed event data */ std::vector const& getObservedEventsStdDev() const; /** - * @brief get function that returns a pointer to standard deviation of - * observed event data at ie-th occurrence + * @brief Get pointer to standard deviation of + * observed event data at ie-th occurrence. * * @param ie event occurrence * From 9886c690f3c5619148a6fd9541e7d3741bbf108a Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Sat, 6 Jan 2024 10:40:32 +0100 Subject: [PATCH 2/2] Fix swig shadow warning + other linting issues (#2261) Fixes swig warning ``` include/amici/simulation_parameters.h:71: Warning 509: Overloaded method amici::SimulationParameters::SimulationParameters(std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >) effectively ignored, include/amici/simulation_parameters.h:54: Warning 509: as it is shadowed by amici::SimulationParameters::SimulationParameters(std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< int,std::allocator< int > >). ``` and some other linting warnings. --- include/amici/logging.h | 2 +- include/amici/model.h | 2 +- include/amici/simulation_parameters.h | 6 ++++++ src/steadystateproblem.cpp | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/amici/logging.h b/include/amici/logging.h index 0118bedd28..6af039d4c4 100644 --- a/include/amici/logging.h +++ b/include/amici/logging.h @@ -83,7 +83,7 @@ struct LogItem { , message(message){}; /** Severity level */ - LogSeverity severity; + LogSeverity severity = LogSeverity::error; /** Short identifier for the logged event */ std::string identifier; diff --git a/include/amici/model.h b/include/amici/model.h index f5421bed3d..3d2645028a 100644 --- a/include/amici/model.h +++ b/include/amici/model.h @@ -1437,7 +1437,7 @@ class Model : public AbstractModel, public ModelDimensions { std::vector const& getReinitializationStateIdxs() const; /** Flag indicating Matlab- or Python-based model generation */ - bool pythonGenerated; + bool pythonGenerated = false; /** * @brief getter for dxdotdp (matlab generated) diff --git a/include/amici/simulation_parameters.h b/include/amici/simulation_parameters.h index ca0e127c5c..55db090184 100644 --- a/include/amici/simulation_parameters.h +++ b/include/amici/simulation_parameters.h @@ -35,6 +35,11 @@ class SimulationParameters { this->parameters.size(), ParameterScaling::none )) {} +#ifndef SWIGPYTHON + /* + * include/amici/simulation_parameters.h:71: Warning 509: Overloaded method amici::SimulationParameters::SimulationParameters(std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >) effectively ignored, + * include/amici/simulation_parameters.h:54: Warning 509: as it is shadowed by amici::SimulationParameters::SimulationParameters(std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< int,std::allocator< int > >). + */ /** * @brief Constructor * @param fixedParameters Model constants @@ -69,6 +74,7 @@ class SimulationParameters { this->parameters.size(), ParameterScaling::none )) , ts_(std::move(timepoints)) {} +#endif /** * @brief Set reinitialization of all states based on model constants for diff --git a/src/steadystateproblem.cpp b/src/steadystateproblem.cpp index 4576b43363..98c36589f7 100644 --- a/src/steadystateproblem.cpp +++ b/src/steadystateproblem.cpp @@ -601,8 +601,6 @@ void SteadystateProblem::applyNewtonsMethod(Model& model, bool newton_retry) { int& i_newtonstep = numsteps_.at(newton_retry ? 2 : 0); i_newtonstep = 0; gamma_ = 1.0; - bool update_direction = true; - bool step_successful = false; if (model.nx_solver == 0) return; @@ -613,6 +611,8 @@ void SteadystateProblem::applyNewtonsMethod(Model& model, bool newton_retry) { bool converged = false; wrms_ = getWrms(model, SensitivityMethod::none); converged = newton_retry ? false : wrms_ < conv_thresh; + bool update_direction = true; + while (!converged && i_newtonstep < max_steps_) { /* If Newton steps are necessary, compute the initial search @@ -634,7 +634,7 @@ void SteadystateProblem::applyNewtonsMethod(Model& model, bool newton_retry) { /* Compute new xdot and residuals */ realtype wrms_tmp = getWrms(model, SensitivityMethod::none); - step_successful = wrms_tmp < wrms_; + bool step_successful = wrms_tmp < wrms_; if (step_successful) { /* If new residuals are smaller than old ones, update state */ wrms_ = wrms_tmp;