#include #include #include #include "extent-sampling.h" #include "oracles.h" #define DIMENSION_START 5 #define DIMENSION_STEP 5 #define DIMENSION_STOP 100 #define RTOL 0.1 #define SAMPLES_PER_CONE 1000 #define SOLID_ANGLE_FACTOR 1.1 void run_experiment (double eccentricity, double solid_angle_threshold_exponent_factor, FILE* fp) { gsl_rng_env_setup(); gsl_rng* r = gsl_rng_alloc(gsl_rng_default); spheroid_params params = {eccentricity}; extent_oracle_t oracle = {spheroid_extent_oracle, ¶ms}; fprintf(fp, "# spheroid eccentricity = %g\n", eccentricity); fprintf(fp, "# samples per cone = %d\n", SAMPLES_PER_CONE); fprintf(fp, "# solid angle threshold = 2^(-%gn)\n", solid_angle_threshold_exponent_factor); fprintf(fp, "# solid angle factor = %g\n", SOLID_ANGLE_FACTOR); fprintf(fp, "dimension\tvolume\tsamples\ttime\n"); for (int dim=DIMENSION_START; dim<=DIMENSION_STOP; dim+=DIMENSION_STEP) { gsl_vector* mean = gsl_vector_alloc(dim); gsl_vector_set_basis(mean, 0); unsigned int samples; clock_t begin = clock(); double volume = volume_importance(&oracle, r, mean, SAMPLES_PER_CONE, SOLID_ANGLE_FACTOR, solid_angle_threshold_exponent_factor, &samples); clock_t end = clock(); fprintf(fp, "%d\t%g\t%d\t%g\n", dim, 2*volume / spheroid_true_volume(dim, ¶ms), samples, (double)(end-begin)/CLOCKS_PER_SEC); fflush(NULL); gsl_vector_free(mean); } gsl_rng_free(r); } int main () { FILE* fp = fopen("spheroid-eccentricity10.dat", "w"); run_experiment(10, 2, fp); fclose(fp); fp = fopen("spheroid-eccentricity100.dat", "w"); run_experiment(100, 6, fp); fclose(fp); return 0; }