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

butterflies: stats fixes

parent 4a2b1186
No related branches found
No related tags found
No related merge requests found
...@@ -183,14 +183,6 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info ...@@ -183,14 +183,6 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info
butterflies_cell_dispersal(grid, ts, row, col, false, false); butterflies_cell_dispersal(grid, ts, row, col, false, false);
} }
} }
/*
if (ts->rw_debug_cells_with_adults) {
log_message(LOG_INFO, "thread %d: %ld cells with adults, %ld random walks, %ld deposits",
ts->id, ts->rw_debug_cells_with_adults, ts->rw_debug_random_walks, ts->rw_debug_deposits);
}
*/
} }
...@@ -250,9 +242,10 @@ enum action_status bf_action_dispersal(struct cats_grid *grid, struct cats_confi ...@@ -250,9 +242,10 @@ 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_RANDOM_WALK_DEPOSIT_COUNT; which < BF_STAT_MAX; which++) { for (enum butterfly_stats which = BF_RANDOM_WALK_DEPOSIT_COUNT; which < BF_OUTPUT_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): %ld", bf_get_stats_field_name(which), stat_id,
grid->stats.custom_stats[stat_id]);
} }
return ACTION_RUN; return ACTION_RUN;
...@@ -300,8 +293,7 @@ enum action_status bf_action_generation_update(struct cats_grid *grid, struct ca ...@@ -300,8 +293,7 @@ enum action_status bf_action_generation_update(struct cats_grid *grid, struct ca
int64_t cells_with_eggs_removed = grid->stats.custom_stats[egg_cells_removed_id]; int64_t cells_with_eggs_removed = grid->stats.custom_stats[egg_cells_removed_id];
log_message(LOG_INFO, "%ld cells with eggs left, %ld cells with eggs removed", cells_with_eggs, log_message(LOG_INFO, "%ld cells with eggs left, %ld cells with eggs removed", cells_with_eggs,
cells_with_eggs_removed); cells_with_eggs_removed);
grid->stats.custom_stats[egg_cells_id] = 0;
grid->stats.custom_stats[egg_cells_removed_id] = 0;
return ACTION_RUN; return ACTION_RUN;
} }
...@@ -312,7 +304,6 @@ enum action_status bf_action_overlay_update(struct cats_grid *grid, struct cats_ ...@@ -312,7 +304,6 @@ enum action_status bf_action_overlay_update(struct cats_grid *grid, struct cats_
} }
enum action_status bf_action_generation_finish(struct cats_grid *grid, struct cats_configuration *conf) enum action_status bf_action_generation_finish(struct cats_grid *grid, struct cats_configuration *conf)
{ {
const int module_id = CATS_MODULE_ID; const int module_id = CATS_MODULE_ID;
...@@ -322,7 +313,7 @@ enum action_status bf_action_generation_finish(struct cats_grid *grid, struct ca ...@@ -322,7 +313,7 @@ enum action_status bf_action_generation_finish(struct cats_grid *grid, struct ca
data->generation_current--; data->generation_current--;
assert(data->generation_current >= 0); assert(data->generation_current >= 0);
// struct conf_data_butterflies *data = CATS_MODULE_DATA;
return ACTION_RUN; return ACTION_RUN;
} }
......
...@@ -42,6 +42,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -42,6 +42,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
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]; const int64_t stat_id_deposits = module_conf->stat_ids[BF_RANDOM_WALK_DEPOSIT_COUNT];
const int64_t stat_id_rw_steps = module_conf->stat_ids[BF_RANDOM_WALK_STEP_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;
...@@ -72,6 +73,8 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -72,6 +73,8 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
return; // we escaped the simulation extent and got lost return; // we escaped the simulation extent and got lost
} }
increase_custom_stat(ts->stats, stat_id_rw_steps, 1);
// is the cell a valid dispersal target location? // is the cell a valid dispersal target location?
if (!(data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)) { if (!(data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)) {
...@@ -214,7 +217,6 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, ...@@ -214,7 +217,6 @@ 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);
increase_custom_stat(ts->stats, stat_id_rw, 1); increase_custom_stat(ts->stats, stat_id_rw, 1);
......
...@@ -26,12 +26,10 @@ const char *bf_get_stats_field_name(enum butterfly_stats which) ...@@ -26,12 +26,10 @@ 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_RANDOM_WALK_DEPOSIT_COUNT: case BF_RANDOM_WALK_DEPOSIT_COUNT:
return "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";
case BF_RANDOM_WALK_STEP_COUNT: case BF_RANDOM_WALK_STEP_COUNT:
return "random_walk_step_count"; return "random_walk_step_count";
case BF_OUTPUT_STAT_MAX: case BF_OUTPUT_STAT_MAX:
......
...@@ -16,9 +16,9 @@ enum butterfly_stats { ...@@ -16,9 +16,9 @@ enum butterfly_stats {
BF_RANDOM_WALK_DEPOSIT_COUNT, BF_RANDOM_WALK_DEPOSIT_COUNT,
BF_RANDOM_WALK_COUNT, BF_RANDOM_WALK_COUNT,
BF_RANDOM_WALK_STEP_COUNT, BF_RANDOM_WALK_STEP_COUNT,
BF_OUTPUT_STAT_MAX,
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
}; };
...@@ -31,7 +31,6 @@ static inline void increase_custom_stat(struct statistics *stats, int64_t stat_i ...@@ -31,7 +31,6 @@ static inline void increase_custom_stat(struct statistics *stats, int64_t stat_i
assert(stats != NULL); assert(stats != NULL);
assert(stat_id >= 0 && stat_id < stats->custom_stat_count); assert(stat_id >= 0 && stat_id < stats->custom_stat_count);
stats->custom_stats[stat_id] += by; stats->custom_stats[stat_id] += by;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment