Skip to content

Commit

Permalink
Merge branch 'develop' into gha_split_macos
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Jan 6, 2024
2 parents 9a8e7a5 + 9886c69 commit 748b7af
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
61 changes: 31 additions & 30 deletions include/amici/edata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<realtype> const& ts);
Expand Down Expand Up @@ -225,7 +235,7 @@ class ExpData : public SimulationParameters {
void setObservedDataStdDev(std::vector<realtype> const& observedDataStdDev);

/**
* @brief Set indentical standard deviation for all measurements.
* @brief Set identical standard deviation for all measurements.
*
* @param stdDev standard deviation (dimension: scalar)
*/
Expand Down Expand Up @@ -278,26 +288,23 @@ 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)
*/
void setObservedEvents(std::vector<realtype> 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
*/
void setObservedEvents(std::vector<realtype> 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
Expand All @@ -306,42 +313,38 @@ 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<realtype> 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
*/
void
setObservedEventsStdDev(std::vector<realtype> 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)
Expand All @@ -352,17 +355,16 @@ 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
*/
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
Expand All @@ -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<realtype> 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
*
Expand Down
2 changes: 1 addition & 1 deletion include/amici/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ class Model : public AbstractModel, public ModelDimensions {
std::vector<int> const& getReinitializationStateIdxs() const;

/** Flag indicating Matlab- or Python-based model generation */
bool pythonGenerated;
bool pythonGenerated = false;

/**
* @brief getter for dxdotdp (matlab generated)
Expand Down
6 changes: 6 additions & 0 deletions include/amici/simulation_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/steadystateproblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 748b7af

Please sign in to comment.