From 7c1b17759ce40203cace0907c02ef5d26ca85b87 Mon Sep 17 00:00:00 2001
From: Andreas Gattringer <gattringera@a772-cvl-ws23.biodiv.univie.ac.at>
Date: Tue, 13 Jun 2023 15:11:19 +0200
Subject: [PATCH] butterflies: debug carrying capacity when setting initial
 population

---
 src/modules/butterflies/butterflies_actions.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/modules/butterflies/butterflies_actions.c b/src/modules/butterflies/butterflies_actions.c
index cc2cf7a..aedcd40 100644
--- a/src/modules/butterflies/butterflies_actions.c
+++ b/src/modules/butterflies/butterflies_actions.c
@@ -167,6 +167,15 @@ 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) {
+                const int32_t max_i = 10;
+                struct cats_vital_rate *cc_rate = &grid->param.carrying_capacity;
+                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);
+
+                }
                 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);
-- 
GitLab