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

butterflies: more initial population debugging

parent 7c1b1775
No related branches found
No related tags found
No related merge requests found
......@@ -167,15 +167,47 @@ void initial_population_adjustment(struct cats_configuration *conf, struct cats_
int64_t invalid_habitat = butterflies_prune_invalid_cells(grid);
log_message(LOG_IMPORTANT, "Loaded initial populations: %ld cells occupied before adjustment", init_populated_cells);
if (grid->param.initial_population.set_to_cc == true) {
#define DEBUG_INITIAL_POPULATIONS
#ifdef DEBUG_INITIAL_POPULATIONS
const int32_t max_i = 10;
struct cats_vital_rate *cc_rate = &grid->param.carrying_capacity;
cats_dt_rates OT = grid->param.OT;
for (int32_t i = 0; i < max_i; i++) {
cats_dt_rates OT = grid->param.OT;
cats_dt_rates suit = OT + i * (1.0 - OT)/max_i;
cats_dt_rates cc = cc_rate->func->func(cc_rate, &grid->param, suit, 0, NAN);
log_message(LOG_INFO, "Carrying capacity for suitability %Lf: %Lf", suit, cc);
}
const cats_dt_coord rows = grid->dimension.rows;
const cats_dt_coord cols = grid->dimension.cols;
int64_t start = 0;
int64_t multi_excluded = 0;
for (cats_dt_coord row = 0; row < rows; row++) {
for (cats_dt_coord col = 0; col < cols; col++) {
if (get_adult_population(grid, row, col) == 0) continue;
start += 1;
cats_dt_rates multiplier = 1.0;
if (conf->overlays.overlay[OL_HABITAT_TYPE_CC].enabled) {
multiplier *= conf->overlays.habitat_cc->data[row][col];
}
cats_dt_rates suit = get_suitability(grid, row, col);
cats_dt_rates cc_raw = cc_rate->func->func(cc_rate, &grid->param, suit, 0, NAN);
if (multiplier == 0) {
multi_excluded += 1;
}
cats_dt_population cc = get_carrying_capacity(grid, row, col);
printf("DEBUG::row %d col %d, suit %Lf, cc multi %Lf, cc raw %Lf, cc %d\n", row, col, suit, multiplier, cc_raw, cc);
}
}
#endif
increase_initial_population_to_cc(grid, conf);
int64_t populated_cells_after_cc = count_populated_cells(grid);
log_message(LOG_IMPORTANT, "\t%ld cells occupied after setting population sizes to carrying capacity", populated_cells_after_cc);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment