Skip to content

Commit 40432be

Browse files
authored
Merge pull request #231 from ICB-DCM/develop
Release 0.4.2 * Improve parallel scaling by better message handling * Remove unreliable auto-detection of launch via mpi launcher, use --mpi instead * Allow setting integration retries / tolerance relaxation via environment variables PARPE_NUM_SIMULATION_TRIALS and PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR * CMake: enable use of PACKAGE_ROOT * Minor fixes
2 parents 1ce7004 + b37dc30 commit 40432be

File tree

21 files changed

+386
-158
lines changed

21 files changed

+386
-158
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
cmake_minimum_required(VERSION 3.7)
22
cmake_policy(VERSION 3.7)
33

4+
if(POLICY CMP0074)
5+
# Use package_ROOT environment variables
6+
cmake_policy(SET CMP0074 NEW)
7+
endif(POLICY CMP0074)
8+
49
project(parpe)
510

611
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMakeModules/)
@@ -44,9 +49,9 @@ set_property(CACHE BLAS PROPERTY STRINGS "CBLAS" "MKL")
4449
set(PARPE_ENABLE_MPI TRUE CACHE BOOL "Use MPI?")
4550
set(IPOPT_DIR "" CACHE PATH "IpOpt root directory")
4651
set(IPOPT_INCLUDE_DIRS "${IPOPT_DIR}/include/coin/" CACHE PATH "IpOpt include directory")
47-
set(IPOPT_LIBRARIES ${IPOPT_DIR}/lib/libipopt.a ${IPOPT_DIR}/lib/libcoinhsl.a gfortran CACHE STRINGS "IpOpt library")
52+
set(IPOPT_LIBRARIES ${IPOPT_DIR}/lib/libipopt.a ${IPOPT_DIR}/lib/libcoinhsl.a gfortran CACHE STRING "IpOpt library")
4853
set(CERES_INCLUDE_DIRS "" "/usr/include/eigen3" CACHE PATH "CERES include directories")
49-
set(CERES_LIBRARIES "" CACHE STRINGS "CERES libraries")
54+
set(CERES_LIBRARIES "" CACHE STRING "CERES libraries")
5055
set(PARPE_ENABLE_IPOPT TRUE CACHE BOOL "Enable ipopt optimizer?")
5156
set(PARPE_ENABLE_CERES TRUE CACHE BOOL "Enable ceres optimizer?")
5257
set(PARPE_ENABLE_DLIB FALSE CACHE BOOL "Enable dlib optimizers?")

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[![Run Status](https://api.shippable.com/projects/59463d3e8993d7070010407b/badge?branch=master)](https://app.shippable.com/github/dweindl/parPE)
22
[![Coverage Badge](https://api.shippable.com/projects/59463d3e8993d7070010407b/coverageBadge?branch=master)](https://app.shippable.com/github/dweindl/parPE)
33
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1f1ee5a0d90d431499f200a148fb7fdc)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=ICB-DCM/parPE&utm_campaign=Badge_Grade)
4-
[![DOI](https://zenodo.org/badge/92953596.svg)](https://zenodo.org/badge/latestdoi/92953596)
4+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3478612.svg)](https://doi.org/10.5281/zenodo.3478612)
5+
56

67
# parPE
78

deps/AMICI/ThirdParty/sundials/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ reporting work done with SUNDIALS:
114114
* Alan C. Hindmarsh, Peter N. Brown, Keith E. Grant, Steven L. Lee, Radu
115115
Serban, Dan E. Shumaker, and Carol S. Woodward. 2005. SUNDIALS: Suite of
116116
nonlinear and differential/algebraic equation solvers. ACM Trans. Math. Softw.
117-
31, 3 (September 2005), 363-396. DOI=http://dx.doi.org/10.1145/1089014.1089020
117+
31, 3 (September 2005), 363-396. DOI=https://doi.org/10.1145/1089014.1089020
118118

119119
## License ##
120120
SUNDIALS is released under the BSD 3-clause license. See the [LICENSE](./LICENSE)

deps/AMICI/documentation/amici_refs.bib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ @article{LoosMoe2018
300300
Title = {A Hierarchical, Data-Driven Approach to Modeling Single-Cell Populations Predicts Latent Causes of Cell-To-Cell Variability},
301301
Volume = {6},
302302
Year = {2018},
303-
Bdsk-Url-1 = {http://dx.doi.org/10.1016/j.cels.2018.04.008}}
303+
Bdsk-Url-1 = {https://doi.org/10.1016/j.cels.2018.04.008}}
304304

305305
@article{MaierLoo2017,
306306
Author = {Maier, C. and Loos, C. and Hasenauer, J.},
@@ -457,7 +457,7 @@ @Article{SchmiesterSch2019
457457
year = {2019},
458458
month = {07},
459459
issn = {1367-4803},
460-
abstract = {{Mechanistic models of biochemical reaction networks facilitate the quantitative understanding of biological processes and the integration of heterogeneous datasets. However, some biological processes require the consideration of comprehensive reaction networks and therefore large-scale models. Parameter estimation for such models poses great challenges, in particular when the data are on a relative scale.Here, we propose a novel hierarchical approach combining (i) the efficient analytic evaluation of optimal scaling, offset, and error model parameters with (ii) the scalable evaluation of objective function gradients using adjoint sensitivity analysis. We evaluate the properties of the methods by parameterizing a pan-cancer ordinary differential equation model (\\>1000 state variables, \\>4000 parameters) using relative protein, phospho-protein and viability measurements. The hierarchical formulation improves optimizer performance considerably. Furthermore, we show that this approach allows estimating error model parameters with negligible computational overhead when no experimental estimates are available, providing an unbiased way to weight heterogeneous data. Overall, our hierarchical formulation is applicable to a wide range of models, and allows for the efficient parameterization of large-scale models based on heterogeneous relative measurements.Supplementary information are available at Bioinformatics online. Supplementary code and data are available online at http://doi.org/10.5281/zenodo.3254429 and http://doi.org/10.5281/zenodo.3254441.}},
460+
abstract = {{Mechanistic models of biochemical reaction networks facilitate the quantitative understanding of biological processes and the integration of heterogeneous datasets. However, some biological processes require the consideration of comprehensive reaction networks and therefore large-scale models. Parameter estimation for such models poses great challenges, in particular when the data are on a relative scale.Here, we propose a novel hierarchical approach combining (i) the efficient analytic evaluation of optimal scaling, offset, and error model parameters with (ii) the scalable evaluation of objective function gradients using adjoint sensitivity analysis. We evaluate the properties of the methods by parameterizing a pan-cancer ordinary differential equation model (\\>1000 state variables, \\>4000 parameters) using relative protein, phospho-protein and viability measurements. The hierarchical formulation improves optimizer performance considerably. Furthermore, we show that this approach allows estimating error model parameters with negligible computational overhead when no experimental estimates are available, providing an unbiased way to weight heterogeneous data. Overall, our hierarchical formulation is applicable to a wide range of models, and allows for the efficient parameterization of large-scale models based on heterogeneous relative measurements.Supplementary information are available at Bioinformatics online. Supplementary code and data are available online at https://doi.org/10.5281/zenodo.3254429 and https://doi.org/10.5281/zenodo.3254441.}},
461461
doi = {10.1093/bioinformatics/btz581},
462462
eprint = {http://oup.prod.sis.lan/bioinformatics/advance-article-pdf/doi/10.1093/bioinformatics/btz581/29004243/btz581.pdf},
463463
url = {https://doi.org/10.1093/bioinformatics/btz581},

doc/optimizationApplication.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ Run the created executable with the `-h`/`--help` argument.
6161

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

64+
- **PARPE_NUM_SIMULATION_TRIALS** (integer) and
65+
**PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR** (float)
66+
67+
In case of simulation failure, parPE try rerunning an AMICI simulation with a
68+
`PARPE_INTEGRATION_TOLERANCE_RELAXATION_FACTOR`-fold higher error tolerance
69+
for a total of `PARPE_NUM_SIMULATION_TRIALS` times (including the initial
70+
attempt).

doc/snakemake_workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ provided in `snakemake/config.schema.yaml`.
2323
After that you can run the full pipeline with:
2424

2525
cd snakemake
26-
snakemake --configfile parpe_optimize_petab_steadystate.yaml postprocess
26+
snakemake --configfile parpe_optimize_petab_steadystate.yaml -- postprocess
2727

2828
This generate C++ code of the model, build model specific binaries for
2929
parameter estimation, run parameters, and process the results.

examples/parpeamici/steadystate/main_simulator.cpp

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,54 @@
1+
#include <parpecommon/parpeConfig.h>
2+
13
#include "steadyStateMultiConditionDataprovider.h"
24

35
#include <parpeamici/standaloneSimulator.h>
46
#include <parpecommon/misc.h>
7+
#include <parpecommon/parpeConfig.h>
58

69
#include <cstdio> // remove
710
#include <iostream>
11+
#include <stdexcept>
12+
13+
#ifdef PARPE_ENABLE_MPI
14+
#include <mpi.h>
15+
#endif
816

917
std::unique_ptr<amici::Model> getModel();
1018

19+
void printUsage() {
20+
std::cerr<<"Error: wrong number of arguments.\n";
21+
std::cerr<<"Usage: ... CONDITION_FILE_NAME CONDITION_FILE_PATH "
22+
"[PARAMETER_FILE_NAME PARAMETER_FILE_PATH] "
23+
"OUTFILENAME OUTFILEPATH "
24+
"--at-optimum|--along-trajectory "
25+
"--mpi|--nompi\n";
26+
// |--parameter-matrix=PATH-UNSUPPORTED
27+
}
28+
1129
int main(int argc, char **argv) {
1230
int status = EXIT_SUCCESS;
1331

14-
parpe::initMpiIfNeeded(&argc, &argv);
32+
if(argc != 7 && argc != 9) {
33+
printUsage();
34+
return EXIT_FAILURE;
35+
}
36+
37+
38+
if(std::string(argv[argc -1]) == "--mpi") {
39+
#ifdef PARPE_ENABLE_MPI
40+
MPI_Init(&argc, &argv);
41+
#else
42+
throw std::runtime_error("parPE was built without MPI support.");
43+
#endif
44+
} else if(std::string(argv[argc -1]) == "--nompi") {
45+
;
46+
} else {
47+
printUsage();
48+
return EXIT_FAILURE;
49+
}
1550

16-
switch(argc)
17-
{
18-
case 6:
19-
{
51+
if(argc == 7) {
2052
std::string dataFileName = argv[1];
2153
std::string dataFilePath = argv[2];
2254
std::string resultFileName = argv[3];
@@ -32,10 +64,7 @@ int main(int argc, char **argv) {
3264
dataFileName, dataFilePath,
3365
dataFileName, dataFilePath,
3466
resultFileName, resultPath);
35-
break;
36-
}
37-
case 8:
38-
{
67+
} else if(argc == 9) {
3968
// simulate on test set: need optimizer result and test set data as inputs
4069
std::string conditionFileName = argv[1];
4170
std::string conditionFilePath = argv[2];
@@ -66,12 +95,6 @@ int main(int argc, char **argv) {
6695
conditionFileName, conditionFilePath,
6796
parameterFileName, parameterFilePath,
6897
resultFileName, resultPath);
69-
break;
70-
}
71-
default:
72-
std::cerr<<"Error: wrong number of arguments.\n";
73-
std::cerr<<"Usage: ... CONDITION_FILE_NAME CONDITION_FILE_PATH [PARAMETER_FILE_NAME PARAMETER_FILE_PATH] OUTFILENAME OUTFILEPATH --at-optimum|--along-trajectory\n"; // |--parameter-matrix=PATH-UNSUPPORTED
74-
status = EXIT_FAILURE;
7598
}
7699

77100
parpe::finalizeMpiIfNeeded();

examples/parpeamici/steadystate/run-examples.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rm -rf example_steadystate_multi-test-optimize/
3434
rm -f simulate1.h5
3535
./example_steadystate_multi_simulator \
3636
example_steadystate_multi-test-optimize/_rank00000.h5 / simulate1.h5 / \
37-
--at-optimum 2>&1 > test.log
37+
--at-optimum --nompi 2>&1 > test.log
3838
(! grep ERR test.log)
3939
(! grep WRN test.log)
4040
(! grep exception test.log)
@@ -48,7 +48,7 @@ test -f simulate1.h5
4848
# Run optimization with default settings
4949

5050
rm -rf example_steadystate_multi-test-optimize/
51-
${MPIEXEC} ./example_steadystate_multi \
51+
${MPIEXEC} ./example_steadystate_multi --mpi \
5252
-o example_steadystate_multi-test-optimize/ ${HDF5_FILE} 2>&1 >> test.log
5353
(! grep ERR test.log)
5454
(! grep WRN test.log)
@@ -58,7 +58,7 @@ ${MPIEXEC} ./example_steadystate_multi \
5858
rm -f simulate2.h5
5959
${MPIEXEC} ./example_steadystate_multi_simulator \
6060
example_steadystate_multi-test-optimize/_rank00000.h5 / simulate2.h5 / \
61-
--along-trajectory 2>&1 >> test.log
61+
--along-trajectory --mpi 2>&1 >> test.log
6262
(! grep ERR test.log)
6363
(! grep WRN test.log)
6464
(! grep exception test.log)
@@ -67,11 +67,10 @@ test -f simulate2.h5
6767

6868
# Simulate on test set
6969

70-
7170
rm -f simulate3.h5
7271
${MPIEXEC} ./example_steadystate_multi_simulator \
7372
${HDF5_FILE_TEST} / example_steadystate_multi-test-optimize/_rank00000.h5 / \
74-
simulate3.h5 / --at-optimum
73+
simulate3.h5 / --at-optimum --mpi
7574
h5dump -d /multistarts/0/ySim/3 simulate3.h5 # test dataset exists
7675
(! grep ERR test.log)
7776
(! grep WRN test.log)

include/parpeamici/optimizationApplication.h

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class OptimizationApplication {
3535

3636
/**
3737
* @brief User-provided problem initialization.
38-
* Must set OptimizationApplication::problem, OptimizationApplication::multiStartOptimization and should set
38+
* Must set OptimizationApplication::problem,
39+
* OptimizationApplication::multiStartOptimization and should set
3940
* OptimizationApplication::resultWriter
4041
* @param inFileArgument
4142
* @param outFileArgument
@@ -45,14 +46,15 @@ class OptimizationApplication {
4546

4647
/**
4748
* @brief Start the optimization run. Must only be called once.
49+
* Initializes MPI if not already done.
50+
* Must be called before any other functions.
4851
* @return status code; 0 on success
4952
*/
5053
int run(int argc, char **argv);
5154

5255
/**
5356
* @brief This is run by the MPI rank 0 process when started with multiple
5457
* processes.
55-
* @return
5658
*/
5759
virtual void runMaster();
5860

@@ -105,14 +107,26 @@ class OptimizationApplication {
105107
static void initMPI(int *argc, char ***argv);
106108

107109
/**
108-
* @brief Parse command line Options.
109-
* Must be called before any other functions.
110-
* Initializes MPI if not already done.
110+
* @brief Parse command line options before MPI_INIT is potentially called.
111+
*
112+
* Used e.g. to print usage information without first initialization MPI.
113+
*
114+
* Argv may contain extra MPI arguments.
115+
* @param argc
116+
* @param argv
117+
* @return
118+
*/
119+
virtual int parseCliOptionsPreMpiInit(int argc, char **argv);
120+
121+
/**
122+
* @brief Parse command line options after MPI_Init is called.
123+
*
124+
* Any MPI-related CLI arguments will be removed here.
111125
* @param argc
112126
* @param argv
113127
* @return
114128
*/
115-
virtual int parseOptions(int argc, char **argv);
129+
virtual int parseCliOptionsPostMpiInit(int argc, char **argv);
116130

117131
/**
118132
* @brief Print CLI usage
@@ -134,12 +148,13 @@ class OptimizationApplication {
134148

135149
protected:
136150
// command line option parsing
137-
const char *shortOptions = "dhvt:o:s:";
138-
struct option const longOptions[8] = {
151+
const char *shortOptions = "dhvmt:o:s:";
152+
struct option const longOptions[9] = {
139153
{"debug", no_argument, NULL, 'd'},
140154
{"print-worklist", no_argument, NULL, 'p'},
141155
{"help", no_argument, NULL, 'h'},
142156
{"version", no_argument, NULL, 'v'},
157+
{"mpi", no_argument, NULL, 'm'},
143158
{"task", required_argument, NULL, 't'},
144159
{"outfile-prefix", required_argument, NULL, 'o'},
145160
{"first-start-idx", required_argument, NULL, 's'},
@@ -158,9 +173,10 @@ class OptimizationApplication {
158173
// the need to be filled in by sub
159174
std::unique_ptr<MultiStartOptimizationProblem> multiStartOptimizationProblem;
160175
std::unique_ptr<OptimizationProblem> problem;
161-
hid_t file_id;
176+
hid_t file_id = 0;
162177
OperationType operationType = OperationType::parameterEstimation;
163178
LoadBalancerMaster loadBalancer;
179+
bool withMPI = false;
164180
};
165181

166182

include/parpecommon/misc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ void fillArrayRandomDoubleSameInterval(double min, double max, gsl::span<double>
112112
int getMpiRank();
113113
int getMpiCommSize();
114114
int getMpiActive();
115+
116+
/**
117+
* @brief Was application launched by mpiexec?
118+
*
119+
* Make an educated guess if the application was launched with mpiexec
120+
* or similar and therefore require MPI_INIT.
121+
* @return True if probably launched by mpiexec
122+
*/
115123
bool launchedWithMpi();
116124

117125
void initMpiIfNeeded(int *argc, char ***argv);

0 commit comments

Comments
 (0)