Skip to content
Snippets Groups Projects
Commit abf5fc80 authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

cats, butterflies: remove debug variables and use stats instead

parent b3a79a2a
No related branches found
No related tags found
No related merge requests found
...@@ -50,9 +50,6 @@ initialize_thread(struct cats_thread_info *thread, struct cats_grid *grid, struc ...@@ -50,9 +50,6 @@ initialize_thread(struct cats_thread_info *thread, struct cats_grid *grid, struc
zero_statistics_stats(&thread->stats[i]); zero_statistics_stats(&thread->stats[i]);
} }
thread->rw_debug_cells_with_adults = 0;
thread->rw_debug_random_walks = 0;
thread->rw_debug_deposits = 0;
thread->seed = get_random_seed(false); thread->seed = get_random_seed(false);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
......
...@@ -50,9 +50,6 @@ struct cats_thread_info { ...@@ -50,9 +50,6 @@ struct cats_thread_info {
struct cats_configuration *conf; struct cats_configuration *conf;
gsl_rng *rng; gsl_rng *rng;
unsigned int rng_seed; unsigned int rng_seed;
int64_t rw_debug_cells_with_adults;
int64_t rw_debug_random_walks;
int64_t rw_debug_deposits;
char *rng_state_buffer; char *rng_state_buffer;
int32_t rng_buf_size; int32_t rng_buf_size;
struct random_data *rng_state; struct random_data *rng_state;
......
...@@ -112,7 +112,6 @@ void grid_butterflies_maturation(struct cats_grid *grid, struct cats_thread_info ...@@ -112,7 +112,6 @@ void grid_butterflies_maturation(struct cats_grid *grid, struct cats_thread_info
const cats_dt_coord start_col = ts->area.start_col; const cats_dt_coord start_col = ts->area.start_col;
const cats_dt_coord end_col = ts->area.end_col; const cats_dt_coord end_col = ts->area.end_col;
ts->rw_debug_cells_with_adults = 0;
for (cats_dt_coord row = start_row; row < end_row; row++) { for (cats_dt_coord row = start_row; row < end_row; row++) {
for (cats_dt_coord col = start_col; col < end_col; col++) { for (cats_dt_coord col = start_col; col < end_col; col++) {
...@@ -174,11 +173,6 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info ...@@ -174,11 +173,6 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info
const cats_dt_coord start_col = ts->area.start_col; const cats_dt_coord start_col = ts->area.start_col;
const cats_dt_coord end_col = ts->area.end_col; const cats_dt_coord end_col = ts->area.end_col;
ts->rw_debug_cells_with_adults = 0;
ts->rw_debug_random_walks = 0;
ts->rw_debug_deposits = 0;
for (cats_dt_coord row = start_row; row < end_row; row++) { for (cats_dt_coord row = start_row; row < end_row; row++) {
for (cats_dt_coord col = start_col; col < end_col; col++) { for (cats_dt_coord col = start_col; col < end_col; col++) {
if (cell_excluded_by_overlay(conf, row, col) if (cell_excluded_by_overlay(conf, row, col)
...@@ -256,12 +250,11 @@ enum action_status bf_action_dispersal(struct cats_grid *grid, struct cats_confi ...@@ -256,12 +250,11 @@ enum action_status bf_action_dispersal(struct cats_grid *grid, struct cats_confi
threaded_action(&butterflies_area_dispersal, grid, conf, TS_DISPERSAL); threaded_action(&butterflies_area_dispersal, grid, conf, TS_DISPERSAL);
struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; struct conf_data_butterflies *module_conf = CATS_MODULE_DATA;
for (enum butterfly_stats which = BF_POPULATED_AT_DISPERSAL; which < BF_STAT_MAX; which++) { for (enum butterfly_stats which = BF_RANDOM_WALK_DEPOSIT_COUNT; which < BF_STAT_MAX; which++) {
int64_t stat_id = module_conf->stat_ids[which]; int64_t stat_id = module_conf->stat_ids[which];
log_message(LOG_INFO, "STAT %s: %ld", bf_get_stats_field_name(which), grid->stats.stats[stat_id]); log_message(LOG_INFO, "STAT %s: %ld", bf_get_stats_field_name(which), grid->stats.stats[stat_id]);
} }
return ACTION_RUN; return ACTION_RUN;
} }
......
...@@ -41,7 +41,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -41,7 +41,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
const struct grid_data_butterflies *data = grid->grid_modules[module_id].module_data; const struct grid_data_butterflies *data = grid->grid_modules[module_id].module_data;
const struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; const struct conf_data_butterflies *module_conf = CATS_MODULE_DATA;
const bool debug_rw = module_conf->debug_rw; const bool debug_rw = module_conf->debug_rw;
const int64_t stat_id_deposits = module_conf->stat_ids[BF_RANDOM_WALK_DEPOSIT_COUNT];
int32_t eggs_left = eggs; int32_t eggs_left = eggs;
const cats_dt_coord max_steps = module_conf->animal_dispersal_max_radius; const cats_dt_coord max_steps = module_conf->animal_dispersal_max_radius;
...@@ -94,7 +94,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -94,7 +94,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
eggs_left -= eggs_to_deposit; eggs_left -= eggs_to_deposit;
data->eggs[row][col] += (float) eggs_to_deposit; data->eggs[row][col] += (float) eggs_to_deposit;
ts->rw_debug_deposits++; increase_custom_stat(ts->stats, stat_id_deposits, 1);
if (debug_rw) { if (debug_rw) {
fprintf(module_conf->debug_rw_file, "%d,%d,%d,%d,%d,%d,%d\n", rw_num, row, col, step + 1, fprintf(module_conf->debug_rw_file, "%d,%d,%d,%d,%d,%d,%d\n", rw_num, row, col, step + 1,
module_conf->animal_dispersal_max_radius - step - 1, eggs_to_deposit, eggs_left); module_conf->animal_dispersal_max_radius - step - 1, eggs_to_deposit, eggs_left);
...@@ -127,7 +127,6 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, ...@@ -127,7 +127,6 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts,
const cats_dt_population total_adults = get_adult_population(grid, row, col); const cats_dt_population total_adults = get_adult_population(grid, row, col);
if (total_adults == 0) return; if (total_adults == 0) return;
ts->rw_debug_cells_with_adults++;
struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; struct conf_data_butterflies *module_conf = CATS_MODULE_DATA;
// total females: how many of the total adults are female, as drawn from a binomial distribution with p = 0.5 // total females: how many of the total adults are female, as drawn from a binomial distribution with p = 0.5
// can be safely cast, because gsl_ran_binomial will return a number <= total_adults // can be safely cast, because gsl_ran_binomial will return a number <= total_adults
...@@ -164,7 +163,7 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, ...@@ -164,7 +163,7 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts,
assert(stationary_females >= 0); assert(stationary_females >= 0);
assert(wandering_females >= 0); assert(wandering_females >= 0);
const int64_t stat_id_rw = module_conf->stat_ids[BF_RANDOM_WALK_COUNT];
const int module_id = CATS_MODULE_ID; const int module_id = CATS_MODULE_ID;
struct grid_data_butterflies *data = grid->grid_modules[module_id].module_data; struct grid_data_butterflies *data = grid->grid_modules[module_id].module_data;
const bool debug_rw = module_conf->debug_rw; const bool debug_rw = module_conf->debug_rw;
...@@ -217,7 +216,8 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, ...@@ -217,7 +216,8 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts,
single_random_walk(ts, grid, row, col, eggs_to_disperse_per_female, egg_fraction_step, rw_number); single_random_walk(ts, grid, row, col, eggs_to_disperse_per_female, egg_fraction_step, rw_number);
ts->rw_debug_random_walks++; increase_custom_stat(ts->stats, stat_id_rw, 1);
} }
if (debug_rw) { if (debug_rw) {
fflush(module_conf->debug_rw_file); fflush(module_conf->debug_rw_file);
......
...@@ -26,9 +26,9 @@ const char *bf_get_stats_field_name(enum butterfly_stats which) ...@@ -26,9 +26,9 @@ const char *bf_get_stats_field_name(enum butterfly_stats which)
return "unpopulated_unfit"; return "unpopulated_unfit";
case BF_STAT_EXCLUDED: case BF_STAT_EXCLUDED:
return "excluded"; return "excluded";
case BF_POPULATED_AT_DISPERSAL:
return "populated_at_dispersal";
case BF_RANDOM_WALK_DEPOSIT_COUNT:
return "random_walk_deposit_count";
case BF_RANDOM_WALK_COUNT: case BF_RANDOM_WALK_COUNT:
return "random_walk_count"; return "random_walk_count";
...@@ -36,7 +36,6 @@ const char *bf_get_stats_field_name(enum butterfly_stats which) ...@@ -36,7 +36,6 @@ const char *bf_get_stats_field_name(enum butterfly_stats which)
return "random_walk_step_count"; return "random_walk_step_count";
case BF_OUTPUT_STAT_MAX: case BF_OUTPUT_STAT_MAX:
return "<guard value>"; return "<guard value>";
case BF_STAT_MAX: case BF_STAT_MAX:
break; break;
case BF_CELLS_WITH_EGGS: case BF_CELLS_WITH_EGGS:
......
...@@ -13,12 +13,12 @@ enum butterfly_stats { ...@@ -13,12 +13,12 @@ enum butterfly_stats {
BF_STAT_UNPOPULATED_FIT, BF_STAT_UNPOPULATED_FIT,
BF_STAT_UNPOPULATED_UNFIT, BF_STAT_UNPOPULATED_UNFIT,
BF_STAT_EXCLUDED, BF_STAT_EXCLUDED,
BF_OUTPUT_STAT_MAX, BF_RANDOM_WALK_DEPOSIT_COUNT,
BF_POPULATED_AT_DISPERSAL,
BF_RANDOM_WALK_COUNT, BF_RANDOM_WALK_COUNT,
BF_RANDOM_WALK_STEP_COUNT, BF_RANDOM_WALK_STEP_COUNT,
BF_CELLS_WITH_EGGS, BF_CELLS_WITH_EGGS,
BF_CELLS_WITH_EGGS_REMOVED, BF_CELLS_WITH_EGGS_REMOVED,
BF_OUTPUT_STAT_MAX,
BF_STAT_MAX BF_STAT_MAX
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment