star-mc

Parallel estimation of Monte Carlo integrators
git clone git://git.meso-star.fr/star-mc.git
Log | Files | Refs | README | LICENSE

commit c7a8d7c5ff73b8879c3316cc092c4824d59b4e6e
parent f11e1a62d03e91e51f31b5bf23f2ac5af198dc9f
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 21 Apr 2016 12:03:25 +0200

Amend c5ef2779: return RES_OK if auto cancel occured.

We consider auto cancel as OK as it is the required behaviour.

Diffstat:
Msrc/smc.h | 7++-----
Msrc/smc_accumulator.c | 1-
Msrc/smc_estimator.c | 2--
Msrc/test_smc_errors.c | 8+++++---
4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/smc.h b/src/smc.h @@ -179,7 +179,6 @@ smc_device_get_rng_type /******************************************************************************* * Integration API ******************************************************************************/ -/* Return RES_BAD_OP if the maximum number of failures is reached */ SMC_API res_T smc_solve (struct smc_device* dev, @@ -187,7 +186,6 @@ smc_solve void* ctx, struct smc_estimator** estimator); -/* Return RES_BAD_OP if the maximum number of failures is reached */ SMC_API res_T smc_solve_N (struct smc_device* dev, @@ -213,9 +211,8 @@ smc_estimator_get_status /******************************************************************************* * Accumulation API ******************************************************************************/ -/* Raw integration. The realisations must be accumulated by the user defined - * integrand. Return RES_BAD_OP if auto cancel is enabled and the number of - * error is reached */ +/* Raw integration. + * The realisations must be accumulated by the user defined integrand */ SMC_API res_T smc_integrate (struct smc_device* dev, diff --git a/src/smc_accumulator.c b/src/smc_accumulator.c @@ -179,7 +179,6 @@ smc_integrate ++nfailed; if (nfailed > integrator->max_failures) { cancel = 1; - res = RES_BAD_OP; } } } diff --git a/src/smc_estimator.c b/src/smc_estimator.c @@ -215,7 +215,6 @@ smc_solve ++nfailed; if (nfailed > integrator->max_failures) { cancel = 1; - res = RES_BAD_OP; } } } @@ -319,7 +318,6 @@ smc_solve_N ++estimators[i]->nfailed; if (estimators[i]->nfailed > integrator->max_failures) { cancel = 1; - res = RES_BAD_OP; } } } diff --git a/src/test_smc_errors.c b/src/test_smc_errors.c @@ -85,14 +85,16 @@ main(int argc, char** argv) /* set auto cancel ON */ integrator.max_failures = integrator.max_steps / 1000; - CHECK(smc_solve(dev, &integrator, NULL, &estimator), - RES_BAD_OP); /* it is expected that solve was canceled */ + SMC(solve(dev, &integrator, NULL, &estimator)); SMC(estimator_get_status(estimator, &status)); + /* it is expected that solve was auto-canceled */ + NCHECK(integrator.max_steps, status.N); + CHECK(status.NF, integrator.max_failures + 1); + /* result must be 1 with std err = 0 */ CHECK(SMC_DOUBLE(status.E), 1); CHECK(SMC_DOUBLE(status.SE), 0); - CHECK(status.NF >= integrator.max_failures, 1); printf("OK realizations = %lu; KO realizations = %lu\n", (unsigned long)status.N, (unsigned long)status.NF);