Skip to content

Commit

Permalink
Merge branch 'develop' into fix_1949_notrun
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Feb 13, 2023
2 parents 47c399c + e51815d commit a72fe96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion documentation/rtd_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sphinx_rtd_theme>=1.0.0
petab>=0.1.20
sphinx-autodoc-typehints==1.19.2
git+https://github.com/readthedocs/sphinx-hoverxref@main
ipython==8.4.0
ipython==8.10.0
breathe==4.34.0
#exhale>=0.3.5
-e git+https://github.com/mithro/sphinx-contrib-mithro#egg=sphinx-contrib-exhale-multiproject&subdirectory=sphinx-contrib-exhale-multiproject
Expand Down
7 changes: 4 additions & 3 deletions include/amici/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "amici/logging.h"

#include <cmath>
#include <ctime>
#include <functional>
#include <memory>
#include <chrono>
Expand Down Expand Up @@ -487,7 +488,7 @@ class Solver {
double getMaxTime() const;

/**
* @brief Set the maximum time allowed for integration
* @brief Set the maximum CPU time allowed for integration
* @param maxtime Time in seconds
*/
void setMaxTime(double maxtime);
Expand Down Expand Up @@ -1607,11 +1608,11 @@ class Solver {
/** maximum number of allowed integration steps */
long int maxsteps_ {10000};

/** Maximum wall-time for integration in seconds */
/** Maximum CPU-time for integration in seconds */
std::chrono::duration<double, std::ratio<1>> maxtime_ {std::chrono::duration<double>::max()};

/** Time at which solver timer was started */
mutable std::chrono::time_point<std::chrono::system_clock> starttime_;
mutable std::clock_t starttime_;

/** linear solver for the forward problem */
mutable std::unique_ptr<SUNLinSolWrapper> linear_solver_;
Expand Down
8 changes: 4 additions & 4 deletions src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ int Model::checkFinite(gsl::span<const realtype> array,
if(hasObservableIds())
row_id += " " + getObservableIds()[row];
if(hasParameterIds())
col_id += " " + getParameterIds()[plist(col)];
col_id += " " + getParameterIds()[plist(gsl::narrow<int>(col))];
break;
case ModelQuantity::dydx:
if(hasObservableIds())
Expand All @@ -1488,7 +1488,7 @@ int Model::checkFinite(gsl::span<const realtype> array,
if(hasStateIds())
row_id += " " + getStateIdsSolver()[row];
if(hasParameterIds())
col_id += " " + getParameterIds()[plist(col)];
col_id += " " + getParameterIds()[plist(gsl::narrow<int>(col))];
break;
case ModelQuantity::dJydy:
case ModelQuantity::dJydy_matlab:
Expand All @@ -1510,7 +1510,7 @@ int Model::checkFinite(gsl::span<const realtype> array,
case ModelQuantity::drzdp:
case ModelQuantity::dsigmazdp:
if(hasParameterIds())
col_id += " " + getParameterIds()[plist(col)];
col_id += " " + getParameterIds()[plist(gsl::narrow<int>(col))];
break;
case ModelQuantity::dsigmaydy:
if(hasObservableIds()) {
Expand Down Expand Up @@ -1610,7 +1610,7 @@ int Model::checkFinite(SUNMatrix m, ModelQuantity model_quantity, realtype t) co
if(hasExpressionIds())
row_id += " " + getExpressionIds()[row];
if(hasParameterIds())
col_id += " " + getParameterIds()[plist(col)];
col_id += " " + getParameterIds()[plist(gsl::narrow<int>(col))];
break;
default:
break;
Expand Down
5 changes: 3 additions & 2 deletions src/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,13 @@ void Solver::setMaxTime(double maxtime)

void Solver::startTimer() const
{
starttime_ = std::chrono::system_clock::now();
starttime_ = std::clock();
}

bool Solver::timeExceeded() const
{
return std::chrono::system_clock::now() - starttime_ > maxtime_;
auto cputime_exceed = static_cast<double>(std::clock() - starttime_) / CLOCKS_PER_SEC;
return std::chrono::duration<double>(cputime_exceed) > maxtime_;
}

void Solver::setMaxSteps(const long int maxsteps) {
Expand Down

0 comments on commit a72fe96

Please sign in to comment.