Skip to content

Commit

Permalink
Allow setting integration retries / tolerance relaxation via environ…
Browse files Browse the repository at this point in the history
…ment variables (#229)

* Allow setting integration retries / tolerance relaxation via environment variables

Closes #224

* Document PARPE_NUM_SIMULATION_TRIALS and PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR
  • Loading branch information
dweindl authored Jan 27, 2020
1 parent c9955ec commit b37dc30
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
7 changes: 7 additions & 0 deletions doc/optimizationApplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,10 @@ Run the created executable with the `-h`/`--help` argument.

Note: These variables have no effect in case of shared-memory (non-MPI) execution

- **PARPE_NUM_SIMULATION_TRIALS** (integer) and
**PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR** (float)

In case of simulation failure, parPE try rerunning an AMICI simulation with a
`PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR`-fold higher error tolerance
for a total of `PARPE_NUM_SIMULATION_TRIALS` times (including the initial
attempt).
27 changes: 22 additions & 5 deletions src/parpeamici/multiConditionProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,28 @@ AmiciSimulationRunner::AmiciResultPackageSimple runAndLogSimulation(
* and sensitivity options have been set already */
auto edata = dataProvider->getExperimentalDataForCondition(conditionIdx);

/* In case of simulation failure, try rerunning with higher error tolerance
* for a total of maxNumTrials times */
constexpr int maxNumTrials = 6; // on failure, rerun simulation
// Error tolerance relaxation factor upon failure
constexpr double errorRelaxation = 1e2;
// TODO: extract class to handle tolerance relaxation

/*
* In case of simulation failure, try rerunning with a
* `errorRelaxation`-fold higher error tolerance for a total of
* `maxNumTrials` times (including the initial attempt).
*/
constexpr int defaultMaxNumTrials = 6;
constexpr double defaultErrorRelaxation = 1e2;

int maxNumTrials = defaultMaxNumTrials;
double errorRelaxation = defaultErrorRelaxation;

// Set via environment variables?
if(auto env = std::getenv("PARPE_NUM_SIMULATION_TRIALS")) {
maxNumTrials = std::stoi(env);
}
if(auto env =
std::getenv("PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR")) {
errorRelaxation = std::stod(env);
}

std::unique_ptr<amici::ReturnData> rdata;

// redirect AMICI output to parPE logging
Expand Down

0 comments on commit b37dc30

Please sign in to comment.